From 056184a4f57ef7adf22628cd44310e3d42411cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20ud=C3=A9n?= Date: Sun, 21 Apr 2024 22:22:11 +0200 Subject: [PATCH] title countdown --- config.yml | 3 ++- .../configuration/SurvivalGamesConfig.kt | 3 +++ .../games/survivalgames/game/SurvivalGames.kt | 17 +++++++++-------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/config.yml b/config.yml index 0b9fb23..997afad 100644 --- a/config.yml +++ b/config.yml @@ -19,6 +19,7 @@ DisableDefaultEndSound: false DisableBuiltInCountdownSound: false DisableActionBar: false -DisableChatCountdown: false +DisableChatCountdown: true +DisableTitleCountdown: false ShuffleSpawnLocations: false \ No newline at end of file diff --git a/src/main/kotlin/net/novauniverse/games/survivalgames/configuration/SurvivalGamesConfig.kt b/src/main/kotlin/net/novauniverse/games/survivalgames/configuration/SurvivalGamesConfig.kt index caa5c44..227dcd1 100644 --- a/src/main/kotlin/net/novauniverse/games/survivalgames/configuration/SurvivalGamesConfig.kt +++ b/src/main/kotlin/net/novauniverse/games/survivalgames/configuration/SurvivalGamesConfig.kt @@ -33,4 +33,7 @@ class SurvivalGamesConfig(configFile: FileConfiguration) { @get:JvmName("isShuffleSpawnLocations") var shuffleSpawnLocations = configFile.getBoolean("ShuffleSpawnLocations") + + @get:JvmName("isDisableTitleCountdown") + var disableTitleCountdown = configFile.getBoolean("DisableTitleCountdown") } \ No newline at end of file diff --git a/src/main/kotlin/net/novauniverse/games/survivalgames/game/SurvivalGames.kt b/src/main/kotlin/net/novauniverse/games/survivalgames/game/SurvivalGames.kt index 4c52cec..a62e6c2 100644 --- a/src/main/kotlin/net/novauniverse/games/survivalgames/game/SurvivalGames.kt +++ b/src/main/kotlin/net/novauniverse/games/survivalgames/game/SurvivalGames.kt @@ -334,7 +334,7 @@ class SurvivalGames(@SuppressWarnings("WeakerAccess") val plugin: SurvivalGamesP if (!plugin.survivalGamesConfig!!.disableChatCountdown) { player.sendMessage(LanguageManager.getString(player, "survivalgames.game.starting_in", countdownTime)) } - VersionIndependentUtils.get().sendTitle(player, "", LanguageManager.getString(player, "survivalgames.game.starting_in_title", countdownTime), 10, 20, 10) + VersionIndependentUtils.get().sendTitle(player, "", LanguageManager.getString(player, "survivalgames.game.starting_in_title", countdownTime), 0, 20, 10) } val startTimer = BasicTimer(countdownTime.toLong(), 20L) @@ -358,11 +358,7 @@ class SurvivalGames(@SuppressWarnings("WeakerAccess") val plugin: SurvivalGamesP if (!plugin.survivalGamesConfig!!.disableBuiltInCountdownSound) { VersionIndependentUtils.get().playSound(player, player!!.location, VersionIndependentSound.NOTE_PLING, 1f, 1.3f) } - if (plugin.survivalGamesConfig!!.disableActionBar) { - if (timeLeft > 0) { - VersionIndependentUtils.getInstance().sendTitle(player, "", LanguageManager.getString(player, "survivalgames.game.starting_in_title", timeLeft), 0, 20, 5) - } - } else { + if (!plugin.survivalGamesConfig!!.disableActionBar) { VersionIndependentUtils.get().sendActionBarMessage(player, LanguageManager.getString(player, "survivalgames.game.starting_in", timeLeft)) } if (!plugin.survivalGamesConfig!!.disableChatCountdown) { @@ -370,6 +366,11 @@ class SurvivalGames(@SuppressWarnings("WeakerAccess") val plugin: SurvivalGamesP player!!.sendMessage(LanguageManager.getString(player, "survivalgames.game.starting_in", timeLeft)) } } + if (!plugin.survivalGamesConfig!!.disableTitleCountdown) { + if (timeLeft > 0) { + VersionIndependentUtils.getInstance().sendTitle(player, "", LanguageManager.getString(player, "survivalgames.game.starting_in_title", timeLeft), 0, 20, 5) + } + } } } startTimer.start() @@ -479,7 +480,7 @@ class SurvivalGames(@SuppressWarnings("WeakerAccess") val plugin: SurvivalGamesP @EventHandler(priority = EventPriority.NORMAL) fun onGameBegin(e: GameBeginEvent) { - if(modifierBeginCalled) { + if (modifierBeginCalled) { return } @@ -490,7 +491,7 @@ class SurvivalGames(@SuppressWarnings("WeakerAccess") val plugin: SurvivalGamesP @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) fun onEntityDamage(e: EntityDamageEvent) { - if(ended) { + if (ended) { e.isCancelled = true return }