From 5308904bb63a3abcec0dadb1af57f590e0e5a021 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 9 Aug 2022 23:52:31 +0200 Subject: [PATCH] adding >2.1b support for custom ah (#214) --- .../notenoughupdates/auction/APIManager.java | 6 ++-- .../notenoughupdates/auction/CustomAH.java | 28 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java index 7c58cb4d6f..29b5f4a51c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -123,7 +123,7 @@ public HashSet getAuctionsForInternalname(String internalname) { public class Auction { public String auctioneerUuid; public long end; - public int starting_bid; + public long starting_bid; public int highest_bid_amount; public int bid_count; public boolean bin; @@ -137,7 +137,7 @@ public class Auction { public int enchLevel = 0; //0 = clean, 1 = ench, 2 = ench/hpb public Auction( - String auctioneerUuid, long end, int starting_bid, int highest_bid_amount, int bid_count, + String auctioneerUuid, long end, long starting_bid, int highest_bid_amount, int bid_count, boolean bin, String category, String rarity, int dungeonTier, String item_tag_str ) { this.auctioneerUuid = auctioneerUuid; @@ -540,7 +540,7 @@ private void processAuction(JsonObject auction) { String auctionUuid = auction.get("uuid").getAsString(); String auctioneerUuid = auction.get("auctioneer").getAsString(); long end = auction.get("end").getAsLong(); - int starting_bid = auction.get("starting_bid").getAsInt(); + long starting_bid = auction.get("starting_bid").getAsLong(); int highest_bid_amount = auction.get("highest_bid_amount").getAsInt(); int bid_count = auction.get("bids").getAsJsonArray().size(); boolean bin = false; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java index d8fedecb83..f0ef1ec6a3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java @@ -94,7 +94,7 @@ private enum PriceFilter { private boolean shouldUpdateSearch = false; private boolean shouldSortItems = false; - private int startingBid = 0; + private long startingBid = 0; private String currentAucId = null; private int clickedMainCategory = -1; @@ -640,7 +640,7 @@ public void drawScreen(int mouseX, int mouseY) { } } if (priceNumbers.length() > 0) { - startingBid = Integer.parseInt(priceNumbers.toString()); + startingBid = Long.parseLong(priceNumbers.toString()); } } } @@ -1578,18 +1578,18 @@ public void sortItems() throws ConcurrentModificationException { if (auc2 == null) return -1; if (sortMode == SORT_MODE_HIGH) { - int price1 = Math.max(auc1.highest_bid_amount, auc1.starting_bid); - int price2 = Math.max(auc2.highest_bid_amount, auc2.starting_bid); - int diff = price2 - price1; + long price1 = Math.max(auc1.highest_bid_amount, auc1.starting_bid); + long price2 = Math.max(auc2.highest_bid_amount, auc2.starting_bid); + long diff = price2 - price1; if (diff != 0) { - return diff; + return Long.compare(price2, price1); } } else if (sortMode == SORT_MODE_LOW) { - int price1 = Math.max(auc1.highest_bid_amount, auc1.starting_bid); - int price2 = Math.max(auc2.highest_bid_amount, auc2.starting_bid); - int diff = price1 - price2; + long price1 = Math.max(auc1.highest_bid_amount, auc1.starting_bid); + long price2 = Math.max(auc2.highest_bid_amount, auc2.starting_bid); + long diff = price1 - price2; if (diff != 0) { - return diff; + return Long.compare(price1, price2); } } else { long end1 = auc1.end; @@ -1679,16 +1679,16 @@ private void increasePriceByFactor(float factor) { priceField.setText((int) (priceI * factor) + end); } - private int getPriceFilterAmount() { + private long getPriceFilterAmount() { return getNumberFromTextBox(priceFilterField); } - private int getNumberFromTextBox(GuiTextField textField) { + private long getNumberFromTextBox(GuiTextField textField) { if (textField.getText().equals("")) { return -2; } try { - int parsed = Integer.parseInt(textField.getText()); + long parsed = Long.parseLong(textField.getText()); if (parsed < 0) { return -1; } @@ -1698,7 +1698,7 @@ private int getNumberFromTextBox(GuiTextField textField) { } } - private int getBinPriceFilterAmount() { + private long getBinPriceFilterAmount() { return getNumberFromTextBox(binPriceFilterField); }