From 1078df493e6473f0b5cfa0409857c16e6fd60f53 Mon Sep 17 00:00:00 2001 From: ronald Date: Sun, 30 Jul 2023 17:51:53 -0500 Subject: Added fallback for players lobbyswapping to flee slayer boss to event system --- .../com/dulkirfabric/events/SlayerBossEvents.kt | 2 +- src/main/kotlin/com/dulkirfabric/util/Utils.kt | 25 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'src') 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 -- cgit