Improved wildcard command blocking. Fixes #1842

This commit is contained in:
JeromSar 2016-08-26 11:38:35 +02:00
parent 92a7e354ba
commit 580e88d1a9

View file

@ -1,5 +1,7 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
@ -12,6 +14,13 @@ import org.bukkit.entity.Player;
public class Command_wildcard extends FreedomCommand
{
public static final List<String> BLOCKED_COMMANDS = Arrays.asList(
"wildcard",
"gtfo",
"doom",
"saconfig"
);
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
@ -20,25 +29,16 @@ public class Command_wildcard extends FreedomCommand
return false;
}
if (args[0].equals("wildcard"))
Command runCmd = server.getPluginCommand(args[0]);
if (runCmd == null)
{
msg("What the hell are you trying to do, you stupid idiot...", ChatColor.RED);
msg("Unknown command: " + args[0], ChatColor.RED);
return true;
}
if (args[0].equals("gtfo"))
if (BLOCKED_COMMANDS.contains(runCmd.getName()))
{
msg("Nice try", ChatColor.RED);
return true;
}
if (args[0].equals("doom"))
{
msg("Look, we all hate people, but this is not the way to deal with it, doom is evil enough!", ChatColor.RED);
return true;
}
if (args[0].equals("saconfig"))
{
msg("WOA, WTF are you trying to do???", ChatColor.RED);
return true;
msg("Did you really think that was going to work?", ChatColor.RED);
}
String baseCommand = StringUtils.join(args, " ");
@ -51,9 +51,9 @@ public class Command_wildcard extends FreedomCommand
for (Player player : server.getOnlinePlayers())
{
String out_command = baseCommand.replaceAll("\\x3f", player.getName());
msg("Running Command: " + out_command);
server.dispatchCommand(sender, out_command);
baseCommand = baseCommand.replaceAll("\\x3f", player.getName());
msg("Running Command: " + baseCommand);
server.dispatchCommand(sender, baseCommand);
}
return true;