Remove a boom body after it exploded
This commit is contained in:
parent
f9841bd01b
commit
165a2c056b
2 changed files with 4 additions and 2 deletions
|
@ -21,6 +21,7 @@ import org.bukkit.event.inventory.InventoryClickEvent
|
||||||
import org.bukkit.inventory.Inventory
|
import org.bukkit.inventory.Inventory
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.inventory.meta.SkullMeta
|
import org.bukkit.inventory.meta.SkullMeta
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
object BoomBody: TTTItem<BoomBody.Instance>(
|
object BoomBody: TTTItem<BoomBody.Instance>(
|
||||||
type = Type.SPECIAL,
|
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) {
|
override val listener = object : TTTItemListener<Instance>(this) {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
fun onCorpseClick(event: CorpseClickEvent) {
|
fun onCorpseClick(event: CorpseClickEvent) {
|
||||||
if (boomBodies.contains(event.tttCorpse)) {
|
if (boomBodies.contains(event.tttCorpse)) {
|
||||||
boomBodies.remove(event.tttCorpse)
|
boomBodies.remove(event.tttCorpse)
|
||||||
|
event.tttCorpse.destroy()
|
||||||
event.isCancelled = true
|
event.isCancelled = true
|
||||||
createKillExplosion(event.tttCorpse.spawnedBy!!, event.tttCorpse.location, 5.0)
|
createKillExplosion(event.tttCorpse.spawnedBy!!, event.tttCorpse.location, 5.0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ fun createKillExplosion(tttPlayer: TTTPlayer, location: Location, radius: Double
|
||||||
Particle.EXPLOSION_LARGE,
|
Particle.EXPLOSION_LARGE,
|
||||||
location,
|
location,
|
||||||
10,
|
10,
|
||||||
radius, radius, radius
|
1.0, 1.0, 1.0
|
||||||
)
|
)
|
||||||
|
|
||||||
GameManager.world.playSound(
|
GameManager.world.playSound(
|
||||||
|
|
Reference in a new issue