diff --git a/build.gradle.kts b/build.gradle.kts index ba2d2300a..e19645700 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "com.github.shynixn" -version = "7.13.0" +version = "7.13.1" repositories { mavenLocal() @@ -37,7 +37,7 @@ dependencies { implementation("com.github.shynixn.shyscoreboard:shyscoreboard:1.0.2") implementation("com.github.shynixn.mcutils:common:2025.5") implementation("com.github.shynixn.mcutils:packet:2025.9") - implementation("com.github.shynixn.mcutils:database:2025.2") + implementation("com.github.shynixn.mcutils:database:2025.4") implementation("com.github.shynixn.mcutils:sign:2025.1") } diff --git a/src/main/java/com/github/shynixn/blockball/BlockBallDependencyInjectionModule.kt b/src/main/java/com/github/shynixn/blockball/BlockBallDependencyInjectionModule.kt index 6dce04394..5b9dc37ca 100644 --- a/src/main/java/com/github/shynixn/blockball/BlockBallDependencyInjectionModule.kt +++ b/src/main/java/com/github/shynixn/blockball/BlockBallDependencyInjectionModule.kt @@ -68,29 +68,35 @@ class BlockBallDependencyInjectionModule( module.addService(language) // Repositories - val arenaRepository = CachedRepositoryImpl( - YamlFileRepositoryImpl( - plugin, "arena", - listOf(Pair("arena_sample.yml", "arena_sample.yml")), - listOf("arena_sample.yml"), - object : TypeReference() {} - )) - module.addService>(arenaRepository) - module.addService>(arenaRepository) - val configSelectedPlayerDataRepository = ConfigSelectedRepositoryImpl( - plugin, - "BlockBall", - plugin.dataFolder.toPath().resolve("BlockBall.sqlite"), - object : TypeReference() {}, - plugin.minecraftDispatcher - ) - val playerDataRepository = AutoSavePlayerDataRepositoryImpl( - 1000 * 60L * plugin.config.getInt("database.autoSaveIntervalMinutes"), - CachedPlayerDataRepositoryImpl(configSelectedPlayerDataRepository, plugin.minecraftDispatcher), - plugin.scope, plugin.minecraftDispatcher - ) - module.addService>(playerDataRepository) - module.addService>(playerDataRepository) + module.addService> { + module.getService>() + } + module.addService> { + CachedRepositoryImpl( + YamlFileRepositoryImpl( + plugin, "arena", + listOf(Pair("arena_sample.yml", "arena_sample.yml")), + listOf("arena_sample.yml"), + object : TypeReference() {} + )) + } + module.addService> { + module.getService>() + } + module.addService> { + val configSelectedPlayerDataRepository = ConfigSelectedRepositoryImpl( + plugin, + "BlockBall", + plugin.dataFolder.toPath().resolve("BlockBall.sqlite"), + object : TypeReference() {}, + plugin.minecraftDispatcher + ) + AutoSavePlayerDataRepositoryImpl( + 1000 * 60L * plugin.config.getInt("database.autoSaveIntervalMinutes"), + CachedPlayerDataRepositoryImpl(configSelectedPlayerDataRepository, plugin.minecraftDispatcher), + plugin.scope, plugin.minecraftDispatcher + ) + } module.addService { SignServiceImpl(plugin, module.getService(), language.noPermissionMessage.text) } diff --git a/src/main/java/com/github/shynixn/blockball/BlockBallPlugin.kt b/src/main/java/com/github/shynixn/blockball/BlockBallPlugin.kt index 553e4a834..593a3f72d 100644 --- a/src/main/java/com/github/shynixn/blockball/BlockBallPlugin.kt +++ b/src/main/java/com/github/shynixn/blockball/BlockBallPlugin.kt @@ -113,6 +113,16 @@ class BlockBallPlugin : JavaPlugin() { this.scoreboardModule = loadShyScoreboardModule(language) this.module = BlockBallDependencyInjectionModule(this, language, this.scoreboardModule.getService()).build() + // Connect to database + try { + val playerDataRepository = module.getService>() + playerDataRepository.createIfNotExist() + } catch (e: Exception) { + e.printStackTrace() + Bukkit.getPluginManager().disablePlugin(this) + return + } + // Register PlaceHolder PlaceHolder.registerAll( module.getService(), module.getService(), module.getService(), module.getService() @@ -137,7 +147,6 @@ class BlockBallPlugin : JavaPlugin() { ) Bukkit.getServicesManager() .register(GameService::class.java, module.getService(), this, ServicePriority.Normal) - val plugin = this plugin.launch { // Load Games @@ -148,17 +157,6 @@ class BlockBallPlugin : JavaPlugin() { plugin.logger.log(Level.WARNING, "Cannot start game of soccerArena ${e.arena.name}.", e) } - // Connect to PlayerData Repository. - try { - val playerDataRepository = module.getService>() - playerDataRepository.createIfNotExist() - } catch (e: Exception) { - e.printStackTrace() - immidiateDisable = true - Bukkit.getPluginManager().disablePlugin(plugin) - return@launch - } - // Enable stats module.getService().register() diff --git a/src/main/resources/plugin-legacy.yml b/src/main/resources/plugin-legacy.yml index 9db01e4e5..3e38312ee 100644 --- a/src/main/resources/plugin-legacy.yml +++ b/src/main/resources/plugin-legacy.yml @@ -1,5 +1,5 @@ name: BlockBall -version: 7.13.0 +version: 7.13.1 author: Shynixn website: https://www.spigotmc.org/members/shynixn.63455/ main: com.github.shynixn.blockball.BlockBallPlugin diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index f01e57bd2..d0b3c74dc 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: BlockBall -version: 7.13.0 +version: 7.13.1 author: Shynixn website: https://www.spigotmc.org/members/shynixn.63455/ main: com.github.shynixn.blockball.BlockBallPlugin