aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-03-27 19:12:44 +0200
committerGitHub <noreply@github.com>2022-03-27 19:12:44 +0200
commit47efdd4f84cc9a29738fe16d631eb33ee716db61 (patch)
treeaf7514fac2d55c7a2885025d6e858b8a2cfa3b55 /src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java
parente202e4adf979073921455083f5e737bc4fcf5f14 (diff)
downloadnotenoughupdates-47efdd4f84cc9a29738fe16d631eb33ee716db61.tar.gz
notenoughupdates-47efdd4f84cc9a29738fe16d631eb33ee716db61.tar.bz2
notenoughupdates-47efdd4f84cc9a29738fe16d631eb33ee716db61.zip
New wiki in wiki renderer (#97)
* partly working and pushing cuz jani * way better rendering stuff but still not perfect * finish most of wiki renderer for new wiki * JANI MY FRIEND PLEASE TEST * Windows time :sad: * fix wiki renderer * Some things I forgor * changelog * Better corrupted file handling in graph and added check for crash that I have no idea how it happened.
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java
index 3955b35f..63a08d41 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java
@@ -117,12 +117,11 @@ public class GuiPriceGraph extends GuiScreen {
Utils.drawStringCentered("Loading...", Minecraft.getMinecraft().fontRendererObj,
guiLeft + 166, guiTop + 116, false, 0xffffff00
);
- else if (dataPoints == null || dataPoints.get() == null || dataPoints.get().size() <= 1)
+ else if (dataPoints == null || dataPoints.get() == null || dataPoints.get().size() <= 1 || lowestValue == null)
Utils.drawStringCentered("No data found.", Minecraft.getMinecraft().fontRendererObj,
guiLeft + 166, guiTop + 116, false, 0xffff0000
);
else {
-
int graphColor = SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.ahGraph.graphColor);
int graphColor2 = SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.ahGraph.graphColor2);
Integer lowestDist = null;
@@ -399,15 +398,17 @@ public class GuiPriceGraph extends GuiScreen {
if (!file.getName().endsWith(".gz")) continue;
if (file.lastModified() <
System.currentTimeMillis() - NotEnoughUpdates.INSTANCE.config.ahGraph.dataRetention * 86400000L)
+ //noinspection ResultOfMethodCallIgnored
file.delete();
}
Date date = new Date();
Long epochSecond = date.toInstant().getEpochSecond();
File file = new File(dir, "prices_" + format.format(date) + ".gz");
HashMap<String, Data> prices = new HashMap<>();
- if (file.exists())
- prices = load(file);
- if (prices == null) return;
+ if (file.exists()) {
+ HashMap<String, Data> tempPrices = load(file);
+ if (tempPrices != null) prices = tempPrices;
+ }
for (Map.Entry<String, JsonElement> item : items.entrySet()) {
if (prices.containsKey(item.getKey())) {
if (bazaar && item.getValue().getAsJsonObject().has("curr_buy") && item.getValue().getAsJsonObject().has(
@@ -493,7 +494,10 @@ public class GuiPriceGraph extends GuiScreen {
))
) {
return GSON.fromJson(reader, type);
- } catch (Exception ignored) {
+ } catch (Exception e) {
+ System.out.println("Deleting " + file.getName() + " because it is probably corrupted.");
+ //noinspection ResultOfMethodCallIgnored
+ file.delete();
}
}
return null;