aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2023-02-03 08:29:58 +0100
committerGitHub <noreply@github.com>2023-02-03 18:29:58 +1100
commit75c6b9a2312682d059c6786f5253028566fbad94 (patch)
treeaea2cbf9530996a5a8c5a7257f1a52cab63aa2a2 /src/main/java/io
parent13452658006ba945cec1491cb198f05b2258af93 (diff)
downloadNotEnoughUpdates-75c6b9a2312682d059c6786f5253028566fbad94.tar.gz
NotEnoughUpdates-75c6b9a2312682d059c6786f5253028566fbad94.tar.bz2
NotEnoughUpdates-75c6b9a2312682d059c6786f5253028566fbad94.zip
No bazaar data when no bazaar data (#577)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java17
2 files changed, 22 insertions, 13 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java
index 8096c2d5..5c851211 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java
@@ -54,8 +54,8 @@ public class ItemPriceInformation {
private static final NumberFormat format = new DecimalFormat("#,##0.#", new DecimalFormatSymbols(Locale.US));
public static String STACKSIZE_OVERRIDE = "NEU_STACKSIZE_OVERRIDE";
- public static boolean addToTooltip(List<String> tooltip, String internalname, ItemStack stack) {
- return addToTooltip(tooltip, internalname, stack, true);
+ public static void addToTooltip(List<String> tooltip, String internalName, ItemStack stack) {
+ addToTooltip(tooltip, internalName, stack, true);
}
public static void init(File saveLocation, Gson neuGson) {
@@ -92,16 +92,16 @@ public class ItemPriceInformation {
}
}
- public static boolean addToTooltip(List<String> tooltip, String internalname, ItemStack stack, boolean useStackSize) {
+ public static void addToTooltip(List<String> tooltip, String internalname, ItemStack stack, boolean useStackSize) {
if (stack.getTagCompound().hasKey("disableNeuTooltip") && stack.getTagCompound().getBoolean("disableNeuTooltip")) {
- return false;
+ return;
}
if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.disablePriceKey &&
!KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.disablePriceKeyKeybind)) {
- return false;
+ return;
}
if (internalname.equals("SKYBLOCK_MENU")) {
- return false;
+ return;
}
JsonObject auctionInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname);
JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalname);
@@ -207,7 +207,6 @@ public class ItemPriceInformation {
}
}
- return added;
} else if (auctionItem && !auctionInfoErrored) {
List<Integer> lines = NotEnoughUpdates.INSTANCE.config.tooltipTweaks.priceInfoAuc;
@@ -366,21 +365,16 @@ public class ItemPriceInformation {
}
}
- return added;
} else if (auctionInfoErrored && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
String message = EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD + "[NEU] API is down";
if (auctionableItems != null && !auctionableItems.isEmpty()) {
if (auctionableItems.contains(internalname)) {
tooltip.add(message);
- return true;
}
} else {
tooltip.add(message + " and no item data is cached");
- return true;
}
}
-
- return false;
}
private static String formatPrice(String label, double price) {
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 6ae5dd80..5ec3724a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
@@ -744,7 +744,9 @@ public class APIManager {
JsonObject productInfo = new JsonObject();
JsonObject product = entry.getValue().getAsJsonObject();
- JsonObject quickStatus = product.get("quick_status").getAsJsonObject();
+ JsonObject quickStatus = product.getAsJsonObject("quick_status");
+ if (!hasData(quickStatus)) continue;
+
productInfo.addProperty("avg_buy", quickStatus.get("buyPrice").getAsFloat());
productInfo.addProperty("avg_sell", quickStatus.get("sellPrice").getAsFloat());
@@ -771,6 +773,19 @@ public class APIManager {
});
}
+ private static boolean hasData(JsonObject quickStatus) {
+ for (Map.Entry<String, JsonElement> e : quickStatus.entrySet()) {
+ String key = e.getKey();
+ if (!key.equals("productId")) {
+ double value = e.getValue().getAsDouble();
+ if (value != 0) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
public void updateAvgPrices() {
manager.apiUtils
.newMoulberryRequest("auction_averages/3day.json.gz")