From 278c6f966cd91e9fef345901a0ac68e1a0a6c5b3 Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Sat, 20 Oct 2018 12:51:40 +0800 Subject: [PATCH] updater Former-commit-id: 3a7857930b7cf700b58a36e5f9c3c56697c63c1a --- .../org/maxgamer/quickshop/QuickShop.java | 63 ++++++------------- .../org/maxgamer/quickshop/Util/Updater.java | 39 ++++++++++++ .../quickshop/Watcher/UpdateWatcher.java | 51 +++++++++++++++ src/main/resources/config.yml | 5 +- 4 files changed, 114 insertions(+), 44 deletions(-) create mode 100644 src/main/java/org/maxgamer/quickshop/Util/Updater.java create mode 100644 src/main/java/org/maxgamer/quickshop/Watcher/UpdateWatcher.java diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java index aaf72e19c..4584f8328 100644 --- a/src/main/java/org/maxgamer/quickshop/QuickShop.java +++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java @@ -62,11 +62,14 @@ import org.maxgamer.quickshop.Shop.ShopType; import org.maxgamer.quickshop.Util.MsgUtil; //import org.maxgamer.quickshop.Util.NMS; import org.maxgamer.quickshop.Util.Permissions; +import org.maxgamer.quickshop.Util.Updater; import org.maxgamer.quickshop.Util.Util; import org.maxgamer.quickshop.Watcher.ItemWatcher; import org.maxgamer.quickshop.Watcher.LogWatcher; +import org.maxgamer.quickshop.Watcher.UpdateWatcher; import com.onarandombox.MultiverseCore.MultiverseCore; +import com.sun.deploy.uitoolkit.impl.fx.Utils; @@ -202,7 +205,7 @@ public class QuickShop extends JavaPlugin { LockListener ll = new LockListener(this); getServer().getPluginManager().registerEvents(ll, this); } - + getServer().getPluginManager().registerEvents(new UpdateWatcher(), this); // ConfigurationSection cPotionSection = this.getConfig().getConfigurationSection("custom-potions-name"); // if (cPotionSection!=null) { // CustomPotionsName.setSignFormat(new String[]{cPotionSection.getString("sign.format"), cPotionSection.getString("sign.variety.normal"), cPotionSection.getString("sign.variety.splash"), cPotionSection.getString("sign.variety.lingering")}); @@ -665,14 +668,9 @@ public class QuickShop extends JavaPlugin { } else { getLogger().info("You have disabled mertics, Skipping..."); } - getLogger().info("Async checking for updates..."); - new BukkitRunnable() { - - @Override - public void run() { - checkUpdate("59134"); - } - }.runTaskTimerAsynchronously(this, 1, 1000 * 60 * 30); + + UpdateWatcher.init(); + } public String boolean2String(boolean bool) { if(bool) { @@ -682,28 +680,20 @@ public class QuickShop extends JavaPlugin { } } public boolean updateConfig(int oldConfigVersion, int currentConfigVersion) { - // TODO Auto-generated method stub - while (currentConfigVersion-oldConfigVersion!=0 && oldConfigVersion