mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Improved wildcard command blocking. Fixes #1842
This commit is contained in:
parent
92a7e354ba
commit
580e88d1a9
@ -1,5 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -12,6 +14,13 @@ import org.bukkit.entity.Player;
|
|||||||
public class Command_wildcard extends FreedomCommand
|
public class Command_wildcard extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static final List<String> BLOCKED_COMMANDS = Arrays.asList(
|
||||||
|
"wildcard",
|
||||||
|
"gtfo",
|
||||||
|
"doom",
|
||||||
|
"saconfig"
|
||||||
|
);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
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;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
if (args[0].equals("gtfo"))
|
|
||||||
|
if (BLOCKED_COMMANDS.contains(runCmd.getName()))
|
||||||
{
|
{
|
||||||
msg("Nice try", ChatColor.RED);
|
msg("Did you really think that was going to work?", 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String baseCommand = StringUtils.join(args, " ");
|
String baseCommand = StringUtils.join(args, " ");
|
||||||
@ -51,9 +51,9 @@ public class Command_wildcard extends FreedomCommand
|
|||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
String out_command = baseCommand.replaceAll("\\x3f", player.getName());
|
baseCommand = baseCommand.replaceAll("\\x3f", player.getName());
|
||||||
msg("Running Command: " + out_command);
|
msg("Running Command: " + baseCommand);
|
||||||
server.dispatchCommand(sender, out_command);
|
server.dispatchCommand(sender, baseCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user