aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-04-18 22:27:55 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-04-18 22:27:55 +0200
commit9ed4a9462f0e494001cbe470477624c3dd73053a (patch)
tree22eb21429038fe9d78509f5f3fb75330664bab9b
parentcb8d4eef2826e84e9df3d6735635fe02e33f8d6e (diff)
parent25c958f75cab5ccba7fab2312a7855230859964e (diff)
downloadskyhanni-9ed4a9462f0e494001cbe470477624c3dd73053a.tar.gz
skyhanni-9ed4a9462f0e494001cbe470477624c3dd73053a.tar.bz2
skyhanni-9ed4a9462f0e494001cbe470477624c3dd73053a.zip
Merge remote-tracking branch 'origin/beta' into beta
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt42
1 files changed, 34 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt
index 1327ffa33..180bd0a69 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt
@@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.events.SlayerChangeEvent
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.itemName
@@ -22,6 +23,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.formatLong
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.StringUtils.removeWordsAtEnd
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
@@ -38,6 +40,10 @@ class SlayerRngMeterDisplay {
"inventoryname",
"(?<name>.*) RNG Meter"
)
+ private val slayerInventoryNamePattern by patternGroup.pattern(
+ "inventoryname.slayer",
+ "Slayer"
+ )
private val updatePattern by patternGroup.pattern(
"update",
" {3}§dRNG Meter §f- §d(?<exp>.*) Stored XP"
@@ -127,26 +133,46 @@ class SlayerRngMeterDisplay {
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
if (!isEnabled()) return
+ readRngmeterInventory(event)
+ readSlayerInventory(event)
+ }
+
+ private fun readRngmeterInventory(event: InventoryFullyOpenedEvent) {
val name = inventoryNamePattern.matchMatcher(event.inventoryName) {
group("name")
} ?: return
if (name != getCurrentSlayer()) return
- val storage = getStorage() ?: return
+ val internalName = event.inventoryItems.values
+ .find { item -> item.getLore().any { it.contains("§a§lSELECTED") } }
+ setNewGoal(internalName?.getInternalName())
+ }
+
+ private fun readSlayerInventory(event: InventoryFullyOpenedEvent) {
+ if (!slayerInventoryNamePattern.matches(event.inventoryName)) return
+ val item = event.inventoryItems[35] ?: return
+ val lore = item.getLore()
+ val name = lore.firstOrNull()?.removeColor() ?: return
- val selectedItem =
- event.inventoryItems.values.find { item -> item.getLore().any { it.contains("§a§lSELECTED") } }
- if (selectedItem == null) {
+ if (name != getCurrentSlayer()) return
+
+ val selectedItem = lore.nextAfter("§7Selected Drop") ?: return
+ val internalName = NEUInternalName.fromItemName(selectedItem)
+ setNewGoal(internalName)
+ }
+
+ private fun setNewGoal(internalName: NEUInternalName?) {
+ val storage = getStorage() ?: return
+ if (internalName == null) {
storage.itemGoal = ""
storage.goalNeeded = -1
} else {
- storage.itemGoal = selectedItem.itemName
- storage.goalNeeded = rngScore[getCurrentSlayer()]?.get(selectedItem.getInternalName())
+ storage.itemGoal = internalName.itemName
+ storage.goalNeeded = rngScore[getCurrentSlayer()]?.get(internalName)
?: ErrorManager.skyHanniError(
"RNG Meter goal setting failed",
- "selectedItem" to selectedItem,
- "selectedItemInternalName" to selectedItem.getInternalName(),
+ "internalName" to internalName,
"currentSlayer" to getCurrentSlayer(),
"repo" to rngScore
)