mirror of
https://github.com/kaboomserver/extras.git
synced 2025-08-06 04:23:21 +00:00
Fix logic error in command checker
This commit is contained in:
parent
f7e86e696b
commit
9e967c9748
2 changed files with 13 additions and 7 deletions
|
@ -44,10 +44,10 @@ class PlayerCommand implements Listener {
|
||||||
final boolean isConsoleCommand = false;
|
final boolean isConsoleCommand = false;
|
||||||
final String checkedCommand = ServerCommand.checkCommand(sender, command, isConsoleCommand);
|
final String checkedCommand = ServerCommand.checkCommand(sender, command, isConsoleCommand);
|
||||||
|
|
||||||
if (checkedCommand != null) {
|
if (checkedCommand.equals("cancel")) {
|
||||||
event.setMessage(checkedCommand);
|
|
||||||
} else {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
} else if (checkedCommand != null) {
|
||||||
|
event.setMessage(checkedCommand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ class ServerCommand implements Listener {
|
||||||
"save-off".equalsIgnoreCase(arr[i+1]) ||
|
"save-off".equalsIgnoreCase(arr[i+1]) ||
|
||||||
"stop".equalsIgnoreCase(arr[i+1])) {
|
"stop".equalsIgnoreCase(arr[i+1])) {
|
||||||
Command.broadcastCommandMessage(sender, "Forbidden execute command detected");
|
Command.broadcastCommandMessage(sender, "Forbidden execute command detected");
|
||||||
|
return "cancel";
|
||||||
} else if (i+3 < arr.length &&
|
} else if (i+3 < arr.length &&
|
||||||
"gamerule".equalsIgnoreCase(arr[i+1])) {
|
"gamerule".equalsIgnoreCase(arr[i+1])) {
|
||||||
if ("randomTickSpeed".equalsIgnoreCase(arr[i+2]) &&
|
if ("randomTickSpeed".equalsIgnoreCase(arr[i+2]) &&
|
||||||
|
@ -75,6 +76,7 @@ class ServerCommand implements Listener {
|
||||||
|
|
||||||
if (asAtCount >= 2) {
|
if (asAtCount >= 2) {
|
||||||
Command.broadcastCommandMessage(sender, "Forbidden execute pattern detected");
|
Command.broadcastCommandMessage(sender, "Forbidden execute pattern detected");
|
||||||
|
return "cancel";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -118,17 +120,20 @@ class ServerCommand implements Listener {
|
||||||
Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues when using some plugins.");
|
Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues when using some plugins.");
|
||||||
Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
||||||
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete.");
|
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete.");
|
||||||
|
return "cancel";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "/spigot:restart":
|
case "/spigot:restart":
|
||||||
case "/restart":
|
case "/restart":
|
||||||
if (sender.hasPermission("bukkit.command.restart")) {
|
if (sender.hasPermission("bukkit.command.restart")) {
|
||||||
|
return "cancel";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "/minecraft:save-off":
|
case "/minecraft:save-off":
|
||||||
case "/save-off":
|
case "/save-off":
|
||||||
if (sender.hasPermission("minecraft.command.save.disable")) {
|
if (sender.hasPermission("minecraft.command.save.disable")) {
|
||||||
Command.broadcastCommandMessage(sender, "Automatic saving is now disabled");
|
Command.broadcastCommandMessage(sender, "Automatic saving is now disabled");
|
||||||
|
return "cancel";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "/minecraft:spreadplayers":
|
case "/minecraft:spreadplayers":
|
||||||
|
@ -152,6 +157,7 @@ class ServerCommand implements Listener {
|
||||||
case "/stop":
|
case "/stop":
|
||||||
if (sender.hasPermission("minecraft.command.stop")) {
|
if (sender.hasPermission("minecraft.command.stop")) {
|
||||||
Command.broadcastCommandMessage(sender, "Stopping the server");
|
Command.broadcastCommandMessage(sender, "Stopping the server");
|
||||||
|
return "cancel";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -172,10 +178,10 @@ class ServerCommand implements Listener {
|
||||||
final boolean isConsoleCommand = true;
|
final boolean isConsoleCommand = true;
|
||||||
final String checkedCommand = checkCommand(sender, command, isConsoleCommand);
|
final String checkedCommand = checkCommand(sender, command, isConsoleCommand);
|
||||||
|
|
||||||
if (checkedCommand != null) {
|
if (checkedCommand.equals("cancel")) {
|
||||||
event.setCommand(checkedCommand);
|
|
||||||
} else {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
} else if (checkedCommand != null) {
|
||||||
|
event.setCommand(checkedCommand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue