From 39a60438362289427d559f2c5000745b45e70ceb Mon Sep 17 00:00:00 2001 From: symt <28537235+symt@users.noreply.github.com> Date: Tue, 26 Jul 2022 14:50:30 -0500 Subject: [PATCH] 1.4.12: Fixed alpha chat message changes (#80) --- build.gradle | 2 +- src/main/java/dev/meyi/bn/BazaarNotifier.java | 2 +- .../dev/meyi/bn/handlers/ChestTickHandler.java | 18 ++++++++++++++---- .../dev/meyi/bn/handlers/EventHandler.java | 6 +++--- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 25233f0..967aced 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ compileJava { sourceCompatibility = '1.8' targetCompatibility = '1.8' } -version = "1.4.11" +version = "1.4.12" group = "dev.meyi.bn" archivesBaseName = "BazaarNotifier" diff --git a/src/main/java/dev/meyi/bn/BazaarNotifier.java b/src/main/java/dev/meyi/bn/BazaarNotifier.java index 9606d6c..ac0f347 100644 --- a/src/main/java/dev/meyi/bn/BazaarNotifier.java +++ b/src/main/java/dev/meyi/bn/BazaarNotifier.java @@ -28,7 +28,7 @@ public class BazaarNotifier { public static final String MODID = "BazaarNotifier"; - public static final String VERSION = "1.4.11"; + public static final String VERSION = "1.4.12"; public static final String prefix = EnumChatFormatting.GOLD + "[" + EnumChatFormatting.YELLOW + "BN" + EnumChatFormatting.GOLD + "] " + EnumChatFormatting.RESET; public static String apiKey = ""; diff --git a/src/main/java/dev/meyi/bn/handlers/ChestTickHandler.java b/src/main/java/dev/meyi/bn/handlers/ChestTickHandler.java index 9ff92c6..09133c2 100644 --- a/src/main/java/dev/meyi/bn/handlers/ChestTickHandler.java +++ b/src/main/java/dev/meyi/bn/handlers/ChestTickHandler.java @@ -4,6 +4,8 @@ import dev.meyi.bn.utilities.Utils; import java.util.ArrayList; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.inventory.IInventory; @@ -39,10 +41,18 @@ public static void updateBazaarOrders(IInventory chest) { lore.add(StringUtils.stripControlCodes(lorePreFilter.getStringTagAt(j))); } - String displayName = StringUtils - .stripControlCodes(chest.getStackInSlot(i).getDisplayName().split(": ")[1]); - String type = StringUtils.stripControlCodes( - chest.getStackInSlot(i).getDisplayName().split(": ")[0].toLowerCase()); + Pattern p = Pattern + .compile("(BUY|SELL):? (.*)"); + Matcher m = p.matcher(StringUtils.stripControlCodes(chest.getStackInSlot(i).getDisplayName())); + String displayName = ""; + String type = ""; + if (m.find()) { + displayName = m.group(2); + type = m.group(1).toLowerCase(); + } else { + System.out.println("Bazaar item header incorrect. Aborting!"); + return; + } if (BazaarNotifier.bazaarConversionsReversed.has(displayName)) { int amountLeft = -1; diff --git a/src/main/java/dev/meyi/bn/handlers/EventHandler.java b/src/main/java/dev/meyi/bn/handlers/EventHandler.java index 4f89b7e..ed0333d 100644 --- a/src/main/java/dev/meyi/bn/handlers/EventHandler.java +++ b/src/main/java/dev/meyi/bn/handlers/EventHandler.java @@ -24,7 +24,7 @@ public void bazaarChatHandler(ClientChatReceivedEvent e) { return; } String message = StringUtils.stripControlCodes(e.message.getUnformattedText()); - if (message.startsWith("Buy Order Setup!") || message.startsWith("Sell Offer Setup!")) { + if (message.startsWith("Buy Order Setup!") || message.startsWith("Sell Offer Setup!") || message.startsWith("[Bazaar] Buy Order Setup!") || message.startsWith("[Bazaar] Sell Offer Setup!")) { if (productVerify[0] != null && productVerify[1] != null && productVerify[0] .equals(BazaarNotifier.bazaarConversionsReversed .getString(message.split("x ", 2)[1].split(" for ")[0])) && productVerify[1] @@ -70,7 +70,7 @@ public void bazaarChatHandler(ClientChatReceivedEvent e) { } else { System.err.println("There is some error in removing your order from the list!!!"); } - } else if (message.startsWith("Cancelled!")) { + } else if (message.startsWith("Cancelled!") || message.startsWith("[Bazaar] Cancelled!")) { double refund = 0; int refundAmount = 0; String itemRefunded = ""; @@ -102,7 +102,7 @@ public void bazaarChatHandler(ClientChatReceivedEvent e) { } } } - } else if (message.startsWith("Bazaar! Claimed ")) { + } else if (message.startsWith("Bazaar! Claimed ") || message.startsWith("[Bazaar] Claimed ")) { ChestTickHandler.lastScreenDisplayName = ""; // Force update on next tick // ChestTickHandler.updateBazaarOrders( // ((GuiChest) Minecraft.getMinecraft().currentScreen).lowerChestInventory);