9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-19 15:09:17 +00:00

Compare commits

...

21 Commits

Author SHA1 Message Date
Auxilor
ec9d4c0dd6 libreforge-updater 2022-07-24 22:49:25 +01:00
Auxilor
b3a0c1fa67 libreforge-updater 2022-07-24 21:50:54 +01:00
Auxilor
88294a17cd libreforge-updater 2022-07-23 17:42:53 +01:00
Auxilor
1ac6a350ec libreforge-updater 2022-07-22 14:20:45 +01:00
Auxilor
a9333cb8b5 libreforge-updater 2022-07-21 20:14:10 +01:00
Auxilor
23085e74e2 Codestyle 2022-07-21 15:48:46 +01:00
Auxilor
80f02a07a4 Updated to 8.60.1 2022-07-21 15:48:22 +01:00
Will FP
a63625593d Merge pull request #45 from grzybeek/chunkticker
Fix spawning bosses on unloaded chunks
2022-07-21 15:26:05 +01:00
Auxilor
1dfd7bac1f libreforge-updater 2022-07-20 00:10:12 +01:00
Auxilor
34b983b185 libreforge-updater 2022-07-13 21:22:38 +01:00
Auxilor
33b2fd9e13 libreforge-updater 2022-07-12 14:58:43 +01:00
Auxilor
85cfb542dc libreforge-updater 2022-07-11 16:16:12 +01:00
Auxilor
197f9e91aa libreforge-updater 2022-07-09 12:10:35 +01:00
grzybeek
9d4a91805a Fix spawning bosses on unloaded chunks, keep them loaded and remove afterwards
Entity is no longer null, change not needed "?: return"
2022-07-06 02:06:46 +02:00
Auxilor
87b91c46d1 libreforge-updater 2022-07-05 18:32:14 +01:00
Auxilor
4a7e6e9ff1 libreforge-updater 2022-07-04 18:45:14 +01:00
Auxilor
b59e54be01 libreforge-updater 2022-06-30 22:54:36 +01:00
Auxilor
d26f0294cc libreforge-updater 2022-06-30 22:34:13 +01:00
Auxilor
150433d46b libreforge-updater 2022-06-26 13:03:03 +01:00
Auxilor
7de4d75c93 libreforge-updater 2022-06-25 22:22:48 +01:00
Auxilor
9790459a26 libreforge-updater 2022-06-24 13:57:52 +01:00
14 changed files with 58 additions and 30 deletions

View File

@@ -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.69.0'
implementation 'com.willfp:libreforge:3.77.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) {

View File

@@ -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

View File

@@ -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

View File

@@ -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}}"
}
}

View File

@@ -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(

View File

@@ -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")
}

View File

@@ -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)
}

View File

@@ -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())

View File

@@ -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)
}
}

View File

@@ -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

View File

@@ -16,7 +16,7 @@ class LifespanTicker : BossTicker {
boss.remove()
boss.boss.handleLifecycle(
BossLifecycle.DESPAWN,
boss.entity?.location ?: return,
boss.entity.location,
boss.entity
)
}

View File

@@ -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

View File

@@ -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
}

View File

@@ -1,4 +1,4 @@
#libreforge-updater
#Wed Jun 22 22:24:46 BST 2022
version=8.54.0
#Sun Jul 24 22:49:25 BST 2022
version=8.62.0
plugin-name=EcoBosses