aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-01-06 23:12:44 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-01-06 23:12:44 +0100
commit139a55b1c40ba5fa7eeae352cdde5034516a150d (patch)
tree80e16fe3f6161f4bc4c459ccb659d0d3e57170b9
parent362e3efddab52c954a46766e217d6b4faba5332e (diff)
downloadskyhanni-139a55b1c40ba5fa7eeae352cdde5034516a150d.tar.gz
skyhanni-139a55b1c40ba5fa7eeae352cdde5034516a150d.tar.bz2
skyhanni-139a55b1c40ba5fa7eeae352cdde5034516a150d.zip
debug command logic and console filter changes
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt10
6 files changed, 28 insertions, 13 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index fa5cc233f..a88ef4696 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -186,11 +186,9 @@ public class SkyHanniMod {
private void registerEvent(Object object) {
listenerClasses.add(object);
String simpleName = object.getClass().getSimpleName();
- consoleLog("SkyHanni registering '" + simpleName + "'");
long start = System.currentTimeMillis();
MinecraftForge.EVENT_BUS.register(object);
long duration = System.currentTimeMillis() - start;
- consoleLog("Done after " + duration + " ms!");
}
public static GuiScreen screenToOpen = null;
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
index c2c8bcb18..857305c27 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
@@ -8,7 +8,7 @@ import net.minecraft.item.ItemStack
class BazaarApi {
companion object {
- private val bazaarMap = mutableMapOf<String, BazaarData>()
+ val bazaarMap = mutableMapOf<String, BazaarData>()
fun isBazaarInventory(inventoryName: String): Boolean {
if (inventoryName.contains(" ➜ ") && !inventoryName.contains("Museum")) return true
diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt
index 5395dbf36..92275ed69 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt
@@ -38,7 +38,6 @@ object CopyItemCommand {
val string = resultList.joinToString("\n")
OSUtils.copyToClipboard(string)
- LorenzUtils.debug("item info printed!")
LorenzUtils.chat("§e[SkyHanni] item info copied into the clipboard!")
} catch (_: Throwable) {
LorenzUtils.chat("§c[SkyHanni] No item in hand!")
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt
index 5584da0fe..908d8b810 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt
@@ -3,6 +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 org.apache.http.client.config.RequestConfig
import org.apache.http.client.methods.HttpGet
import org.apache.http.impl.client.HttpClientBuilder
@@ -40,7 +41,13 @@ object APIUtil {
val entity = response.entity
if (entity != null) {
val retSrc = EntityUtils.toString(entity)
- return parser.parse(retSrc) as JsonObject
+ try {
+ return parser.parse(retSrc) as JsonObject
+ } catch (e: MalformedJsonException) {
+ LorenzUtils.error("MalformedJsonException!")
+ println("MalformedJsonException at '$urlString'")
+ e.printStackTrace()
+ }
}
}
} catch (throwable: Throwable) {
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index c4c9cedca..e37aedbc6 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -33,11 +33,17 @@ object LorenzUtils {
val inKuudraFight: Boolean
get() = skyBlockIsland == "Instanced"
- const val DEBUG_PREFIX = "[Debug] §7"
+ const val DEBUG_PREFIX = "[SkyHanni Debug] §7"
private val log = LorenzLogger("chat/mod_sent")
fun debug(message: String) {
- internalChat(DEBUG_PREFIX + message)
+ if (SkyHanniMod.feature.dev.debugEnabled) {
+ if (internalChat(DEBUG_PREFIX + message)) {
+ consoleLog("[Debug] $message")
+ }
+ } else {
+ consoleLog("[Debug] $message")
+ }
}
fun warning(message: String) {
@@ -52,21 +58,22 @@ object LorenzUtils {
internalChat(message)
}
- private fun internalChat(message: String) {
+ private fun internalChat(message: String): Boolean {
log.log(message)
val minecraft = Minecraft.getMinecraft()
if (minecraft == null) {
consoleLog(message.removeColor())
- return
+ return false
}
val thePlayer = minecraft.thePlayer
if (thePlayer == null) {
consoleLog(message.removeColor())
- return
+ return false
}
thePlayer.addChatMessage(ChatComponentText(message))
+ return true
}
//TODO move into StringUtils
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt b/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt
index c0e64c7be..9882f8578 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt
@@ -130,15 +130,19 @@ class MinecraftConsoleFilter(private val loggerConfigName: String) : Filter {
if (cause.stackTrace.isNotEmpty()) {
val first = cause.stackTrace[0]
if (SkyHanniMod.feature.dev.filterScoreboardErrors) {
- if (first.toString() == "net.minecraft.scoreboard.Scoreboard.removeTeam(Scoreboard.java:229)") {
+ val firstName = first.toString()
+ if (firstName == "net.minecraft.scoreboard.Scoreboard.removeTeam(Scoreboard.java:229)" ||
+ firstName == "net.minecraft.scoreboard.Scoreboard.removeTeam(Scoreboard.java:262)"
+ ) {
filterConsole("NullPointerException at Scoreboard.removeTeam")
return Filter.Result.DENY
}
- if (first.toString() == "net.minecraft.scoreboard.Scoreboard.createTeam(Scoreboard.java:218)") {
+ if (firstName == "net.minecraft.scoreboard.Scoreboard.createTeam(Scoreboard.java:218)") {
filterConsole("IllegalArgumentException at Scoreboard.createTeam")
return Filter.Result.DENY
}
- if (first.toString() == "net.minecraft.scoreboard.Scoreboard.removeObjective(Scoreboard.java:179)") {
+ if (firstName == "net.minecraft.scoreboard.Scoreboard.removeObjective(Scoreboard.java:179)" ||
+ firstName == "net.minecraft.scoreboard.Scoreboard.removeObjective(Scoreboard.java:198)") {
filterConsole("IllegalArgumentException at Scoreboard.removeObjective")
return Filter.Result.DENY
}