48 lines
1.7 KiB
Java
48 lines
1.7 KiB
Java
package cn.citycraft.ProtectItem.commands;
|
|
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandException;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
|
import cn.citycraft.PluginHelper.utils.LocalUtil;
|
|
import cn.citycraft.ProtectItem.ProtectItem;
|
|
import cn.citycraft.ProtectItem.utils.ActionType;
|
|
|
|
public class CommandBan extends BaseCommand {
|
|
ProtectItem plugin;
|
|
|
|
public CommandBan(final ProtectItem main) {
|
|
super("ban");
|
|
this.plugin = main;
|
|
setPermission("pi.ban");
|
|
setOnlyPlayerExecutable();
|
|
setDescription("§c封禁手持物品");
|
|
setPossibleArguments("<封禁类型>");
|
|
}
|
|
|
|
@Override
|
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
|
final Player p = (Player) sender;
|
|
final ItemStack item = p.getItemInHand();
|
|
final String itemname = plugin.getItemManager().getItemName(item);
|
|
switch (args.length) {
|
|
case 0:
|
|
plugin.getItemManager().banItem(item);
|
|
p.sendMessage(plugin.pluginname + "§c当前物品 §a" + LocalUtil.getItemName(itemname) + " §c已被禁封!");
|
|
return;
|
|
case 1:
|
|
try {
|
|
final ActionType action = Enum.valueOf(ActionType.class, args[0]);
|
|
plugin.getItemManager().banItem(item, action);
|
|
p.sendMessage(plugin.pluginname + "§c当前物品 §a" + LocalUtil.getItemName(itemname) + " §c已被禁封 §c操作 §b" + action.toString() + "!");
|
|
} catch (final Exception e) {
|
|
p.sendMessage(plugin.pluginname + "§c未知的操作类型" + args[0] + "!");
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|