diff --git a/src/main/kotlin/de/moritzruth/spigot_ttt/game/corpses/CorpseManager.kt b/src/main/kotlin/de/moritzruth/spigot_ttt/game/corpses/CorpseManager.kt index e80d816..a40812b 100644 --- a/src/main/kotlin/de/moritzruth/spigot_ttt/game/corpses/CorpseManager.kt +++ b/src/main/kotlin/de/moritzruth/spigot_ttt/game/corpses/CorpseManager.kt @@ -5,7 +5,7 @@ import org.bukkit.entity.Zombie import org.bukkit.inventory.Inventory object CorpseManager { - private val corpses = mutableListOf() + val corpses = mutableListOf() fun getTTTCorpse(entity: Entity): TTTCorpse? = if (entity is Zombie) corpses.find { it.entity === entity } else null @@ -17,7 +17,6 @@ object CorpseManager { fun isCorpseInventory(inventory: Inventory) = corpses.find { it.inventory == inventory } != null fun destroyAll() { - corpses.forEach(TTTCorpse::destroy) - corpses.clear() + corpses.toSet().forEach(TTTCorpse::destroy) } } diff --git a/src/main/kotlin/de/moritzruth/spigot_ttt/game/corpses/TTTCorpse.kt b/src/main/kotlin/de/moritzruth/spigot_ttt/game/corpses/TTTCorpse.kt index cdc50bf..d9d55e4 100644 --- a/src/main/kotlin/de/moritzruth/spigot_ttt/game/corpses/TTTCorpse.kt +++ b/src/main/kotlin/de/moritzruth/spigot_ttt/game/corpses/TTTCorpse.kt @@ -138,6 +138,7 @@ class TTTCorpse private constructor( entity.remove() updateTimeTask.cancel() inventory.viewers.toSet().forEach { it.closeInventory() } + CorpseManager.corpses.remove(this) } private fun ensureNotDestroyed() { diff --git a/src/main/kotlin/de/moritzruth/spigot_ttt/game/items/impl/Defibrillator.kt b/src/main/kotlin/de/moritzruth/spigot_ttt/game/items/impl/Defibrillator.kt index 1ccc694..8774498 100644 --- a/src/main/kotlin/de/moritzruth/spigot_ttt/game/items/impl/Defibrillator.kt +++ b/src/main/kotlin/de/moritzruth/spigot_ttt/game/items/impl/Defibrillator.kt @@ -45,7 +45,7 @@ object Defibrillator: TTTItem( "${ChatColor.BOLD}Defibrillator", BarColor.GREEN, BarStyle.SOLID - ) + ).also { it.isVisible = false } override fun onCarrierSet(carrier: TTTPlayer, isFirst: Boolean) { bossBar.addPlayer(carrier.player) @@ -87,7 +87,7 @@ object Defibrillator: TTTItem( ) action.cancelTask.cancel() - event.tttPlayer.player.inventory.removeTTTItemNextTick(Defibrillator) + event.tttPlayer.removeItem(Defibrillator) } catch(e: TTTPlayer.AlreadyLivingException) { action.cancel() } diff --git a/src/main/kotlin/de/moritzruth/spigot_ttt/game/items/impl/FakeCorpse.kt b/src/main/kotlin/de/moritzruth/spigot_ttt/game/items/impl/FakeCorpse.kt index fa7bc28..799035f 100644 --- a/src/main/kotlin/de/moritzruth/spigot_ttt/game/items/impl/FakeCorpse.kt +++ b/src/main/kotlin/de/moritzruth/spigot_ttt/game/items/impl/FakeCorpse.kt @@ -33,7 +33,7 @@ object FakeCorpse: TTTItem( price = 2 ), templateItemStack = ItemStack(Resourcepack.Items.fakeCorpse).applyMeta { - setDisplayName(FakeCorpse.DISPLAY_NAME) + setDisplayName("${ChatColor.YELLOW}${ChatColor.BOLD}Fake-Leiche") lore = listOf( "", "${ChatColor.GOLD}Spawnt eine Fake-Leiche", @@ -42,7 +42,7 @@ object FakeCorpse: TTTItem( hideInfo() } ) { - private val DISPLAY_NAME = "${ChatColor.YELLOW}${ChatColor.BOLD}Fake-Leiche" + private val INVENTORY_TITLE = "${ChatColor.RED}${ChatColor.BOLD}Fake-Leiche" class Instance: TTTItem.Instance(FakeCorpse) { var chosenRole: Role? = null @@ -56,7 +56,7 @@ object FakeCorpse: TTTItem( private val chooseRoleInventory = plugin.server.createInventory( null, InventoryType.HOPPER, - "${DISPLAY_NAME}${ChatColor.RESET} - Rolle" + "${INVENTORY_TITLE}${ChatColor.RESET} - Rolle" ).apply { addItem(*Role.values() .map { @@ -71,7 +71,7 @@ object FakeCorpse: TTTItem( private fun createChoosePlayerInventory() = plugin.server.createInventory( null, InventoryType.CHEST, - "${DISPLAY_NAME}${ChatColor.RESET} - Spieler" + "${INVENTORY_TITLE}${ChatColor.RESET} - Spieler" ).apply { addItem(*PlayerManager.tttPlayers .map { diff --git a/src/main/kotlin/de/moritzruth/spigot_ttt/game/items/impl/SecondChance.kt b/src/main/kotlin/de/moritzruth/spigot_ttt/game/items/impl/SecondChance.kt index afaa6bd..bd188ba 100644 --- a/src/main/kotlin/de/moritzruth/spigot_ttt/game/items/impl/SecondChance.kt +++ b/src/main/kotlin/de/moritzruth/spigot_ttt/game/items/impl/SecondChance.kt @@ -56,7 +56,7 @@ object SecondChance: TTTItem( lateinit var tttPlayer: TTTPlayer fun possiblyTrigger() { - if (true || Random.nextBoolean()) trigger() + if (Random.nextBoolean()) trigger() } private fun trigger() { diff --git a/src/main/kotlin/de/moritzruth/spigot_ttt/game/players/TTTPlayer.kt b/src/main/kotlin/de/moritzruth/spigot_ttt/game/players/TTTPlayer.kt index 625a10f..960ed96 100644 --- a/src/main/kotlin/de/moritzruth/spigot_ttt/game/players/TTTPlayer.kt +++ b/src/main/kotlin/de/moritzruth/spigot_ttt/game/players/TTTPlayer.kt @@ -196,6 +196,8 @@ class TTTPlayer(player: Player, role: Role, val tttClass: TTTClassCompanion = TT } private fun clearInventory(becauseOfDeath: Boolean) { + player.closeInventory() + Shop.clear(this) val owningTTTItemInstances = getOwningTTTItemInstances() owningTTTItemInstances.forEach {