From fd22a19a401c50d103722c7a1694d051bc7cb84d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 8 Sep 2023 17:42:10 +0200 Subject: moving current area into test class and code cleanup --- .../java/at/hannibal2/skyhanni/data/HypixelData.kt | 22 ++++++++---------- .../hannibal2/skyhanni/test/SkyHanniTestCommand.kt | 26 ++++++++++++++++------ 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 043ee6442..329b6b1b3 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -5,7 +5,6 @@ import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData @@ -19,7 +18,7 @@ class HypixelData { private val tabListProfilePattern = "§e§lProfile: §r§a(?.*)".toPattern() private val westVillageFarmArea = AxisAlignedBB(-54.0, 69.0, -115.0, -40.0, 75.0, -127.0) private val howlingCaveArea = AxisAlignedBB(-401.0, 50.0, -104.0, -337.0, 90.0, 36.0) - private val zealotBruiserHideoutFixArea = AxisAlignedBB(-520.0, 66.0, -332.0, -558.0, 85.0, -280.0) + private val zealotBruiserHideoutArea = AxisAlignedBB(-520.0, 66.0, -332.0, -558.0, 85.0, -280.0) companion object { var hypixelLive = false @@ -73,25 +72,22 @@ class HypixelData { } } - @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { - if (LorenzUtils.inSkyBlock && Minecraft.getMinecraft().gameSettings.showDebugInfo) { - config.debugLocationPos.renderString("Current Area: $skyBlockArea", posLabel = "SkyBlock Area (Debug)") - } - } - @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (event.isMod(2)) { if (LorenzUtils.inSkyBlock) { - skyBlockArea = ScoreboardData.sidebarLinesFormatted + val originalLocation = ScoreboardData.sidebarLinesFormatted .firstOrNull { it.startsWith(" §7⏣ ") || it.startsWith(" §5ф ") } ?.substring(5)?.removeColor() ?: "?" - if (skyBlockIsland == IslandType.THE_RIFT && westVillageFarmArea.isPlayerInside()) skyBlockArea = "Dreadfarm" - if (skyBlockIsland == IslandType.THE_PARK && howlingCaveArea.isPlayerInside()) skyBlockArea = "Howling Cave" - if (skyBlockIsland == IslandType.THE_END && zealotBruiserHideoutFixArea.isPlayerInside()) skyBlockArea = "The End" + skyBlockArea = when { + skyBlockIsland == IslandType.THE_RIFT && westVillageFarmArea.isPlayerInside() -> "Dreadfarm" + skyBlockIsland == IslandType.THE_PARK && howlingCaveArea.isPlayerInside() -> "Howling Cave" + skyBlockIsland == IslandType.THE_END && zealotBruiserHideoutArea.isPlayerInside() -> "The End" + + else -> originalLocation + } checkProfileName() } diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniTestCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniTestCommand.kt index 63bc5f471..da7ec6d4e 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniTestCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniTestCommand.kt @@ -15,6 +15,7 @@ import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems +import net.minecraft.client.Minecraft import net.minecraft.nbt.NBTTagCompound import net.minecraftforge.common.MinecraftForge import net.minecraftforge.event.entity.player.ItemTooltipEvent @@ -24,6 +25,7 @@ import java.io.File class SkyHanniTestCommand { companion object { + private val config get() = SkyHanniMod.feature.dev var displayLine = "" var displayList = emptyList>() @@ -198,7 +200,7 @@ class SkyHanniTestCommand { builder.append("\n") builder.append("player name: '${LorenzUtils.getPlayerName()}'\n") builder.append("player uuid: '${LorenzUtils.getPlayerUuid()}'\n") - builder.append("repoAutoUpdate: ${SkyHanniMod.feature.dev.repoAutoUpdate}\n") + builder.append("repoAutoUpdate: ${config.repoAutoUpdate}\n") builder.append("\n") builder.append("onHypixel: ${LorenzUtils.onHypixel}\n") @@ -232,16 +234,16 @@ class SkyHanniTestCommand { @SubscribeEvent fun onShowInternalName(event: ItemTooltipEvent) { - if (!SkyHanniMod.feature.dev.showInternalName) return + if (!config.showInternalName) return val itemStack = event.itemStack ?: return val internalName = itemStack.getInternalName() - if ((internalName == NEUInternalName.NONE) && !SkyHanniMod.feature.dev.showEmptyNames) return + if ((internalName == NEUInternalName.NONE) && !config.showEmptyNames) return event.toolTip.add("Internal Name: '${internalName.asString()}'") } @SubscribeEvent fun onSHowNpcPrice(event: ItemTooltipEvent) { - if (!SkyHanniMod.feature.dev.showNpcPrice) return + if (!config.showNpcPrice) return val itemStack = event.itemStack ?: return val internalName = itemStack.getInternalNameOrNull() ?: return @@ -249,6 +251,16 @@ class SkyHanniTestCommand { event.toolTip.add("§7Npc price: §6${npcPrice.addSeparators()}") } + @SubscribeEvent + fun onRenderLocation(event: GuiRenderEvent.GameOverlayRenderEvent) { + if (LorenzUtils.inSkyBlock && Minecraft.getMinecraft().gameSettings.showDebugInfo) { + config.debugLocationPos.renderString( + "Current Area: ${HypixelData.skyBlockArea}", + posLabel = "SkyBlock Area (Debug)" + ) + } + } + @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { @@ -257,12 +269,12 @@ class SkyHanniTestCommand { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { if (!LorenzUtils.inSkyBlock) return - if (!SkyHanniMod.feature.dev.debugEnabled) return + if (!config.debugEnabled) return if (displayLine.isNotEmpty()) { - SkyHanniMod.feature.dev.debugPos.renderString("test: $displayLine", posLabel = "Test") + config.debugPos.renderString("test: $displayLine", posLabel = "Test") } - SkyHanniMod.feature.dev.debugPos.renderStringsAndItems(displayList, posLabel = "Test Display") + config.debugPos.renderStringsAndItems(displayList, posLabel = "Test Display") } @SubscribeEvent -- cgit