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;
|
2018-08-09 06:26:12 +00:00
|
|
|
import org.spigotmc.SpigotConfig;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
|
|
|
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 message;
|
2018-07-31 06:41:56 +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 = rank;
|
|
|
|
this.action = action;
|
|
|
|
this.command = command;
|
2017-10-13 18:35:11 +00:00
|
|
|
this.message = ((message == null || message.equals("_")) ? "That command is blocked." : message);
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
2018-07-31 06:41:56 +00:00
|
|
|
|
2018-01-01 03:43:10 +00:00
|
|
|
public void doActions(CommandSender sender)
|
|
|
|
{
|
|
|
|
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
|
|
|
|
{
|
2018-07-31 07:01:29 +00:00
|
|
|
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)
|
|
|
|
{
|
2018-08-09 06:26:12 +00:00
|
|
|
sender.sendMessage(SpigotConfig.unknownCommandMessage);
|
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
|
|
|
}
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|