Improve update system and info

This commit is contained in:
libraryaddict 2020-04-27 17:03:11 +12:00
parent 7090ea51cc
commit 5b5cdd0395
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4
4 changed files with 67 additions and 27 deletions

@ -23,6 +23,7 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
getCommands().add(new LDHelp(this));
getCommands().add(new LDReload());
getCommands().add(new LDUpdate());
getCommands().add(new LDChangelog());
getCommands().add(new LDCount());
getCommands().add(new LDConfig());
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 check
// 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
@ -31,25 +31,6 @@ public class LDUpdate implements LDCommand {
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
public void onCommand(CommandSender sender, String[] args) {
UpdateChecker checker = LibsDisguises.getInstance().getUpdateChecker();
@ -59,11 +40,6 @@ public class LDUpdate implements LDCommand {
return;
}
if (args[0].equalsIgnoreCase("changelog")) {
doChangelog(sender);
return;
}
boolean releaseBuilds = checker.isUsingReleaseBuilds();
if (args.length > 1) {

@ -313,7 +313,10 @@ public enum LibsMsg {
LD_COMMAND_CONFIG(ChatColor.BLUE + "/libsdisguises config - " + ChatColor.AQUA +
"Tells you what's not normal in your config"),
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 +
"Turns the current held item into a string format"),
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 +
"Used to help debug scoreboard issues on a player disguise");
private String string;
private final String string;
LibsMsg(String string) {
this.string = string;