From e39f882ea7b480cab4d0beb2b0e90162879039b6 Mon Sep 17 00:00:00 2001 From: Focusvity Date: Wed, 8 Mar 2023 21:46:27 +1100 Subject: [PATCH] Fix out of bounds exception - closes #54 --- .../java/dev/plex/command/impl/DebugCMD.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/server/src/main/java/dev/plex/command/impl/DebugCMD.java b/server/src/main/java/dev/plex/command/impl/DebugCMD.java index c6fced9..fbdbc72 100644 --- a/server/src/main/java/dev/plex/command/impl/DebugCMD.java +++ b/server/src/main/java/dev/plex/command/impl/DebugCMD.java @@ -36,13 +36,16 @@ public class DebugCMD extends PlexCommand } if (args[0].equalsIgnoreCase("redis-reset")) { - Player player = getNonNullPlayer(args[1]); - if (plugin.getRedisConnection().getJedis().exists(player.getUniqueId().toString())) + if (args.length == 2) { - plugin.getRedisConnection().getJedis().del(player.getUniqueId().toString()); - return componentFromString("Successfully reset " + player.getName() + "'s Redis punishments!").color(NamedTextColor.YELLOW); + Player player = getNonNullPlayer(args[1]); + if (plugin.getRedisConnection().getJedis().exists(player.getUniqueId().toString())) + { + plugin.getRedisConnection().getJedis().del(player.getUniqueId().toString()); + return componentFromString("Successfully reset " + player.getName() + "'s Redis punishments!").color(NamedTextColor.YELLOW); + } + return componentFromString("Couldn't find player in Redis punishments."); } - return componentFromString("Couldn't find player in Redis punishments."); } if (args[0].equalsIgnoreCase("gamerules")) { @@ -64,15 +67,18 @@ public class DebugCMD extends PlexCommand } if (args[0].equalsIgnoreCase("aliases")) { - String commandName = args[1]; - Command command = plugin.getServer().getCommandMap().getCommand(commandName); - if (command == null) + if (args.length == 2) { - return mmString("That command could not be found!"); + String commandName = args[1]; + Command command = plugin.getServer().getCommandMap().getCommand(commandName); + if (command == null) + { + return mmString("That command could not be found!"); + } + return mmString("Aliases for " + commandName + " are: " + Arrays.toString(command.getAliases().toArray(new String[0]))); } - return mmString("Aliases for " + commandName + " are: " + Arrays.toString(command.getAliases().toArray(new String[0]))); } - return null; + return usage(); } @Override