diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/TextInput.kt b/src/main/java/at/hannibal2/skyhanni/data/model/TextInput.kt index 6ae2342b6909..0646b884cdec 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/model/TextInput.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/model/TextInput.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data.model import at.hannibal2.skyhanni.utils.KeyboardManager import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyClicked +import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.StringUtils.insert @@ -73,7 +74,11 @@ class TextInput { fun onGuiInput(ci: CallbackInfo) { if (activeInstance != null) { - ci.cancel() + if (Keyboard.KEY_ESCAPE.isKeyHeld()) { + disable() + } else { + ci.cancel() + } return } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/Enchant.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/Enchant.kt index 8058fc223fc0..286560c73fea 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/Enchant.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/Enchant.kt @@ -3,13 +3,15 @@ package at.hannibal2.skyhanni.features.misc.items.enchants import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.features.chroma.ChromaManager import at.hannibal2.skyhanni.utils.ItemCategory +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull -import at.hannibal2.skyhanni.utils.ItemUtils.itemNameWithoutColor +import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.StringUtils.removeColor import com.google.gson.annotations.Expose import io.github.notenoughupdates.moulconfig.observer.Property -import net.minecraft.item.ItemStack import java.util.TreeSet +import net.minecraft.item.ItemStack open class Enchant : Comparable { @Expose @@ -64,7 +66,8 @@ open class Enchant : Comparable { val config = SkyHanniMod.feature.inventory.enchantParsing val itemCategory = itemStack?.getItemCategoryOrNull() - val itemName = itemStack?.itemNameWithoutColor + val internalName = itemStack?.getInternalNameOrNull() + val itemName = internalName?.itemName?.removeColor() if (this.nbtName == "efficiency") { // If the item is a Stonk, or a non-mining tool with Efficiency 5 (whilst not being a Promising Shovel), 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 f3d7e8017a24..66c4c040716a 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 @@ -19,8 +19,10 @@ import at.hannibal2.skyhanni.utils.ItemUtils.isEnchanted import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getExtraAttributes import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import java.lang.ArithmeticException import net.minecraft.event.HoverEvent import net.minecraft.item.ItemStack import net.minecraft.util.ChatComponentText @@ -202,7 +204,26 @@ object EnchantParser { val insertEnchants: MutableList = mutableListOf() // Format enchants based on format config option - formatEnchants(insertEnchants) + try { + formatEnchants(insertEnchants) + } catch (e: ArithmeticException) { + ErrorManager.logErrorWithData( + e, + "Item has enchants in nbt but none were found?", + "item" to currentItem, + "loreList" to loreList, + "nbt" to currentItem?.getExtraAttributes() + ) + return + } catch (e: ConcurrentModificationException) { + ErrorManager.logErrorWithData( + e, + "ConcurrentModificationException whilst formatting enchants", + "loreList" to loreList, + "format" to config.format.get(), + "orderedEnchants" to orderedEnchants + ) + } // Add our parsed enchants back into the lore loreList.addAll(startEnchant, insertEnchants) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 1a75b4cbcff1..774638c5d66f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -370,7 +370,7 @@ object ItemUtils { getAttributeFromShard()?.let { return it.getAttributeName() } - return getInternalName().itemName + return getInternalNameOrNull()?.itemName ?: "" } fun ItemStack.getAttributeFromShard(): Pair? {