diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-01-13 19:54:17 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-01-13 19:54:17 +0100 |
commit | d3f059ccdddeda951231389987e8c4582321084b (patch) | |
tree | 474e035e281ef15a2aedfb846dd79a767e66309c /src/main/java/at/hannibal2 | |
parent | 6341705f54847552e83baa25405ff0c0ea88fe0b (diff) | |
parent | 34bd66af164d7a3ca07fd90bc3f04a5e4aaec386 (diff) | |
download | skyhanni-d3f059ccdddeda951231389987e8c4582321084b.tar.gz skyhanni-d3f059ccdddeda951231389987e8c4582321084b.tar.bz2 skyhanni-d3f059ccdddeda951231389987e8c4582321084b.zip |
Merge branch 'dev' into crimson_isle_reputation
Diffstat (limited to 'src/main/java/at/hannibal2')
10 files changed, 33 insertions, 13 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 599fae67e..296098f37 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -189,7 +189,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/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/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] 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/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 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("<center><h1>502 Bad Gateway</h1></center>")) { + 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() } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index cc5483d5c..7dea12015 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', '.') 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 } 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<String> = ArrayList() for (info in players) { val name = Minecraft.getMinecraft().ingameGUI.tabList.getPlayerName(info) - result.add(name) + result.add(LorenzUtils.stripVanillaMessage(name)) } return result } |