9
0
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:
Will FP
2022-08-13 12:00:09 +02:00
committed by GitHub
2 changed files with 8 additions and 8 deletions

View File

@@ -7,7 +7,7 @@ import org.bukkit.entity.Mob
class LivingEcoBoss( class LivingEcoBoss(
plugin: EcoPlugin, plugin: EcoPlugin,
private val mob: Mob, val entity: Mob,
val boss: EcoBoss, val boss: EcoBoss,
private val tickers: Set<BossTicker> private val tickers: Set<BossTicker>
) { ) {
@@ -17,9 +17,6 @@ class LivingEcoBoss(
} }
}.apply { runTaskTimer(1, 1) } }.apply { runTaskTimer(1, 1) }
val entity: Mob
get() = mob
val chunk: Chunk val chunk: Chunk
get() = entity.location.chunk get() = entity.location.chunk
@@ -46,13 +43,11 @@ class LivingEcoBoss(
ticker.cancel() ticker.cancel()
entity.remove() entity.remove()
tickers.forEach { it.onDeath(this, currentTick) } 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 { override fun toString(): String {
return "LivingEcoBoss{boss=${boss}, uuid=${mob.uniqueId}}" return "LivingEcoBoss{boss=${boss}, uuid=${entity.uniqueId}}"
} }
} }

View File

@@ -18,4 +18,9 @@ class ChunkTicker : BossTicker {
currentChunk.isForceLoaded = true currentChunk.isForceLoaded = true
boss.forceLoadedChunks.add(currentChunk) boss.forceLoadedChunks.add(currentChunk)
} }
override fun onDeath(boss: LivingEcoBoss, tick: Int) {
boss.forceLoadedChunks.forEach { it.isForceLoaded = false }
boss.forceLoadedChunks.clear()
}
} }