aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerDropTracker.kt43
3 files changed, 47 insertions, 22 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt
index 79202ffa2..ad5d01d3c 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt
@@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUItems
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import com.google.gson.JsonElement
import net.minecraft.item.ItemStack
import net.minecraft.nbt.CompressedStreamTools
@@ -20,7 +21,7 @@ import java.util.Base64
class CropAccessoryData {
// TODO USE SH-REPO
- private val accessoryBagNamePattern = "Accessory Bag \\((\\d)/(\\d)\\)".toRegex()
+ private val accessoryBagNamePattern = "Accessory Bag \\((?<current>\\d)/(?<total>\\d)\\)".toPattern()
private var loadedAccessoryThisProfile = false
private var ticks = 0
private var accessoryInBag: CropAccessory? = null
@@ -48,10 +49,11 @@ class CropAccessoryData {
return
}
- val groups = accessoryBagNamePattern.matchEntire(event.inventoryName)?.groups ?: return
- isLoadingAccessories = true
- accessoryBagPageCount = groups[2]!!.value.toInt()
- accessoryBagPageNumber = groups[1]!!.value.toInt()
+ accessoryBagNamePattern.matchMatcher(event.inventoryName) {
+ isLoadingAccessories = true
+ accessoryBagPageNumber = group("current").toInt()
+ accessoryBagPageCount = group("total").toInt()
+ } ?: return
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
index 57e674976..0f14c98c3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
@@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.inventory.ContainerChest
@@ -109,11 +110,12 @@ class BazaarApi {
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
- if ("\\[Bazaar] (Buy Order Setup!|Bought).*$currentSearchedItem.*".toRegex()
- .matches(event.message.removeColor())
- ) {
- currentSearchedItem = ""
- }
+ if (!LorenzUtils.inSkyBlock) return
+ if (!inBazaarInventory) return
+ // TODO USE SH-REPO
+ // TODO remove dynamic pattern
+ "\\[Bazaar] (Buy Order Setup!|Bought).*$currentSearchedItem.*".toPattern()
+ .matchMatcher(event.message.removeColor()) { currentSearchedItem = "" }
}
private fun checkIfInBazaar(event: InventoryFullyOpenedEvent): Boolean {
@@ -146,4 +148,4 @@ class BazaarApi {
inBazaarInventory = false
currentlyOpenedProduct = null
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerDropTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerDropTracker.kt
index c57447233..b347d6dfe 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerDropTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerDropTracker.kt
@@ -12,10 +12,12 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.LorenzUtils.addOrPut
import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
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 DicerDropTracker {
private val itemDrops = mutableListOf<ItemDrop>()
@@ -32,16 +34,35 @@ object DicerDropTracker {
var drops: MutableMap<CropType, MutableMap<DropRarity, Int>> = mutableMapOf()
}
+ // TODO USE SH-REPO
+ private val melonUncommonDropPattern =
+ "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Melon§r§e!".toPattern()
+ private val melonRareDropPattern =
+ "§9§lRARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Melon§r§e!".toPattern()
+ private val melonCrazyRareDropPattern =
+ "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§[a|9](\\d+)x §r§[a|9]Enchanted Melon(?: Block)?§r§e!".toPattern()
+ private val melonRngesusDropPattern =
+ "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§9(\\d+)x §r§9Enchanted Melon Block§r§e!".toPattern()
+
+ private val pumpkinUncommonDropPattern =
+ "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toPattern()
+ private val pumpkinRareDropPattern =
+ "§9§lRARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toPattern()
+ private val pumpkinCrazyRareDropPattern =
+ "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toPattern()
+ private val pumpkinRngesusDropPattern =
+ "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§[a|9](\\d+)x §r§(aEnchanted|9Polished) Pumpkin§r§e!".toPattern()
+
init {
- itemDrops.add(ItemDrop(CropType.MELON, DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Melon§r§e!".toRegex()))
- itemDrops.add(ItemDrop(CropType.MELON, DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Melon§r§e!".toRegex()))
- itemDrops.add(ItemDrop(CropType.MELON, DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§[a|9](\\d+)x §r§[a|9]Enchanted Melon(?: Block)?§r§e!".toRegex()))
- itemDrops.add(ItemDrop(CropType.MELON, DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§9(\\d+)x §r§9Enchanted Melon Block§r§e!".toRegex()))
-
- itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toRegex()))
- itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toRegex()))
- itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toRegex()))
- itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§[a|9](\\d+)x §r§(aEnchanted|9Polished) Pumpkin§r§e!".toRegex()))
+ itemDrops.add(ItemDrop(CropType.MELON, DropRarity.UNCOMMON, melonUncommonDropPattern))
+ itemDrops.add(ItemDrop(CropType.MELON, DropRarity.RARE, melonRareDropPattern))
+ itemDrops.add(ItemDrop(CropType.MELON, DropRarity.CRAZY_RARE, melonCrazyRareDropPattern))
+ itemDrops.add(ItemDrop(CropType.MELON, DropRarity.PRAY_TO_RNGESUS, melonRngesusDropPattern))
+
+ itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.UNCOMMON, pumpkinUncommonDropPattern))
+ itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.RARE, pumpkinRareDropPattern))
+ itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.CRAZY_RARE, pumpkinCrazyRareDropPattern))
+ itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.PRAY_TO_RNGESUS, pumpkinRngesusDropPattern))
}
enum class DropRarity(val displayName: String) {
@@ -58,7 +79,7 @@ object DicerDropTracker {
val message = event.message
for (drop in itemDrops) {
- if (drop.pattern.matches(message)) {
+ drop.pattern.matchMatcher(message) {
addDrop(drop.crop, drop.rarity)
if (config.hideChat) {
event.blockedReason = "dicer_drop_tracker"
@@ -106,7 +127,7 @@ object DicerDropTracker {
tracker.renderDisplay(config.pos)
}
- class ItemDrop(val crop: CropType, val rarity: DropRarity, val pattern: Regex)
+ class ItemDrop(val crop: CropType, val rarity: DropRarity, val pattern: Pattern)
fun isEnabled() = GardenAPI.inGarden() && config.display