Fix out of bounds exception - closes #54

This commit is contained in:
Focusvity 2023-03-08 21:46:27 +11:00
parent 344d890877
commit e39f882ea7
No known key found for this signature in database
GPG Key ID: 85AD157561ABE94B
1 changed files with 17 additions and 11 deletions

View File

@ -36,13 +36,16 @@ public class DebugCMD extends PlexCommand
} }
if (args[0].equalsIgnoreCase("redis-reset")) if (args[0].equalsIgnoreCase("redis-reset"))
{ {
Player player = getNonNullPlayer(args[1]); if (args.length == 2)
if (plugin.getRedisConnection().getJedis().exists(player.getUniqueId().toString()))
{ {
plugin.getRedisConnection().getJedis().del(player.getUniqueId().toString()); Player player = getNonNullPlayer(args[1]);
return componentFromString("Successfully reset " + player.getName() + "'s Redis punishments!").color(NamedTextColor.YELLOW); 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")) if (args[0].equalsIgnoreCase("gamerules"))
{ {
@ -64,15 +67,18 @@ public class DebugCMD extends PlexCommand
} }
if (args[0].equalsIgnoreCase("aliases")) if (args[0].equalsIgnoreCase("aliases"))
{ {
String commandName = args[1]; if (args.length == 2)
Command command = plugin.getServer().getCommandMap().getCommand(commandName);
if (command == null)
{ {
return mmString("<red>That command could not be found!"); String commandName = args[1];
Command command = plugin.getServer().getCommandMap().getCommand(commandName);
if (command == null)
{
return mmString("<red>That command could not be found!");
}
return mmString("<aqua>Aliases for " + commandName + " are: " + Arrays.toString(command.getAliases().toArray(new String[0])));
} }
return mmString("<aqua>Aliases for " + commandName + " are: " + Arrays.toString(command.getAliases().toArray(new String[0])));
} }
return null; return usage();
} }
@Override @Override