@Command( aliases = {"set"}, desc = "Set a setting to a specific value.", usage = "<setting> <value>", min = 2) public static void set(final CommandContext cmd, CommandSender sender) throws CommandException { if (sender instanceof Player) { if (Settings.getSettingByName(cmd.getString(0)) != null) { if (Settings.getSettingByName(cmd.getString(0)).getSettingValueByName(cmd.getString(1)) != null) { Settings.getSettingByName(cmd.getString(0)) .setValueByPlayer( (Player) sender, Settings.getSettingByName(cmd.getString(0)) .getSettingValueByName(cmd.getString(1))); sender.sendMessage( ChatColor.YELLOW + Settings.getSettingByName(cmd.getString(0)).getNames().get(0) + ": " + ChatColor.WHITE + Settings.getSettingByName(cmd.getString(0)) .getSettingValueByName(cmd.getString(1)) .getValue()); if (Settings.getSettingByName("Observers") != null && Settings.getSettingByName(cmd.getString(0)) .equals(Settings.getSettingByName("Observers"))) { Bukkit.getServer() .getPluginManager() .callEvent(new PlayerVisibilityChangeEvent((Player) sender)); } } else throw new CommandException("No value by this name!"); } else throw new CommandException("No setting by this name!"); } else throw new CommandException("Console cannot use this command."); }
@Command( aliases = {"forestgen"}, usage = "[size] [type] [density]", desc = "Generate a forest", min = 0, max = 3) @CommandPermissions({"worldedit.generation.forest"}) @Logging(POSITION) public static void forestGen( CommandContext args, WorldEdit we, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 10; TreeGenerator.TreeType type = args.argsLength() > 1 ? type = TreeGenerator.lookup(args.getString(1)) : TreeGenerator.TreeType.TREE; double density = args.argsLength() > 2 ? args.getDouble(2) / 100 : 0.05; if (type == null) { player.printError("Tree type '" + args.getString(1) + "' is unknown."); return; } else { } int affected = editSession.makeForest(player.getPosition(), size, density, new TreeGenerator(type)); player.print(affected + " trees created."); }
@Command( aliases = {"/redo", "redo"}, usage = "[times] [player]", desc = "Redoes the last action (from history)", min = 0, max = 2) @CommandPermissions("worldedit.history.redo") public void redo( CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { int times = Math.max(1, args.getInteger(0, 1)); for (int i = 0; i < times; ++i) { EditSession redone; if (args.argsLength() < 2) { redone = session.redo(session.getBlockBag(player)); } else { player.checkPermission("worldedit.history.redo.other"); LocalSession sess = we.getSession(args.getString(1)); if (sess == null) { player.printError("Unable to find session for " + args.getString(1)); break; } redone = sess.redo(session.getBlockBag(player)); } if (redone != null) { player.print("Redo successful."); we.flushBlockBag(player, redone); } else { player.printError("Nothing left to redo."); } } }
@Command( aliases = {"take"}, usage = "<target> <item[:data]> [amount]", desc = "Take an item", flags = "", min = 2, max = 3) @CommandPermissions({"commandbook.take.other"}) public void take(CommandContext args, CommandSender sender) throws CommandException { ItemStack item = null; int amt = config.defaultItemStackSize; Player target = null; // Two arguments: Player, item type if (args.argsLength() == 2) { target = PlayerUtil.matchSinglePlayer(sender, args.getString(0)); item = matchItem(sender, args.getString(1)); // Three arguments: Player, item type, and item amount } else if (args.argsLength() == 3) { target = PlayerUtil.matchSinglePlayer(sender, args.getString(0)); item = matchItem(sender, args.getString(1)); amt = args.getInteger(2); } if (item == null) { throw new CommandException("Something went wrong parsing the item info!"); } takeItem(sender, item, amt, target); }
@Command( aliases = {"/hsphere"}, usage = "<block> <radius> [raised?] ", desc = "Generate a hollow sphere", min = 2, max = 3) @CommandPermissions({"worldedit.generation.sphere"}) @Logging(PLACEMENT) public static void hsphere( CommandContext args, WorldEdit we, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { Pattern block = we.getBlockPattern(player, args.getString(0)); double radius = Math.max(1, args.getDouble(1)); boolean raised = args.argsLength() > 2 ? (args.getString(2).equalsIgnoreCase("true") || args.getString(2).equalsIgnoreCase("yes")) : false; Vector pos = session.getPlacementPosition(player); if (raised) { pos = pos.add(0, radius, 0); } int affected = editSession.makeSphere(pos, block, radius, false); player.findFreePosition(); player.print(affected + " block(s) have been created."); }
@Command( aliases = {"item", "i"}, usage = "[target] <item[:data]> [amount]", desc = "Give an item", flags = "do", min = 1, max = 3) @CommandPermissions({"commandbook.give"}) public void item(CommandContext args, CommandSender sender) throws CommandException { ItemStack item = null; int amt = config.defaultItemStackSize; Iterable<Player> targets = null; // How this command handles parameters depends on how many there // are, so the following code splits the incoming input // into three different possibilities // One argument: Just the item type and amount 1 if (args.argsLength() == 1) { item = matchItem(sender, args.getString(0)); targets = PlayerUtil.matchPlayers(PlayerUtil.checkPlayer(sender)); // Two arguments: Item type and amount } else if (args.argsLength() == 2) { item = matchItem(sender, args.getString(0)); amt = args.getInteger(1); targets = PlayerUtil.matchPlayers(PlayerUtil.checkPlayer(sender)); // Three arguments: Player, item type, and item amount } else if (args.argsLength() == 3) { item = matchItem(sender, args.getString(1)); amt = args.getInteger(2); targets = PlayerUtil.matchPlayers(sender, args.getString(0)); // Make sure that this player has permission to give items to other /// players! CommandBook.inst().checkPermission(sender, "commandbook.give.other"); } if (item == null) { throw new CommandException("Something went wrong parsing the item info!"); } giveItem( sender, item, amt, targets, InventoryComponent.this, args.hasFlag('d'), args.hasFlag('o')); }
@Command( aliases = {"/move"}, usage = "[count] [direction] [leave-id]", flags = "s", desc = "Move the contents of the selection", min = 0, max = 3) @CommandPermissions("worldedit.region.move") @Logging(ORIENTATION_REGION) public static void move( CommandContext args, WorldEdit we, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { int count = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1; Vector dir = we.getDirection(player, args.argsLength() > 1 ? args.getString(1).toLowerCase() : "me"); BaseBlock replace; // Replacement block argument if (args.argsLength() > 2) { replace = we.getBlock(player, args.getString(2)); } else { replace = new BaseBlock(BlockID.AIR); } int affected = editSession.moveCuboidRegion( session.getSelection(player.getWorld()), dir, count, true, replace); if (args.hasFlag('s')) { try { Region region = session.getSelection(player.getWorld()); region.expand(dir.multiply(count)); region.contract(dir.multiply(count)); session.getRegionSelector().learnChanges(); session.getRegionSelector().explainRegionAdjust(player, session); } catch (RegionOperationException e) { player.printError(e.getMessage()); } } player.print(affected + " blocks moved."); }
@Command( aliases = {"/set"}, usage = "<block>", desc = "Set all the blocks inside the selection to a block", min = 1, max = 1) @CommandPermissions("worldedit.region.set") @Logging(REGION) public static void set( CommandContext args, WorldEdit we, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { Pattern pattern = we.getBlockPattern(player, args.getString(0)); int affected; if (pattern instanceof SingleBlockPattern) { affected = editSession.setBlocks( session.getSelection(player.getWorld()), ((SingleBlockPattern) pattern).getBlock()); } else { affected = editSession.setBlocks(session.getSelection(player.getWorld()), pattern); } player.print(affected + " block(s) have been changed."); }
@Command( aliases = {"/faces", "/outline"}, usage = "<block>", desc = "Build the walls, ceiling, and floor of a selection", min = 1, max = 1) @CommandPermissions("worldedit.region.faces") @Logging(REGION) public static void faces( CommandContext args, WorldEdit we, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { Pattern pattern = we.getBlockPattern(player, args.getString(0)); int affected; if (pattern instanceof SingleBlockPattern) { affected = editSession.makeCuboidFaces( session.getSelection(player.getWorld()), ((SingleBlockPattern) pattern).getBlock()); } else { affected = editSession.makeCuboidFaces(session.getSelection(player.getWorld()), pattern); } player.print(affected + " block(s) have been changed."); }
@Command( aliases = {"/overlay"}, usage = "<block>", desc = "Set a block on top of blocks in the region", min = 1, max = 1) @CommandPermissions("worldedit.region.overlay") @Logging(REGION) public static void overlay( CommandContext args, WorldEdit we, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { Pattern pat = we.getBlockPattern(player, args.getString(0)); Region region = session.getSelection(player.getWorld()); int affected = 0; if (pat instanceof SingleBlockPattern) { affected = editSession.overlayCuboidBlocks(region, ((SingleBlockPattern) pat).getBlock()); } else { affected = editSession.overlayCuboidBlocks(region, pat); } player.print(affected + " block(s) have been overlayed."); }
@Command( aliases = {"/fillr"}, usage = "<block> <radius> [depth]", desc = "Fill a hole recursively", min = 2, max = 3) @CommandPermissions("worldedit.fill.recursive") @Logging(PLACEMENT) public void fillr( CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { Pattern pattern = we.getBlockPattern(player, args.getString(0)); double radius = Math.max(1, args.getDouble(1)); we.checkMaxRadius(radius); int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : 1; Vector pos = session.getPlacementPosition(player); int affected = 0; if (pattern instanceof SingleBlockPattern) { affected = editSession.fillXZ(pos, ((SingleBlockPattern) pattern).getBlock(), radius, depth, true); } else { affected = editSession.fillXZ(pos, pattern, radius, depth, true); } player.print(affected + " block(s) have been created."); }
@Command( aliases = {"dispenser"}, usage = "<nom_distributeur>", desc = "Information sur un distributeur.", min = 1, max = 1) @CommandPermissions({"mho.donjon.admin"}) public void dispenser(CommandContext args, CommandSender sender) { Player player = null; if (sender instanceof Player) { player = (Player) sender; } else { return; } String donjon = Manager.getDonjon().getDonjon(player.getName()); String dispenser = args.getString(0).toLowerCase(); if (Manager.getDonjon().existDonjon(donjon)) { if (Manager.getDonjon().existDispenser(donjon, dispenser)) { player.sendMessage( "Information du Distributeur: " + ChatColor.GREEN + dispenser + ChatColor.RESET); player.sendMessage(Manager.getDonjon().infoLocationDispenser(donjon, dispenser)); String[] items = Manager.getDonjon().infoItemsDispenser(donjon, dispenser); for (String item : items) { player.sendMessage("Item: " + item); } } else { player.sendMessage(ChatColor.RED + "Le distributeur n'existe pas." + ChatColor.RESET); } } else { player.sendMessage(ChatColor.RED + "Le donjon n'existe pas." + ChatColor.RESET); } }
@Command( aliases = {"baninfo"}, usage = "<target>", desc = "Check if a user is banned", min = 1, max = 1) @CommandPermissions({"commandbook.bans.baninfo"}) public void banInfo(CommandContext args, CommandSender sender) throws CommandException { String banName = args.getString(0).replace("\r", "").replace("\n", "").replace("\0", "").replace("\b", ""); Ban ban = getBanDatabase().getBannedName(banName); if (ban == null) { sender.sendMessage(ChatColor.YELLOW + banName + " is NOT banned."); } else { sender.sendMessage( ChatColor.YELLOW + "Ban for " + banName + ":" + ban.getAddress() + " for reason: '" + ban.getReason() + "' until " + (ban.getEnd() == 0L ? " forever" : dateFormat.format(new Date(ban.getEnd())))); } }
@Command( aliases = {"banip", "ipban"}, usage = "<target> [reason...]", desc = "Ban an IP address", flags = "st:", min = 1, max = -1) @CommandPermissions({"commandbook.bans.ban.ip"}) public void banIP(CommandContext args, CommandSender sender) throws CommandException { String message = args.argsLength() >= 2 ? args.getJoinedStrings(1) : "Banned!"; long endDate = args.hasFlag('t') ? CommandBookUtil.matchFutureDate(args.getFlag('t')) : 0L; String addr = args.getString(0).replace("\r", "").replace("\n", "").replace("\0", "").replace("\b", ""); // Need to kick + log for (Player player : CommandBook.server().getOnlinePlayers()) { if (player.getAddress().getAddress().getHostAddress().equals(addr)) { player.kickPlayer(message); getBanDatabase().logKick(player, sender, message); } } getBanDatabase().ban(null, addr, sender, message, endDate); sender.sendMessage(ChatColor.YELLOW + addr + " banned."); if (!getBanDatabase().save()) { sender.sendMessage(ChatColor.RED + "Bans database failed to save. See console."); } }
@Command( aliases = {"chest"}, usage = "<nom_coffre>", desc = "Information sur un coffre.", min = 1, max = 1) @CommandPermissions({"mho.donjon.admin"}) public void chest(CommandContext args, CommandSender sender) { Player player = null; if (sender instanceof Player) { player = (Player) sender; } else { return; } String donjon = Manager.getDonjon().getDonjon(player.getName()); String chest = args.getString(0).toLowerCase(); if (Manager.getDonjon().existDonjon(donjon)) { if (Manager.getDonjon().existChest(donjon, chest)) { player.sendMessage("Information du Coffre: " + ChatColor.GREEN + chest + ChatColor.RESET); player.sendMessage(Manager.getDonjon().infoLocationChest(donjon, chest)); String[] items = Manager.getDonjon().infoItemsChest(donjon, chest); for (String item : items) { player.sendMessage("Item: " + item); } } else { player.sendMessage(ChatColor.RED + "Le coffre n'existe pas." + ChatColor.RESET); } } else { player.sendMessage(ChatColor.RED + "Le donjon n'existe pas." + ChatColor.RESET); } }
@Command( aliases = {"/hpyramid"}, usage = "<block> <range>", desc = "Generate a hollow pyramid", min = 2, max = 2) @CommandPermissions({"worldedit.generation.pyramid"}) @Logging(PLACEMENT) public static void hpyramid( CommandContext args, WorldEdit we, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { Pattern block = we.getBlockPattern(player, args.getString(0)); int size = Math.max(1, args.getInteger(1)); Vector pos = session.getPlacementPosition(player); int affected = editSession.makePyramid(pos, block, size, false); player.findFreePosition(); player.print(affected + " block(s) have been created."); }
@Override public void processCommand(String header, CommandContext args, Player player) { if (!header.equals("sb")) return; if (args.argsLength() == 0) { player.sendMessage("SoundByte!"); return; } if (Helper.argEquals(args.getString(0), "CreateSoundByte")) { Block st = player.getLocation().getBlock(); BlockFace face = getCardinalDirection(player); createBoard(st, face); created = true; return; } player.sendMessage("Tetris Command not found: " + args.getString(0)); }
@Command( aliases = {"delete"}, desc = "Lists the areas of the given namespace or lists all areas.", usage = "[-n namespace] [area]", flags = "an:") public void delete(CommandContext context, CommandSender sender) throws CommandException { if (!(sender instanceof Player)) return; LocalPlayer player = plugin.wrapPlayer((Player) sender); String namespace = "~" + player.getName(); String areaId = null; // Get the namespace if (context.hasFlag('n') && player.hasPermission("craftbook.mech.area.delete." + context.getFlag('n'))) { namespace = context.getFlag('n'); } else if (!player.hasPermission("craftbook.mech.area.delete.self")) throw new CommandPermissionsException(); if (plugin.getConfiguration().areaShortenNames && namespace.length() > 14) namespace = namespace.substring(0, 14); boolean deleteAll = false; if (context.argsLength() > 0 && !context.hasFlag('a')) { areaId = context.getString(0); } else if (context.hasFlag('a') && player.hasPermission("craftbook.mech.area.delete." + namespace + ".all")) { deleteAll = true; } else throw new CommandException("You need to define an area or -a to delete all areas."); // add the area suffix areaId = areaId + (config.areaUseSchematics ? ".schematic" : ".cbcopy"); File areas = null; try { areas = new File(plugin.getDataFolder(), "areas/" + namespace); } catch (Exception ignored) { } if (areas == null || !areas.exists()) throw new CommandException("The namespace " + namespace + " does not exist."); if (deleteAll) { if (deleteDir(areas)) { player.print("All areas in the namespace " + namespace + " have been deleted."); } } else { File file = new File(areas, areaId); if (file.delete()) { player.print( "The area '" + areaId + " in the namespace '" + namespace + "' has been deleted."); } } }
@Command( aliases = {"toggle"}, desc = "Toggle a setting.", usage = "<setting>", min = 1) public static void toggle(final CommandContext cmd, CommandSender sender) throws CommandException { if (sender instanceof Player) { if (Settings.getSettingByName(cmd.getString(0)) != null) { int index = Settings.getSettingByName(cmd.getString(0)) .getValues() .indexOf( Settings.getSettingByName(cmd.getString(0)).getValueByPlayer((Player) sender)); index++; if (index >= Settings.getSettingByName(cmd.getString(0)).getValues().size()) index = 0; Bukkit.dispatchCommand( sender, "set " + cmd.getString(0) + " " + Settings.getSettingByName(cmd.getString(0)).getValues().get(index).getValue()); } else throw new CommandException("No setting by this name!"); } else throw new CommandException("Console cannot use this command."); }
@Command( aliases = {"remove", "rem", "rement"}, usage = "<type> <radius>", desc = "Remove all entities of a type", min = 2, max = 2) @CommandPermissions("worldedit.remove") @Logging(PLACEMENT) public void remove( CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { String typeStr = args.getString(0); int radius = args.getInteger(1); if (radius < -1) { player.printError("Use -1 to remove all entities in loaded chunks"); return; } EntityType type = null; if (typeStr.matches("all")) { type = EntityType.ALL; } else if (typeStr.matches("projectiles?|arrows?")) { type = EntityType.PROJECTILES; } else if (typeStr.matches("items?") || typeStr.matches("drops?")) { type = EntityType.ITEMS; } else if (typeStr.matches("falling(blocks?|sand|gravel)")) { type = EntityType.FALLING_BLOCKS; } else if (typeStr.matches("paintings?") || typeStr.matches("art")) { type = EntityType.PAINTINGS; } else if (typeStr.matches("(item)frames?")) { type = EntityType.ITEM_FRAMES; } else if (typeStr.matches("boats?")) { type = EntityType.BOATS; } else if (typeStr.matches("minecarts?") || typeStr.matches("carts?")) { type = EntityType.MINECARTS; } else if (typeStr.matches("tnt")) { type = EntityType.TNT; } else if (typeStr.matches("xp")) { type = EntityType.XP_ORBS; } else { player.printError( "Acceptable types: projectiles, items, paintings, itemframes, boats, minecarts, tnt, xp, or all"); return; } Vector origin = session.getPlacementPosition(player); int removed = player.getWorld().removeEntities(type, origin, radius); player.print("Marked " + removed + " entit(ies) for removal."); }
@Command( aliases = {"addserver"}, desc = "Add a BungeeCord server", usage = "<name> <address> [port]", flags = "r", min = 2, max = 4) @CommandPermissions("bungeeutils.addserver") public static void addserver(final CommandContext args, CommandSender sender) throws CommandException { String name = args.getString(0); String address = args.getString(1); int port = args.argsLength() > 2 ? args.getInteger(2) : 25565; boolean restricted = args.hasFlag('r'); ServerInfo serverInfo = ProxyServer.getInstance() .constructServerInfo(name, new InetSocketAddress(address, port), "", restricted); ProxyServer.getInstance().getServers().put(name, serverInfo); sender.sendMessage(ChatColor.GREEN + "Added server " + ChatColor.GOLD + name); }
@Command( aliases = {"/replace"}, usage = "[from-block] <to-block>", desc = "Replace all blocks in the selection with another", flags = "f", min = 1, max = 2) @CommandPermissions("worldedit.region.replace") @Logging(REGION) public static void replace( CommandContext args, WorldEdit we, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { Set<BaseBlock> from; Pattern to; if (args.argsLength() == 1) { from = null; to = we.getBlockPattern(player, args.getString(0)); } else { from = we.getBlocks(player, args.getString(0), true, !args.hasFlag('f')); to = we.getBlockPattern(player, args.getString(1)); } int affected = 0; if (to instanceof SingleBlockPattern) { affected = editSession.replaceBlocks( session.getSelection(player.getWorld()), from, ((SingleBlockPattern) to).getBlock()); } else { affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from, to); } player.print(affected + " block(s) have been replaced."); }
@Command( aliases = {"/replacenear", "replacenear"}, usage = "<size> <from-id> <to-id>", desc = "Replace nearby blocks", flags = "f", min = 3, max = 3) @CommandPermissions("worldedit.replacenear") @Logging(PLACEMENT) public void replaceNear( CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { int size = Math.max(1, args.getInteger(0)); int affected; Set<BaseBlock> from; Pattern to; if (args.argsLength() == 2) { from = null; to = we.getBlockPattern(player, args.getString(1)); } else { from = we.getBlocks(player, args.getString(1), true, !args.hasFlag('f')); to = we.getBlockPattern(player, args.getString(2)); } Vector base = session.getPlacementPosition(player); Vector min = base.subtract(size, size, size); Vector max = base.add(size, size, size); Region region = new CuboidRegion(player.getWorld(), min, max); if (to instanceof SingleBlockPattern) { affected = editSession.replaceBlocks(region, from, ((SingleBlockPattern) to).getBlock()); } else { affected = editSession.replaceBlocks(region, from, to); } player.print(affected + " block(s) have been replaced."); }
@Command( aliases = {"/cut"}, usage = "[leave-id]", desc = "Вырезает выделенную территорию в буфер обмена", help = "Вырезает выделенную территорию в буфер обмена\n" + "Флаги:\n" + " -e controls определяет, будут ли объекты копироваться в буфер обмена\n" + "ПРЕДУПРЕЖДЕНИЕ: Вырезанные и вставленные объекты не могут быть отменены!", flags = "e", min = 0, max = 1) @CommandPermissions("worldedit.clipboard.cut") @Logging(REGION) public void cut( CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { BaseBlock block = new BaseBlock(BlockID.AIR); LocalWorld world = player.getWorld(); if (args.argsLength() > 0) { block = we.getBlock(player, args.getString(0)); } Region region = session.getSelection(world); Vector min = region.getMinimumPoint(); Vector max = region.getMaximumPoint(); Vector pos = session.getPlacementPosition(player); CuboidClipboard clipboard = new CuboidClipboard(max.subtract(min).add(new Vector(1, 1, 1)), min, min.subtract(pos)); clipboard.copy(editSession); if (args.hasFlag('e')) { LocalEntity[] entities = world.getEntities(region); for (LocalEntity entity : entities) { clipboard.storeEntity(entity); } world.killEntities(entities); } session.setClipboard(clipboard); int affected = editSession.setBlocks(session.getSelection(world), block); player.print( affected + " " + StringUtil.plural(affected, "блок вырезан", "блока вырезано", "блоков вырезано") + "."); }
@Command( aliases = {"unfreeze"}, usage = "<target>", desc = "Unmute a player", min = 1, max = 1) @CommandPermissions({"commandbook.freeze"}) public void unfreeze(CommandContext args, CommandSender sender) throws CommandException { Player player = PlayerUtil.matchSinglePlayer(sender, args.getString(0)); sessions.getAdminSession(player).setFrozen(false); player.sendMessage(ChatColor.YELLOW + "You've been unfrozen by " + PlayerUtil.toName(sender)); sender.sendMessage(ChatColor.YELLOW + "You've unfrozen " + PlayerUtil.toName(player)); }
@Command( aliases = "toggle", desc = "Toggle an area sign at the given location.", usage = "[-w world] <x,y,z>", flags = "sw:", min = 1) @CommandPermissions("craftbook.mech.area.command.toggle") public void toggle(CommandContext context, CommandSender sender) throws CommandException { World world = null; boolean hasWorldFlag = context.hasFlag('w'); if (hasWorldFlag) { world = Bukkit.getWorld(context.getFlag('w')); } else if (sender instanceof Player) { world = ((Player) sender).getWorld(); } if (world == null) { throw new CommandException( "You must be a player or specify a valid world to use this command."); } int[] xyz = new int[3]; String[] loc = context.getString(0).split(","); if (loc.length != 3) { throw new CommandException("Invalid location specified."); } try { for (int i = 0; i < xyz.length; i++) { xyz[i] = Integer.parseInt(loc[i]); } } catch (NumberFormatException ex) { throw new CommandException("Invalid location specified."); } Block block = world.getBlockAt(xyz[0], xyz[1], xyz[2]); if (!SignUtil.isSign(block)) throw new CommandException("No sign found at the specified location."); if (!Area.toggleCold(BukkitUtil.toChangedSign(block))) { throw new CommandException("Failed to toggle an area at the specified location."); } // TODO Make a sender wrap for this if (!context.hasFlag('s')) sender.sendMessage(ChatColor.YELLOW + "Area toggled!"); }
@Command( aliases = {"delserver"}, desc = "Remove a BungeeCord server", usage = "<name>", min = 1, max = 1) @CommandPermissions("bungeeutils.delserver") public static void delserver(final CommandContext args, CommandSender sender) throws CommandException { String name = args.getString(0); if (ProxyServer.getInstance().getServers().remove(name) == null) { sender.sendMessage(ChatColor.RED + "Could not find server " + ChatColor.GOLD + name); } else { sender.sendMessage(ChatColor.GREEN + "Removed server " + ChatColor.GOLD + name); } }
@Command( aliases = {"isbanned"}, usage = "<target>", desc = "Check if a user is banned", min = 1, max = 1) @CommandPermissions({"commandbook.bans.isbanned"}) public void isBanned(CommandContext args, CommandSender sender) throws CommandException { String banName = args.getString(0).replace("\r", "").replace("\n", "").replace("\0", "").replace("\b", ""); if (getBanDatabase().isBannedName(banName)) { sender.sendMessage(ChatColor.YELLOW + banName + " is banned."); } else { sender.sendMessage(ChatColor.YELLOW + banName + " NOT banned."); } }
@Command( aliases = {"kick"}, usage = "<target> [reason...]", desc = "Kick a user", flags = "os", min = 1, max = -1) @CommandPermissions({"commandbook.kick"}) public void kick(CommandContext args, CommandSender sender) throws CommandException { Iterable<Player> targets = PlayerUtil.matchPlayers(sender, args.getString(0)); String message = args.argsLength() >= 2 ? args.getJoinedStrings(1) : "Kicked!"; String broadcastPlayers = ""; for (Player player : targets) { if (CommandBook.inst().hasPermission(player, "commandbook.kick.exempt") && !(args.hasFlag('o') && CommandBook.inst().hasPermission(sender, "commandbook.kick.exempt.override"))) { sender.sendMessage( ChatColor.RED + "Player " + player.getName() + ChatColor.RED + " is exempt from being kicked!"); continue; } player.kickPlayer(message); broadcastPlayers += PlayerUtil.toColoredName(player, ChatColor.YELLOW) + " "; getBanDatabase().logKick(player, sender, message); } if (broadcastPlayers.length() > 0) { sender.sendMessage(ChatColor.YELLOW + "Player(s) kicked."); // Broadcast the Message if (config.broadcastKicks && !args.hasFlag('s')) { BasePlugin.server() .broadcastMessage( ChatColor.YELLOW + PlayerUtil.toColoredName(sender, ChatColor.YELLOW) + " has kicked " + broadcastPlayers + " - " + message); } } }
@Command( aliases = {"flushstates", "clearstates"}, usage = "[player]", desc = "Flush the state manager", max = 1) @CommandPermissions("worldguard.flushstates") public void flushStates(CommandContext args, CommandSender sender) throws CommandException { if (args.argsLength() == 0) { plugin.getFlagStateManager().forgetAll(); sender.sendMessage("Cleared all states."); } else { Player player = plugin.getServer().getPlayer(args.getString(0)); if (player != null) { plugin.getFlagStateManager().forget(player); sender.sendMessage("Cleared states for player \"" + player.getName() + "\"."); } } }