From edd1f10c784728913983e26ac40b49c485ad3a8e Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 13 Jan 2023 19:51:29 +0100 Subject: Add test command /shstoplisteners --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java | 2 +- .../java/at/hannibal2/skyhanni/config/commands/Commands.kt | 1 + src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) (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 ef768b6ef..f99a0ee2b 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -186,7 +186,7 @@ public class SkyHanniMod { repo.loadRepoInformation(); } - private void loadModule(Object object) { + public void loadModule(Object object) { modules.add(object); MinecraftForge.EVENT_BUS.register(object); } diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 9bda0fda1..c8e8d8889 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -37,6 +37,7 @@ object Commands { registerCommand("shmarkplayer") { MarkedPlayerManager.command(it) } registerCommand("togglepacketlog") { LorenzTest.togglePacketLog() } registerCommand("shreloadlisteners") { LorenzTest.reloadListeners() } + registerCommand("shstoplisteners") { LorenzTest.stopListeners() } registerCommand("shresetburrowwarps") { BurrowWarpHelper.resetDisabledWarps() } registerCommand("shtrackcollection") { CollectionCounter.command(it) } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt index f7ab6a90b..f72430139 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt @@ -103,6 +103,17 @@ class LorenzTest { } LorenzUtils.chat("§e[SkyHanni] reloaded ${modules.size} listener classes.") } + + fun stopListeners() { + val modules = SkyHanniMod.modules + for (original in modules.toMutableList()) { + val javaClass = original.javaClass + val simpleName = javaClass.simpleName + MinecraftForge.EVENT_BUS.unregister(original) + println("Unregistered listener $simpleName") + } + LorenzUtils.chat("§e[SkyHanni] stopped ${modules.size} listener classes.") + } } @SubscribeEvent -- cgit From e0e473e47453a3d7de37e0fd71e6f08a65ccc9f0 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 13 Jan 2023 19:52:11 +0100 Subject: Removed §r from tablist. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt | 4 ++-- src/main/java/at/hannibal2/skyhanni/utils/TabListUtils.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt index 2bb7c7678..30e03732e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt @@ -123,10 +123,10 @@ class HyPixelData { var newIsland = "" var guesting = false for (line in TabListUtils.getTabList()) { - if (line.startsWith("§r§b§lArea: ")) { + if (line.startsWith("§b§lArea: ")) { newIsland = line.split(": ")[1].removeColor() } - if (line == "§r Status: §r§9Guest§r") { + if (line == " Status: §r§9Guest") { guesting = true } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TabListUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/TabListUtils.kt index 15b5a10ef..a81675f74 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/TabListUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/TabListUtils.kt @@ -34,7 +34,7 @@ object TabListUtils { val result: MutableList = ArrayList() for (info in players) { val name = Minecraft.getMinecraft().ingameGUI.tabList.getPlayerName(info) - result.add(name) + result.add(LorenzUtils.stripVanillaMessage(name)) } return result } -- cgit From d8d0badd698d81ab916e0498de26158777ccbf23 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 13 Jan 2023 19:52:40 +0100 Subject: Now formatInteger accepts Long too. --- .../skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt | 2 +- src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt index 9118ac6a2..aca78fd0a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt @@ -74,7 +74,7 @@ enum class ItemAbility( } else { duration /= 1000 duration++ - LorenzUtils.formatInteger(duration.toInt()) + LorenzUtils.formatInteger(duration) } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 043978277..9d783ce86 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -117,7 +117,9 @@ object LorenzUtils { fun formatPercentage(percentage: Double, format: String?): String = DecimalFormat(format).format(percentage * 100).replace(',', '.') + "%" - fun formatInteger(i: Int): String = DecimalFormat("#,##0").format(i.toLong()).replace(',', '.') + fun formatInteger(i: Int): String = formatInteger(i.toLong()) + + fun formatInteger(l: Long): String = DecimalFormat("#,##0").format(l).replace(',', '.') fun formatDouble(d: Double, format: String?): String = DecimalFormat(format).format(d).replace(',', 'x').replace('.', ',').replace('x', '.') -- cgit From 202675df454c4a4565052f12ede037c7212631ab Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 13 Jan 2023 19:52:56 +0100 Subject: Code cleanup --- .../at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt index 200c3e69e..a496bd2b5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt @@ -47,8 +47,8 @@ class BazaarBestSellMethod { for (slot in chest.inventorySlots) { if (slot == null) continue if (slot.slotNumber == slot.slotIndex) continue - if (slot.stack == null) continue - val stack = slot.stack + val stack = slot.stack ?: continue + var displayName = stack.displayName if (displayName.endsWith("Enchanted Book")) { displayName = stack.getLore()[0] -- cgit From f91ec749011d318af0b823535daed4aef890db5f Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 13 Jan 2023 19:53:19 +0100 Subject: Better explanation for the bazaar api error. --- src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt index 908d8b810..d776cfa01 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.SkyHanniMod import com.google.gson.JsonObject import com.google.gson.JsonParser -import com.google.gson.stream.MalformedJsonException +import com.google.gson.JsonSyntaxException import org.apache.http.client.config.RequestConfig import org.apache.http.client.methods.HttpGet import org.apache.http.impl.client.HttpClientBuilder @@ -43,9 +43,15 @@ object APIUtil { val retSrc = EntityUtils.toString(entity) try { return parser.parse(retSrc) as JsonObject - } catch (e: MalformedJsonException) { - LorenzUtils.error("MalformedJsonException!") - println("MalformedJsonException at '$urlString'") + } catch (e: JsonSyntaxException) { + if (retSrc.contains("

502 Bad Gateway

")) { + println("502 Bad Gateway at getJSONResponse '$urlString'") + LorenzUtils.error("[SkyHanni] Hypixel API error: 502 Bad Gateway!") + } else { + println("JsonSyntaxException at getJSONResponse '$urlString'") + LorenzUtils.error("[SkyHanni] JsonSyntaxException at getJSONResponse!") + println("result: '$retSrc'") + } e.printStackTrace() } } -- cgit From 4aefc67250d485f9196d2a911f6ec22b5dd17bf5 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 13 Jan 2023 19:53:49 +0100 Subject: Successfully hiding console message "A team with the name x already exist" message. --- src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt b/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt index 1036dab62..da359ff1e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt @@ -150,7 +150,7 @@ class MinecraftConsoleFilter(private val loggerConfigName: String) : Filter { } } if (SkyHanniMod.feature.dev.filterScoreboardErrors) { - if (thrown.toString() == "java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: A team with the name '") { + if (thrown.toString().contains(" java.lang.IllegalArgumentException: A team with the name '")) { filterConsole("IllegalArgumentException because scoreboard team already exists") return Filter.Result.DENY } -- cgit