aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/DebugDataCollectEvent.kt39
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt24
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt132
5 files changed, 145 insertions, 72 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt
index 2829bcb8d..c86563361 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt
@@ -75,18 +75,16 @@ object SlayerAPI {
event.title("Slayer")
if (!hasActiveSlayerQuest()) {
- event.exit("no active slayer quest")
+ event.ignore("no active slayer quest")
return
}
- event.addData(
- buildList {
- add("activeSlayer: ${getActiveSlayer()}")
- add("isInCorrectArea: $isInCorrectArea")
- add("isInAnyArea: $isInAnyArea")
- add("latestSlayerProgress: $latestSlayerProgress")
- }
- )
+ event.addData {
+ add("activeSlayer: ${getActiveSlayer()}")
+ add("isInCorrectArea: $isInCorrectArea")
+ add("isInAnyArea: $isInAnyArea")
+ add("latestSlayerProgress: $latestSlayerProgress")
+ }
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/events/DebugDataCollectEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/DebugDataCollectEvent.kt
index a53a144cf..1a4eabb92 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/DebugDataCollectEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/DebugDataCollectEvent.kt
@@ -2,10 +2,11 @@ package at.hannibal2.skyhanni.events
import at.hannibal2.skyhanni.utils.StringUtils.equalsIgnoreColor
-class DebugDataCollectEvent(private val builder: StringBuilder, private val search: String?) : LorenzEvent() {
+class DebugDataCollectEvent(private val list: MutableList<String>, private val search: String?) : LorenzEvent() {
+ var empty = true
private var currentTitle = ""
- private var exit = false
+ private var ignore = false
fun title(title: String) {
if (currentTitle != "") error("Title already set: '$currentTitle'")
@@ -13,8 +14,28 @@ class DebugDataCollectEvent(private val builder: StringBuilder, private val sear
currentTitle = title
}
- fun exit(text: String) {
- exit = true
+ fun ignore(block: MutableList<String>.() -> Unit) {
+ val list = mutableListOf<String>()
+ block(list)
+ ignore(list)
+ }
+
+ fun ignore(text: String) {
+ ignore(listOf(text))
+ }
+
+ private fun ignore(text: List<String>) {
+ ignore = true
+ addData(text)
+ }
+
+ fun addData(block: MutableList<String>.() -> Unit) {
+ val list = mutableListOf<String>()
+ block(list)
+ addData(list)
+ }
+
+ fun addData(text: String) {
addData(listOf(text))
}
@@ -22,11 +43,11 @@ class DebugDataCollectEvent(private val builder: StringBuilder, private val sear
if (currentTitle == "") error("Title not set")
writeData(text)
currentTitle = ""
- exit = false
+ ignore = false
}
private fun writeData(text: List<String>) {
- if (exit && search == null) return
+ if (ignore && search == null) return
search?.let {
if (!search.equalsIgnoreColor("all")) {
if (!currentTitle.contains(search, ignoreCase = true)) {
@@ -34,9 +55,11 @@ class DebugDataCollectEvent(private val builder: StringBuilder, private val sear
}
}
}
- builder.append("\n== $currentTitle ==\n")
+ empty = false
+ list.add("")
+ list.add("== $currentTitle ==")
for (line in text) {
- builder.append(" $line\n")
+ list.add(" $line")
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt
index fb141ad30..7657a27e4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt
@@ -226,22 +226,20 @@ class DungeonAPI {
event.title("Dungeon")
if (!LorenzUtils.inDungeons) {
- event.exit("not in dungeons")
+ event.ignore("not in dungeons")
return
}
- event.addData(
- buildList {
- add("dungeonFloor: $dungeonFloor")
- add("started: $started")
- add("getRoomID: ${getRoomID()}")
- add("inBossRoom: $inBossRoom")
- add("")
- add("playerClass: $playerClass")
- add("isUniqueClass: $isUniqueClass")
- add("playerClassLevel: $playerClassLevel")
- }
- )
+ event.addData {
+ add("dungeonFloor: $dungeonFloor")
+ add("started: $started")
+ add("getRoomID: ${getRoomID()}")
+ add("inBossRoom: $inBossRoom")
+ add("")
+ add("playerClass: $playerClass")
+ add("isUniqueClass: $isUniqueClass")
+ add("playerClassLevel: $playerClassLevel")
+ }
}
enum class DungeonFloor(private val bossName: String) {
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 396501104..27c7b1b0d 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
@@ -70,16 +70,16 @@ class BurrowWarpHelper {
event.title("Diana Burrow Nearest Warp")
if (!DianaAPI.isDoingDiana()) {
- event.exit("not doing diana")
+ event.ignore("not doing diana")
return
}
if (!config.burrowNearestWarp) {
- event.exit("disabled in config")
+ event.ignore("disabled in config")
return
}
val target = GriffinBurrowHelper.targetLocation
if (target == null) {
- event.exit("targetLocation is null")
+ event.ignore("targetLocation is null")
return
}
diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
index 2855662f6..091ddf499 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
@@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.config.ConfigManager
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.core.config.Position
import at.hannibal2.skyhanni.data.HypixelData
+import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.DebugDataCollectEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
@@ -349,54 +350,107 @@ class SkyHanniDebugsAndTests {
LorenzUtils.chat("§eManually set profileName to '${HypixelData.profileName}'")
return
}
- val builder = StringBuilder()
- builder.append("```\n")
- builder.append("= Debug Information = \n")
- builder.append("\n")
- builder.append("SkyHanni ${SkyHanniMod.version}\n")
- builder.append("\n")
- builder.append("player name: '${LorenzUtils.getPlayerName()}'\n")
- builder.append("player uuid: '${LorenzUtils.getPlayerUuid()}'\n")
- builder.append("repoAutoUpdate: ${config.repoAutoUpdate}\n")
- if (!config.repoAutoUpdate) {
- builder.append("REPO DOES NOT AUTO UPDATE\n")
+ val list = mutableListOf<String>()
+ list.add("```")
+ list.add("= Debug Information for SkyHanni ${SkyHanniMod.version} =")
+ list.add("")
+
+ val search = args.getOrNull(0)
+ list.add(
+ if (search != null) {
+ if (search.equalsIgnoreColor("all")) {
+ "search for everything."
+ } else "search: '$search'"
+ } else "search not specified, showing only interesting stuff"
+ )
+
+ val event = DebugDataCollectEvent(list, search)
+
+ event.title("Player")
+ event.ignore {
+ add("name: '${LorenzUtils.getPlayerName()}'")
+ add("uuid: '${LorenzUtils.getPlayerUuid()}'")
}
- builder.append("globalRender: ${globalRender}\n")
- if (!globalRender) {
- builder.append("GLOBAL RENDERER IS DISABLED\n")
+
+ event.title("Repo Auto Update")
+ if (config.repoAutoUpdate) {
+ event.ignore("normally enabled")
+ } else {
+ event.addData("The repo does not auto update because auto update is disabled!")
}
- builder.append("\n")
-
- builder.append("onHypixel: ${LorenzUtils.onHypixel}\n")
- val inSkyBlock = LorenzUtils.inSkyBlock
- builder.append("inSkyBlock: $inSkyBlock\n")
-
- if (inSkyBlock) {
- builder.append("\n")
- builder.append("skyBlockIsland: ${LorenzUtils.skyBlockIsland}\n")
- builder.append("skyBlockArea: '${LorenzUtils.skyBlockArea}'\n")
- builder.append("profileName: '${HypixelData.profileName}'\n")
- builder.append("\n")
- builder.append("ironman: ${HypixelData.ironman}\n")
- builder.append("stranded: ${HypixelData.stranded}\n")
- builder.append("bingo: ${HypixelData.bingo}\n")
+
+ event.title("Global Render")
+ if (globalRender) {
+ event.ignore("normally enabled")
+ } else {
+ event.addData {
+ add("Global renderer is disabled!")
+ add("No renderable elements from SkyHanni will show up anywhere!")
+ }
}
- val search = args.getOrNull(0)
- builder.append("\n")
- if (search != null) {
- if (search.equalsIgnoreColor("all")) {
- builder.append("search for everything.\n")
+ event.title("SkyBlock Status")
+ if (!LorenzUtils.onHypixel) {
+ event.addData("not on Hypixel")
+ } else {
+ if (!LorenzUtils.inSkyBlock) {
+ event.addData("not on SkyBlock, but on Hypixel")
+ } else {
+ if (LorenzUtils.skyBlockIsland == IslandType.UNKNOWN) {
+ event.addData("Unknown SkyBlock island!")
+ } else {
+ event.ignore {
+ add("on Hypixel SkyBlock")
+ add("skyBlockIsland: ${LorenzUtils.skyBlockIsland}")
+ add("skyBlockArea: '${LorenzUtils.skyBlockArea}'")
+ }
+ }
+ }
+ }
+
+ event.title("Profile Name")
+ if (!LorenzUtils.inSkyBlock) {
+ event.ignore("Not on SkyBlcok")
+ } else {
+ if (HypixelData.profileName != "") {
+ event.ignore("profileName: '${HypixelData.profileName}'")
} else {
- builder.append("search: '$search'\n")
+ event.addData("profile name is empty!")
}
+ }
+
+
+ event.title("Profile Type")
+ if (!LorenzUtils.inSkyBlock) {
+ event.ignore("Not on SkyBlcok")
} else {
- builder.append("search not set.\n")
+ val classic = !LorenzUtils.noTradeMode
+ if (classic) {
+ event.ignore("on classic")
+ } else {
+ if (HypixelData.ironman) {
+ event.addData("on ironman")
+ }
+ if (HypixelData.stranded) {
+ event.addData("on stranded")
+ }
+ if (HypixelData.bingo) {
+ event.addData("on bingo")
+ }
+ }
+ }
+
+ event.postAndCatch()
+
+ if (event.empty) {
+ list.add("")
+ list.add("Nothing interesting to show right now!")
+ list.add("Looking for something specific? /shdebug <search>")
+ list.add("Wanna see everything? /shdebug all")
}
- DebugDataCollectEvent(builder, search).postAndCatch()
- builder.append("```")
- OSUtils.copyToClipboard(builder.toString())
+ list.add("```")
+ OSUtils.copyToClipboard(list.joinToString("\n"))
LorenzUtils.chat("§eCopied SkyHanni debug data in the clipboard.")
}