mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-20 15:39:31 +00:00
Merge pull request #47 from grzybeek/chunkticker
small chunkticker code cleanup
This commit is contained in:
@@ -7,7 +7,7 @@ import org.bukkit.entity.Mob
|
||||
|
||||
class LivingEcoBoss(
|
||||
plugin: EcoPlugin,
|
||||
private val mob: Mob,
|
||||
val entity: Mob,
|
||||
val boss: EcoBoss,
|
||||
private val tickers: Set<BossTicker>
|
||||
) {
|
||||
@@ -17,9 +17,6 @@ class LivingEcoBoss(
|
||||
}
|
||||
}.apply { runTaskTimer(1, 1) }
|
||||
|
||||
val entity: Mob
|
||||
get() = mob
|
||||
|
||||
val chunk: Chunk
|
||||
get() = entity.location.chunk
|
||||
|
||||
@@ -46,13 +43,11 @@ class LivingEcoBoss(
|
||||
ticker.cancel()
|
||||
entity.remove()
|
||||
tickers.forEach { it.onDeath(this, currentTick) }
|
||||
forceLoadedChunks.forEach { it.isForceLoaded = false }
|
||||
forceLoadedChunks.clear()
|
||||
|
||||
boss.markDead(mob.uniqueId)
|
||||
boss.markDead(entity.uniqueId)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "LivingEcoBoss{boss=${boss}, uuid=${mob.uniqueId}}"
|
||||
return "LivingEcoBoss{boss=${boss}, uuid=${entity.uniqueId}}"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,9 @@ class ChunkTicker : BossTicker {
|
||||
currentChunk.isForceLoaded = true
|
||||
boss.forceLoadedChunks.add(currentChunk)
|
||||
}
|
||||
|
||||
override fun onDeath(boss: LivingEcoBoss, tick: Int) {
|
||||
boss.forceLoadedChunks.forEach { it.isForceLoaded = false }
|
||||
boss.forceLoadedChunks.clear()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user