aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/ambientaddons/utils/LocationUtils.kt
diff options
context:
space:
mode:
authorAppability <appable@icloud.com>2022-10-12 20:48:51 -0700
committerAppability <appable@icloud.com>2022-10-12 20:48:51 -0700
commitc599ee0d78ed8bc17488636f2d9b9b1d5b6dd4a8 (patch)
treef362a5f60f31e27f1567c7319a78d861b19430a7 /src/main/kotlin/com/ambientaddons/utils/LocationUtils.kt
parent03728b81851af00cd265fadd4ce6eaa3a8066dcb (diff)
downloadAmbientAddons-c599ee0d78ed8bc17488636f2d9b9b1d5b6dd4a8.tar.gz
AmbientAddons-c599ee0d78ed8bc17488636f2d9b9b1d5b6dd4a8.tar.bz2
AmbientAddons-c599ee0d78ed8bc17488636f2d9b9b1d5b6dd4a8.zip
uh a lot of things
Diffstat (limited to 'src/main/kotlin/com/ambientaddons/utils/LocationUtils.kt')
-rw-r--r--src/main/kotlin/com/ambientaddons/utils/LocationUtils.kt87
1 files changed, 0 insertions, 87 deletions
diff --git a/src/main/kotlin/com/ambientaddons/utils/LocationUtils.kt b/src/main/kotlin/com/ambientaddons/utils/LocationUtils.kt
deleted file mode 100644
index d185a08..0000000
--- a/src/main/kotlin/com/ambientaddons/utils/LocationUtils.kt
+++ /dev/null
@@ -1,87 +0,0 @@
-package com.ambientaddons.utils
-
-import AmbientAddons.Companion.mc
-import com.ambientaddons.utils.DungeonFloor.Companion.toDungeonFloor
-import com.ambientaddons.utils.Extensions.cleanSB
-import com.ambientaddons.utils.Extensions.stripControlCodes
-import com.ambientaddons.utils.Extensions.substringBetween
-import com.ambientaddons.utils.TabListUtils.fetchTabEntries
-import net.minecraft.scoreboard.Score
-import net.minecraft.scoreboard.ScorePlayerTeam
-import net.minecraftforge.event.world.WorldEvent
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import net.minecraftforge.fml.common.gameevent.TickEvent
-import net.minecraftforge.fml.common.network.FMLNetworkEvent
-
-object LocationUtils {
- private var areaRegex = Regex("^(?:Area|Dungeon): ([\\w ].+)\$")
- private var onHypixel = false
- var inSkyblock = false
- var location: String? = null
- var dungeonFloor: DungeonFloor? = null
- var ticks = 0
-
- @SubscribeEvent
- fun onWorldUnload(event: WorldEvent.Unload) {
- inSkyblock = false
- dungeonFloor = null
- location = null
- }
-
- @SubscribeEvent
- fun onConnect(event: FMLNetworkEvent.ClientConnectedToServerEvent) {
- onHypixel = mc.runCatching {
- !event.isLocal && ((thePlayer?.clientBrand?.lowercase()?.contains("hypixel")
- ?: currentServerData?.serverIP?.lowercase()?.contains("hypixel")) == true)
- }.getOrDefault(false)
- }
-
- @SubscribeEvent
- fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) {
- onHypixel = false
- }
-
- // from Skytils, under AGPL 3.0
- fun fetchScoreboardLines(): List<String> {
- val scoreboard = mc.theWorld?.scoreboard ?: return emptyList()
- val objective = scoreboard.getObjectiveInDisplaySlot(1) ?: return emptyList()
- val scores = scoreboard.getSortedScores(objective).filter { input: Score? ->
- input != null && input.playerName != null && !input.playerName
- .startsWith("#")
- }.take(15)
- return scores.map {
- ScorePlayerTeam.formatPlayerName(scoreboard.getPlayersTeam(it.playerName), it.playerName).cleanSB()
- }.asReversed()
- }
-
- // modified from Harry282/Skyblock-Client, under AGPL 3.0
- @SubscribeEvent
- fun onTick(event: TickEvent.ClientTickEvent) {
- if (!onHypixel || event.phase != TickEvent.Phase.START) return
- if (ticks % 10 == 0) {
- val title = mc.theWorld?.scoreboard?.getObjectiveInDisplaySlot(1)?.displayName?.cleanSB()
- if (!inSkyblock) {
- inSkyblock = title?.contains("SKYBLOCK") == true
- }
- if (inSkyblock) {
- if (location == null) {
- val tab = fetchTabEntries()
- location = tab.firstNotNullOfOrNull { areaRegex.find(it.text.stripControlCodes()) }?.let {
- it.groupValues.getOrNull(1)
- }
- }
- if (location == "Catacombs" && dungeonFloor == null) {
- val dungeonLine = fetchScoreboardLines().find {
- it.run { contains("The Catacombs (") && !contains("Queue") }
- }
- dungeonFloor = dungeonLine?.substringBetween("(", ")")?.toDungeonFloor()
- }
- }
- }
- ticks++
- }
-
- override fun toString(): String =
- "onHypixel: $onHypixel, inSkyblock: $inSkyblock, location: $location, floor: $dungeonFloor"
-
-} \ No newline at end of file