1
0
Fork 0

Fix Defibrillator

This commit is contained in:
Moritz Ruth 2020-06-08 20:43:45 +02:00
parent 3aa2bdc082
commit 73a86e9bc0
No known key found for this signature in database
GPG key ID: AFD57E23E753841B
2 changed files with 8 additions and 3 deletions

View file

@ -73,7 +73,7 @@ object Defibrillator: TTTItem, Buyable {
state.reset(tttPlayer)
isc.remove(tttPlayer)
} catch(e: TTTPlayer.AlreadyLivingException) {
// do not cancel the cancelTask
action.cancel()
}
} else state.bossBar.progress = progress
}
@ -94,9 +94,14 @@ object Defibrillator: TTTItem, Buyable {
val duration get() = Duration.between(startedAt, Instant.now()).toMillis().toDouble() / 1000
fun createCancelTask() = plugin.server.scheduler.runTaskLater(plugin, fun() {
state.action = Canceled(tttPlayer)
cancel()
}, 10)
fun cancel() {
cancelTask.cancel()
state.action = Canceled(tttPlayer)
}
init {
state.bossBar.color = BarColor.GREEN
state.bossBar.addPlayer(tttPlayer.player)

View file

@ -14,7 +14,7 @@ import org.bukkit.inventory.ItemStack
object EnderPearl: TTTItem, Buyable {
override val type = TTTItem.Type.SPECIAL
override val itemStack = ItemStack(Material.ENDER_PEARL).applyMeta {
setDisplayName("${ChatColor.DARK_GREEN}Ender Perle")
setDisplayName("${ChatColor.DARK_GREEN}Enderperle")
}
override val buyableBy = roles(Role.TRAITOR, Role.JACKAL, Role.DETECTIVE)
override val price = 1