From 24257e89a3a467c096212d4e39283cc2d50a292f Mon Sep 17 00:00:00 2001 From: SrJss <31166687+jonagamerpro1234@users.noreply.github.com> Date: Sun, 11 Jun 2023 21:03:37 -0400 Subject: [PATCH] added support for version 1.20 --- CustomJoinAndQuitMessagesOld/pom.xml | 8 ++--- .../customjoinandquitmessages/utils/Util.java | 4 +-- .../src/main/resources/groups.yml | 3 +- .../src/main/resources/plugin.yml | 2 +- bukkit/pom.xml | 9 ++++-- .../CustomJoinAndQuitMessage.java | 4 ++- .../commands/CommandHandler.java | 17 ++++++---- .../commands/subcommands/DisplayCommand.java | 10 +++--- .../commands/subcommands/HelpCommand.java | 7 ++-- .../commands/subcommands/InfoCommand.java | 6 ++-- .../commands/subcommands/ReloadCommand.java | 32 ++++++++++++++++--- .../commands/utils/SubCommand.java | 21 ------------ bukkit/src/main/resources/plugin.yml | 4 +++ 13 files changed, 74 insertions(+), 53 deletions(-) delete mode 100644 bukkit/src/main/java/jss/customjoinandquitmessage/commands/utils/SubCommand.java diff --git a/CustomJoinAndQuitMessagesOld/pom.xml b/CustomJoinAndQuitMessagesOld/pom.xml index 8a7ed90..568b100 100644 --- a/CustomJoinAndQuitMessagesOld/pom.xml +++ b/CustomJoinAndQuitMessagesOld/pom.xml @@ -9,7 +9,7 @@ CustomJoinAndQuitMessagesOld - 1.7.10-beta + 1.7.12-beta 8 @@ -144,13 +144,13 @@ org.spigotmc spigot-api - 1.19.3-R0.1-SNAPSHOT + 1.20-R0.1-SNAPSHOT provided org.bstats bstats-bukkit - 3.0.0 + 3.0.1 compile @@ -178,7 +178,7 @@ com.github.cryptomorin XSeries - 9.1.0 + 9.2.0 me.clip diff --git a/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/utils/Util.java b/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/utils/Util.java index d08bd20..3101eec 100644 --- a/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/utils/Util.java +++ b/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/utils/Util.java @@ -130,7 +130,7 @@ public static void setEnabled(String version) { sendEnable(prefix, "&5 <|| &c* &bThe plugin is &d[&aSuccessfully activated&d]"); sendEnable(prefix, "&5 <|| &c* &bVersion: &e[&a" + version + "&e]"); sendEnable(prefix, "&5 <|| &c* &bBy: &e[&bjonagamerpro1234&e]"); - sendEnable(prefix, "&5 <|| &c* &bTested Versions &3|&a1.8.x &3- &a1.19.x&3| &eComing Soon -> &c1.20"); + sendEnable(prefix, "&5 <|| &c* &bTested Versions &3|&a1.8 &3- &a1.20&3| &eComing Soon -> &c1.21"); sendEnable(prefix, "&5 <||============================================----"); } @@ -139,7 +139,7 @@ public static void setDisabled(String version) { sendEnable(prefix, "&5 <|| &c* &bThe plugin is &d[&cSuccessfully disabled&c]"); sendEnable(prefix, "&5 <|| &c* &bVersion: &e[&a" + version + "&e]"); sendEnable(prefix, "&5 <|| &c* &bBy: &e[&bjonagamerpro1234&e]"); - sendEnable(prefix, "&5 <|| &c* &bTested Versions &3|&a1.8.x &3- &a1.19.x&3| &eComing Soon -> &c1.20"); + sendEnable(prefix, "&5 <|| &c* &bTested Versions &3|&a1.8 &3- &a1.20&3| &eComing Soon -> &c1.21"); sendEnable(prefix, "&5 <|| &a* &eThanks for using CustomJoinAndQuitMessage &c<3"); sendEnable(prefix, "&5 <||============================================----"); } diff --git a/CustomJoinAndQuitMessagesOld/src/main/resources/groups.yml b/CustomJoinAndQuitMessagesOld/src/main/resources/groups.yml index 41f0c8e..e01a6ae 100644 --- a/CustomJoinAndQuitMessagesOld/src/main/resources/groups.yml +++ b/CustomJoinAndQuitMessagesOld/src/main/resources/groups.yml @@ -9,6 +9,7 @@ # ● For more information you can visit the CustomJoinAndQuitMessages Wiki # # ● Wiki [Working Progress]: --- +# ● Spigot: https://www.spigotmc.org/resources/custom-join-and-quit-message-1-8-1-19-4.57006/ # default: @@ -61,7 +62,7 @@ default: Command: '/say hello server' # |Url| Clicking on the chat opens a link - Url: 'https://www.spigotmc.org/resources/custom-join-and-quit-message-1-7-x-1-17-x.57006/' + Url: 'https://www.spigotmc.org/resources/custom-join-and-quit-message-1-8-1-19-4.57006/' # |Suggest-Command| Clicking on the chat suggests a command that you define in the config Suggest-Command: '/msg ' diff --git a/CustomJoinAndQuitMessagesOld/src/main/resources/plugin.yml b/CustomJoinAndQuitMessagesOld/src/main/resources/plugin.yml index 7508bea..0dd4a5a 100644 --- a/CustomJoinAndQuitMessagesOld/src/main/resources/plugin.yml +++ b/CustomJoinAndQuitMessagesOld/src/main/resources/plugin.yml @@ -4,7 +4,7 @@ version: "${version}" author: jonagamerpro1234 api-version: 1.13 prefix: CustomJoinAndQuitMessages -website: https://www.spigotmc.org/resources/custom-join-and-quit-message-1-8-x-1-19-x.57006/ +website: https://www.spigotmc.org/resources/custom-join-and-quit-message-1-8-1-19-4.57006/ loadbefore: [ Essentials ] softdepend: [ PlaceholderAPI, DiscordSRV, diff --git a/bukkit/pom.xml b/bukkit/pom.xml index de10995..b6fc149 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -82,13 +82,13 @@ org.spigotmc spigot-api - 1.16.5-R0.1-SNAPSHOT + 1.19.3-R0.1-SNAPSHOT provided org.jetbrains annotations - 23.0.0 + 24.0.1 compile @@ -103,5 +103,10 @@ 2.6 compile + + jss.commandapi + command-api + 0.0.3-alpha + diff --git a/bukkit/src/main/java/jss/customjoinandquitmessage/CustomJoinAndQuitMessage.java b/bukkit/src/main/java/jss/customjoinandquitmessage/CustomJoinAndQuitMessage.java index 82d6e8e..eb00247 100644 --- a/bukkit/src/main/java/jss/customjoinandquitmessage/CustomJoinAndQuitMessage.java +++ b/bukkit/src/main/java/jss/customjoinandquitmessage/CustomJoinAndQuitMessage.java @@ -46,7 +46,9 @@ public void onDisable() { } public void reloadAllFiles(){ - + reloadConfig(); + preConfigLoader.loadConfigs(); + preConfigLoader.loadLangs(); } private void registerListener(Listener @NotNull ...listeners){ diff --git a/bukkit/src/main/java/jss/customjoinandquitmessage/commands/CommandHandler.java b/bukkit/src/main/java/jss/customjoinandquitmessage/commands/CommandHandler.java index ae19f4c..2a0a856 100644 --- a/bukkit/src/main/java/jss/customjoinandquitmessage/commands/CommandHandler.java +++ b/bukkit/src/main/java/jss/customjoinandquitmessage/commands/CommandHandler.java @@ -1,10 +1,11 @@ package jss.customjoinandquitmessage.commands; +import jss.commandapi.SubCommand; import jss.customjoinandquitmessage.CustomJoinAndQuitMessage; +import jss.customjoinandquitmessage.commands.subcommands.DisplayCommand; import jss.customjoinandquitmessage.commands.subcommands.HelpCommand; import jss.customjoinandquitmessage.commands.subcommands.InfoCommand; import jss.customjoinandquitmessage.commands.subcommands.ReloadCommand; -import jss.customjoinandquitmessage.commands.utils.SubCommand; import jss.customjoinandquitmessage.files.utils.Settings; import jss.customjoinandquitmessage.utils.Utils; import org.bukkit.command.Command; @@ -29,13 +30,12 @@ public void register(){ pluginCommand.setExecutor(this); pluginCommand.setTabCompleter(this); - subCommands.addAll(Arrays.asList(new HelpCommand(), new ReloadCommand(), new InfoCommand())); + subCommands.addAll(Arrays.asList(new HelpCommand(), new ReloadCommand(), new InfoCommand(), new DisplayCommand())); } - @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String @NotNull [] args) { if(args.length >= 1){ - // execute subcommand + for(SubCommand s : getSubCommands()){ if (args[0].equalsIgnoreCase(s.name())){ if (s.isEnabled()){ @@ -45,7 +45,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N return true; } - if (s.requiresPermission() && !sender.hasPermission(s.permission())) { + if (!sender.isOp() || (s.requiresPermission() && !sender.hasPermission("cjm." + s.permission()))) { Utils.sendColorMessage(sender, Settings.lang_nopermission); return true; } @@ -67,7 +67,6 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N return true; } - @Override public List onTabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String alias, String @NotNull [] args) { List listOptions = new ArrayList<>(); String lastArgs = args.length != 0 ? args[args.length - 1] : ""; @@ -84,6 +83,12 @@ public List onTabComplete(@NotNull CommandSender sender, @NotNull Comman listOptions.add("help"); listOptions.add("reload"); break; + case 2: + if(args[0].equalsIgnoreCase("reload")){ + listOptions.add("config"); + listOptions.add("lang"); + } + break; } return Utils.setLimitTab(listOptions, lastArgs); diff --git a/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/DisplayCommand.java b/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/DisplayCommand.java index 3913a5e..634a8d0 100644 --- a/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/DisplayCommand.java +++ b/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/DisplayCommand.java @@ -1,6 +1,6 @@ package jss.customjoinandquitmessage.commands.subcommands; -import jss.customjoinandquitmessage.commands.utils.SubCommand; +import jss.commandapi.SubCommand; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -11,19 +11,19 @@ public String name() { return "display"; } - @Override public String permission() { - return null; + return "command.display"; } public boolean requiresPermission() { return true; } - public void onCommand(CommandSender sender, String[] args) { + public boolean onCommand(CommandSender sender, String[] args) { if(!(sender instanceof Player)){ } + return true; } public boolean allowConsole() { @@ -31,7 +31,7 @@ public boolean allowConsole() { } public boolean isEnabled() { - return false; + return true; } public String disabledMessage() { diff --git a/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/HelpCommand.java b/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/HelpCommand.java index e2598e6..9fdf55b 100644 --- a/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/HelpCommand.java +++ b/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/HelpCommand.java @@ -1,6 +1,6 @@ package jss.customjoinandquitmessage.commands.subcommands; -import jss.customjoinandquitmessage.commands.utils.SubCommand; +import jss.commandapi.SubCommand; import jss.customjoinandquitmessage.files.utils.Settings; import jss.customjoinandquitmessage.utils.Utils; import org.bukkit.command.CommandSender; @@ -11,7 +11,7 @@ public String name() { return "help"; } - public String permission(){ + public String permission() { return "command.help"; } @@ -19,10 +19,11 @@ public boolean requiresPermission() { return true; } - public void onCommand(CommandSender sender, String[] args) { + public boolean onCommand(CommandSender sender, String[] args) { for (String s : Settings.lang_helpCommand) { Utils.sendColorMessage(sender, s); } + return true; } public boolean allowConsole() { diff --git a/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/InfoCommand.java b/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/InfoCommand.java index cd5c50e..6d46459 100644 --- a/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/InfoCommand.java +++ b/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/InfoCommand.java @@ -1,6 +1,6 @@ package jss.customjoinandquitmessage.commands.subcommands; -import jss.customjoinandquitmessage.commands.utils.SubCommand; +import jss.commandapi.SubCommand; import jss.customjoinandquitmessage.files.utils.Settings; import org.bukkit.command.CommandSender; @@ -10,7 +10,6 @@ public String name() { return "info"; } - @Override public String permission() { return null; } @@ -19,8 +18,9 @@ public boolean requiresPermission() { return false; } - public void onCommand(CommandSender sender, String[] args) { + public boolean onCommand(CommandSender sender, String[] args) { + return true; } public boolean allowConsole() { diff --git a/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/ReloadCommand.java b/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/ReloadCommand.java index 3fe505c..200d5d7 100644 --- a/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/ReloadCommand.java +++ b/bukkit/src/main/java/jss/customjoinandquitmessage/commands/subcommands/ReloadCommand.java @@ -1,25 +1,49 @@ package jss.customjoinandquitmessage.commands.subcommands; -import jss.customjoinandquitmessage.commands.utils.SubCommand; +import jss.commandapi.SubCommand; +import jss.customjoinandquitmessage.CustomJoinAndQuitMessage; +import jss.customjoinandquitmessage.files.utils.Settings; +import jss.customjoinandquitmessage.utils.Utils; import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; public class ReloadCommand extends SubCommand { + private static final CustomJoinAndQuitMessage plugin = CustomJoinAndQuitMessage.get(); + public String name() { return "reload"; } - @Override public String permission() { - return null; + return "command.reload"; } public boolean requiresPermission() { return true; } - public void onCommand(CommandSender sender, String[] args) { + public boolean onCommand(CommandSender sender, String @NotNull [] args) { + if (args.length >= 1){ + + if(args[0].equalsIgnoreCase("config")){ + + Utils.sendColorMessage(sender, Settings.lang_reloadCommand); + return true; + } + if (args[0].equalsIgnoreCase("lang")){ + + Utils.sendColorMessage(sender, Settings.lang_reloadCommand); + return true; + } + Utils.sendColorMessage(sender, Settings.lang_unknownArguments); + return true; + } + + plugin.reloadAllFiles(); + Utils.sendColorMessage(sender, Settings.lang_reloadCommand); + return true; } public boolean allowConsole() { diff --git a/bukkit/src/main/java/jss/customjoinandquitmessage/commands/utils/SubCommand.java b/bukkit/src/main/java/jss/customjoinandquitmessage/commands/utils/SubCommand.java deleted file mode 100644 index f2af8cd..0000000 --- a/bukkit/src/main/java/jss/customjoinandquitmessage/commands/utils/SubCommand.java +++ /dev/null @@ -1,21 +0,0 @@ -package jss.customjoinandquitmessage.commands.utils; - -import org.bukkit.command.CommandSender; - -public abstract class SubCommand { - - public abstract String name(); - - public abstract String permission(); - - public abstract boolean requiresPermission(); - - public abstract void onCommand(CommandSender sender, String[] args); - - public abstract boolean allowConsole(); - - public abstract boolean isEnabled(); - - public abstract String disabledMessage(); - -} diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 17b3e40..08b48f1 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -24,6 +24,7 @@ permissions: cjm.update: true cjm.command.reload: true cjm.command.help: true + cjm.command.display: true cjm.command.tabcomplete: true default: op cjm.update: @@ -38,3 +39,6 @@ permissions: cjm.command.tabcomplete: description: allows you to see the list of available commands default: op + cjm.command.display: + description: ---- + default: op