From a0e1a0e5745cb9fc4386fa6c830ec9eaaa6869b5 Mon Sep 17 00:00:00 2001 From: Detlev1 <71934197+Detlev1@users.noreply.github.com> Date: Tue, 13 Feb 2024 18:50:42 +0100 Subject: [PATCH] 1.7.1: Important bug fixes (#123) Co-authored-by: symt <28537235+symt@users.noreply.github.com> --- build.gradle.kts | 2 +- src/main/java/dev/meyi/bn/BazaarNotifier.java | 2 +- .../meyi/bn/handlers/ChestTickHandler.java | 3 +- src/main/java/dev/meyi/bn/json/Order.java | 13 +++++--- src/main/java/dev/meyi/bn/modules/Module.java | 31 +++++++++---------- .../java/dev/meyi/bn/modules/ModuleList.java | 2 +- .../meyi/bn/modules/module/BankModule.java | 6 ++-- .../bn/modules/module/CraftingModule.java | 13 ++++---- .../bn/modules/module/NotificationModule.java | 6 ++-- .../bn/modules/module/SuggestionModule.java | 7 +++-- 10 files changed, 44 insertions(+), 41 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index da7d8f6..3a8884d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ plugins { } group = "dev.meyi.bazaarnotifier" -version = "1.7.0" +version = "1.7.1" val mod_id = "bazaarnotifier" java { diff --git a/src/main/java/dev/meyi/bn/BazaarNotifier.java b/src/main/java/dev/meyi/bn/BazaarNotifier.java index 1dec281..9e576f0 100644 --- a/src/main/java/dev/meyi/bn/BazaarNotifier.java +++ b/src/main/java/dev/meyi/bn/BazaarNotifier.java @@ -42,7 +42,7 @@ public class BazaarNotifier { public static final String MODID = "BazaarNotifier"; - public static final String VERSION = "1.7.0"; + public static final String VERSION = "1.7.1"; public static final String prefix = EnumChatFormatting.GOLD + "[" + EnumChatFormatting.YELLOW + "BN" + EnumChatFormatting.GOLD + "] " + EnumChatFormatting.RESET; diff --git a/src/main/java/dev/meyi/bn/handlers/ChestTickHandler.java b/src/main/java/dev/meyi/bn/handlers/ChestTickHandler.java index e1b101e..c3adc5b 100644 --- a/src/main/java/dev/meyi/bn/handlers/ChestTickHandler.java +++ b/src/main/java/dev/meyi/bn/handlers/ChestTickHandler.java @@ -103,7 +103,7 @@ public static void updateBazaarOrders(IInventory chest) { break; } } - if (creator.equals(playerName)) { + if (creator.equals(playerName) || creator.isEmpty()) { //isEmpty for non Coop Islands if (lore.get(4).toLowerCase().contains("expire") || lore.get(5).toLowerCase().contains("expire")) { continue; } @@ -114,6 +114,7 @@ public static void updateBazaarOrders(IInventory chest) { if (newOrder.getAmountRemaining() != 0) { BazaarNotifier.orders.add(newOrder); verifiedOrders = Arrays.copyOf(verifiedOrders, verifiedOrders.length + 1); + verifiedOrders[verifiedOrders.length-1] = 1; } } } diff --git a/src/main/java/dev/meyi/bn/json/Order.java b/src/main/java/dev/meyi/bn/json/Order.java index 13b9728..eaf46b6 100644 --- a/src/main/java/dev/meyi/bn/json/Order.java +++ b/src/main/java/dev/meyi/bn/json/Order.java @@ -11,7 +11,7 @@ public class Order { public int startAmount; public double pricePerUnit; public String priceString; - public OrderStatus orderStatus = OrderStatus.BEST; + public OrderStatus orderStatus = OrderStatus.SEARCHING; public double orderValue; public OrderType type; private int amountRemaining; @@ -54,12 +54,12 @@ public String getProductId() { } public void updateStatus() { - OrderStatus newOrderStatus = null; + OrderStatus newOrderStatus; if (!BazaarNotifier.activeBazaar) { return; } if (OrderType.BUY.equals(this.type)) { - if (BazaarNotifier.bazaarDataRaw.products.get(getProductId()).sell_summary.size() == 0) { + if (BazaarNotifier.bazaarDataRaw.products.get(getProductId()).sell_summary.isEmpty()) { orderStatus = OrderStatus.SEARCHING; return; } @@ -79,9 +79,11 @@ public void updateStatus() { BazaarNotifier.orders.stream().filter(order -> this.product.equals(order.product) && this.pricePerUnit == order.pricePerUnit).count() != bazaarSubItem.orders) { newOrderStatus = OrderStatus.MATCHED; + } else { + newOrderStatus = OrderStatus.BEST; } } else { - if (BazaarNotifier.bazaarDataRaw.products.get(getProductId()).buy_summary.size() == 0) { + if (BazaarNotifier.bazaarDataRaw.products.get(getProductId()).buy_summary.isEmpty()) { orderStatus = OrderStatus.SEARCHING; return; } @@ -100,6 +102,8 @@ public void updateStatus() { BazaarNotifier.orders.stream().filter(order -> this.product.equals(order.product) && this.pricePerUnit == order.pricePerUnit).count() != bazaarSubItem.orders) { newOrderStatus = OrderStatus.MATCHED; + } else { + newOrderStatus = OrderStatus.BEST; } } if (this.orderStatus != newOrderStatus) { @@ -125,5 +129,4 @@ public enum OrderType { this.longName = longName; } } - } \ No newline at end of file diff --git a/src/main/java/dev/meyi/bn/modules/Module.java b/src/main/java/dev/meyi/bn/modules/Module.java index a57b553..829a3cc 100644 --- a/src/main/java/dev/meyi/bn/modules/Module.java +++ b/src/main/java/dev/meyi/bn/modules/Module.java @@ -3,6 +3,7 @@ import cc.polyfrost.oneconfig.config.annotations.Switch; import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.hud.Hud; +import cc.polyfrost.oneconfig.platform.GuiPlatform; import cc.polyfrost.oneconfig.platform.Platform; import dev.meyi.bn.BazaarNotifier; import net.minecraft.client.Minecraft; @@ -36,24 +37,21 @@ public Module() { @Override protected boolean shouldShow() { - if(BazaarNotifier.inBazaar || Platform.getGuiPlatform().getCurrentScreen() != null){ - //Drawing at this case is handled by the ChestTickHandler to keep it above the gray gui background; - return false; - } - if (showInGuis && Platform.getGuiPlatform().getCurrentScreen() != null && - (Platform.getGuiPlatform().getCurrentScreen() instanceof OneConfigGui)) return false; if(enabled) { - if (showInChat && Platform.getGuiPlatform().isInChat()) return true; - if (showInDebug && Platform.getGuiPlatform().isInDebug()) return true; + GuiPlatform guiPlatform = Platform.getGuiPlatform(); + if(BazaarNotifier.inBazaar){ + //Drawing at this case is handled by the ChestTickHandler to keep it above the gray gui background; + return false; + } + if (showInGuis && (guiPlatform.getCurrentScreen() instanceof OneConfigGui)) return false; + if (showInChat && guiPlatform.isInChat()) return true; + if (showInDebug && guiPlatform.isInDebug()) return true; + if (showInGuis && guiPlatform.getCurrentScreen() != null) return true; return showEverywhere; }else { return false; } } - - public boolean shouldShowGui(){ - return enabled && (BazaarNotifier.inBazaar || showInGuis || showInChat || showInDebug || showEverywhere); - } public abstract void draw(); protected abstract void reset(); @@ -75,8 +73,8 @@ public void handleMovement() { public void drawBounds() { if (shouldDrawBounds()) { - Gui.drawRect((int)position.getX() - padding, (int)position.getY() - padding, - (int)position.getRightX() + padding, (int)position.getBottomY() + padding, 0x66000000); + Gui.drawRect((int)position.getX(), (int)position.getY(), + (int)position.getRightX(), (int)position.getBottomY(), 0x66000000); } } @@ -107,10 +105,9 @@ public void setActive(boolean active) { } public float getModuleWidth(){ - return this.getWidth(scale, false) + 2 * padding; + return this.getWidth(scale, false); } public float getModuleHeight(){ - return this.getHeight(scale, false) + 2 * padding; - } + return this.getHeight(scale, false); } } diff --git a/src/main/java/dev/meyi/bn/modules/ModuleList.java b/src/main/java/dev/meyi/bn/modules/ModuleList.java index d9f18d9..8105def 100644 --- a/src/main/java/dev/meyi/bn/modules/ModuleList.java +++ b/src/main/java/dev/meyi/bn/modules/ModuleList.java @@ -87,7 +87,7 @@ public void pageFlipCheck() { public void drawAllGui(){ if (BazaarNotifier.config.enabled && BazaarNotifier.activeBazaar) { for (Module m : this) { - if (m.shouldShowGui()) { + if (m.isEnabled() && BazaarNotifier.inBazaar) { m.position.setSize(m.getModuleWidth(), m.getModuleHeight()); m.draw(); } diff --git a/src/main/java/dev/meyi/bn/modules/module/BankModule.java b/src/main/java/dev/meyi/bn/modules/module/BankModule.java index 04d0272..27f0eaf 100644 --- a/src/main/java/dev/meyi/bn/modules/module/BankModule.java +++ b/src/main/java/dev/meyi/bn/modules/module/BankModule.java @@ -44,12 +44,12 @@ protected void draw(UMatrixStack matrices, float x, float y, float scale, boolea @Override protected float getWidth(float scale, boolean example) { - return RenderUtils.getStringWidth(longestString)*scale; + return RenderUtils.getStringWidth(longestString)* scale + 2 * padding * scale; } @Override protected float getHeight(float scale, boolean example) { - return ((Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT * lines) + lines )*scale - 2; + return (((Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT * lines) + lines ) * scale - 2) + 2 * padding * scale; } @@ -94,7 +94,7 @@ public void draw() { longestString = RenderUtils.getLongestString(items); - RenderUtils.drawColorfulParagraph(items, (int)position.getX(), (int)position.getY(), scale); + RenderUtils.drawColorfulParagraph(items, (int)position.getX() + padding, (int)position.getY() + padding, scale); GL11.glTranslated(0, 0, -1); } diff --git a/src/main/java/dev/meyi/bn/modules/module/CraftingModule.java b/src/main/java/dev/meyi/bn/modules/module/CraftingModule.java index bbb767a..b941c1f 100644 --- a/src/main/java/dev/meyi/bn/modules/module/CraftingModule.java +++ b/src/main/java/dev/meyi/bn/modules/module/CraftingModule.java @@ -77,15 +77,16 @@ protected void draw(UMatrixStack matrices, float x, float y, float scale, boolea @Override protected float getWidth(float scale, boolean example) { - return RenderUtils.getStringWidth(longestString) * scale; + return RenderUtils.getStringWidth(longestString) * scale + 2 * padding * scale; } @Override protected float getHeight(float scale, boolean example) { try { - return (Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT + return ((Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT * (BazaarNotifier.config.craftingModule.craftingListLength + 1) - + (BazaarNotifier.config.craftingModule.craftingListLength + 1) * 2) * scale - 2; + + (BazaarNotifier.config.craftingModule.craftingListLength + 1) * 2) * scale - 2) + + 2 * scale * padding; } catch (NullPointerException e) { return 1; } @@ -243,7 +244,7 @@ public void draw() { } longestString = RenderUtils.getLongestString(items); - RenderUtils.drawColorfulParagraph(items, (int) position.getX(), (int) position.getY(), scale); + RenderUtils.drawColorfulParagraph(items, (int) position.getX() + padding, (int) position.getY() + padding, scale); if (BazaarNotifier.inBazaar) { renderMaterials(checkHoveredText(), list); } @@ -299,12 +300,12 @@ protected int getMaxShift() { } protected int checkHoveredText() { - float _y = position.getY() + 11 * scale; + float _y = position.getY() +(-padding + 11) * scale; float y2 = _y + ((BazaarNotifier.config.craftingModule.craftingListLength) * 11 * scale); int mouseYFormatted = getMouseCoordinateY(); float relativeYMouse = (mouseYFormatted - _y) / (11 * scale); if (getWidth(scale, false) != 0) { - if (inMovementBox() && mouseYFormatted >= _y && mouseYFormatted <= y2 - 3 * scale) { + if (inMovementBox() && mouseYFormatted >= _y && mouseYFormatted <= y2) { return (int) relativeYMouse + shift; } else { return -1; diff --git a/src/main/java/dev/meyi/bn/modules/module/NotificationModule.java b/src/main/java/dev/meyi/bn/modules/module/NotificationModule.java index bbeaa37..a2c8bc1 100644 --- a/src/main/java/dev/meyi/bn/modules/module/NotificationModule.java +++ b/src/main/java/dev/meyi/bn/modules/module/NotificationModule.java @@ -41,7 +41,7 @@ protected void draw(UMatrixStack matrices, float x, float y, float scale, boolea protected float getWidth(float scale, boolean example) { if (longestString != null) { if (!longestString.isEmpty()) { - return RenderUtils.getStringWidth(longestString) * scale; + return RenderUtils.getStringWidth(longestString) * scale + 2 * padding * scale; } } return 200*scale; @@ -49,7 +49,7 @@ protected float getWidth(float scale, boolean example) { @Override protected float getHeight(float scale, boolean example) { - return (Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT * 10 + 20)*scale - 2; + return ((Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT * 10 + 20) * scale - 2) + 2 * padding * scale; } //source dsm public static void drawOnSlot(int chestSize, int slot, int color) { @@ -105,7 +105,7 @@ public void draw() { items.add(message); } longestString = RenderUtils.getLongestString(items); - RenderUtils.drawColorfulParagraph(items, (int)position.getX(), (int)position.getY(), scale); + RenderUtils.drawColorfulParagraph(items, (int)position.getX() + padding, (int)position.getY() + padding, scale); } else { longestString = ""; RenderUtils.drawCenteredString("No orders found", (int)position.getX(), (int)position.getY(), 0xAAAAAA, scale); diff --git a/src/main/java/dev/meyi/bn/modules/module/SuggestionModule.java b/src/main/java/dev/meyi/bn/modules/module/SuggestionModule.java index 5710024..d98ab24 100644 --- a/src/main/java/dev/meyi/bn/modules/module/SuggestionModule.java +++ b/src/main/java/dev/meyi/bn/modules/module/SuggestionModule.java @@ -51,7 +51,7 @@ protected void draw(UMatrixStack matrices, float x, float y, float scale, boolea @Override protected float getWidth(float scale, boolean example) { - return RenderUtils.getStringWidth(longestString)*scale; + return RenderUtils.getStringWidth(longestString)*scale + 2 * padding * scale; } @Override @@ -61,7 +61,8 @@ protected float getHeight(float scale, boolean example) { } return (Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT * BazaarNotifier.config.suggestionModule.suggestionListLength - + BazaarNotifier.config.suggestionModule.suggestionListLength * 2)*scale - 2; + + BazaarNotifier.config.suggestionModule.suggestionListLength * 2)*scale - 2 + + 2 * padding * scale; } @Override @@ -81,7 +82,7 @@ public void draw() { items.add(message); } longestString = RenderUtils.getLongestString(items); - RenderUtils.drawColorfulParagraph(items, (int)position.getX(), (int)position.getY(), scale); + RenderUtils.drawColorfulParagraph(items, (int)position.getX() + padding, (int)position.getY() + padding, scale); } else { RenderUtils.drawCenteredString("Waiting for bazaar data", (int)position.getX(), (int)position.getY(), 0xAAAAAA, scale); //Todo add height and width