Improve update system and info
This commit is contained in:
		| @@ -23,6 +23,7 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { | |||||||
|         getCommands().add(new LDHelp(this)); |         getCommands().add(new LDHelp(this)); | ||||||
|         getCommands().add(new LDReload()); |         getCommands().add(new LDReload()); | ||||||
|         getCommands().add(new LDUpdate()); |         getCommands().add(new LDUpdate()); | ||||||
|  |         getCommands().add(new LDChangelog()); | ||||||
|         getCommands().add(new LDCount()); |         getCommands().add(new LDCount()); | ||||||
|         getCommands().add(new LDConfig()); |         getCommands().add(new LDConfig()); | ||||||
|         getCommands().add(new LDPermTest()); |         getCommands().add(new LDPermTest()); | ||||||
|   | |||||||
| @@ -0,0 +1,60 @@ | |||||||
|  | package me.libraryaddict.disguise.commands.libsdisguises; | ||||||
|  |  | ||||||
|  | import me.libraryaddict.disguise.LibsDisguises; | ||||||
|  | import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||||
|  | import me.libraryaddict.disguise.utilities.updates.UpdateChecker; | ||||||
|  | import org.bukkit.ChatColor; | ||||||
|  | import org.bukkit.command.CommandSender; | ||||||
|  |  | ||||||
|  | import java.util.Collections; | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Created by libraryaddict on 27/04/2020. | ||||||
|  |  */ | ||||||
|  | public class LDChangelog implements LDCommand { | ||||||
|  |     @Override | ||||||
|  |     public List<String> getTabComplete() { | ||||||
|  |         return Collections.singletonList("changelog"); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public boolean hasPermission(CommandSender sender) { | ||||||
|  |         return sender.hasPermission(getPermission()); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public String getPermission() { | ||||||
|  |         return "libsdisguises.update"; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public void onCommand(CommandSender sender, String[] args) { | ||||||
|  |         UpdateChecker checker = LibsDisguises.getInstance().getUpdateChecker(); | ||||||
|  |  | ||||||
|  |         if (checker.isDownloading()) { | ||||||
|  |             sender.sendMessage(LibsMsg.UPDATE_IN_PROGRESS.get()); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if (checker.getUpdate() == null) { | ||||||
|  |             sender.sendMessage(LibsMsg.UPDATE_REQUIRED.get()); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if (!checker.getUpdate().isReleaseBuild()) { | ||||||
|  |             sender.sendMessage( | ||||||
|  |                     ChatColor.GOLD + "You are on build " + (LibsDisguises.getInstance().isNumberedBuild() ? "#" : "") + | ||||||
|  |                             LibsDisguises.getInstance().getBuildNo()); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         for (String msg : checker.getUpdate().getChangelog()) { | ||||||
|  |             sender.sendMessage(ChatColor.GOLD + msg); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public LibsMsg getHelp() { | ||||||
|  |         return LibsMsg.LD_COMMAND_CHANGELOG; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -23,7 +23,7 @@ public class LDUpdate implements LDCommand { | |||||||
|         // Update by download |         // Update by download | ||||||
|         // Update check |         // Update check | ||||||
|         // Update to latest dev build |         // Update to latest dev build | ||||||
|         return Arrays.asList("update", "update dev", "update release", "changelog", "update!"); |         return Arrays.asList("update", "update dev", "update release", "update!"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -31,25 +31,6 @@ public class LDUpdate implements LDCommand { | |||||||
|         return "libsdisguises.update"; |         return "libsdisguises.update"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void doChangelog(CommandSender sender) { |  | ||||||
|         UpdateChecker checker = LibsDisguises.getInstance().getUpdateChecker(); |  | ||||||
|  |  | ||||||
|         if (checker.getUpdate() == null) { |  | ||||||
|             sender.sendMessage(LibsMsg.UPDATE_REQUIRED.get()); |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         if (!checker.getUpdate().isReleaseBuild()) { |  | ||||||
|             sender.sendMessage( |  | ||||||
|                     ChatColor.GOLD + "You are on build " + (LibsDisguises.getInstance().isNumberedBuild() ? "#" : "") + |  | ||||||
|                             LibsDisguises.getInstance().getBuildNo()); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         for (String msg : checker.getUpdate().getChangelog()) { |  | ||||||
|             sender.sendMessage(ChatColor.GOLD + msg); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onCommand(CommandSender sender, String[] args) { |     public void onCommand(CommandSender sender, String[] args) { | ||||||
|         UpdateChecker checker = LibsDisguises.getInstance().getUpdateChecker(); |         UpdateChecker checker = LibsDisguises.getInstance().getUpdateChecker(); | ||||||
| @@ -59,11 +40,6 @@ public class LDUpdate implements LDCommand { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (args[0].equalsIgnoreCase("changelog")) { |  | ||||||
|             doChangelog(sender); |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         boolean releaseBuilds = checker.isUsingReleaseBuilds(); |         boolean releaseBuilds = checker.isUsingReleaseBuilds(); | ||||||
|  |  | ||||||
|         if (args.length > 1) { |         if (args.length > 1) { | ||||||
|   | |||||||
| @@ -313,7 +313,10 @@ public enum LibsMsg { | |||||||
|     LD_COMMAND_CONFIG(ChatColor.BLUE + "/libsdisguises config - " + ChatColor.AQUA + |     LD_COMMAND_CONFIG(ChatColor.BLUE + "/libsdisguises config - " + ChatColor.AQUA + | ||||||
|             "Tells you what's not normal in your config"), |             "Tells you what's not normal in your config"), | ||||||
|     LD_COMMAND_UPDATE(ChatColor.BLUE + "/libsdisguises update - " + ChatColor.AQUA + |     LD_COMMAND_UPDATE(ChatColor.BLUE + "/libsdisguises update - " + ChatColor.AQUA + | ||||||
|             "Update's the plugin, doing 'update!' will force an update. Server must be restarted to install update."), |             "'update' will fetch an update, 'update dev' will fetch a dev build update, 'update release' will fetch a" + | ||||||
|  |             " release build update and 'update!' will download that update!"), | ||||||
|  |     LD_COMMAND_CHANGELOG(ChatColor.BLUE + "/libsdisguises changelog - " + ChatColor.AQUA + | ||||||
|  |             "Gives you the changelog of the current update fetched"), | ||||||
|     LD_COMMAND_JSON(ChatColor.BLUE + "/libsdisguises json - " + ChatColor.AQUA + |     LD_COMMAND_JSON(ChatColor.BLUE + "/libsdisguises json - " + ChatColor.AQUA + | ||||||
|             "Turns the current held item into a string format"), |             "Turns the current held item into a string format"), | ||||||
|     LD_COMMAND_MODS(ChatColor.BLUE + "/libsdisguises mods <Player?> - " + ChatColor.AQUA + |     LD_COMMAND_MODS(ChatColor.BLUE + "/libsdisguises mods <Player?> - " + ChatColor.AQUA + | ||||||
| @@ -327,7 +330,7 @@ public enum LibsMsg { | |||||||
|     LD_COMMAND_DEBUG(ChatColor.BLUE + "/libsdisguises debug - " + ChatColor.AQUA + |     LD_COMMAND_DEBUG(ChatColor.BLUE + "/libsdisguises debug - " + ChatColor.AQUA + | ||||||
|             "Used to help debug scoreboard issues on a player disguise"); |             "Used to help debug scoreboard issues on a player disguise"); | ||||||
|  |  | ||||||
|     private String string; |     private final String string; | ||||||
|  |  | ||||||
|     LibsMsg(String string) { |     LibsMsg(String string) { | ||||||
|         this.string = string; |         this.string = string; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user