2015-11-15 23:32:04 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
|
|
|
import lombok.Getter;
|
2016-05-12 19:40:39 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
public class CommandBlockerEntry
|
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@Getter
|
|
|
|
private final CommandBlockerRank rank;
|
|
|
|
@Getter
|
|
|
|
private final CommandBlockerAction action;
|
|
|
|
@Getter
|
|
|
|
private final String command;
|
|
|
|
@Getter
|
|
|
|
private final String subCommand;
|
|
|
|
@Getter
|
|
|
|
private final String message;
|
2017-10-13 18:35:11 +00:00
|
|
|
|
|
|
|
public CommandBlockerEntry(final CommandBlockerRank rank, final CommandBlockerAction action, final String command, final String message) {
|
2015-10-19 17:43:46 +00:00
|
|
|
this(rank, action, command, null, message);
|
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
|
|
|
|
public CommandBlockerEntry(final CommandBlockerRank rank, final CommandBlockerAction action, final String command, final String subCommand, final String message) {
|
2015-10-19 17:43:46 +00:00
|
|
|
this.rank = rank;
|
|
|
|
this.action = action;
|
|
|
|
this.command = command;
|
2017-10-13 18:35:11 +00:00
|
|
|
this.subCommand = ((subCommand == null) ? null : subCommand.toLowerCase().trim());
|
|
|
|
this.message = ((message == null || message.equals("_")) ? "That command is blocked." : message);
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
|
|
|
|
public void doActions(final CommandSender sender) {
|
|
|
|
if (this.action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player) {
|
|
|
|
TotalFreedomMod.plugin().ae.autoEject((Player)sender, "You used a prohibited command: " + this.command);
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
|
|
|
return;
|
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
if (this.action == CommandBlockerAction.BLOCK_UNKNOWN) {
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.playerMsg(sender, "Unknown command. Type \"help\" for help.", ChatColor.RESET);
|
|
|
|
return;
|
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
FUtil.playerMsg(sender, FUtil.colorize(this.message));
|
|
|
|
}
|
|
|
|
|
|
|
|
public CommandBlockerRank getRank() {
|
|
|
|
return this.rank;
|
|
|
|
}
|
|
|
|
|
|
|
|
public CommandBlockerAction getAction() {
|
|
|
|
return this.action;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getCommand() {
|
|
|
|
return this.command;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getSubCommand() {
|
|
|
|
return this.subCommand;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getMessage() {
|
|
|
|
return this.message;
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
|
|
|
}
|