aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorWalker Selby <git@walkerselby.com>2023-12-16 12:06:44 +0000
committerGitHub <noreply@github.com>2023-12-16 13:06:44 +0100
commitcc1be73101abe20c61e25206875b279145883109 (patch)
treec643e6624ab3f669f1b5bf05ec7037c9b349d968 /src/main/java/at/hannibal2
parented3fca1da9c642ac6bacc2c2254f36d982bd25b2 (diff)
downloadskyhanni-cc1be73101abe20c61e25206875b279145883109.tar.gz
skyhanni-cc1be73101abe20c61e25206875b279145883109.tar.bz2
skyhanni-cc1be73101abe20c61e25206875b279145883109.zip
Feature: Add Vermin Tracker (#804)
Add Vermin Tracker #804
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Storage.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/VerminTrackerConfig.java25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/WestVillageConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt149
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/KloonHacking.kt)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonTerminal.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/KloonTerminal.kt)4
8 files changed, 195 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 7bcf31f72..d6c6b62e1 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -288,7 +288,8 @@ import at.hannibal2.skyhanni.features.rift.area.mirrorverse.RiftLavaMazeParkour
import at.hannibal2.skyhanni.features.rift.area.mirrorverse.RiftUpsideDownParkour
import at.hannibal2.skyhanni.features.rift.area.mirrorverse.TubulatorParkour
import at.hannibal2.skyhanni.features.rift.area.stillgorechateau.RiftBloodEffigies
-import at.hannibal2.skyhanni.features.rift.area.westvillage.KloonHacking
+import at.hannibal2.skyhanni.features.rift.area.westvillage.VerminTracker
+import at.hannibal2.skyhanni.features.rift.area.westvillage.kloon.KloonHacking
import at.hannibal2.skyhanni.features.rift.area.wyldwoods.RiftLarva
import at.hannibal2.skyhanni.features.rift.area.wyldwoods.RiftOdonata
import at.hannibal2.skyhanni.features.rift.area.wyldwoods.ShyCruxWarnings
@@ -682,6 +683,7 @@ class SkyHanniMod {
loadModule(JyrreTimer())
loadModule(NewYearCakeReminder())
loadModule(HighlightInquisitors())
+ loadModule(VerminTracker)
init()
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
index 4a9c94fb5..e17646663 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
@@ -19,7 +19,8 @@ import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward;
import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker;
import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker;
import at.hannibal2.skyhanni.features.misc.visualwords.VisualWord;
-import at.hannibal2.skyhanni.features.rift.area.westvillage.KloonTerminal;
+import at.hannibal2.skyhanni.features.rift.area.westvillage.VerminTracker;
+import at.hannibal2.skyhanni.features.rift.area.westvillage.kloon.KloonTerminal;
import at.hannibal2.skyhanni.features.slayer.SlayerProfitTracker;
import at.hannibal2.skyhanni.utils.LorenzVec;
import at.hannibal2.skyhanni.utils.NEUInternalName;
@@ -358,6 +359,9 @@ public class Storage {
@Expose
public List<KloonTerminal> completedKloonTerminals = new ArrayList<>();
+ @Expose
+ public VerminTracker.Data verminTracker = new VerminTracker.Data();
+
}
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
index 3dba2e047..8f4d96483 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
@@ -41,6 +41,7 @@ import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager
import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager
import at.hannibal2.skyhanni.features.misc.massconfiguration.DefaultConfigFeatures
import at.hannibal2.skyhanni.features.misc.visualwords.VisualWordGui
+import at.hannibal2.skyhanni.features.rift.area.westvillage.VerminTracker
import at.hannibal2.skyhanni.features.slayer.SlayerProfitTracker
import at.hannibal2.skyhanni.test.PacketTest
import at.hannibal2.skyhanni.test.SkyHanniConfigSearchResetCommand
@@ -203,6 +204,10 @@ object Commands {
"shmouselock",
"Lock/Unlock the mouse so it will no longer rotate the player (for farming)"
) { LockMouseLook.toggleLock() }
+ registerCommand(
+ "shresetvermintracker",
+ "Resets the Vermin Tracker"
+ ) { VerminTracker.resetCommand(it) }
}
private fun usersBugFix() {
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/VerminTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/VerminTrackerConfig.java
new file mode 100644
index 000000000..1ada3d883
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/VerminTrackerConfig.java
@@ -0,0 +1,25 @@
+package at.hannibal2.skyhanni.config.features.rift.area.westvillage;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+import at.hannibal2.skyhanni.config.core.config.Position;
+import com.google.gson.annotations.Expose;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.moulberry.moulconfig.annotations.ConfigOption;
+
+public class VerminTrackerConfig {
+ @Expose
+ @ConfigOption(name = "Show Counter", desc = "Count all §aSilverfish§7, §aSpiders, §7and §aFlies §7vacuumed.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean enabled = true;
+
+ @Expose
+ @ConfigOption(name = "Hide Chat", desc = "Hide the chat message when vacuuming a vermin.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean hideChat = false;
+
+ @Expose
+ public Position pos = new Position(16, -232, false, true);
+}
+
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/WestVillageConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/WestVillageConfig.java
index 273080489..478bc4cc9 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/WestVillageConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/WestVillageConfig.java
@@ -10,4 +10,9 @@ public class WestVillageConfig {
@Accordion
@Expose
public KloonHackingConfig hacking = new KloonHackingConfig();
+
+ @ConfigOption(name = "Vermin Tracker", desc = "infested")
+ @Accordion
+ @Expose
+ public VerminTrackerConfig verminTracker = new VerminTrackerConfig();
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt
new file mode 100644
index 000000000..4bb2120b4
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt
@@ -0,0 +1,149 @@
+package at.hannibal2.skyhanni.features.rift.area.westvillage
+
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.features.rift.RiftAPI
+import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
+import at.hannibal2.skyhanni.utils.LorenzUtils.addOrPut
+import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
+import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.StringUtils.matches
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker
+import at.hannibal2.skyhanni.utils.tracker.TrackerData
+import com.google.gson.annotations.Expose
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.regex.Pattern
+
+object VerminTracker {
+ private val silverfishPattern by RepoPattern.pattern(
+ "rift.area.westvillage.vermintracker.silverfish",
+ ".*§eYou vacuumed a §.*Silverfish.*"
+ )
+ private val spiderPattern by RepoPattern.pattern(
+ "rift.area.westvillage.vermintracker.spider",
+ ".*§eYou vacuumed a §.*Spider.*"
+ )
+ private val flyPattern by RepoPattern.pattern(
+ "rift.area.westvillage.vermintracker.fly",
+ ".*§eYou vacuumed a §.*Fly.*"
+ )
+ private val verminBinPattern by RepoPattern.pattern(
+ "rift.area.westvillage.vermintracker.binline",
+ "§fVermin Bin: §\\w(?<count>\\d+) (?<vermin>\\w+)"
+ )
+ private val verminBagPattern by RepoPattern.pattern(
+ "rift.area.westvillage.vermintracker.bagline",
+ "§fVacuum Bag: §\\w(?<count>\\d+) (?<vermin>\\w+)"
+ )
+
+ private val config get() = RiftAPI.config.area.westVillage.verminTracker
+
+ private val tracker = SkyHanniTracker("Vermin Tracker", { Data() }, { it.rift.verminTracker })
+ { drawDisplay(it) }
+
+ class Data : TrackerData() {
+ override fun reset() {
+ count.clear()
+ }
+
+ @Expose
+ var count: MutableMap<VerminType, Int> = mutableMapOf()
+ }
+
+ enum class VerminType(val vermin: String, val pattern: Pattern) {
+ SILVERFISH("§aSilverfish", silverfishPattern),
+ SPIDER("§aSpiders", spiderPattern),
+ FLY("§aFlies", flyPattern),
+ }
+
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ VerminType.entries.forEach { verminType ->
+ if (verminType.pattern.matches(event.message)) {
+ addVermin(verminType)
+ if (config.hideChat) {
+ event.blockedReason = "vermin_vacuumed"
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
+ if (!RiftAPI.inRift() || event.inventoryName != "Vermin Bin") return
+
+ val bin = event.inventoryItems[13]?.getLore() ?: return
+ val bag = InventoryUtils.getItemsInOwnInventory()
+ .firstOrNull { it.getInternalName() == "TURBOMAX_VACUUM".asInternalName() }
+ ?.getLore() ?: emptyList()
+
+ val binCounts = countVermin(bin, verminBinPattern)
+ VerminType.entries.forEach { setVermin(it, binCounts[it] ?: 0) }
+
+ if (bag.isEmpty()) return
+
+ val bagCounts = countVermin(bag, verminBagPattern)
+ VerminType.entries.forEach { addVermin(it, bagCounts[it] ?: 0) }
+ }
+
+ private fun countVermin(lore: List<String>, pattern: Pattern): MutableMap<VerminTracker.VerminType, Int> {
+ val verminCounts = mutableMapOf(
+ VerminType.SILVERFISH to 0,
+ VerminType.SPIDER to 0,
+ VerminType.FLY to 0
+ )
+ for (line in lore) {
+ pattern.matchMatcher(line) {
+ val vermin = group("vermin")?.lowercase() ?: continue
+ val verminCount = group("count")?.toInt() ?: continue
+ val verminType = getVerminType(vermin)
+ verminCounts[verminType] = verminCount
+ }
+ }
+ return verminCounts
+ }
+
+ private fun getVerminType(vermin: String): VerminType {
+ return when (vermin) {
+ "silverfish", "silverfishes" -> VerminType.SILVERFISH
+ "spider", "spiders" -> VerminType.SPIDER
+ "fly", "flies" -> VerminType.FLY
+ else -> VerminType.SILVERFISH
+ }
+ }
+
+ private fun addVermin(vermin: VerminType, count: Int = 1) {
+ tracker.modify { it.count.addOrPut(vermin, count) }
+ }
+
+ private fun setVermin(vermin: VerminType, count: Int) {
+ tracker.modify { it.count[vermin] = count }
+ }
+
+ private fun drawDisplay(data: Data): List<List<Any>> = buildList {
+ addAsSingletonList("§7Vermin Tracker:")
+ data.count.entries.sortedByDescending { it.value }.forEach { (vermin, amount) ->
+ val verminName = vermin.vermin
+ addAsSingletonList(" §7- §e${amount.addSeparators()} $verminName")
+ }
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent) {
+ if (!isEnabled()) return
+
+ tracker.renderDisplay(config.pos)
+ }
+
+ fun resetCommand(args: Array<String>) {
+ tracker.resetCommand(args, "shresetvermintracker")
+ }
+
+ private fun isEnabled() = RiftAPI.inRift() && config.enabled
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/KloonHacking.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt
index 41c52b3f5..eb24782c6 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/KloonHacking.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.features.rift.area.westvillage
+package at.hannibal2.skyhanni.features.rift.area.westvillage.kloon
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.data.ProfileStorageData
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/KloonTerminal.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonTerminal.kt
index b5434d330..201bfca77 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/KloonTerminal.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonTerminal.kt
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.features.rift.area.westvillage
+package at.hannibal2.skyhanni.features.rift.area.westvillage.kloon
import at.hannibal2.skyhanni.utils.LorenzVec
@@ -11,4 +11,4 @@ enum class KloonTerminal(val location: LorenzVec) {
BLUE(LorenzVec(-66.5, 72.0, -119.0)),
PURPLE(LorenzVec(-89.0, 73.0, -115.0)),
PINK(LorenzVec(-110.0, 73.0, -107.0))
-} \ No newline at end of file
+}