Properly fixes usage of jail:jail

This commit is contained in:
Kristian Knarvik 2022-03-11 13:06:12 +01:00
parent eb0c3ba46c
commit b86229dc3c
3 changed files with 14 additions and 6 deletions

View File

@ -182,7 +182,10 @@ public class JailMain extends JavaPlugin {
sender.sendMessage(Lang.PLUGINNOTLOADED.get()); sender.sendMessage(Lang.PLUGINNOTLOADED.get());
getServer().getConsoleSender().sendMessage(Lang.PLUGINNOTLOADED.get()); getServer().getConsoleSender().sendMessage(Lang.PLUGINNOTLOADED.get());
} else { } else {
if (commandLabel.equalsIgnoreCase("jail") || commandLabel.equalsIgnoreCase("j")) { if (commandLabel.equalsIgnoreCase("jail:jail") ||
commandLabel.equalsIgnoreCase("jail") ||
commandLabel.equalsIgnoreCase("jail:j") ||
commandLabel.equalsIgnoreCase("j")) {
jh.parseCommand(jailManager, sender, args); jh.parseCommand(jailManager, sender, args);
} else { } else {
cmdHand.handleCommand(jailManager, sender, command.getName().toLowerCase(), args); cmdHand.handleCommand(jailManager, sender, command.getName().toLowerCase(), args);
@ -200,7 +203,10 @@ public class JailMain extends JavaPlugin {
} else { } else {
debug("Tab Complete Args (" + args.length + ") for '" + commandLabel + "': " + Util.getStringFromArray(", ", args)); debug("Tab Complete Args (" + args.length + ") for '" + commandLabel + "': " + Util.getStringFromArray(", ", args));
try { try {
if (commandLabel.equalsIgnoreCase("jail") || commandLabel.equalsIgnoreCase("j")) { if (commandLabel.equalsIgnoreCase("jail:jail") ||
commandLabel.equalsIgnoreCase("jail") ||
commandLabel.equalsIgnoreCase("jail:j") ||
commandLabel.equalsIgnoreCase("j")) {
return jh.parseTabComplete(jailManager, sender, args); return jh.parseTabComplete(jailManager, sender, args);
} else { } else {
return cmdHand.parseTabComplete(jailManager, sender, command.getName().toLowerCase(), args); return cmdHand.parseTabComplete(jailManager, sender, command.getName().toLowerCase(), args);

View File

@ -65,7 +65,7 @@ public class JailHandler {
for (Command c : commands.values()) { for (Command c : commands.values()) {
CommandInfo i = c.getClass().getAnnotation(CommandInfo.class); CommandInfo i = c.getClass().getAnnotation(CommandInfo.class);
//Skip the jail subcommand instance, since it is unique //Skip the jail subcommand instance, since it is unique
if (i.pattern().equalsIgnoreCase("jail|j")) { if (i.pattern().equalsIgnoreCase("jail:jail|jail|jail:j|j")) {
hasJailPermission = sender.hasPermission(i.permission()); hasJailPermission = sender.hasPermission(i.permission());
continue; continue;
} }
@ -101,9 +101,9 @@ public class JailHandler {
CommandInfo i = c.getClass().getAnnotation(CommandInfo.class); CommandInfo i = c.getClass().getAnnotation(CommandInfo.class);
//since the pattern won't ever match the jail plugin //since the pattern won't ever match the jail plugin
//we can skip it but first we need to see if they have //we can skip it, but first we need to see if they have
//permission to do the jailing //permission to do the jailing
if (i.pattern().equalsIgnoreCase("jail|j")) { if (i.pattern().equalsIgnoreCase("jail:jail|jail|jail:j|j")) {
hasJailPermission = sender.hasPermission(i.permission()); hasJailPermission = sender.hasPermission(i.permission());
continue; continue;
} }

View File

@ -65,7 +65,6 @@ public class JailCommand implements Command {
if (!arguments.contains("-p")) { if (!arguments.contains("-p")) {
arguments.add(0, "-p"); arguments.add(0, "-p");
} }
arguments.removeIf(String::isEmpty);
Jailing params; Jailing params;
@ -146,6 +145,9 @@ public class JailCommand implements Command {
String jailName; String jailName;
if (!params.isJail()) { if (!params.isJail()) {
String dJail = jm.getPlugin().getConfig().getString(Settings.DEFAULTJAIL.getPath()); String dJail = jm.getPlugin().getConfig().getString(Settings.DEFAULTJAIL.getPath());
if (dJail == null) {
return false;
}
if (dJail.equalsIgnoreCase("nearest")) { if (dJail.equalsIgnoreCase("nearest")) {
jailName = jm.getNearestJail(sender).getName(); jailName = jm.getNearestJail(sender).getName();