mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-19 15:09:17 +00:00
Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67d55bbdc2 | ||
|
|
46aa086366 | ||
|
|
9f00334ea4 | ||
|
|
e6db159bfb | ||
|
|
3df7b75737 | ||
|
|
c243a425b3 | ||
|
|
e57fe61d22 | ||
|
|
9830aed484 | ||
|
|
999b89bcb0 | ||
|
|
e7f326efbb | ||
|
|
0cb5b0b7b7 | ||
|
|
8e2d901e9b | ||
|
|
724eede36e | ||
|
|
01a2cc7118 | ||
|
|
20aace3727 | ||
|
|
ec9d4c0dd6 | ||
|
|
b3a0c1fa67 | ||
|
|
88294a17cd | ||
|
|
1ac6a350ec | ||
|
|
a9333cb8b5 | ||
|
|
23085e74e2 | ||
|
|
80f02a07a4 | ||
|
|
a63625593d | ||
|
|
1dfd7bac1f | ||
|
|
34b983b185 | ||
|
|
33b2fd9e13 | ||
|
|
85cfb542dc | ||
|
|
197f9e91aa | ||
|
|
9d4a91805a | ||
|
|
87b91c46d1 | ||
|
|
4a7e6e9ff1 | ||
|
|
b59e54be01 |
@@ -4,7 +4,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,12 +63,12 @@ allprojects {
|
||||
|
||||
dependencies {
|
||||
compileOnly 'com.willfp:eco:6.35.1'
|
||||
implementation 'com.willfp:libreforge:3.71.1'
|
||||
implementation 'com.willfp:libreforge:3.81.0'
|
||||
implementation 'org.joml:joml:1.10.4'
|
||||
|
||||
compileOnly 'org.jetbrains:annotations:23.0.0'
|
||||
|
||||
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.6.21'
|
||||
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.7.10'
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
|
||||
@@ -14,7 +14,7 @@ val Player.bossHolders: Iterable<Holder>
|
||||
|
||||
for (boss in Bosses.values()) {
|
||||
for (livingBoss in boss.getAllAlive()) {
|
||||
val entity = livingBoss.entity ?: continue
|
||||
val entity = livingBoss.entity
|
||||
|
||||
if (entity.world != this.world) {
|
||||
continue
|
||||
|
||||
@@ -332,7 +332,7 @@ class EcoBoss(
|
||||
|
||||
val boss = LivingEcoBoss(
|
||||
plugin,
|
||||
mob.uniqueId,
|
||||
mob,
|
||||
this,
|
||||
createTickers()
|
||||
)
|
||||
@@ -345,7 +345,8 @@ class EcoBoss(
|
||||
LifespanTicker(),
|
||||
DisplayNameTicker(),
|
||||
TargetTicker(),
|
||||
TeleportHandler()
|
||||
TeleportHandler(),
|
||||
ChunkTicker()
|
||||
)
|
||||
|
||||
if (isBossBarEnabled) {
|
||||
@@ -371,7 +372,7 @@ class EcoBoss(
|
||||
}
|
||||
|
||||
fun processRewards(event: BossKillEvent) {
|
||||
val entity = event.boss.entity ?: return
|
||||
val entity = event.boss.entity
|
||||
val location = entity.location
|
||||
val player = event.killer
|
||||
|
||||
|
||||
@@ -2,13 +2,12 @@ package com.willfp.ecobosses.bosses
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.ecobosses.tick.BossTicker
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.Chunk
|
||||
import org.bukkit.entity.Mob
|
||||
import java.util.UUID
|
||||
|
||||
class LivingEcoBoss(
|
||||
plugin: EcoPlugin,
|
||||
private val uuid: UUID,
|
||||
private val mob: Mob,
|
||||
val boss: EcoBoss,
|
||||
private val tickers: Set<BossTicker>
|
||||
) {
|
||||
@@ -18,15 +17,20 @@ class LivingEcoBoss(
|
||||
}
|
||||
}.apply { runTaskTimer(1, 1) }
|
||||
|
||||
val entity: Mob?
|
||||
get() = Bukkit.getEntity(uuid) as? Mob
|
||||
val entity: Mob
|
||||
get() = mob
|
||||
|
||||
val chunk: Chunk
|
||||
get() = entity.location.chunk
|
||||
|
||||
val forceLoadedChunks = mutableListOf<Chunk>()
|
||||
|
||||
val deathTime = System.currentTimeMillis() + (boss.lifespan * 1000)
|
||||
|
||||
private var currentTick = 1 // Start at 1 as 0 is divisible by everything
|
||||
|
||||
private fun tick(): Boolean {
|
||||
if (entity == null || entity?.isDead == true) {
|
||||
if (entity.isDead) {
|
||||
remove()
|
||||
return true
|
||||
}
|
||||
@@ -40,13 +44,15 @@ class LivingEcoBoss(
|
||||
|
||||
fun remove() {
|
||||
ticker.cancel()
|
||||
entity?.remove()
|
||||
entity.remove()
|
||||
tickers.forEach { it.onDeath(this, currentTick) }
|
||||
forceLoadedChunks.forEach { it.isForceLoaded = false }
|
||||
forceLoadedChunks.clear()
|
||||
|
||||
boss.markDead(uuid)
|
||||
boss.markDead(mob.uniqueId)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "LivingEcoBoss{boss=${boss}, uuid=${uuid}}"
|
||||
return "LivingEcoBoss{boss=${boss}, uuid=${mob.uniqueId}}"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class TargetMode(
|
||||
}
|
||||
|
||||
fun getTarget(boss: LivingEcoBoss): LivingEntity? {
|
||||
val entity = boss.entity ?: return null
|
||||
val entity = boss.entity
|
||||
|
||||
return function(
|
||||
entity.getNearbyEntities(
|
||||
|
||||
@@ -34,8 +34,8 @@ class ConsoleLoggers(
|
||||
return
|
||||
}
|
||||
|
||||
val loc = event.boss.entity?.location
|
||||
val location = "${loc?.world?.name}: ${loc?.x}, ${loc?.y}, ${loc?.z}"
|
||||
val loc = event.boss.entity.location
|
||||
val location = "${loc.world?.name}: ${loc.x}, ${loc.y}, ${loc.z}"
|
||||
|
||||
plugin.logger.info("&a${event.boss.boss.id}&r was killed by &a${event.killer?.name}&r at &a$location")
|
||||
}
|
||||
@@ -48,8 +48,8 @@ class ConsoleLoggers(
|
||||
if (!plugin.configYml.getBool("log-spawn-kill")) {
|
||||
return
|
||||
}
|
||||
val loc = event.boss.entity?.location
|
||||
val location = "${loc?.world?.name}: ${loc?.x}, ${loc?.y}, ${loc?.z}"
|
||||
val loc = event.boss.entity.location
|
||||
val location = "${loc.world?.name}: ${loc.x}, ${loc.y}, ${loc.z}"
|
||||
|
||||
plugin.logger.info("&a${event.boss.boss.id}&r despawned at &a$location")
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.willfp.ecobosses.bosses.Bosses
|
||||
import com.willfp.ecobosses.events.BossKillEvent
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.entity.EntityDeathEvent
|
||||
|
||||
@@ -25,7 +26,8 @@ class DeathListeners : Listener {
|
||||
}
|
||||
|
||||
@EventHandler(
|
||||
ignoreCancelled = true
|
||||
ignoreCancelled = true,
|
||||
priority = EventPriority.HIGHEST
|
||||
)
|
||||
fun handle(event: EntityDeathEvent) {
|
||||
val boss = Bosses[event.entity] ?: return
|
||||
|
||||
@@ -28,7 +28,7 @@ class LifecycleHandlers : Listener {
|
||||
priority = EventPriority.MONITOR
|
||||
)
|
||||
fun handle(event: BossKillEvent) {
|
||||
val entity = event.boss.entity ?: return
|
||||
val entity = event.boss.entity
|
||||
|
||||
event.boss.boss.handleLifecycle(BossLifecycle.KILL, entity.location, entity)
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class LifecycleHandlers : Listener {
|
||||
priority = EventPriority.MONITOR
|
||||
)
|
||||
fun handle(event: BossDespawnEvent) {
|
||||
val entity = event.boss.entity ?: return
|
||||
val entity = event.boss.entity
|
||||
|
||||
event.boss.boss.handleLifecycle(BossLifecycle.DESPAWN, entity.location, entity)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class BossBarTicker(
|
||||
private val bar: BossBar
|
||||
) : BossTicker {
|
||||
override fun tick(boss: LivingEcoBoss, tick: Int) {
|
||||
val entity = boss.entity ?: return
|
||||
val entity = boss.entity
|
||||
|
||||
bar.name(entity.customName!!.toComponent())
|
||||
bar.progress((entity.health / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH)!!.value).toFloat())
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.willfp.ecobosses.tick
|
||||
|
||||
import com.willfp.ecobosses.bosses.LivingEcoBoss
|
||||
|
||||
class ChunkTicker : BossTicker {
|
||||
override fun tick(boss: LivingEcoBoss, tick: Int) {
|
||||
val currentChunk = boss.chunk
|
||||
|
||||
if (tick % 10 != 0) {
|
||||
return
|
||||
}
|
||||
|
||||
if (currentChunk.isLoaded && currentChunk.isForceLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentChunk.load()
|
||||
currentChunk.isForceLoaded = true
|
||||
boss.forceLoadedChunks.add(currentChunk)
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import kotlin.math.ceil
|
||||
|
||||
class DisplayNameTicker : BossTicker {
|
||||
override fun tick(boss: LivingEcoBoss, tick: Int) {
|
||||
val entity = boss.entity ?: return
|
||||
val entity = boss.entity
|
||||
|
||||
val timeLeft = ceil(
|
||||
(boss.deathTime - System.currentTimeMillis()) / 1000.0
|
||||
|
||||
@@ -16,7 +16,7 @@ class LifespanTicker : BossTicker {
|
||||
boss.remove()
|
||||
boss.boss.handleLifecycle(
|
||||
BossLifecycle.DESPAWN,
|
||||
boss.entity?.location ?: return,
|
||||
boss.entity.location,
|
||||
boss.entity
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.willfp.ecobosses.bosses.LivingEcoBoss
|
||||
|
||||
class TargetTicker : BossTicker {
|
||||
override fun tick(boss: LivingEcoBoss, tick: Int) {
|
||||
val entity = boss.entity ?: return
|
||||
val entity = boss.entity
|
||||
|
||||
if (tick % 10 != 0) {
|
||||
return
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.bukkit.block.BlockFace
|
||||
|
||||
class TeleportHandler : BossTicker {
|
||||
override fun tick(boss: LivingEcoBoss, tick: Int) {
|
||||
val entity = boss.entity ?: return
|
||||
val entity = boss.entity
|
||||
if (!boss.boss.canTeleport) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#libreforge-updater
|
||||
#Thu Jun 30 22:34:12 BST 2022
|
||||
version=8.56.1
|
||||
#Thu Aug 04 13:03:36 BST 2022
|
||||
version=8.66.0
|
||||
plugin-name=EcoBosses
|
||||
|
||||
Reference in New Issue
Block a user