aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-01-18 18:47:22 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-01-18 18:47:22 +0100
commit4c83ab3595adf8af8588c2bca3b4f7e472b62af0 (patch)
tree858995493b1fecb169c4c84330fa3d44f112b6be /src/main
parent3d3f1f8cc911d02cfdc89074a8b49866f1db5085 (diff)
downloadskyhanni-4c83ab3595adf8af8588c2bca3b4f7e472b62af0.tar.gz
skyhanni-4c83ab3595adf8af8588c2bca3b4f7e472b62af0.tar.bz2
skyhanni-4c83ab3595adf8af8588c2bca3b4f7e472b62af0.zip
Add DebugDataCollectEvent and add Diana Burrow Nearest Warp to /shdebugdata
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/DebugDataCollectEvent.kt26
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt41
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt5
4 files changed, 66 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/events/DebugDataCollectEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/DebugDataCollectEvent.kt
new file mode 100644
index 000000000..1cb72c4f8
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/DebugDataCollectEvent.kt
@@ -0,0 +1,26 @@
+package at.hannibal2.skyhanni.events
+
+class DebugDataCollectEvent(private val builder: StringBuilder) : LorenzEvent() {
+
+ private var currentTitle = ""
+
+ fun title(title: String) {
+ if (currentTitle != "") error("Title already set")
+
+ currentTitle = title
+ }
+
+ fun exit(text: String) {
+ addData(listOf(text))
+ }
+
+ fun addData(text: List<String>) {
+ if (currentTitle == "") error("Title not set")
+
+ builder.append("\n$currentTitle\n")
+ for (line in text) {
+ builder.append(" $line\n")
+ }
+ currentTitle = ""
+ }
+}
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 1125b8c8c..396501104 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
@@ -2,11 +2,13 @@ package at.hannibal2.skyhanni.features.event.diana
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.TitleManager
+import at.hannibal2.skyhanni.events.DebugDataCollectEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzUtils.sorted
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.SimpleTimeMark
@@ -63,22 +65,49 @@ class BurrowWarpHelper {
currentWarp = null
}
+ @SubscribeEvent
+ fun onDebugDataCollect(event: DebugDataCollectEvent) {
+ event.title("Diana Burrow Nearest Warp")
+
+ if (!DianaAPI.isDoingDiana()) {
+ event.exit("not doing diana")
+ return
+ }
+ if (!config.burrowNearestWarp) {
+ event.exit("disabled in config")
+ return
+ }
+ val target = GriffinBurrowHelper.targetLocation
+ if (target == null) {
+ event.exit("targetLocation is null")
+ return
+ }
+
+ val list = mutableListOf<String>()
+ shouldUseWarps(target, list)
+ event.addData(list)
+ }
+
companion object {
private val config get() = SkyHanniMod.feature.event.diana
var currentWarp: WarpPoint? = null
- fun shouldUseWarps(target: LorenzVec) {
+ fun shouldUseWarps(target: LorenzVec, debug: MutableList<String>? = null) {
+ debug?.add("target: ${target.printWithAccuracy(1)}")
val playerLocation = LocationUtils.playerLocation()
+ debug?.add("playerLocation: ${playerLocation.printWithAccuracy(1)}")
val warpPoint = getNearestWarpPoint(target)
+ debug?.add("warpPoint: ${warpPoint.displayName}")
val playerDistance = playerLocation.distance(target)
+ debug?.add("playerDistance: ${playerDistance.round(1)}")
val warpDistance = warpPoint.distance(target)
+ debug?.add("warpDistance: ${warpDistance.round(1)}")
val difference = playerDistance - warpDistance
- currentWarp = if (difference > 10) {
- warpPoint
- } else {
- null
- }
+ debug?.add("difference: ${difference.round(1)}")
+ val setWarpPoint = difference > 10
+ debug?.add("setWarpPoint: $setWarpPoint")
+ currentWarp = if (setWarpPoint) warpPoint else null
}
private fun getNearestWarpPoint(location: LorenzVec) =
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt
index a940403fb..2d88024fc 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt
@@ -36,7 +36,7 @@ import kotlin.time.Duration.Companion.seconds
object GriffinBurrowHelper {
private val config get() = SkyHanniMod.feature.event.diana
- private var targetLocation: LorenzVec? = null
+ var targetLocation: LorenzVec? = null
private var guessLocation: LorenzVec? = null
private var particleBurrows = mapOf<LorenzVec, BurrowType>()
diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
index 1adf858c7..a648144fe 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
@@ -8,6 +8,7 @@ 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.SlayerAPI
+import at.hannibal2.skyhanni.events.DebugDataCollectEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
@@ -400,8 +401,10 @@ class SkyHanniDebugsAndTests {
builder.append(" isInCorrectArea: ${SlayerAPI.isInCorrectArea}\n")
builder.append(" isInAnyArea: ${SlayerAPI.isInAnyArea}\n")
}
-
}
+
+ DebugDataCollectEvent(builder).postAndCatch()
+
builder.append("```")
OSUtils.copyToClipboard(builder.toString())
LorenzUtils.chat("§eCopied SkyHanni debug data to clipboard.")