From 0edf4ecfae15aea960edb1ca8c3c10b26a833518 Mon Sep 17 00:00:00 2001 From: Prototik Date: Sun, 31 May 2015 20:25:54 +0700 Subject: [PATCH] some tweaks for updater --- src/main/java/kcauldron/updater/DefaultUpdateCallback.java | 2 ++ src/main/java/kcauldron/updater/KCauldronUpdater.java | 7 +++++++ src/main/java/kcauldron/updater/KVersionRetriever.java | 6 ++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/kcauldron/updater/DefaultUpdateCallback.java b/src/main/java/kcauldron/updater/DefaultUpdateCallback.java index eaeb57c..485f989 100644 --- a/src/main/java/kcauldron/updater/DefaultUpdateCallback.java +++ b/src/main/java/kcauldron/updater/DefaultUpdateCallback.java @@ -52,6 +52,8 @@ public class DefaultUpdateCallback implements IVersionCheckCallback { mCurrentVersion = currentVersion; mNewVersion = newVersion; if (!mHasUpdate) { + Bukkit.getConsoleSender().sendMessage( + "New version of KCauldron avaiable: " + newVersion); for (Player player : Bukkit.getOnlinePlayers()) { if (hasPermission(player)) { sendUpdate(player); diff --git a/src/main/java/kcauldron/updater/KCauldronUpdater.java b/src/main/java/kcauldron/updater/KCauldronUpdater.java index d97e65d..d8b5186 100644 --- a/src/main/java/kcauldron/updater/KCauldronUpdater.java +++ b/src/main/java/kcauldron/updater/KCauldronUpdater.java @@ -31,12 +31,19 @@ public class KCauldronUpdater implements Runnable { @Override public void upToDate(String version) { + KCauldron.sUpdateInProgress = false; CommandSender sender = getSender(); if (sender != null) { sender.sendMessage(ChatColor.DARK_PURPLE + "Current version (" + version + ") is up to date"); } } + + @Override + public void error(Throwable t) { + super.error(t); + KCauldron.sUpdateInProgress = false; + } } public static void initUpdate(CommandSender sender, String version) { diff --git a/src/main/java/kcauldron/updater/KVersionRetriever.java b/src/main/java/kcauldron/updater/KVersionRetriever.java index e40696f..c0b98d4 100644 --- a/src/main/java/kcauldron/updater/KVersionRetriever.java +++ b/src/main/java/kcauldron/updater/KVersionRetriever.java @@ -81,8 +81,10 @@ public class KVersionRetriever implements Runnable, UncaughtExceptionHandler { JSONObject json = (JSONObject) sParser.parse(new InputStreamReader( response.getEntity().getContent())); String version = (String) json.get("version"); - sLogger.info("Got the latest version: %s", version); - sLogger.info("Current version is %s", sCurrentVersion); + if (DEBUG) { + sLogger.info("Got the latest version: %s", version); + sLogger.info("Current version is %s", sCurrentVersion); + } if (!sCurrentVersion.equals(version)) { mCallback.newVersion(sCurrentVersion, version); } else {