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
|
|
|
|
2018-01-01 03:43:10 +00:00
|
|
|
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
this(rank, action, command, null, message);
|
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
|
2018-01-01 03:43:10 +00:00
|
|
|
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String subCommand, 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
|
|
|
|
2018-01-01 03:43:10 +00:00
|
|
|
public void doActions(CommandSender sender)
|
|
|
|
{
|
|
|
|
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
|
|
|
|
{
|
|
|
|
TotalFreedomMod.plugin().ae.autoEject((Player)sender, "You used a prohibited command: " + command);
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
|
|
|
return;
|
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
if (action == CommandBlockerAction.BLOCK_UNKNOWN)
|
|
|
|
{
|
|
|
|
FUtil.playerMsg(sender, "Unknown command. Type \"/help\" for help.", ChatColor.RESET);
|
2015-10-19 17:43:46 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
FUtil.playerMsg(sender, FUtil.colorize(message));
|
2017-10-13 18:35:11 +00:00
|
|
|
}
|
|
|
|
|
2018-01-01 03:43:10 +00:00
|
|
|
public CommandBlockerRank getRank()
|
|
|
|
{
|
|
|
|
return rank;
|
2017-10-13 18:35:11 +00:00
|
|
|
}
|
|
|
|
|
2018-01-01 03:43:10 +00:00
|
|
|
public CommandBlockerAction getAction()
|
|
|
|
{
|
|
|
|
return action;
|
2017-10-13 18:35:11 +00:00
|
|
|
}
|
|
|
|
|
2018-01-01 03:43:10 +00:00
|
|
|
public String getCommand()
|
|
|
|
{
|
|
|
|
return command;
|
2017-10-13 18:35:11 +00:00
|
|
|
}
|
|
|
|
|
2018-01-01 03:43:10 +00:00
|
|
|
public String getSubCommand()
|
|
|
|
{
|
|
|
|
return subCommand;
|
2017-10-13 18:35:11 +00:00
|
|
|
}
|
|
|
|
|
2018-01-01 03:43:10 +00:00
|
|
|
public String getMessage()
|
|
|
|
{
|
|
|
|
return message;
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
|
|
|
}
|