2015-11-16 00:32:04 +01:00
|
|
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
2015-10-19 19:43:46 +02:00
|
|
|
|
|
|
|
import lombok.Getter;
|
2016-05-12 21:40:39 +02:00
|
|
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
2015-10-19 19:43:46 +02:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
2018-08-08 23:26:12 -07:00
|
|
|
import org.spigotmc.SpigotConfig;
|
2015-10-19 19:43:46 +02:00
|
|
|
|
|
|
|
public class CommandBlockerEntry
|
|
|
|
{
|
2015-11-22 19:26:47 +01:00
|
|
|
|
2015-10-19 19:43:46 +02: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;
|
2018-07-30 23:41:56 -07:00
|
|
|
|
2017-12-31 20:43:10 -07:00
|
|
|
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
|
|
|
|
{
|
2015-10-19 19:43:46 +02:00
|
|
|
this(rank, action, command, null, message);
|
|
|
|
}
|
2018-07-30 23:41:56 -07:00
|
|
|
|
2017-12-31 20:43:10 -07:00
|
|
|
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String subCommand, String message)
|
|
|
|
{
|
2015-10-19 19:43:46 +02:00
|
|
|
this.rank = rank;
|
|
|
|
this.action = action;
|
|
|
|
this.command = command;
|
2017-10-13 23:35:11 +05:00
|
|
|
this.subCommand = ((subCommand == null) ? null : subCommand.toLowerCase().trim());
|
|
|
|
this.message = ((message == null || message.equals("_")) ? "That command is blocked." : message);
|
2015-10-19 19:43:46 +02:00
|
|
|
}
|
2018-07-30 23:41:56 -07:00
|
|
|
|
2017-12-31 20:43:10 -07:00
|
|
|
public void doActions(CommandSender sender)
|
|
|
|
{
|
|
|
|
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
|
|
|
|
{
|
2018-07-31 00:01:29 -07:00
|
|
|
TotalFreedomMod.plugin().ae.autoEject((Player)sender, "You used a prohibited command: " + command);
|
2015-10-19 19:43:46 +02:00
|
|
|
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
|
|
|
return;
|
|
|
|
}
|
2017-12-31 20:43:10 -07:00
|
|
|
if (action == CommandBlockerAction.BLOCK_UNKNOWN)
|
|
|
|
{
|
2018-08-08 23:26:12 -07:00
|
|
|
sender.sendMessage(SpigotConfig.unknownCommandMessage);
|
2015-10-19 19:43:46 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-12-31 20:43:10 -07:00
|
|
|
FUtil.playerMsg(sender, FUtil.colorize(message));
|
2017-10-13 23:35:11 +05:00
|
|
|
}
|
2015-10-19 19:43:46 +02:00
|
|
|
}
|