aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLulonaut <67191924+Lulonaut@users.noreply.github.com>2021-12-02 12:21:33 +0100
committerGitHub <noreply@github.com>2021-12-02 06:21:33 -0500
commit112341e9a72e1f3a6e07cd3c38b1fcba6f222ce4 (patch)
tree8e96d01cf010cb6b0313b52f9605aeb5da2d4aa1
parent1e1ac8f1fa096b2acffb3065e4ba7583a00e1385 (diff)
downloadNotEnoughUpdates-112341e9a72e1f3a6e07cd3c38b1fcba6f222ce4.tar.gz
NotEnoughUpdates-112341e9a72e1f3a6e07cd3c38b1fcba6f222ce4.tar.bz2
NotEnoughUpdates-112341e9a72e1f3a6e07cd3c38b1fcba6f222ce4.zip
Add warning to tooltip when price info is not there/outdated (#27)
* Make fairy souls save per profile * fix commands * Add back support for toggling in /neu * add patch notes * Add warning when price info couldn't be found is outdated
-rw-r--r--Update Notes/2.1.md1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java20
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java8
3 files changed, 24 insertions, 5 deletions
diff --git a/Update Notes/2.1.md b/Update Notes/2.1.md
index 87e322ef..1b623418 100644
--- a/Update Notes/2.1.md
+++ b/Update Notes/2.1.md
@@ -32,6 +32,7 @@
- Added an option to use short numbers (1.5mil) for price tooltips
- Added Drills and Gauntlet to the itemlist tools category - jani
- Added an option to show next click in chronomatron
+- Added a warning in the tooltip when price info couldn't be found/is outdated - Lulonaut
### **Bug Fixes**
- Made titanium overlay and waypoints work with dwarven overlay off
- "fixed" divan rarity in NEUAH (scuffed)
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java
index 8fbb7c40..b563906e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java
@@ -34,12 +34,21 @@ public class ItemPriceInformation {
int lowestBin = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname);
APIManager.CraftInfo craftCost = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(internalname);
- boolean auctionItem = lowestBin > 0 || lowestBinAvg > 0 || auctionInfo != null;
+ boolean auctionItem = lowestBin > 0 || lowestBinAvg > 0;
+ boolean auctionInfoErrored = auctionInfo == null;
+ if (auctionItem) {
+ long currentTime = System.currentTimeMillis();
+ long lastUpdate = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLastLowestBinUpdateTime();
+ //check if info is older than 10 minutes
+ if (currentTime - lastUpdate > 600 * 1000) {
+ tooltip.add(EnumChatFormatting.RED + "[NEU] Price info is outdated by more than 10 minutes.\nIt will updated again as soon as the server can be reached again.");
+ }
+ }
+
boolean bazaarItem = bazaarInfo != null;
NumberFormat format = NumberFormat.getInstance(Locale.US);
boolean shortNumber = NotEnoughUpdates.INSTANCE.config.tooltipTweaks.shortNumberFormatPrices;
-
if (bazaarItem) {
List<Integer> lines = NotEnoughUpdates.INSTANCE.config.tooltipTweaks.priceInfoBaz;
@@ -139,7 +148,7 @@ public class ItemPriceInformation {
added = true;
}
tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Lowest BIN: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + (shortNumber && lowestBin > 1000 ? Utils.shortNumberFormat(lowestBin, 0) : format.format(lowestBin)) + " coins");
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(lowestBin) + " coins");
}
break;
case 1:
@@ -152,7 +161,7 @@ public class ItemPriceInformation {
if (auctionInfo.has("clean_price")) {
tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Price (Clean): " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD +
(shortNumber && auctionInfo.get("clean_price").getAsFloat() > 1000 ? Utils.shortNumberFormat(auctionInfo.get("clean_price").getAsFloat(), 0) : format.format((int) auctionInfo.get("clean_price").getAsFloat())
- + " coins"));
+ + " coins"));
} else {
int auctionPrice = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Price: " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD +
@@ -246,6 +255,9 @@ public class ItemPriceInformation {
}
return added;
+ } else if (auctionInfoErrored) {
+ tooltip.add(EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD + "[NEU] Can't find price info! Please be patient.");
+ return true;
}
return false;
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 6b421192..70b9e312 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
@@ -206,7 +206,6 @@ public class APIManager {
updateBazaar();
}
if (currentTime - lastLowestBinUpdate > 2 * 60 * 1000) {
- lastLowestBinUpdate = currentTime;
updateLowestBin();
}
}
@@ -251,6 +250,9 @@ public class APIManager {
if (lowestBins == null) {
lowestBins = new JsonObject();
}
+ if (!jsonObject.entrySet().isEmpty()) {
+ lastLowestBinUpdate = System.currentTimeMillis();
+ }
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
lowestBins.add(entry.getKey(), entry.getValue());
}
@@ -294,6 +296,10 @@ public class APIManager {
}
}
+ public long getLastLowestBinUpdateTime() {
+ return lastLowestBinUpdate;
+ }
+
private final ExecutorService es = Executors.newSingleThreadExecutor();
private void cleanup() {