aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/dulkirmod')
-rw-r--r--src/main/kotlin/dulkirmod/DulkirMod.kt10
-rw-r--r--src/main/kotlin/dulkirmod/command/LeapNameCommand.kt3
-rw-r--r--src/main/kotlin/dulkirmod/config/Config.kt8
-rw-r--r--src/main/kotlin/dulkirmod/features/BrokenHypeNotif.kt3
-rw-r--r--src/main/kotlin/dulkirmod/features/GardenVisitorAlert.kt28
-rw-r--r--src/main/kotlin/dulkirmod/features/KeeperWaypoints.kt3
-rw-r--r--src/main/kotlin/dulkirmod/features/MatchoAlert.kt33
-rw-r--r--src/main/kotlin/dulkirmod/features/NametagCleaner.kt4
-rw-r--r--src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt4
-rw-r--r--src/main/kotlin/dulkirmod/utils/TablistUtils.kt51
-rw-r--r--src/main/kotlin/dulkirmod/utils/Utils.kt22
11 files changed, 113 insertions, 56 deletions
diff --git a/src/main/kotlin/dulkirmod/DulkirMod.kt b/src/main/kotlin/dulkirmod/DulkirMod.kt
index 51df365..014b06d 100644
--- a/src/main/kotlin/dulkirmod/DulkirMod.kt
+++ b/src/main/kotlin/dulkirmod/DulkirMod.kt
@@ -6,9 +6,9 @@ import dulkirmod.events.ChatEvent
import dulkirmod.features.*
import dulkirmod.features.chat.AbiphoneDND
import dulkirmod.utils.ContainerNameUtil
+import dulkirmod.utils.TabListUtils
import dulkirmod.utils.TextUtils
import dulkirmod.utils.TitleUtils
-import dulkirmod.utils.Utils.getArea
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -74,6 +74,7 @@ class DulkirMod {
mcBus.register(AbiphoneDND())
mcBus.register(KeeperWaypoints())
mcBus.register(ScalableTooltips)
+ mcBus.register(GardenVisitorAlert())
keyBinds.forEach(ClientRegistry::registerKeyBinding)
}
@@ -98,7 +99,10 @@ class DulkirMod {
alarmClock()
brokenHypeNotif()
matchoAlert.alert()
- getArea()
+ gardenVisitorAlert.alert()
+ // Now I don't have to fetch the entries for multiple things, this just updates and caches
+ // the data structure on 1s cooldown
+ TabListUtils.parseTabEntries()
lastLongUpdate = currTime
}
}
@@ -124,6 +128,8 @@ class DulkirMod {
val scope = CoroutineScope(EmptyCoroutineContext)
val titleUtils = TitleUtils()
val matchoAlert = MatchoAlert()
+ val gardenVisitorAlert = GardenVisitorAlert()
+ var tabEntries: List<String?> = emptyList()
val keyBinds = arrayOf(
KeyBinding("Open Settings", Keyboard.KEY_RSHIFT, "Dulkir Mod"),
diff --git a/src/main/kotlin/dulkirmod/command/LeapNameCommand.kt b/src/main/kotlin/dulkirmod/command/LeapNameCommand.kt
index 185a181..f4a86a9 100644
--- a/src/main/kotlin/dulkirmod/command/LeapNameCommand.kt
+++ b/src/main/kotlin/dulkirmod/command/LeapNameCommand.kt
@@ -30,7 +30,7 @@ class LeapNameCommand : ClientCommandBase("hl") {
}
}
private fun findUserNameFor(input: String, isClassName: Boolean): Boolean {
- val scoreboardList = TabListUtils.fetchTabEntires().mapNotNull {
+ val scoreboardList = TabListUtils.fetchTabEntries().mapNotNull {
it.displayName?.unformattedText
}
if (isClassName) {
@@ -41,6 +41,7 @@ class LeapNameCommand : ClientCommandBase("hl") {
return true
}
}
+
TextUtils.info("§6Couldn't find anyone playing this class.")
return false
} else {
diff --git a/src/main/kotlin/dulkirmod/config/Config.kt b/src/main/kotlin/dulkirmod/config/Config.kt
index 6dad478..9ed5c73 100644
--- a/src/main/kotlin/dulkirmod/config/Config.kt
+++ b/src/main/kotlin/dulkirmod/config/Config.kt
@@ -543,6 +543,14 @@ object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod", so
)
var keeperFocus = false
+ @Property(
+ type = PropertyType.SWITCH,
+ name = "Garden Visitor Alert",
+ description = "Notifies you if you have 5/5 garden visitors in queue",
+ category = "Farming"
+ )
+ var notifyMaxVisitors = true
+
fun init() {
initialize()
addDependency("customMessage", "throttleNotifier")
diff --git a/src/main/kotlin/dulkirmod/features/BrokenHypeNotif.kt b/src/main/kotlin/dulkirmod/features/BrokenHypeNotif.kt
index 668751c..27225ff 100644
--- a/src/main/kotlin/dulkirmod/features/BrokenHypeNotif.kt
+++ b/src/main/kotlin/dulkirmod/features/BrokenHypeNotif.kt
@@ -3,6 +3,7 @@ package dulkirmod.features
import dulkirmod.DulkirMod
import dulkirmod.DulkirMod.Companion.mc
import dulkirmod.config.Config
+import dulkirmod.utils.TabListUtils
import dulkirmod.utils.Utils
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
@@ -57,7 +58,7 @@ fun brokenHypeNotif() {
}
// If this section of the code is reached, then we have the same item, and we can check for updated stats
- if (oldKill != kill && oldChampionXp == championXp && Utils.area != "Private Island") {
+ if (oldKill != kill && oldChampionXp == championXp && TabListUtils.area != "Private Island") {
mc.thePlayer.playSound("random.anvil_land", 1f * Config.bestiaryNotifVol, 0f)
val color = Utils.getColorString(Config.bestiaryNotifColor)
DulkirMod.titleUtils.drawStringForTime("${color}Hype Broken", 5000)
diff --git a/src/main/kotlin/dulkirmod/features/GardenVisitorAlert.kt b/src/main/kotlin/dulkirmod/features/GardenVisitorAlert.kt
new file mode 100644
index 0000000..1292b7e
--- /dev/null
+++ b/src/main/kotlin/dulkirmod/features/GardenVisitorAlert.kt
@@ -0,0 +1,28 @@
+package dulkirmod.features
+
+import dulkirmod.DulkirMod
+import dulkirmod.config.Config
+import dulkirmod.utils.TabListUtils
+import dulkirmod.utils.Utils
+
+class GardenVisitorAlert {
+ var hasSentAlert = false
+
+ fun alert() {
+ if (!Config.notifyMaxVisitors) return
+ if (!Utils.isInSkyblock()) return
+
+ if (TabListUtils.area != "Garden") {
+ hasSentAlert = false
+ }
+
+ if (TabListUtils.maxVisitors && !hasSentAlert) {
+ val color = Utils.getColorString(Config.bestiaryNotifColor)
+ DulkirMod.titleUtils.drawStringForTime("${color}Max Visitors", 5000)
+ DulkirMod.mc.thePlayer.playSound("mob.cat.meow", 1f * Config.bestiaryNotifVol, 1f)
+ hasSentAlert = true
+ } else if (!TabListUtils.maxVisitors) hasSentAlert = false
+
+ }
+
+} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/features/KeeperWaypoints.kt b/src/main/kotlin/dulkirmod/features/KeeperWaypoints.kt
index 7b82fa2..bb053a3 100644
--- a/src/main/kotlin/dulkirmod/features/KeeperWaypoints.kt
+++ b/src/main/kotlin/dulkirmod/features/KeeperWaypoints.kt
@@ -2,6 +2,7 @@ package dulkirmod.features
import dulkirmod.DulkirMod.Companion.mc
import dulkirmod.config.Config
+import dulkirmod.utils.TabListUtils
import dulkirmod.utils.Utils
import dulkirmod.utils.WorldRenderUtils
import net.minecraft.util.Vec3
@@ -13,7 +14,7 @@ class KeeperWaypoints {
@SubscribeEvent
fun onWorldRenderLast(event: RenderWorldLastEvent) {
if (!Config.keeperWaypoints) return
- if (Utils.area != "Spider's Den") return
+ if (TabListUtils.area != "Spider's Den") return
val vec1 = Vec3(-208.5, 44.5, -259.5)
val vec2 = Vec3(-311.5, 43.5, -232.5)
diff --git a/src/main/kotlin/dulkirmod/features/MatchoAlert.kt b/src/main/kotlin/dulkirmod/features/MatchoAlert.kt
index c140036..db51a48 100644
--- a/src/main/kotlin/dulkirmod/features/MatchoAlert.kt
+++ b/src/main/kotlin/dulkirmod/features/MatchoAlert.kt
@@ -13,31 +13,16 @@ class MatchoAlert {
if (!Config.notifyMatcho) return
if (!Utils.isInSkyblock()) return
- val scoreboardList: List<String?> = TabListUtils.fetchTabEntires().map {
- it.displayName?.unformattedText
+ if (TabListUtils.area != "Crimson Isle") {
+ hasSentAlert = false
}
- var explo = false
- for (s in scoreboardList) {
- if (explo) {
- // This line is status of Volcano
- if (s != " INACTIVE" && !hasSentAlert) {
- val color = Utils.getColorString(Config.bestiaryNotifColor)
- DulkirMod.titleUtils.drawStringForTime("${color}Matcho", 5000)
- if (Config.bestiaryAlertSounds)
- DulkirMod.mc.thePlayer.playSound("mob.villager.yes", 1f * Config.bestiaryNotifVol, 0f)
- hasSentAlert = true
- } else if (s == " INACTIVE") hasSentAlert = false
- break
- }
- if (s == "Volcano Explosivity:")
- explo = true
- if (s != null) {
- if (s.contains("Area:") && !s.contains("Crimson Isle")) {
- hasSentAlert = false
- break
- }
- }
- }
+ if (TabListUtils.explosivity && !hasSentAlert) {
+ val color = Utils.getColorString(Config.bestiaryNotifColor)
+ DulkirMod.titleUtils.drawStringForTime("${color}Matcho", 5000)
+ if (Config.bestiaryAlertSounds)
+ DulkirMod.mc.thePlayer.playSound("mob.villager.yes", 1f * Config.bestiaryNotifVol, 0f)
+ hasSentAlert = true
+ } else if (!TabListUtils.explosivity) hasSentAlert = false
}
} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/features/NametagCleaner.kt b/src/main/kotlin/dulkirmod/features/NametagCleaner.kt
index 5dd190a..d509d1d 100644
--- a/src/main/kotlin/dulkirmod/features/NametagCleaner.kt
+++ b/src/main/kotlin/dulkirmod/features/NametagCleaner.kt
@@ -2,7 +2,7 @@ package dulkirmod.features
import dulkirmod.DulkirMod.Companion.config
import dulkirmod.DulkirMod.Companion.mc
-import dulkirmod.utils.Utils
+import dulkirmod.utils.TabListUtils
import dulkirmod.utils.Utils.stripColorCodes
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.client.event.RenderLivingEvent
@@ -32,7 +32,7 @@ object NametagCleaner {
}
}
- if (config.keeperFocus && Utils.area == "Spider's Den") {
+ if (config.keeperFocus && TabListUtils.area == "Spider's Den") {
val name = stripColorCodes(event.entity.customNameTag)
if (!name.contains("Keeper"))
mc.theWorld.removeEntity(event.entity)
diff --git a/src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt b/src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt
index f6a90eb..fbd2437 100644
--- a/src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt
+++ b/src/main/kotlin/dulkirmod/features/chat/ThrottleNotif.kt
@@ -2,15 +2,15 @@ package dulkirmod.features.chat
import dulkirmod.DulkirMod
import dulkirmod.config.Config
+import dulkirmod.utils.TabListUtils
import dulkirmod.utils.TextUtils
-import dulkirmod.utils.Utils
import net.minecraftforge.client.event.ClientChatReceivedEvent
object ThrottleNotif {
private var lastThrottle: Long = 0
fun handle(event: ClientChatReceivedEvent, unformatted: String) {
if (unformatted == "This menu has been throttled! Please slow down..." && DulkirMod.config.throttleNotifier
- && Utils.isInDungeons()
+ && TabListUtils.isInDungeons
) {
event.isCanceled = true
if (!Config.throttleNotifierSpam && System.currentTimeMillis() - lastThrottle > 8000) {
diff --git a/src/main/kotlin/dulkirmod/utils/TablistUtils.kt b/src/main/kotlin/dulkirmod/utils/TablistUtils.kt
index 57cb289..da07f0b 100644
--- a/src/main/kotlin/dulkirmod/utils/TablistUtils.kt
+++ b/src/main/kotlin/dulkirmod/utils/TablistUtils.kt
@@ -11,6 +11,11 @@ val NetworkPlayerInfo.text: String
// STOLEN FROM SKYTILS mmm yes
object TabListUtils {
+ var area: String = ""
+ var explosivity: Boolean = false
+ var isInDungeons: Boolean = false
+ var maxVisitors: Boolean = false
+
private val playerInfoOrdering = object : Ordering<NetworkPlayerInfo>() {
override fun compare(p_compare_1_: NetworkPlayerInfo?, p_compare_2_: NetworkPlayerInfo?): Int {
val scorePlayerTeam = p_compare_1_?.playerTeam
@@ -31,8 +36,52 @@ object TabListUtils {
}
}
var tabEntries: List<Pair<NetworkPlayerInfo, String>> = emptyList()
- fun fetchTabEntires(): List<NetworkPlayerInfo> =
+ fun fetchTabEntries(): List<NetworkPlayerInfo> =
if (mc.thePlayer == null) emptyList() else playerInfoOrdering.sortedCopy(
mc.thePlayer.sendQueue.playerInfoMap
)
+
+ /**
+ * Sets a bunch of useful values based on the state of the scoreboard. Functionality is collected all into
+ * this one method in order to avoid more transversal of the list than is necessary, as these checks need
+ * to happen somewhat frequently.
+ */
+ fun parseTabEntries() {
+ // exploFlag is just telling the loop that the next line is the relevant tab entry
+ var exploFlag = false
+ // dungeonFlag keeps track of whether we've found the in-dungeons state.
+ var dungeonFlag = false
+ val scoreboardList: List<String> = fetchTabEntries().mapNotNull {
+ it.displayName?.unformattedText
+ }
+
+ for (line in scoreboardList) {
+ if (line.startsWith("Area: "))
+ area = line.substring(6)
+ else if (line == "Volcano Explosivity:") {
+ exploFlag = true
+ }
+ else if (exploFlag) {
+ explosivity = line != " INACTIVE"
+ exploFlag = false
+ }
+ else if (line == " Dungeon Stats") {
+ isInDungeons = true
+ dungeonFlag = true
+ }
+ // Here is some scuffed code that basically makes sure maxVisitors is assigned appropriately.
+ // It's awful and I do not care to fix it lol.
+ else if (line == " Next Visitor: Queue Full!")
+ maxVisitors = true
+ else if (line.startsWith(" Next Visitor:"))
+ maxVisitors = false
+ }
+
+ if (area != "Crimson Isle")
+ explosivity = false
+ if (area != "Garden")
+ maxVisitors = false
+ if (!dungeonFlag)
+ isInDungeons = false
+ }
} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/utils/Utils.kt b/src/main/kotlin/dulkirmod/utils/Utils.kt
index 47408c3..2ae50cc 100644
--- a/src/main/kotlin/dulkirmod/utils/Utils.kt
+++ b/src/main/kotlin/dulkirmod/utils/Utils.kt
@@ -11,8 +11,6 @@ import java.awt.datatransfer.StringSelection
import java.util.*
object Utils {
-
- var area = ""
fun stripColorCodes(string: String): String {
return string.replace("§.".toRegex(), "")
}
@@ -66,27 +64,7 @@ object Utils {
return false
}
- fun isInDungeons(): Boolean {
- val scoreboardList: List<String?> = TabListUtils.fetchTabEntires().map {
- it.displayName?.unformattedText
- }
- for (l in scoreboardList) {
- if (l == " Dungeon Stats") return true
- }
- return false
- }
-
fun getColorString(int: Int): String {
return if (int == 16) "§z" else EnumChatFormatting.values()[int].toString()
}
-
- fun getArea() {
- val scoreboardList: List<String?> = TabListUtils.fetchTabEntires().map {
- it.displayName?.unformattedText
- }
- for (l in scoreboardList) {
- if (l != null && l.startsWith("Area: "))
- area = l.substring(6)
- }
- }
} \ No newline at end of file