From 8fd26b513a2b9fd03f19e4a7a94a718dad39324e Mon Sep 17 00:00:00 2001 From: Paul Schulze Date: Sun, 24 Feb 2013 10:29:26 +0100 Subject: [PATCH] checkversion command --- .../craftinc/borderprotection/Commands.java | 23 +++++++++++++++++++ .../craftinc/borderprotection/Messages.java | 9 +++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/craftinc/borderprotection/Commands.java b/src/main/java/de/craftinc/borderprotection/Commands.java index ac4e7cf..90dda38 100644 --- a/src/main/java/de/craftinc/borderprotection/Commands.java +++ b/src/main/java/de/craftinc/borderprotection/Commands.java @@ -53,6 +53,29 @@ public class Commands implements CommandExecutor return true; } + // checkversion + if ( args.length > 0 && args[0].equalsIgnoreCase("checkversion") ) + { + if ( !sender.hasPermission("craftinc.borderprotection.update") ) + { + sender.sendMessage(Messages.noPermissionCheckversion); + return false; + } + + if ( UpdateHelper.newVersionAvailable() ) + { + sender.sendMessage( + Messages.updateMessage(UpdateHelper.cachedLatestVersion, UpdateHelper.getCurrentVersion())); + return true; + } + else + { + sender.sendMessage(Messages.noUpdateAvailable); + return true; + } + + } + // set if ( ( args.length == 2 || args.length == 3 ) && args[0].equalsIgnoreCase("set") ) { diff --git a/src/main/java/de/craftinc/borderprotection/Messages.java b/src/main/java/de/craftinc/borderprotection/Messages.java index 231c528..610ffdb 100644 --- a/src/main/java/de/craftinc/borderprotection/Messages.java +++ b/src/main/java/de/craftinc/borderprotection/Messages.java @@ -74,7 +74,8 @@ public class Messages makeCmd("on | off", "enables/disables the border of the current world") + makeCmd("set", "Border rectangle edges will be this far away from point of origin.", "") + makeCmd("set", "Border rectangle is defined by the two points. A point is specified as: x,z", - "", ""); + "", "") + + makeCmd("checkversion", "Checks for a newer version."); public static String borderCreationSuccessful = ChatColor.YELLOW + "New border was set " + @@ -107,6 +108,9 @@ public class Messages public static String noPermissionSet = ChatColor.RED + "Sorry, you don't have permission to change the border."; + public static String noPermissionCheckversion = + ChatColor.RED + "Sorry, you don't have permission to check for new versions."; + public static String borderEnabled = ChatColor.YELLOW + "Border enabled."; @@ -128,4 +132,7 @@ public class Messages ChatColor.AQUA + "http://dev.bukkit.org/server-mods/craftinc-borderprotection" + NEWLINE + ChatColor.YELLOW + "to get the latest version!"; } + + public static String noUpdateAvailable = + ChatColor.YELLOW + "No updates available."; }