From 4776b0d16e58ec81e3e38dd1208a78f2d2a65106 Mon Sep 17 00:00:00 2001 From: MisterCheezeCake <75341435+MisterCheezeCake@users.noreply.github.com> Date: Sat, 11 May 2024 08:38:39 -0400 Subject: Add discount parsing in Enchant Table and Hex GUIs (#1156) --- .../notenoughupdates/miscgui/GuiCustomEnchant.java | 13 +++++++++++++ .../notenoughupdates/miscgui/hex/GuiCustomHex.java | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java index 3041ee43..cbd9d2ba 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java @@ -79,6 +79,7 @@ public class GuiCustomEnchant extends Gui { private static final ModelBook MODEL_BOOK = new ModelBook(); private static final Pattern XP_COST_PATTERN = Pattern.compile("\\u00a73(\\d+) Exp Levels"); + private static final Pattern DISCOUNT_COST_PATTERN = Pattern.compile("\\u00a78\\u00a7m(\\d+)\\u00a73 (\\d+) Exp Levels"); private static final Pattern ENCHANT_LEVEL_PATTERN = Pattern.compile("(.*)_(.*)"); private static final Pattern ENCHANT_NAME_PATTERN = Pattern.compile("([^IVX]*) ([IVX]*)"); @@ -161,6 +162,15 @@ public class GuiCustomEnchant extends Gui { } } + for (String line : this.displayLore) { + Matcher matcher = XP_COST_PATTERN.matcher(line); + Matcher discount_matcher = DISCOUNT_COST_PATTERN.matcher(line); + if (matcher.find()) { + this.xpCost = Integer.parseInt(matcher.group(1)); + } else if (discount_matcher.find()) { + this.xpCost = Integer.parseInt(discount_matcher.group(2)); + } + } } } @@ -432,8 +442,11 @@ public class GuiCustomEnchant extends Gui { if (enchanterCurrentEnch != null && removingEnchantPlayerLevel >= 0) { for (String line : enchanterCurrentEnch.displayLore) { Matcher matcher = XP_COST_PATTERN.matcher(line); + Matcher discount_matcher = DISCOUNT_COST_PATTERN.matcher(line); if (matcher.find()) { enchanterCurrentEnch.xpCost = Integer.parseInt(matcher.group(1)); + } else if (discount_matcher.find()) { + enchanterCurrentEnch.xpCost = Integer.parseInt(discount_matcher.group(2)); } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java index 2e368f79..bd869c90 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java @@ -86,6 +86,7 @@ public class GuiCustomHex extends Gui { private static final ModelBook MODEL_BOOK = new ModelBook(); private static final Pattern XP_COST_PATTERN = Pattern.compile("\\u00a73(\\d+) Exp Levels"); + private static final Pattern DISCOUNT_COST_PATTERN = Pattern.compile("\\u00a78\\u00a7m(\\d+)\\u00a73 (\\d+) Exp Levels"); private static final Pattern ENCHANT_LEVEL_PATTERN = Pattern.compile("(.*)_(.*)"); private static final Pattern ENCHANT_NAME_PATTERN = Pattern.compile("([^IVX]*) ([IVX]*)"); @@ -174,6 +175,15 @@ public class GuiCustomHex extends Gui { } } + for (String line : this.displayLore) { + Matcher matcher = XP_COST_PATTERN.matcher(line); + Matcher discount_matcher = DISCOUNT_COST_PATTERN.matcher(line); + if (matcher.find()) { + this.xpCost = Integer.parseInt(matcher.group(1)); + } else if (discount_matcher.find()) { + this.xpCost = Integer.parseInt(discount_matcher.group(2)); + } + } } } @@ -562,8 +572,11 @@ public class GuiCustomHex extends Gui { if (enchanterCurrentEnch != null && removingEnchantPlayerLevel >= 0) { for (String line : enchanterCurrentEnch.displayLore) { Matcher matcher = XP_COST_PATTERN.matcher(line); + Matcher discount_matcher = DISCOUNT_COST_PATTERN.matcher(line); if (matcher.find()) { enchanterCurrentEnch.xpCost = Integer.parseInt(matcher.group(1)); + } else if (discount_matcher.find()) { + enchanterCurrentEnch.xpCost = Integer.parseInt(discount_matcher.group(2)); } } } -- cgit