1
0
Fork 0

Remove a boom body after it exploded

This commit is contained in:
Moritz Ruth 2020-06-20 23:00:03 +02:00
parent f9841bd01b
commit 165a2c056b
No known key found for this signature in database
GPG key ID: AFD57E23E753841B
2 changed files with 4 additions and 2 deletions

View file

@ -21,6 +21,7 @@ import org.bukkit.event.inventory.InventoryClickEvent
import org.bukkit.inventory.Inventory
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.SkullMeta
import java.util.*
object BoomBody: TTTItem<BoomBody.Instance>(
type = Type.SPECIAL,
@ -52,13 +53,14 @@ object BoomBody: TTTItem<BoomBody.Instance>(
}
}
val boomBodies = mutableSetOf<TTTCorpse>()
val boomBodies: MutableSet<TTTCorpse> = Collections.newSetFromMap(WeakHashMap<TTTCorpse, Boolean>())
override val listener = object : TTTItemListener<Instance>(this) {
@EventHandler
fun onCorpseClick(event: CorpseClickEvent) {
if (boomBodies.contains(event.tttCorpse)) {
boomBodies.remove(event.tttCorpse)
event.tttCorpse.destroy()
event.isCancelled = true
createKillExplosion(event.tttCorpse.spawnedBy!!, event.tttCorpse.location, 5.0)
}

View file

@ -16,7 +16,7 @@ fun createKillExplosion(tttPlayer: TTTPlayer, location: Location, radius: Double
Particle.EXPLOSION_LARGE,
location,
10,
radius, radius, radius
1.0, 1.0, 1.0
)
GameManager.world.playSound(