aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLorenz <ESs95s3P5z8Pheb>2022-07-09 03:20:48 +0200
committerLorenz <ESs95s3P5z8Pheb>2022-07-09 03:20:48 +0200
commitf842a84e3aae31e5fe84b52f23550efca526f6aa (patch)
tree6adfe526a4e9cd9e0544df53ff902a56c823bea7 /src
parent1b45af4cca64914c61648da584f523b90ea0e24e (diff)
downloadskyhanni-f842a84e3aae31e5fe84b52f23550efca526f6aa.tar.gz
skyhanni-f842a84e3aae31e5fe84b52f23550efca526f6aa.tar.bz2
skyhanni-f842a84e3aae31e5fe84b52f23550efca526f6aa.zip
add dungeon api stuff
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/lorenz/mod/LorenzMod.java8
-rw-r--r--src/main/java/at/lorenz/mod/dungeon/DungeonData.kt34
-rw-r--r--src/main/java/at/lorenz/mod/events/DungeonEnterEvent.kt3
-rw-r--r--src/main/java/at/lorenz/mod/misc/HypixelData.kt1
-rw-r--r--src/main/java/at/lorenz/mod/misc/ScoreboardData.kt45
5 files changed, 87 insertions, 4 deletions
diff --git a/src/main/java/at/lorenz/mod/LorenzMod.java b/src/main/java/at/lorenz/mod/LorenzMod.java
index 9b20e924d..39da77c6a 100644
--- a/src/main/java/at/lorenz/mod/LorenzMod.java
+++ b/src/main/java/at/lorenz/mod/LorenzMod.java
@@ -7,11 +7,9 @@ import at.lorenz.mod.chat.ChatManager;
import at.lorenz.mod.chat.PlayerChatFilter;
import at.lorenz.mod.config.Features;
import at.lorenz.mod.dungeon.DungeonChatFilter;
+import at.lorenz.mod.dungeon.DungeonData;
import at.lorenz.mod.dungeon.DungeonHighlightClickedBlocks;
-import at.lorenz.mod.misc.ButtonOnPause;
-import at.lorenz.mod.misc.CurrentPetDisplay;
-import at.lorenz.mod.misc.ExpBottleOnGroundHider;
-import at.lorenz.mod.misc.HypixelData;
+import at.lorenz.mod.misc.*;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.thatgravyboat.skyblockhud_2.commands.Commands;
@@ -49,6 +47,8 @@ public class LorenzMod {
MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(new ChatManager());
MinecraftForge.EVENT_BUS.register(new HypixelData());
+ MinecraftForge.EVENT_BUS.register(new DungeonData());
+ MinecraftForge.EVENT_BUS.register(new ScoreboardData());
MinecraftForge.EVENT_BUS.register(new BazaarOrderHelper());
MinecraftForge.EVENT_BUS.register(new ChatFilter());
diff --git a/src/main/java/at/lorenz/mod/dungeon/DungeonData.kt b/src/main/java/at/lorenz/mod/dungeon/DungeonData.kt
new file mode 100644
index 000000000..d14183d99
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/dungeon/DungeonData.kt
@@ -0,0 +1,34 @@
+package at.lorenz.mod.dungeon
+
+import at.lorenz.mod.events.DungeonEnterEvent
+import at.lorenz.mod.misc.ScoreboardData
+import at.lorenz.mod.utils.LorenzUtils
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+
+class DungeonData {
+
+ var dungeonFloor: String? = null
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (event.phase != TickEvent.Phase.START) return
+ if (LorenzUtils.inDungeons) {
+ if (dungeonFloor == null) {
+ for (line in ScoreboardData.sidebarLines) {
+ if (line.contains("The Catacombs (")) {
+ dungeonFloor = line.substringAfter("(").substringBefore(")")
+ DungeonEnterEvent(dungeonFloor!!).postAndCatch()
+ break
+ }
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onWorldChange(event: WorldEvent.Load) {
+ dungeonFloor = null
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/events/DungeonEnterEvent.kt b/src/main/java/at/lorenz/mod/events/DungeonEnterEvent.kt
new file mode 100644
index 000000000..a1cb18101
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/events/DungeonEnterEvent.kt
@@ -0,0 +1,3 @@
+package at.lorenz.mod.events
+
+class DungeonEnterEvent(dungeonFloor: String): LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/misc/HypixelData.kt b/src/main/java/at/lorenz/mod/misc/HypixelData.kt
index 0c2de6683..9d83e2679 100644
--- a/src/main/java/at/lorenz/mod/misc/HypixelData.kt
+++ b/src/main/java/at/lorenz/mod/misc/HypixelData.kt
@@ -1,5 +1,6 @@
package at.lorenz.mod.misc
+import at.lorenz.mod.events.DungeonEnterEvent
import at.lorenz.mod.events.PacketEvent
import at.lorenz.mod.utils.LorenzUtils
import net.minecraft.client.Minecraft
diff --git a/src/main/java/at/lorenz/mod/misc/ScoreboardData.kt b/src/main/java/at/lorenz/mod/misc/ScoreboardData.kt
new file mode 100644
index 000000000..e1735104d
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/misc/ScoreboardData.kt
@@ -0,0 +1,45 @@
+package at.lorenz.mod.misc
+
+import at.lorenz.mod.utils.LorenzUtils.removeColorCodes
+import net.minecraft.client.Minecraft
+import net.minecraft.scoreboard.Score
+import net.minecraft.scoreboard.ScorePlayerTeam
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+
+class ScoreboardData {
+
+ companion object {
+ var sidebarLines: List<String> = emptyList()
+ }
+
+ @SubscribeEvent(priority = EventPriority.HIGHEST)
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (event.phase != TickEvent.Phase.START) return
+
+ sidebarLines = fetchScoreboardLines().map { cleanSB(it) }
+ }
+
+ private fun cleanSB(scoreboard: String): String {
+ return scoreboard.removeColorCodes().toCharArray().filter { it.code in 21..126 }.joinToString(separator = "")
+ }
+
+ fun fetchScoreboardLines(): List<String> {
+ val scoreboard = Minecraft.getMinecraft().theWorld?.scoreboard ?: return emptyList()
+ val objective = scoreboard.getObjectiveInDisplaySlot(1) ?: return emptyList()
+ var scores = scoreboard.getSortedScores(objective)
+ val list = scores.filter { input: Score? ->
+ input != null && input.playerName != null && !input.playerName
+ .startsWith("#")
+ }
+ scores = if (list.size > 15) {
+ list.drop(15)
+ } else {
+ list
+ }
+ return scores.map {
+ ScorePlayerTeam.formatPlayerName(scoreboard.getPlayersTeam(it.playerName), it.playerName)
+ }
+ }
+} \ No newline at end of file