From 47efdd4f84cc9a29738fe16d631eb33ee716db61 Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Sun, 27 Mar 2022 19:12:44 +0200 Subject: 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. --- .../notenoughupdates/miscgui/GuiPriceGraph.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java') 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 prices = new HashMap<>(); - if (file.exists()) - prices = load(file); - if (prices == null) return; + if (file.exists()) { + HashMap tempPrices = load(file); + if (tempPrices != null) prices = tempPrices; + } for (Map.Entry 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; -- cgit