Skip to content

Commit

Permalink
Merge pull request #614 from Shynixn/development
Browse files Browse the repository at this point in the history
Merge changes to master --release
  • Loading branch information
Shynixn authored Feb 22, 2025
2 parents e47358a + 85d6ecf commit 9cd9d6b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 39 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "com.github.shynixn"
version = "7.13.0"
version = "7.13.1"

repositories {
mavenLocal()
Expand Down Expand Up @@ -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")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,35 @@ class BlockBallDependencyInjectionModule(
module.addService<BlockBallLanguage>(language)

// Repositories
val arenaRepository = CachedRepositoryImpl(
YamlFileRepositoryImpl<SoccerArena>(
plugin, "arena",
listOf(Pair("arena_sample.yml", "arena_sample.yml")),
listOf("arena_sample.yml"),
object : TypeReference<SoccerArena>() {}
))
module.addService<Repository<SoccerArena>>(arenaRepository)
module.addService<CacheRepository<SoccerArena>>(arenaRepository)
val configSelectedPlayerDataRepository = ConfigSelectedRepositoryImpl<PlayerInformation>(
plugin,
"BlockBall",
plugin.dataFolder.toPath().resolve("BlockBall.sqlite"),
object : TypeReference<PlayerInformation>() {},
plugin.minecraftDispatcher
)
val playerDataRepository = AutoSavePlayerDataRepositoryImpl(
1000 * 60L * plugin.config.getInt("database.autoSaveIntervalMinutes"),
CachedPlayerDataRepositoryImpl(configSelectedPlayerDataRepository, plugin.minecraftDispatcher),
plugin.scope, plugin.minecraftDispatcher
)
module.addService<PlayerDataRepository<PlayerInformation>>(playerDataRepository)
module.addService<CachePlayerRepository<PlayerInformation>>(playerDataRepository)
module.addService<Repository<SoccerArena>> {
module.getService<CacheRepository<SoccerArena>>()
}
module.addService<CacheRepository<SoccerArena>> {
CachedRepositoryImpl(
YamlFileRepositoryImpl<SoccerArena>(
plugin, "arena",
listOf(Pair("arena_sample.yml", "arena_sample.yml")),
listOf("arena_sample.yml"),
object : TypeReference<SoccerArena>() {}
))
}
module.addService<PlayerDataRepository<PlayerInformation>> {
module.getService<CachePlayerRepository<PlayerInformation>>()
}
module.addService<CachePlayerRepository<PlayerInformation>> {
val configSelectedPlayerDataRepository = ConfigSelectedRepositoryImpl<PlayerInformation>(
plugin,
"BlockBall",
plugin.dataFolder.toPath().resolve("BlockBall.sqlite"),
object : TypeReference<PlayerInformation>() {},
plugin.minecraftDispatcher
)
AutoSavePlayerDataRepositoryImpl(
1000 * 60L * plugin.config.getInt("database.autoSaveIntervalMinutes"),
CachedPlayerDataRepositoryImpl(configSelectedPlayerDataRepository, plugin.minecraftDispatcher),
plugin.scope, plugin.minecraftDispatcher
)
}
module.addService<SignService> {
SignServiceImpl(plugin, module.getService(), language.noPermissionMessage.text)
}
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/com/github/shynixn/blockball/BlockBallPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlayerInformation>>()
playerDataRepository.createIfNotExist()
} catch (e: Exception) {
e.printStackTrace()
Bukkit.getPluginManager().disablePlugin(this)
return
}

// Register PlaceHolder
PlaceHolder.registerAll(
module.getService(), module.getService(), module.getService(), module.getService()
Expand All @@ -137,7 +147,6 @@ class BlockBallPlugin : JavaPlugin() {
)
Bukkit.getServicesManager()
.register(GameService::class.java, module.getService<GameService>(), this, ServicePriority.Normal)

val plugin = this
plugin.launch {
// Load Games
Expand All @@ -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<PlayerInformation>>()
playerDataRepository.createIfNotExist()
} catch (e: Exception) {
e.printStackTrace()
immidiateDisable = true
Bukkit.getPluginManager().disablePlugin(plugin)
return@launch
}

// Enable stats
module.getService<StatsService>().register()

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin-legacy.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 9cd9d6b

Please sign in to comment.