aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-05 10:47:21 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-05 10:47:21 +0100
commitfd47344a8fb5c9b1657a2696bc298659b9458fd9 (patch)
treeeec6c34b391d674718b9e93b79c27faf37bf4da9 /src/main
parentdfa6c8e5304b36dc9de9c177934d6cbddbd9868d (diff)
downloadskyhanni-fd47344a8fb5c9b1657a2696bc298659b9458fd9.tar.gz
skyhanni-fd47344a8fb5c9b1657a2696bc298659b9458fd9.tar.bz2
skyhanni-fd47344a8fb5c9b1657a2696bc298659b9458fd9.zip
code cleanup
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/CrimsonIsleConfig.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/QuestItemHelper.kt31
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt5
7 files changed, 35 insertions, 35 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/CrimsonIsleConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/CrimsonIsleConfig.java
index 7dc558b15..cb94035a7 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/CrimsonIsleConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/CrimsonIsleConfig.java
@@ -144,7 +144,7 @@ public class CrimsonIsleConfig {
@Expose
@ConfigOption(name = "Quest Item Helper", desc = "When you open the fetch item quest in the town board, " +
- "it shows a clickable chat message that will grab the items needed from the sacks.")
+ "it shows a clickable chat message that will grab the items needed from the sacks.")
@ConfigEditorBoolean
@FeatureToggle
public boolean questItemHelper = false;
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt
index 034761654..ee72bec69 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt
@@ -10,9 +10,9 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.PreProfileSwitchEvent
-import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy
+import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
@@ -161,7 +161,7 @@ class FrozenTreasureTracker {
event.move(2, "misc.frozenTreasureTracker", "event.winter.frozenTreasureTracker")
}
- private fun onJerryWorkshop() = LorenzUtils.inIsland(IslandType.WINTER)
+ private fun onJerryWorkshop() = IslandType.WINTER.isInIsland()
private fun inGlacialCave() = onJerryWorkshop() && ScoreboardData.sidebarLinesFormatted.contains(" §7⏣ §3Glacial Cave")
-} \ No newline at end of file
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt
index b3b002c24..99b8240a6 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt
@@ -58,4 +58,4 @@ class OdgerWaypoint {
}
fun isEnabled() = IslandType.CRIMSON_ISLE.isInIsland() && config.odgerLocation
-} \ No newline at end of file
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt
index f34931eb5..89a0a1917 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt
@@ -6,16 +6,19 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.minutes
// https://wiki.hypixel.net/Pablo
class PabloHelper {
+ private val config get() = SkyHanniMod.feature.crimsonIsle
// There is a different message if the player asks Pablo with an item in their hand, but I don't think it's necessary
- // I'll add it if requested
+ // I'll add it if requested ~NetheriteMiner
private val pabloMessagePattern = "\\[NPC] Pablo: Could you bring me an (?<flower>[\\w ]+).*".toPattern()
private var lastSentMessage = SimpleTimeMark.farPast()
@@ -23,17 +26,15 @@ class PabloHelper {
fun onChat(event: LorenzChatEvent) {
if (!isEnabled()) return
if (lastSentMessage.passedSince() < 5.minutes) return
- val pabloMatcher = pabloMessagePattern.matcher(event.message.removeColor())
+ val itemName = pabloMessagePattern.matchMatcher(event.message.removeColor()) {
+ group("flower")
+ } ?: return
- if (!pabloMatcher.matches()) return
- val item = pabloMatcher.group("flower")
+ if (InventoryUtils.countItemsInLowerInventory { it.name?.contains(itemName) == true } > 0) return
- if (InventoryUtils.countItemsInLowerInventory { it.name?.contains(item) == true } > 0) return
-
- LorenzUtils.clickableChat("§e[SkyHanni] Click here to grab an $item from sacks!", "gfs $item 1")
+ LorenzUtils.clickableChat("§e[SkyHanni] Click here to grab an $itemName from sacks!", "gfs $itemName 1")
lastSentMessage = SimpleTimeMark.now()
}
- fun isEnabled() =
- LorenzUtils.skyBlockIsland == IslandType.CRIMSON_ISLE && SkyHanniMod.feature.crimsonIsle.pabloHelper
+ fun isEnabled() = IslandType.CRIMSON_ISLE.isInIsland() && config.pabloHelper
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/QuestItemHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/QuestItemHelper.kt
index 24d47c317..e87a3f63b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/QuestItemHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/QuestItemHelper.kt
@@ -17,8 +17,6 @@ class QuestItemHelper {
private val config get() = SkyHanniMod.feature.crimsonIsle
private val itemCollectionPattern = ". (?<name>[\\w ]+) x(?<amount>\\d+)".toPattern()
- private var questItem = ""
- private var questAmount = 0
private var lastSentMessage = SimpleTimeMark.farPast()
@SubscribeEvent
@@ -26,19 +24,22 @@ class QuestItemHelper {
if (!isEnabled()) return
if (event.inventoryName != "Fetch") return
if (lastSentMessage.passedSince() < 1.hours) return
- items@ for ((_, item) in event.inventoryItems) {
- itemCollectionPattern.matchMatcher(item.displayName.removeColor()) {
- if (!matches()) continue@items
- questItem = group("name")
- questAmount = group("amount").toInt()
- questAmount -= InventoryUtils.countItemsInLowerInventory { it.name?.contains(questItem) == true }
- LorenzUtils.clickableChat(
- "§e[SkyHanni] Click here to grab x$questAmount $questItem from sacks!",
- "gfs $questItem $questAmount"
- )
- lastSentMessage = SimpleTimeMark.now()
- break@items
- }
+
+ for ((_, item) in event.inventoryItems) {
+ val (questItem, need) = itemCollectionPattern.matchMatcher(item.displayName.removeColor()) {
+ group("name") to group("amount").toInt()
+ } ?: continue
+
+ val have = InventoryUtils.countItemsInLowerInventory { it.name?.contains(questItem) == true }
+ if (have >= need) break
+
+ val missingAmount = have - need
+ LorenzUtils.clickableChat(
+ "§e[SkyHanni] Click here to grab x$missingAmount $questItem from sacks!",
+ "gfs $questItem $missingAmount"
+ )
+ lastSentMessage = SimpleTimeMark.now()
+ break
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt
index 3a37cc435..4fbbed3d3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt
@@ -5,12 +5,13 @@ import at.hannibal2.skyhanni.config.features.RiftConfig
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import net.minecraft.item.ItemStack
object RiftAPI {
- fun inRift() = LorenzUtils.inIsland(IslandType.THE_RIFT)
+ fun inRift() = IslandType.THE_RIFT.isInIsland()
val config: RiftConfig get() = SkyHanniMod.feature.rift
@@ -30,4 +31,4 @@ object RiftAPI {
fun inLivingStillness() = LorenzUtils.skyBlockArea == "Living Stillness"
fun inStillgoreChateau() = LorenzUtils.skyBlockArea == "Stillgore Château" || LorenzUtils.skyBlockArea == "Oubliette"
fun inDreadfarm() = LorenzUtils.skyBlockArea == "Dreadfarm"
-} \ No newline at end of file
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 751271510..d4f35c2d8 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -431,10 +431,7 @@ object LorenzUtils {
&& tileSign.signText[3].unformattedText.removeColor() == "speed cap!")
}
- fun inIsland(island: IslandType) =
- inSkyBlock && (skyBlockIsland == island || island == IslandType.CATACOMBS && inDungeons)
-
- fun IslandType.isInIsland() = inIsland(this)
+ fun IslandType.isInIsland() = inSkyBlock && (skyBlockIsland == this || this == IslandType.CATACOMBS && inDungeons)
fun <K> MutableMap<K, Int>.addOrPut(key: K, number: Int): Int {
val currentValue = this[key] ?: 0