From 957db001954a4948214641264d484ae3daa812de Mon Sep 17 00:00:00 2001 From: Cow Date: Sun, 23 Jul 2023 22:09:07 +0200 Subject: Changed lowest BIN values from int to long --- CHANGELOG.md | 3 ++- .../java/de/cowtipper/cowlection/chesttracker/ChestTracker.java | 2 +- .../java/de/cowtipper/cowlection/chesttracker/data/ItemData.java | 6 +++--- .../de/cowtipper/cowlection/chesttracker/data/LowestBinsCache.java | 2 +- src/main/java/de/cowtipper/cowlection/util/GsonUtils.java | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd4405e..13b8d97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,10 +30,11 @@ All other features *do not* require an API key and thus should be unaffected by ### Fixed - Pet exp in tooltips: fixed rare crash caused by unexpected NBT data typing -- Bazaar: fixed "Show items left to buy/sell" not working anymore +- Bazaar: fixed "Show items left to buy/sell" for buy/sell orders not working anymore - Enchanted books: fixed "price converted to level 1 books", as enchantments are now sold on the Bazaar, and no longer inside the Auction house - works on "intermediate" Bazaar pages, so the 'overview' Bazaar pages that list all levels of a certain enchantment (GUI title starts with either `Enchantments ➜` or `Ultimate Enchantments ➜`) - (related config options: `/moo config enchantment`) +- `/moo analyzeChests`: lowest BINs are now stored as long values instead of integers (affects only a handful of items with very high BIN prices) ### Changed - Dungeons overlay: now disabled by default (old config entries aren't modified) diff --git a/src/main/java/de/cowtipper/cowlection/chesttracker/ChestTracker.java b/src/main/java/de/cowtipper/cowlection/chesttracker/ChestTracker.java index a823401..4e60ce2 100644 --- a/src/main/java/de/cowtipper/cowlection/chesttracker/ChestTracker.java +++ b/src/main/java/de/cowtipper/cowlection/chesttracker/ChestTracker.java @@ -160,7 +160,7 @@ public class ChestTracker { } if (!foundPriceForItem && checkLowestBinPrices) { String productKey = itemEntry.getKey().replace(':', '-'); - Integer lowestBin = lowestBinsCache.get(productKey); + Long lowestBin = lowestBinsCache.get(productKey); if (lowestBin != null) { // item is sold via BIN itemData.setLowestBin(lowestBin); diff --git a/src/main/java/de/cowtipper/cowlection/chesttracker/data/ItemData.java b/src/main/java/de/cowtipper/cowlection/chesttracker/data/ItemData.java index 616032d..f79ec2f 100644 --- a/src/main/java/de/cowtipper/cowlection/chesttracker/data/ItemData.java +++ b/src/main/java/de/cowtipper/cowlection/chesttracker/data/ItemData.java @@ -10,7 +10,7 @@ public class ItemData { private int amount; private double bazaarInstantSellPrice = 0; private double bazaarSellOfferPrice = 0; - private int lowestBin = 0; + private long lowestBin = 0; private double npcPrice = 0; private PriceType priceType; private boolean isHidden = false; @@ -76,7 +76,7 @@ public class ItemData { this.priceType = PriceType.BAZAAR; } - public void setLowestBin(int lowestBin) { + public void setLowestBin(long lowestBin) { this.lowestBin = lowestBin; this.priceType = PriceType.LOWEST_BIN; } @@ -100,7 +100,7 @@ public class ItemData { } public long getLowestBinValue() { - return (long) amount * lowestBin; + return ((long) amount) * lowestBin; } public long getNpcSellValue() { diff --git a/src/main/java/de/cowtipper/cowlection/chesttracker/data/LowestBinsCache.java b/src/main/java/de/cowtipper/cowlection/chesttracker/data/LowestBinsCache.java index 344f6bb..37cdec6 100644 --- a/src/main/java/de/cowtipper/cowlection/chesttracker/data/LowestBinsCache.java +++ b/src/main/java/de/cowtipper/cowlection/chesttracker/data/LowestBinsCache.java @@ -2,7 +2,7 @@ package de.cowtipper.cowlection.chesttracker.data; import java.util.HashMap; -public class LowestBinsCache extends HashMap { +public class LowestBinsCache extends HashMap { public boolean hasData() { return size() > 0; } diff --git a/src/main/java/de/cowtipper/cowlection/util/GsonUtils.java b/src/main/java/de/cowtipper/cowlection/util/GsonUtils.java index c21a1fd..ae2ddb2 100644 --- a/src/main/java/de/cowtipper/cowlection/util/GsonUtils.java +++ b/src/main/java/de/cowtipper/cowlection/util/GsonUtils.java @@ -187,9 +187,9 @@ public final class GsonUtils { JsonObject lowestBins = json.getAsJsonObject(); for (Map.Entry entry : lowestBins.entrySet()) { try { - lowestBinsCache.put(entry.getKey(), entry.getValue().getAsInt()); + lowestBinsCache.put(entry.getKey(), entry.getValue().getAsLong()); } catch (ClassCastException | NumberFormatException ignored) { - // somehow not an integer + // somehow not a long } } return lowestBinsCache; -- cgit