diff --git a/core/src/main/java/com/boydti/fawe/Fawe.java b/core/src/main/java/com/boydti/fawe/Fawe.java index 87dd2cc1..9d86de7c 100644 --- a/core/src/main/java/com/boydti/fawe/Fawe.java +++ b/core/src/main/java/com/boydti/fawe/Fawe.java @@ -275,10 +275,10 @@ public class Fawe { if (Settings.IMP.UPDATE && isJava8()) { // Delayed updating + updater = new Updater(); TaskManager.IMP.repeatAsync(new Runnable() { @Override public void run() { - updater = new Updater(); updater.update(IMP.getPlatform(), getVersion()); } }, 36000); diff --git a/core/src/main/java/com/boydti/fawe/util/Updater.java b/core/src/main/java/com/boydti/fawe/util/Updater.java index e97c6d1a..8077bb81 100644 --- a/core/src/main/java/com/boydti/fawe/util/Updater.java +++ b/core/src/main/java/com/boydti/fawe/util/Updater.java @@ -12,9 +12,14 @@ import java.util.Scanner; public class Updater { private FaweVersion newVersion; - private String changes = "N/A"; + private String changes; public String getChanges() throws IOException { + if (changes == null) { + try (Scanner scanner = new Scanner(new URL("http://boydti.com/fawe/cl?" + Integer.toHexString(Fawe.get().getVersion().hash)).openStream(), "UTF-8")) { + changes = scanner.useDelimiter("\\A").next(); + } + } return changes; } @@ -29,7 +34,7 @@ public class Updater { try (Scanner reader = new Scanner(url.openStream())) { String versionString = reader.next(); FaweVersion version = new FaweVersion(versionString); - if (currentVersion == null || version.isNewer(newVersion != null ? newVersion : currentVersion)) { + if (version.isNewer(newVersion != null ? newVersion : currentVersion)) { newVersion = version; URL download = new URL(downloadUrl.replaceAll("%platform%", platform).replaceAll("%version%", versionString)); try (ReadableByteChannel rbc = Channels.newChannel(download.openStream())) { @@ -48,12 +53,10 @@ public class Updater { fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); } Fawe.debug("Updated FAWE to " + versionString); - Scanner scanner = new Scanner(new URL("http://boydti.com/fawe/cl?" + Integer.toHexString(Fawe.get().getVersion().hash)).openStream(), "UTF-8"); - changes = scanner.useDelimiter("\\A").next(); - scanner.close(); MainUtil.sendAdmin("&7Restart to update FAWE with these changes: &c/fawe changelog &7or&c " + "http://boydti.com/fawe/cl?" + Integer.toHexString(currentVersion.hash)); - } + } else { + System.out.println("Not newer"); } } } catch (Throwable ignore) {}