diff --git a/src/main/java/com/shweit/serverapi/commands/version/VersionCommand.java b/src/main/java/com/shweit/serverapi/commands/version/VersionCommand.java index 8432bb1..e0701bd 100644 --- a/src/main/java/com/shweit/serverapi/commands/version/VersionCommand.java +++ b/src/main/java/com/shweit/serverapi/commands/version/VersionCommand.java @@ -2,6 +2,7 @@ import com.shweit.serverapi.MinecraftServerAPI; import com.shweit.serverapi.commands.SubCommand; +import com.shweit.serverapi.utils.CheckForUpdate; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -27,6 +28,20 @@ public String getSyntax() { @Override public void perform(final CommandSender commandSender, final Command command, final String label, final String[] args) { commandSender.sendMessage(ChatColor.GREEN + "MinecraftServerAPI version: " + ChatColor.GOLD + MinecraftServerAPI.getInstance().getDescription().getVersion()); + commandSender.sendMessage(""); + commandSender.sendMessage(ChatColor.GREEN + "Check for updates..."); + + // Check for updates + CheckForUpdate checkForUpdate = new CheckForUpdate(); + boolean updateAvailable = checkForUpdate.checkForPluginUpdate(); + if (updateAvailable) { + commandSender.sendMessage(ChatColor.GREEN + "Update available! New Version: " + + ChatColor.GOLD + MinecraftServerAPI.getInstance().getDescription().getVersion() + + ChatColor.GREEN + " -> " + ChatColor.GOLD + checkForUpdate.latestVersion + ); + } else { + commandSender.sendMessage(ChatColor.GREEN + "No updates available."); + } } @Override diff --git a/src/main/java/com/shweit/serverapi/utils/CheckForUpdate.java b/src/main/java/com/shweit/serverapi/utils/CheckForUpdate.java index 1e6fe75..7cab2df 100644 --- a/src/main/java/com/shweit/serverapi/utils/CheckForUpdate.java +++ b/src/main/java/com/shweit/serverapi/utils/CheckForUpdate.java @@ -16,7 +16,7 @@ public final class CheckForUpdate implements Listener { private static final String GITHUB_API_URL = "https://api.github.com/repos/Shweit/MinecraftServerAPI/releases/latest"; private static final String USER_AGENT = "Mozilla/5.0"; - private String latestVersion; + public String latestVersion; public boolean checkForPluginUpdate() { latestVersion = fetchLatestVersion();