diff options
author | MisterCheezeCake <75341435+MisterCheezeCake@users.noreply.github.com> | 2024-05-11 08:38:39 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-11 14:38:39 +0200 |
commit | 4776b0d16e58ec81e3e38dd1208a78f2d2a65106 (patch) | |
tree | 1e6ad648b899df0e89eb6a5985190e329e05222c /src | |
parent | 46bcdafb0f77f44a9d8592516a20acc0278f5bad (diff) | |
download | NotEnoughUpdates-4776b0d16e58ec81e3e38dd1208a78f2d2a65106.tar.gz NotEnoughUpdates-4776b0d16e58ec81e3e38dd1208a78f2d2a65106.tar.bz2 NotEnoughUpdates-4776b0d16e58ec81e3e38dd1208a78f2d2a65106.zip |
Add discount parsing in Enchant Table and Hex GUIs (#1156)
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java | 13 | ||||
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java | 13 |
2 files changed, 26 insertions, 0 deletions
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)); } } } |