diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/events/SlayerBossEvents.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/util/Utils.kt | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/events/SlayerBossEvents.kt b/src/main/kotlin/com/dulkirfabric/events/SlayerBossEvents.kt index 7097ccb..e1138fb 100644 --- a/src/main/kotlin/com/dulkirfabric/events/SlayerBossEvents.kt +++ b/src/main/kotlin/com/dulkirfabric/events/SlayerBossEvents.kt @@ -14,7 +14,7 @@ class SlayerBossEvents { ): Event() data class Fail( - val type: String, + val type: String?, var timestamp: Long = System.currentTimeMillis() ): Event() } diff --git a/src/main/kotlin/com/dulkirfabric/util/Utils.kt b/src/main/kotlin/com/dulkirfabric/util/Utils.kt index 18a442e..a0fec78 100644 --- a/src/main/kotlin/com/dulkirfabric/util/Utils.kt +++ b/src/main/kotlin/com/dulkirfabric/util/Utils.kt @@ -2,6 +2,7 @@ package com.dulkirfabric.util import com.dulkirfabric.events.PlaySoundEvent import com.dulkirfabric.events.SlayerBossEvents +import com.dulkirfabric.events.WorldLoadEvent import com.dulkirfabric.events.chat.ChatEvents import meteordevelopment.orbit.EventHandler import net.minecraft.block.entity.SkullBlockEntity @@ -12,6 +13,9 @@ import net.minecraft.nbt.NbtHelper import net.minecraft.util.math.Vec3d object Utils { + + private var inSlayerBoss = false + fun isInSkyblock(): Boolean { return ScoreBoardUtils.getLines() != null } @@ -47,6 +51,27 @@ object Utils { } } + @EventHandler + fun onSpawn(event: SlayerBossEvents.Spawn) { + inSlayerBoss = true + } + + @EventHandler + fun onSwap(event: WorldLoadEvent) { + if (inSlayerBoss) + SlayerBossEvents.Fail(ScoreBoardUtils.slayerType).post() + } + + @EventHandler + fun onKill(event: SlayerBossEvents.Kill) { + inSlayerBoss = false + } + + @EventHandler + fun onFail(event: SlayerBossEvents.Fail) { + inSlayerBoss = false + } + fun getSkullTexture(itemStack: ItemStack): String? { return itemStack.getSubNbt(SkullBlockEntity.SKULL_OWNER_KEY)?.let(NbtHelper::toGameProfile)?.properties?.get( PlayerSkinProvider.TEXTURES)?.first()?.value |