TFM_CommandBlockerNew cleanup.

This commit is contained in:
Steven Lawson 2013-07-26 19:48:18 -04:00
parent b24f1d9247
commit c482349f47

View File

@ -142,7 +142,7 @@ public class TFM_CommandBlockerNew
{ {
if (doAction) if (doAction)
{ {
doBlockedCommandAction(sender, blockedCommandEntry); blockedCommandEntry.doActions(sender);
} }
return true; return true;
@ -152,36 +152,6 @@ public class TFM_CommandBlockerNew
return false; return false;
} }
private void doBlockedCommandAction(CommandSender sender, TFM_CommandBlocker_BlockedCommandEntry blockedCommandEntry)
{
CommandBlockerAction action = blockedCommandEntry.getAction();
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
{
TFM_Util.autoEject((Player) sender, "You used a prohibited command: " + blockedCommandEntry.getCommand());
TFM_Util.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
}
else
{
String message = blockedCommandEntry.getMessage();
if (action == CommandBlockerAction.BLOCK_UNKNOWN)
{
message = "Unknown command. Type \"help\" for help.";
}
else if (message == null || "_".equals(message))
{
message = ChatColor.GRAY + "That command is blocked.";
}
else
{
message = ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', message);
}
sender.sendMessage(message);
}
}
private static enum CommandBlockerRank private static enum CommandBlockerRank
{ {
ANYONE("a", 0), ANYONE("a", 0),
@ -201,7 +171,7 @@ public class TFM_CommandBlockerNew
public String getToken() public String getToken()
{ {
return token; return this.token;
} }
public boolean hasPermission(CommandSender sender) public boolean hasPermission(CommandSender sender)
@ -261,7 +231,7 @@ public class TFM_CommandBlockerNew
public String getToken() public String getToken()
{ {
return token; return this.token;
} }
public static CommandBlockerAction fromToken(String token) public static CommandBlockerAction fromToken(String token)
@ -294,28 +264,56 @@ public class TFM_CommandBlockerNew
public CommandBlockerAction getAction() public CommandBlockerAction getAction()
{ {
return action; return this.action;
} }
public String getCommand() public String getCommand()
{ {
return command; return this.command;
} }
public String getMessage() public String getMessage()
{ {
return message; return this.message;
} }
public CommandBlockerRank getRank() public CommandBlockerRank getRank()
{ {
return rank; return this.rank;
} }
public void setCommand(String command) public void setCommand(String command)
{ {
this.command = command; this.command = command;
} }
private void doActions(CommandSender sender)
{
if (this.action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
{
TFM_Util.autoEject((Player) sender, "You used a prohibited command: " + this.command);
TFM_Util.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
}
else
{
String response;
if (this.action == CommandBlockerAction.BLOCK_UNKNOWN)
{
response = "Unknown command. Type \"help\" for help.";
}
else if (this.message == null || "_".equals(this.message))
{
response = ChatColor.GRAY + "That command is blocked.";
}
else
{
response = ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', this.message);
}
sender.sendMessage(response);
}
}
} }
public static TFM_CommandBlockerNew getInstance() public static TFM_CommandBlockerNew getInstance()