From 68011f43cd9b4cb341d5cf18251fb1fdbde51db5 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Fri, 21 Oct 2016 03:51:27 +1100 Subject: [PATCH] Fixes #1390 --- .../plot/util/HastebinUtility.java | 17 +++++++++-------- .../plot/util/expiry/ExpireManager.java | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/HastebinUtility.java b/Core/src/main/java/com/intellectualcrafters/plot/util/HastebinUtility.java index 8acddb621..71e605598 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/HastebinUtility.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/HastebinUtility.java @@ -1,13 +1,10 @@ package com.intellectualcrafters.plot.util; -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStreamReader; +import java.io.*; import java.net.HttpURLConnection; import java.net.URL; +import java.util.ArrayList; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -49,13 +46,17 @@ public class HastebinUtility { public static String upload(final File file) throws IOException { final StringBuilder content = new StringBuilder(); + List lines = new ArrayList<>(); try (BufferedReader reader = new BufferedReader(new FileReader(file))) { String line; int i = 0; - while ((line = reader.readLine()) != null && i++ < 1000) { - content.append(line).append("\n"); + while ((line = reader.readLine()) != null) { + lines.add(line); } } + for (int i = Math.max(0, lines.size() - 1000); i < lines.size(); i++) { + content.append(lines.get(i)).append("\n"); + } return upload(content.toString()); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java b/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java index 08ba065b9..22349a858 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java @@ -52,7 +52,7 @@ public class ExpireManager { public void handleJoin(PlotPlayer pp) { storeDate(pp.getUUID(), System.currentTimeMillis()); - if (!plotsToDelete.isEmpty()) { + if (plotsToDelete != null && !plotsToDelete.isEmpty()) { for (Plot plot : pp.getPlots()) { plotsToDelete.remove(plot); } @@ -77,7 +77,7 @@ public class ExpireManager { } public void updateExpired(Plot plot) { - if (!plotsToDelete.isEmpty() && plotsToDelete.contains(plot)) { + if (plotsToDelete != null && !plotsToDelete.isEmpty() && plotsToDelete.contains(plot)) { if (isExpired(new ArrayDeque<>(tasks), plot).isEmpty()) { plotsToDelete.remove(plot); }