Skip to content

Commit

Permalink
title countdown
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonUden committed Apr 21, 2024
1 parent 04fbd35 commit 056184a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ DisableDefaultEndSound: false

DisableBuiltInCountdownSound: false
DisableActionBar: false
DisableChatCountdown: false
DisableChatCountdown: true
DisableTitleCountdown: false

ShuffleSpawnLocations: false
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ class SurvivalGamesConfig(configFile: FileConfiguration) {

@get:JvmName("isShuffleSpawnLocations")
var shuffleSpawnLocations = configFile.getBoolean("ShuffleSpawnLocations")

@get:JvmName("isDisableTitleCountdown")
var disableTitleCountdown = configFile.getBoolean("DisableTitleCountdown")
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -358,18 +358,19 @@ 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) {
if (timeLeft > 0) {
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()
Expand Down Expand Up @@ -479,7 +480,7 @@ class SurvivalGames(@SuppressWarnings("WeakerAccess") val plugin: SurvivalGamesP

@EventHandler(priority = EventPriority.NORMAL)
fun onGameBegin(e: GameBeginEvent) {
if(modifierBeginCalled) {
if (modifierBeginCalled) {
return
}

Expand All @@ -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
}
Expand Down

0 comments on commit 056184a

Please sign in to comment.