aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorVixid <52578495+VixidDev@users.noreply.github.com>2024-08-26 13:47:50 +0100
committerGitHub <noreply@github.com>2024-08-26 14:47:50 +0200
commit13e8fe4d44a8b8ca3568265ca2cd6e11bacc470e (patch)
treede4cdb927c2bb5d322cbab02a8a2b3f0a7aabdce /src/main/java/at
parentd15d82ce6706c78265486a5114828ff5f1d02317 (diff)
downloadskyhanni-13e8fe4d44a8b8ca3568265ca2cd6e11bacc470e.tar.gz
skyhanni-13e8fe4d44a8b8ca3568265ca2cd6e11bacc470e.tar.bz2
skyhanni-13e8fe4d44a8b8ca3568265ca2cd6e11bacc470e.zip
Revert "Improvement: Enchant Parsing SBA Convert Roman Numerals and NEU Inventories compat" (#2417)
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt32
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/FormattedEnchant.kt3
2 files changed, 14 insertions, 21 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt
index dbd8a3a1b..a1aacfb0c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt
@@ -1,13 +1,12 @@
package at.hannibal2.skyhanni.features.misc.items.enchants
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.config.features.inventory.EnchantParsingConfig
import at.hannibal2.skyhanni.config.features.inventory.EnchantParsingConfig.CommaFormat
import at.hannibal2.skyhanni.events.ChatHoverEvent
import at.hannibal2.skyhanni.events.ConfigLoadEvent
+import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
-import at.hannibal2.skyhanni.events.item.ItemHoverEvent
import at.hannibal2.skyhanni.features.chroma.ChromaManager
import at.hannibal2.skyhanni.mixins.hooks.GuiChatHook
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
@@ -39,7 +38,7 @@ object EnchantParser {
val patternGroup = RepoPattern.group("misc.items.enchantparsing")
val enchantmentPattern by patternGroup.pattern(
- "enchants", "(§9§d§l|§d§l§d§l|§9)(?<enchant>[A-Za-z][A-Za-z '-]+) (?<levelNumeral>[IVXLCDM]+|[0-9]+)(?<stacking>§9, |\$| §8\\d{1,3}(,\\d{3})*)"
+ "enchants", "(?<enchant>[A-Za-z][A-Za-z '-]+) (?<levelNumeral>[IVXLCDM]+)(?<stacking>, |\$| \\d{1,3}(,\\d{3})*)"
)
private val grayEnchantPattern by patternGroup.pattern(
"grayenchants", "^(Respiration|Aqua Affinity|Depth Strider|Efficiency).*"
@@ -92,10 +91,10 @@ object EnchantParser {
}
}
- @HandleEvent(onlyOnSkyblock = true)
- fun onTooltipEvent(event: ItemHoverEvent) {
+ @SubscribeEvent
+ fun onTooltipEvent(event: LorenzToolTipEvent) {
// If enchants doesn't have any enchant data then we have no data to parse enchants correctly
- if (!this.enchants.hasEnchantData()) return
+ if (!isEnabled() || !this.enchants.hasEnchantData()) return
currentItem = event.itemStack
@@ -221,7 +220,7 @@ object EnchantParser {
val strippedLine = loreList[i].removeColor()
if (startEnchant == -1) {
- if (this.enchants.containsEnchantment(enchants, loreList[i])) startEnchant = i
+ if (this.enchants.containsEnchantment(enchants, strippedLine)) startEnchant = i
} else if (strippedLine.trim().isEmpty() && endEnchant == -1) endEnchant = i - 1
}
@@ -233,27 +232,22 @@ object EnchantParser {
var lastEnchant: FormattedEnchant? = null
for (i in startEnchant..endEnchant) {
- val matcher = enchantmentPattern.matcher(loreList[i])
+ val unformattedLine = loreList[i].removeColor()
+ val matcher = enchantmentPattern.matcher(unformattedLine)
var containsEnchant = false
var enchantsOnThisLine = 0
- var isRoman = true
while (matcher.find()) {
// Pull enchant, enchant level and stacking amount if applicable
val enchant = this.enchants.getFromLore(matcher.group("enchant"))
- val level = try {
- // If one enchant is not a roman numeral we assume all are not roman numerals (idk a situation where this wouldn't be the case)
- matcher.group("levelNumeral").toInt().also { isRoman = false }
- } catch (e: NumberFormatException) {
- matcher.group("levelNumeral").romanToDecimal()
- }
- val stacking = if (matcher.group("stacking").trimStart().removeColor().matches("[\\d,]+\$".toRegex())) {
+ val level = matcher.group("levelNumeral").romanToDecimal()
+ val stacking = if (matcher.group("stacking").trimStart().matches("[\\d,]+\$".toRegex())) {
shouldBeSingleColumn = true
matcher.group("stacking")
} else "empty"
// Last found enchant
- lastEnchant = FormattedEnchant(enchant, level, stacking, isRoman)
+ lastEnchant = FormattedEnchant(enchant, level, stacking)
if (!orderedEnchants.add(lastEnchant)) {
for (e: FormattedEnchant in orderedEnchants) {
@@ -281,10 +275,10 @@ object EnchantParser {
// Normal is leaving the formatting as Hypixel provides it
if (config.format.get() == EnchantParsingConfig.EnchantFormat.NORMAL) {
normalFormatting(insertEnchants)
- // Compressed is always forcing 3 enchants per line, except when there is stacking enchant progress visible
+ // Compressed is always forcing 3 enchants per line, except when there is stacking enchant progress visible
} else if (config.format.get() == EnchantParsingConfig.EnchantFormat.COMPRESSED && !shouldBeSingleColumn) {
compressedFormatting(insertEnchants)
- // Stacked is always forcing 1 enchant per line
+ // Stacked is always forcing 1 enchant per line
} else {
stackedFormatting(insertEnchants)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/FormattedEnchant.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/FormattedEnchant.kt
index 73cf57e7a..504415296 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/FormattedEnchant.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/FormattedEnchant.kt
@@ -6,7 +6,6 @@ class FormattedEnchant(
private val enchant: Enchant,
private val level: Int,
stacking: String,
- private val isRoman: Boolean
) : Comparable<FormattedEnchant> {
private val stacking: String = stacking
get() = "§8$field"
@@ -20,7 +19,7 @@ class FormattedEnchant(
fun getFormattedString(): String {
val builder = StringBuilder()
- builder.append(enchant.getFormattedName(level)).append(" ").append(if (isRoman) level.toRoman() else level)
+ builder.append(enchant.getFormattedName(level)).append(" ").append(level.toRoman())
return if (!stacking.contains("empty")) builder.append(stacking).toString() else builder.toString()
}