From 81fb353be88bc99c27e5933c982e6f8b84a192b0 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Tue, 18 Jun 2024 13:42:57 +0200 Subject: [PATCH] so I can't do it conveniently --- release.properties | 2 +- .../java/eu/m724/realweather/RealWeatherPlugin.java | 3 +-- .../eu/m724/realweather/commands/AdminCommand.java | 12 +++++++++++- .../eu/m724/realweather/commands/UpdateCommand.java | 8 ++++++-- src/main/resources/plugin.yml | 4 ---- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/release.properties b/release.properties index 7a9fbfb..a595cec 100644 --- a/release.properties +++ b/release.properties @@ -1,5 +1,5 @@ #release configuration -#Tue Jun 18 13:28:07 CEST 2024 +#Tue Jun 18 13:42:52 CEST 2024 completedPhase=check-poms exec.pomFileName=pom.xml exec.snapshotReleasePluginAllowed=false diff --git a/src/main/java/eu/m724/realweather/RealWeatherPlugin.java b/src/main/java/eu/m724/realweather/RealWeatherPlugin.java index 317e947..c85eab7 100644 --- a/src/main/java/eu/m724/realweather/RealWeatherPlugin.java +++ b/src/main/java/eu/m724/realweather/RealWeatherPlugin.java @@ -138,8 +138,7 @@ public class RealWeatherPlugin extends JavaPlugin { GlobalConstants.thunderMaster = thunderMaster; - getCommand("rwadmin").setExecutor(new AdminCommand()); - getCommand("rwadmin update").setExecutor(new UpdateCommand(updater)); + getCommand("rwadmin").setExecutor(new AdminCommand(updater)); getCommand("geo").setExecutor(new GeoCommand()); if (GlobalConstants.timeConfig.enabled) diff --git a/src/main/java/eu/m724/realweather/commands/AdminCommand.java b/src/main/java/eu/m724/realweather/commands/AdminCommand.java index 59a3ad3..1904cfe 100644 --- a/src/main/java/eu/m724/realweather/commands/AdminCommand.java +++ b/src/main/java/eu/m724/realweather/commands/AdminCommand.java @@ -12,6 +12,7 @@ import eu.m724.realweather.mapper.MapperConfig; import eu.m724.realweather.thunder.ThunderConfig; import eu.m724.realweather.thunder.ThunderMaster; import eu.m724.realweather.time.TimeConfig; +import eu.m724.realweather.updater.Updater; import eu.m724.realweather.weather.WeatherConfig; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.BaseComponent; @@ -19,6 +20,7 @@ import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.TextComponent; public class AdminCommand implements CommandExecutor { + private UpdateCommand updateCommand; private Plugin plugin = GlobalConstants.getPlugin(); private WeatherConfig weatherConfig = GlobalConstants.getWeatherConfig(); @@ -31,9 +33,17 @@ public class AdminCommand implements CommandExecutor { private BaseComponent enabledComponent = TextComponent.fromLegacy("YES\n", ChatColor.GREEN); private BaseComponent disabledComponent = TextComponent.fromLegacy("NO\n", ChatColor.RED); + public AdminCommand(Updater updater) { + this.updateCommand = new UpdateCommand(updater); + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - + + if (args.length > 0 && args[0].equals("update")) { + return updateCommand.onCommand(sender, command, label, args); + } + ComponentBuilder componentBuilder = new ComponentBuilder("\nRealWeather " + plugin.getDescription().getVersion() + "\n\n") .color(ChatColor.YELLOW); diff --git a/src/main/java/eu/m724/realweather/commands/UpdateCommand.java b/src/main/java/eu/m724/realweather/commands/UpdateCommand.java index bc16fc8..bc5f1b8 100644 --- a/src/main/java/eu/m724/realweather/commands/UpdateCommand.java +++ b/src/main/java/eu/m724/realweather/commands/UpdateCommand.java @@ -9,15 +9,19 @@ import org.bukkit.command.CommandSender; import eu.m724.realweather.updater.Updater; import eu.m724.realweather.updater.metadata.VersionMetadata; -public class UpdateCommand implements CommandExecutor { +/** + * not actually a command but deserves a separate file + */ +public class UpdateCommand { private Updater updater; public UpdateCommand(Updater updater) { this.updater = updater; } - @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!sender.hasPermission("realweather.admin.update")) return false; + sender.sendMessage("Please wait"); CompletableFuture latestFuture = updater.getLatestVersion(); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index efad6c8..53bbe08 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -16,10 +16,6 @@ commands: description: RealWeather admin command permission: realweather.admin permission-message: You do not have permission to use this command. - rwadmin update: - description: Update RealWeather - permission: realweather.admin.update - permission-message: You do not have permission to use this command. geo: description: Convert lat,lon to x,y,z and vice versa