protected void checkPermission(T player, Method method) throws CommandException { if (!hasPermission(method, player)) { throw new CommandPermissionsException(); } }
/** * 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); }
/** * 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); }
@Command( aliases = { "/hpyramid" }, usage = "<block> <size>", desc = "Generate a hollow pyramid", min = 2, max = 2 ) @CommandPermissions("worldedit.generation.pyramid") @Logging(PLACEMENT) public void hollowPyramid(Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size) throws WorldEditException { pyramid(player, session, editSession, pattern, size, true); }
@Command( aliases = { "/help" }, usage = "[<command>]", desc = "Displays help for WorldEdit commands", min = 0, max = -1 ) @CommandPermissions("worldedit.help") public void help(Actor actor, CommandContext args) throws WorldEditException { help(args, we, actor); }
@Override public void markConsumed() { index = context.argsLength(); }
/** * Register an class that contains commands (denoted by {@link Command}. * If no dependency injector is specified, then the methods of the * class will be registered to be called statically. Otherwise, new * instances will be created of the command classes and methods will * not be called statically. * * @param cls the class to register */ public void register(Class<?> cls) { registerMethods(cls, null); }
@Override public String toString() { return forFlag() ? ("-" + getFlag()) : (forHangingValue() ? "hanging" : "last"); }
public static SuggestionContext flag(Character flag) { return new SuggestionContext(flag, false); }
/** * Create a new instance using the given context. * * @param context the context * @param arguments an argument string to be parsed * @param nonNullBoolean true to have {@link #nextBoolean()} return false instead of null */ public StringArgumentStack( CommandContext context, String arguments, boolean nonNullBoolean) { this.context = context; this.arguments = CommandContext.split(arguments); this.nonNullBoolean = nonNullBoolean; }
@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 void faces(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException { int affected = editSession.makeCuboidFaces(region, pattern); player.print(affected + " block(s) have been changed."); }
@Command( aliases = { "help" }, usage = "[<command>]", desc = "Displays help for WorldEdit commands", min = 0, max = -1 ) @CommandPermissions("worldedit.help") public void help(Actor actor, CommandContext args) throws WorldEditException { UtilityCommands.help(args, we, actor); } }
/** * Reset to the previously {@link #mark()}ed position of the stack, and return * the arguments that were consumed between this point and that previous point. * * <p>The marked position initially starts at 0.</p> * * @return the consumed arguments */ public String reset() { String value = context.getString(markedIndex, index); index = markedIndex; return value; }
/** * Register an class that contains commands (denoted by {@link Command}. * If no dependency injector is specified, then the methods of the * class will be registered to be called statically. Otherwise, new * instances will be created of the command classes and methods will * not be called statically. A List of {@link Command} annotations from * registered commands is returned. * * @param cls the class to register * @return A List of {@link Command} annotations from registered commands, * for use in eg. a dynamic command registration system. */ public List<Command> registerAndReturn(Class<?> cls) { return registerMethods(cls, null); }
@Command( aliases = { "/naturalize" }, usage = "", desc = "3 layers of dirt on top then rock below", min = 0, max = 0 ) @CommandPermissions("worldedit.region.naturalize") @Logging(REGION) public void naturalize(Player player, EditSession editSession, @Selection Region region) throws WorldEditException { int affected = editSession.naturalizeCuboidBlocks(region); player.print(affected + " block(s) have been made to look more natural."); }
@Command( aliases = { "unstuck", "!" }, usage = "", desc = "Escape from being stuck inside a block", min = 0, max = 0 ) @CommandPermissions("worldedit.navigation.unstuck") public void unstuck(Player player) throws WorldEditException { player.print("There you go!"); player.findFreePosition(); }
@Command( aliases = { "/walls" }, usage = "<block>", desc = "Build the four sides of the selection", min = 1, max = 1 ) @CommandPermissions("worldedit.region.walls") @Logging(REGION) public void walls(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException { int affected = editSession.makeWalls(region, pattern); player.print(affected + " block(s) have been changed."); }
@Command( aliases = { "/clearhistory", "clearhistory" }, usage = "", desc = "Clear your history", min = 0, max = 0 ) @CommandPermissions("worldedit.history.clear") public void clearHistory(Player player, LocalSession session, EditSession editSession) throws WorldEditException { session.clearHistory(); player.print("History cleared."); }
@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 void overlay(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException { int affected = editSession.overlayCuboidBlocks(region, pattern); player.print(affected + " block(s) have been overlaid."); }
@Command( aliases = { "thru" }, usage = "", desc = "Passthrough walls", min = 0, max = 0 ) @CommandPermissions("worldedit.navigation.thru.command") public void thru(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { if (player.passThroughForwardWall(6)) { player.print("Whoosh!"); } else { player.printError("No free spot ahead of you found."); } }