From ce0956ac232f444724f90f0633b4b35f3dd8cfdf Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 7 Jan 2023 02:35:44 +0100 Subject: Renamed hypixel and skyblock. --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 2 +- .../java/at/hannibal2/skyhanni/data/HyPixelData.kt | 155 +++++++++++++++++++++ .../java/at/hannibal2/skyhanni/data/HypixelData.kt | 155 --------------------- .../skyhanni/features/chat/PlayerDeathMessages.kt | 7 - .../features/event/diana/BurrowWarpHelper.kt | 3 +- .../at/hannibal2/skyhanni/utils/LorenzUtils.kt | 14 +- 6 files changed, 164 insertions(+), 172 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index c59444b99..298b01686 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -86,7 +86,7 @@ public class SkyHanniMod { new BazaarApi(); loadModule(this); loadModule(new ChatManager()); - loadModule(new HypixelData()); + loadModule(new HyPixelData()); loadModule(new DungeonData()); loadModule(new ScoreboardData()); loadModule(new ApiDataLoader()); diff --git a/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt new file mode 100644 index 000000000..e1c466762 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt @@ -0,0 +1,155 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.events.IslandChangeEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.utils.LorenzLogger +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.TabListUtils +import net.minecraft.client.Minecraft +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent +import net.minecraftforge.fml.common.network.FMLNetworkEvent + +class HyPixelData { + + companion object { + var hypixel = false + var skyBlock = false + var skyBlockIsland: String = "" + + //Ironman, Stranded and Bingo + var noTrade = false + + var ironman = false + var stranded = false + var bingo = false + + fun readSkyBlockArea(): String { + for (line in ScoreboardData.sidebarLinesFormatted()) { + if (line.startsWith(" §7⏣ ")) { + return line.substring(5).removeColor() + } + } + + return "invalid" + } + } + + private var loggerIslandChange = LorenzLogger("debug/island_change") + + @SubscribeEvent + fun onConnect(event: FMLNetworkEvent.ClientConnectedToServerEvent) { + hypixel = Minecraft.getMinecraft().runCatching { + !event.isLocal && (thePlayer?.clientBrand?.lowercase()?.contains("hypixel") + ?: currentServerData?.serverIP?.lowercase()?.contains("hypixel") ?: false) + }.onFailure { it.printStackTrace() }.getOrDefault(false) + } + + @SubscribeEvent + fun onWorldChange(event: WorldEvent.Load) { + skyBlock = false + } + + @SubscribeEvent + fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) { + hypixel = false + skyBlock = false + } + + @SubscribeEvent + fun onStatusBar(event: LorenzChatEvent) { + if (!hypixel) return + + val message = event.message.removeColor().lowercase() + if (message.startsWith("your profile was changed to:")) { + val stripped = message.replace("your profile was changed to:", "").replace("(co-op)", "").trim() + ProfileJoinEvent(stripped).postAndCatch() + } + if (message.startsWith("you are playing on profile:")) { + val stripped = message.replace("you are playing on profile:", "").replace("(co-op)", "").trim() + ProfileJoinEvent(stripped).postAndCatch() + } + } + + var tick = 0 + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (!hypixel) return + if (event.phase != TickEvent.Phase.START) return + + tick++ + + if (tick % 5 != 0) return + + val inSkyBlock = checkScoreboard() + if (inSkyBlock) { + checkIsland() + checkSidebar() + } + + if (inSkyBlock == skyBlock) return + skyBlock = inSkyBlock + } + + private fun checkSidebar() { + ironman = false + stranded = false + bingo = false + + for (line in ScoreboardData.sidebarLinesFormatted()) { + when (line) { + " §7Ⓑ §7Bingo", // No Rank + " §bⒷ §bBingo", // Rank 1 + " §9Ⓑ §9Bingo", // Rank 2 + " §5Ⓑ §5Bingo", // Rank 3 + " §6Ⓑ §6Bingo", // Rank 4 + -> { + bingo = true + } + + // TODO implemennt stranded check + + " §7♲ §7Ironman" -> { + ironman = true + } + + } + } + + noTrade = ironman || stranded || bingo + } + + private fun checkIsland() { + var newIsland = "" + var guesting = false + for (line in TabListUtils.getTabList()) { + if (line.startsWith("§r§b§lArea: ")) { + newIsland = line.split(": ")[1].removeColor() + } + if (line == "§r Status: §r§9Guest§r") { + guesting = true + } + } + if (guesting) { + newIsland = "$newIsland guesting" + } + + if (skyBlockIsland != newIsland) { + IslandChangeEvent(newIsland, skyBlockIsland).postAndCatch() + loggerIslandChange.log(newIsland) + skyBlockIsland = newIsland + } + } + + private fun checkScoreboard(): Boolean { + val minecraft = Minecraft.getMinecraft() + val world = minecraft.theWorld ?: return false + + val objective = world.scoreboard.getObjectiveInDisplaySlot(1) ?: return false + val displayName = objective.displayName + return displayName.removeColor().contains("SKYBLOCK") + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt deleted file mode 100644 index bbb3db69d..000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ /dev/null @@ -1,155 +0,0 @@ -package at.hannibal2.skyhanni.data - -import at.hannibal2.skyhanni.events.IslandChangeEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.ProfileJoinEvent -import at.hannibal2.skyhanni.utils.LorenzLogger -import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import at.hannibal2.skyhanni.utils.TabListUtils -import net.minecraft.client.Minecraft -import net.minecraftforge.event.world.WorldEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent -import net.minecraftforge.fml.common.network.FMLNetworkEvent - -class HypixelData { - - companion object { - var hypixel = false - var skyBlock = false - var skyBlockIsland: String = "" - - //Ironman, Stranded and Bingo - var noTrade = false - - var ironman = false - var stranded = false - var bingo = false - - fun readSkyBlockArea(): String { - for (line in ScoreboardData.sidebarLinesFormatted()) { - if (line.startsWith(" §7⏣ ")) { - return line.substring(5).removeColor() - } - } - - return "invalid" - } - } - - var loggerIslandChange = LorenzLogger("debug/island_change") - - @SubscribeEvent - fun onConnect(event: FMLNetworkEvent.ClientConnectedToServerEvent) { - hypixel = Minecraft.getMinecraft().runCatching { - !event.isLocal && (thePlayer?.clientBrand?.lowercase()?.contains("hypixel") - ?: currentServerData?.serverIP?.lowercase()?.contains("hypixel") ?: false) - }.onFailure { it.printStackTrace() }.getOrDefault(false) - } - - @SubscribeEvent - fun onWorldChange(event: WorldEvent.Load) { - skyBlock = false - } - - @SubscribeEvent - fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) { - hypixel = false - skyBlock = false - } - - @SubscribeEvent - fun onStatusBar(event: LorenzChatEvent) { - if (!hypixel) return - - val message = event.message.removeColor().lowercase() - if (message.startsWith("your profile was changed to:")) { - val stripped = message.replace("your profile was changed to:", "").replace("(co-op)", "").trim() - ProfileJoinEvent(stripped).postAndCatch() - } - if (message.startsWith("you are playing on profile:")) { - val stripped = message.replace("you are playing on profile:", "").replace("(co-op)", "").trim() - ProfileJoinEvent(stripped).postAndCatch() - } - } - - var tick = 0 - - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (!hypixel) return - if (event.phase != TickEvent.Phase.START) return - - tick++ - - if (tick % 5 != 0) return - - val inSkyBlock = checkScoreboard() - if (inSkyBlock) { - checkIsland() - checkSidebar() - } - - if (inSkyBlock == skyBlock) return - skyBlock = inSkyBlock - } - - private fun checkSidebar() { - ironman = false - stranded = false - bingo = false - - for (line in ScoreboardData.sidebarLinesFormatted()) { - when (line) { - " §7Ⓑ §7Bingo", // No Rank - " §bⒷ §bBingo", // Rank 1 - " §9Ⓑ §9Bingo", // Rank 2 - " §5Ⓑ §5Bingo", // Rank 3 - " §6Ⓑ §6Bingo", // Rank 4 - -> { - bingo = true - } - - // TODO implemennt stranded check - - " §7♲ §7Ironman" -> { - ironman = true - } - - } - } - - noTrade = ironman || stranded || bingo - } - - private fun checkIsland() { - var newIsland = "" - var guesting = false - for (line in TabListUtils.getTabList()) { - if (line.startsWith("§r§b§lArea: ")) { - newIsland = line.split(": ")[1].removeColor() - } - if (line == "§r Status: §r§9Guest§r") { - guesting = true - } - } - if (guesting) { - newIsland = "$newIsland guesting" - } - - if (skyBlockIsland != newIsland) { - IslandChangeEvent(newIsland, skyBlockIsland).postAndCatch() - loggerIslandChange.log(newIsland) - skyBlockIsland = newIsland - } - } - - private fun checkScoreboard(): Boolean { - val minecraft = Minecraft.getMinecraft() - val world = minecraft.theWorld ?: return false - - val objective = world.scoreboard.getObjectiveInDisplaySlot(1) ?: return false - val displayName = objective.displayName - return displayName.removeColor().contains("SKYBLOCK") - } -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt index 27e520ad0..8e6cd4d4a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt @@ -1,7 +1,6 @@ package at.hannibal2.skyhanni.features.chat import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.utils.LocationUtils @@ -10,7 +9,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP -import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent import java.util.regex.Pattern @@ -62,11 +60,6 @@ class PlayerDeathMessages { } } - @SubscribeEvent - fun onWorldChange(event: WorldEvent.Load) { - HypixelData.skyBlock = false - } - private fun checkOtherPlayers() { val location = LocationUtils.playerLocation() for (otherPlayer in Minecraft.getMinecraft().theWorld.loadedEntityList diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt index cbfa28c9a..245fa85af 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt @@ -1,6 +1,5 @@ package at.hannibal2.skyhanni.features.event.diana -import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LorenzUtils @@ -44,7 +43,7 @@ class BurrowWarpHelper { @SubscribeEvent fun onStatusBar(event: LorenzChatEvent) { - if (!HypixelData.skyBlock) return + if (!LorenzUtils.inSkyBlock) return if (event.message == "§cYou haven't unlocked this fast travel destination!") { val time = System.currentTimeMillis() - lastWarpTime diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 4d0c5a2ff..8140cddfa 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.data.HypixelData +import at.hannibal2.skyhanni.data.HyPixelData import at.hannibal2.skyhanni.features.dungeon.DungeonData import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.client.Minecraft @@ -15,29 +15,29 @@ import java.text.SimpleDateFormat object LorenzUtils { val isHyPixel: Boolean - get() = HypixelData.hypixel && Minecraft.getMinecraft().thePlayer != null + get() = HyPixelData.hypixel && Minecraft.getMinecraft().thePlayer != null val inSkyBlock: Boolean - get() = isHyPixel && HypixelData.skyBlock + get() = isHyPixel && HyPixelData.skyBlock val inDungeons: Boolean get() = inSkyBlock && DungeonData.inDungeon() val skyBlockIsland: String - get() = HypixelData.skyBlockIsland + get() = HyPixelData.skyBlockIsland //TODO add cache val skyBlockArea: String - get() = HypixelData.readSkyBlockArea() + get() = HyPixelData.readSkyBlockArea() val inKuudraFight: Boolean get() = skyBlockIsland == "Instanced" val noTradeMode: Boolean - get() = HypixelData.noTrade + get() = HyPixelData.noTrade val isBingoProfile: Boolean - get() = inSkyBlock && HypixelData.bingo + get() = inSkyBlock && HyPixelData.bingo const val DEBUG_PREFIX = "[SkyHanni Debug] §7" private val log = LorenzLogger("chat/mod_sent") -- cgit