@Command( aliases = { "/fill" }, usage = "<block> <radius> [depth]", desc = "Fill a hole", min = 2, max = 3 ) @CommandPermissions("worldedit.fill") @Logging(PLACEMENT) public void fill(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { ParserContext context = new ParserContext(); context.setActor(player); context.setWorld(player.getWorld()); context.setSession(session); Pattern pattern = we.getPatternFactory().parseFromInput(args.getString(0), context); double radius = Math.max(1, args.getDouble(1)); we.checkMaxRadius(radius); int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : 1; BlockVector3 pos = session.getPlacementPosition(player); int affected = editSession.fillXZ(pos, pattern, radius, depth, false); player.print(affected + " block(s) have been created."); }
Actor sender = context.getLocals().get(Actor.class); Player player; builder.append(": ").append(context.getCommand()); if (context.argsLength() > 0) { builder.append(" ").append(context.getJoinedStrings(0));
/** * Get the unconsumed arguments left over, without touching the stack. * * @return the unconsumed arguments */ public String getUnconsumed() { if (index >= context.argsLength()) { return null; } return context.getJoinedStrings(index); }
public CommandArgs parse(String arguments) throws CommandException { CommandContext context = new CommandContext(CommandContext.split("_ " + arguments), Collections.<Character>emptySet(), false, null, false); List<String> args = Lists.newArrayList(); for (int i = 0; i < context.argsLength(); i++) { args.add(context.getString(i)); } if (isUsingHangingArguments()) { if (arguments.isEmpty() || arguments.endsWith(" ")) { args.add(""); } } return new CommandArgs(args); } }
@Command( aliases = { "/green", "green" }, usage = "[radius]", desc = "Greens the area", flags = "f", min = 0, max = 1 ) @CommandPermissions("worldedit.green") @Logging(PLACEMENT) public void green(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { final double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10; final boolean onlyNormalDirt = !args.hasFlag('f'); final int affected = editSession.green(session.getPlacementPosition(player), size, onlyNormalDirt); player.print(affected + " surfaces greened."); }
@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) : null; long endDate = args.hasFlag('t') ? InputUtil.TimeParser.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 == null ? "Banned!" : message); getBanDatabase().logKick(player, sender, message); } } getBanDatabase().ban(null, 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."); } }
int change = args.getInteger(0); if (args.argsLength() == 2) { if (args.getString(1).contains(",")) { for (String s : args.getString(1).split(",")) { dirs.add(we.getDirection(player, s.toLowerCase())); dirs.add(we.getDirection(player, args.getString(1).toLowerCase()));
public void replaceNear(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { int size = Math.max(1, args.getInteger(0)); int affected; Set<BaseBlock> from; context.setSession(session); context.setRestricted(false); context.setPreferringWildcard(!args.hasFlag('f')); if (args.argsLength() == 2) { from = null; to = we.getPatternFactory().parseFromInput(args.getString(1), context); } else { from = we.getBlockFactory().parseFromListInput(args.getString(1), context); to = we.getPatternFactory().parseFromInput(args.getString(2), context);
public void list(CommandContext args, CommandSender sender) throws CommandException { World world = null; if (getManager().isPerWorld()) { if (args.hasFlag('w')) { world = InputUtil.LocationParser.matchWorld(sender, args.getFlag('w')); } else { world = PlayerUtil.checkPlayer(sender).getWorld(); } if (world == null) throw new CommandException("Error finding world to use!"); } getListResult().display(sender, getManager().getLocations(world), args.getInteger(0, 1)); }
Player player; float walkMultiplier = 1f; if (args.argsLength() == 2) { player = InputUtil.PlayerParser.matchSinglePlayer(sender, args.getString(0)); walkMultiplier = (float) args.getDouble(1); } else if (args.argsLength() == 1) { try { walkMultiplier = (float) args.getDouble(0); player = PlayerUtil.checkPlayer(sender); } catch (NumberFormatException e) { player = InputUtil.PlayerParser.matchSinglePlayer(sender, args.getString(0));
@Command( aliases = { "/removebelow", "removebelow" }, usage = "[size] [height]", desc = "Remove blocks below you.", min = 0, max = 2 ) @CommandPermissions("worldedit.removebelow") @Logging(PLACEMENT) public void removeBelow(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1; we.checkMaxRadius(size); World world = player.getWorld(); int height = args.argsLength() > 1 ? Math.min((world.getMaxY() + 1), args.getInteger(1) + 2) : (world.getMaxY() + 1); int affected = editSession.removeBelow(session.getPlacementPosition(player), size, height); player.print(affected + " block(s) have been removed."); }
@Command(aliases = {"setwarp"}, usage = "<warp> [location]", desc = "Set a warp", min = 1, max = 2) @CommandPermissions({"commandbook.warp.set"}) public void setWarp(CommandContext args, CommandSender sender) throws CommandException { String warpName = args.getString(0); Location loc; Player player = null; if (args.argsLength() == 1) { player = PlayerUtil.checkPlayer(sender); loc = player.getLocation(); } else { loc = InputUtil.LocationParser.matchLocation(sender, args.getString(1)); if (sender instanceof Player) { player = (Player) sender; CommandBook.inst().checkPermission(sender, "commandbook.warp.set.override"); if (!sessions.getSession(UserSession.class, sender).checkOrQueueConfirmed(args.getCommand() + " " + args.getJoinedStrings(0))) { throw new CommandException("Warp already exists! Type /confirm to confirm overwriting");
public void profile(final CommandContext args, final Actor sender) throws CommandException, AuthorizationException { Predicate<ThreadInfo> threadFilter; String threadName = args.getFlag('t'); final boolean pastebin; if (args.hasFlag('p')) { sender.checkPermission("worldguard.report.pastebin"); pastebin = true; if (args.argsLength() == 0) { minutes = 5; } else { minutes = args.getInteger(0); if (minutes < 1) { throw new CommandException("You must run the profile for at least 1 minute.");
@Command( aliases = { "tree" }, usage = "[type]", desc = "Tree generator tool", min = 0, max = 1 ) @CommandPermissions("worldedit.tool.tree") public void tree(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { TreeGenerator.TreeType type = args.argsLength() > 0 ? TreeGenerator.lookup(args.getString(0)) : TreeGenerator.TreeType.TREE; if (type == null) { player.printError("Tree type '" + args.getString(0) + "' is unknown."); return; } BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); session.setTool(itemStack.getType(), new TreePlanter(type)); player.print("Tree tool bound to " + itemStack.getType().getName() + "."); }
if (args.argsLength() == 1) { loc = InputUtil.LocationParser.matchLocation(sender, args.getString(0)); // matches both #7 and #8 } else if (args.argsLength() == 2) { targets = InputUtil.PlayerParser.matchPlayers(sender, args.getString(0)); loc = InputUtil.LocationParser.matchLocation(sender, args.getString(1)); // matches both #4 and #5 if (loc.getX() == loc.getBlockX()) loc.add(0.5, 0, 0); if (loc.getZ() == loc.getBlockZ()) loc.add(0, 0, 0.5); } else if (args.argsLength() == 3) { double x = args.getDouble(0); double y = args.getDouble(1); double z = args.getDouble(2); loc = new Location((PlayerUtil.checkPlayer(sender)).getWorld(), x, y, z); if (loc.getX() == loc.getBlockX()) loc.add(0.5, 0, 0); } else if (args.argsLength() == 4) { targets = InputUtil.PlayerParser.matchPlayers(sender, args.getString(0)); // matches #1 String xArg = args.getString(1); String yArg = args.getString(2); String zArg = args.getString(3); CommandBook.inst().checkPermission(sender, "commandbook.locations.coords"); if (xArg.startsWith("~")) relative[0] = true; (new TeleportPlayerIterator(sender, loc, args.hasFlag('s'), relative)).iterate(targets);
/** * Return the arguments that were consumed between this point and that marked point. * * <p>The marked position initially starts at 0.</p> * * @return the consumed arguments */ public String getConsumed() { return context.getString(markedIndex, index); }
Calendar date = session.detectDate(args.getJoinedStrings(0));
@Command(aliases = {"unban"}, usage = "<target>", desc = "Unban a user", min = 1, max = -1) @CommandPermissions({"commandbook.bans.unban"}) public void unban(CommandContext args, CommandSender sender) throws CommandException { String message = args.argsLength() >= 2 ? args.getJoinedStrings(1) : "Unbanned!"; String banName = args.getString(0) .replace("\r", "") .replace("\n", "") .replace("\0", "") .replace("\b", ""); UUID ID = CommandBook.server().getOfflinePlayer(banName).getUniqueId(); if (getBanDatabase().unban(ID, null, sender, message) || getBanDatabase().unbanName(banName, sender, message)) { sender.sendMessage(ChatColor.YELLOW + banName + " unbanned."); if (!getBanDatabase().save()) { sender.sendMessage(ChatColor.RED + "Bans database failed to save. See console."); } } else { sender.sendMessage(ChatColor.RED + banName + " was not banned."); } }
final BlockVector3 max; final World world = player.getWorld(); if (args.hasFlag('s')) { Region region = session.getSelection(world); } else { final BlockVector2 min2D; if (args.argsLength() == 1) { String[] coords = args.getString(0).split(","); if (coords.length != 2) { throw new InsufficientArgumentsException("Invalid coordinates specified."); int z = Integer.parseInt(coords[1]); BlockVector2 pos = BlockVector2.at(x, z); min2D = (args.hasFlag('c')) ? pos : ChunkStore.toChunk(pos.toBlockVector3()); } else {