From cfeaf3cf8d218c59bd85e9a2d59f863c56ae8be2 Mon Sep 17 00:00:00 2001 From: Eric Date: Sat, 25 Aug 2018 23:45:56 +0200 Subject: [PATCH] Allow update checker to be disabled (Only automatic update check on start; command is not affected) Fixes #208 --- src/main/java/de/epiceric/shopchest/ShopChest.java | 4 ++++ src/main/java/de/epiceric/shopchest/config/Config.java | 7 ++++--- .../shopchest/listeners/NotifyPlayerOnJoinListener.java | 3 ++- src/main/resources/config.yml | 6 ++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/ShopChest.java b/src/main/java/de/epiceric/shopchest/ShopChest.java index b63a43c..74b0e66 100644 --- a/src/main/java/de/epiceric/shopchest/ShopChest.java +++ b/src/main/java/de/epiceric/shopchest/ShopChest.java @@ -333,6 +333,10 @@ public class ShopChest extends JavaPlugin { } private void checkForUpdates() { + if (!Config.enableUpdateChecker) { + return; + } + new BukkitRunnable() { @Override public void run() { diff --git a/src/main/java/de/epiceric/shopchest/config/Config.java b/src/main/java/de/epiceric/shopchest/config/Config.java index a65694f..2a3174a 100644 --- a/src/main/java/de/epiceric/shopchest/config/Config.java +++ b/src/main/java/de/epiceric/shopchest/config/Config.java @@ -142,9 +142,10 @@ public class Config { public static boolean confirmShopping; /** - * Whether quality mode should be enabled + *

Whether the update checker should run on start and notify players on join.

+ * The command is not affected by this setting and will continue to check for updates. **/ - public static boolean enableQualityMode; + public static boolean enableUpdateChecker; /** * Whether hologram interaction should be enabled @@ -479,7 +480,7 @@ public class Config { hopperProtection = plugin.getConfig().getBoolean("hopper-protection"); explosionProtection = plugin.getConfig().getBoolean("explosion-protection"); confirmShopping = plugin.getConfig().getBoolean("confirm-shopping"); - enableQualityMode = plugin.getConfig().getBoolean("enable-quality-mode"); + enableUpdateChecker = plugin.getConfig().getBoolean("enable-update-checker"); enableHologramInteraction = plugin.getConfig().getBoolean("enable-hologram-interaction"); enableDebugLog = plugin.getConfig().getBoolean("enable-debug-log"); enableEconomyLog = plugin.getConfig().getBoolean("enable-economy-log"); diff --git a/src/main/java/de/epiceric/shopchest/listeners/NotifyPlayerOnJoinListener.java b/src/main/java/de/epiceric/shopchest/listeners/NotifyPlayerOnJoinListener.java index 7b5fcbe..9ba709a 100644 --- a/src/main/java/de/epiceric/shopchest/listeners/NotifyPlayerOnJoinListener.java +++ b/src/main/java/de/epiceric/shopchest/listeners/NotifyPlayerOnJoinListener.java @@ -7,6 +7,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import de.epiceric.shopchest.ShopChest; +import de.epiceric.shopchest.config.Config; import de.epiceric.shopchest.config.Placeholder; import de.epiceric.shopchest.language.LanguageUtils; import de.epiceric.shopchest.language.Message; @@ -27,7 +28,7 @@ public class NotifyPlayerOnJoinListener implements Listener { public void onPlayerJoin(PlayerJoinEvent e) { final Player p = e.getPlayer(); - if (plugin.isUpdateNeeded()) { + if (plugin.isUpdateNeeded() && Config.enableUpdateChecker) { if (p.hasPermission(Permissions.UPDATE_NOTIFICATION)) { Utils.sendUpdateMessage(plugin, p); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2ddca6c..b871a2b 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -24,6 +24,12 @@ shop-info-item: "STICK" # in order to prevent accidental purchases or sells. confirm-shopping: false +# Set whether the plugin will check for updates on server start +# and notify permitted players on join. +# The command is not affected by this setting and will continue to +# check for updates. +enable-update-checker: true + # Set whether interaction with the hologram should be enabled. # If set to true, a player can do the exact same thing with the # hologram, as with the chest. You can even open the chest if you