diff --git a/src/main/java/net/knarcraft/stargate/config/ConfigOption.java b/src/main/java/net/knarcraft/stargate/config/ConfigOption.java index 9bd6bf9..4709a05 100644 --- a/src/main/java/net/knarcraft/stargate/config/ConfigOption.java +++ b/src/main/java/net/knarcraft/stargate/config/ConfigOption.java @@ -147,7 +147,12 @@ public enum ConfigOption { /** * Whether to enable debug output for debugging permissions */ - PERMISSION_DEBUG("debugging.permissionDebug", "Whether to enable permission debugging output", false); + PERMISSION_DEBUG("debugging.permissionDebug", "Whether to enable permission debugging output", false), + + /** + * Whether to alert admins about new updates + */ + ADMIN_UPDATE_ALERT("adminUpdateAlert", "Whether to alert admins about new plugin updates", true); private final String configNode; diff --git a/src/main/java/net/knarcraft/stargate/config/StargateConfig.java b/src/main/java/net/knarcraft/stargate/config/StargateConfig.java index 19ba95d..f5526d5 100644 --- a/src/main/java/net/knarcraft/stargate/config/StargateConfig.java +++ b/src/main/java/net/knarcraft/stargate/config/StargateConfig.java @@ -319,6 +319,15 @@ public final class StargateConfig { } } + /** + * Gets whether admins should be alerted about new plugin updates + * + * @return

Whether admins should be alerted about new updates

+ */ + public boolean alertAdminsAboutUpdates() { + return (boolean) configOptions.get(ConfigOption.ADMIN_UPDATE_ALERT); + } + /** * Loads all config values */ diff --git a/src/main/java/net/knarcraft/stargate/listener/PlayerEventListener.java b/src/main/java/net/knarcraft/stargate/listener/PlayerEventListener.java index 8ee954e..fdcef17 100644 --- a/src/main/java/net/knarcraft/stargate/listener/PlayerEventListener.java +++ b/src/main/java/net/knarcraft/stargate/listener/PlayerEventListener.java @@ -13,6 +13,7 @@ import net.knarcraft.stargate.utility.BungeeHelper; import net.knarcraft.stargate.utility.MaterialHelper; import net.knarcraft.stargate.utility.PermissionHelper; import net.knarcraft.stargate.utility.UUIDMigrationHelper; +import net.knarcraft.stargate.utility.UpdateChecker; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.block.Block; @@ -48,14 +49,22 @@ public class PlayerEventListener implements Listener { */ @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { + Player player = event.getPlayer(); //Migrate player name to UUID if necessary - UUIDMigrationHelper.migrateUUID(event.getPlayer()); + UUIDMigrationHelper.migrateUUID(player); + + //Notify joining admins about the available update + String availableUpdate = Stargate.getUpdateAvailable(); + if (availableUpdate != null && Stargate.getStargateConfig().alertAdminsAboutUpdates() && + player.hasPermission("stargate.admin")) { + String updateMessage = UpdateChecker.getUpdateAvailableString(availableUpdate, Stargate.getPluginVersion()); + Stargate.getMessageSender().sendErrorMessage(player, updateMessage); + } if (!Stargate.getGateConfig().enableBungee()) { return; } - Player player = event.getPlayer(); //Check if the player is waiting to be teleported to a stargate String destination = BungeeHelper.removeFromQueue(player.getUniqueId()); if (destination == null) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 4852940..474be7f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -18,6 +18,7 @@ # mainSignColor - The color used for drawing signs (Default: BLACK). # highlightSignColor - The color used for sign markings (Default: WHITE) # verifyPortals - Whether all the non-sign blocks are checked to match the gate layout when a stargate is loaded. +# adminUpdateAlert - Whether to alert admins about new plugin updates # I------------I-------------I # # stargate economy options # # I------------I-------------I # @@ -36,6 +37,7 @@ # permissionDebug - This will output any and all Permissions checks to console, used for permissions debugging (Requires debug: true) language: en +adminUpdateAlert: true folders: portalFolder: plugins/Stargate/portals/ gateFolder: plugins/Stargate/gates/