com.sk89q.worldedit.WorldEditException Java Examples

The following examples show how to use com.sk89q.worldedit.WorldEditException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SchematicCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"remap"},
        help = "Remap a clipboard between MCPE/PC values\n",
        desc = "Remap a clipboard between MCPE/PC values\n"
)
@Deprecated
@CommandPermissions({"worldedit.schematic.remap"})
public void remap(final Player player, final LocalSession session) throws WorldEditException {
    ClipboardRemapper remapper;
    if (Fawe.imp().getPlatform().equalsIgnoreCase("nukkit")) {
        remapper = new ClipboardRemapper(ClipboardRemapper.RemapPlatform.PC, ClipboardRemapper.RemapPlatform.PE);
    } else {
        remapper = new ClipboardRemapper(ClipboardRemapper.RemapPlatform.PE, ClipboardRemapper.RemapPlatform.PC);
    }

    for (Clipboard clip : session.getClipboard().getClipboards()) {
        remapper.apply(clip);
    }
    player.print(BBC.getPrefix() + "Remapped schematic");
}
 
Example #2
Source File: DefaultFloorRegenerator.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void regenerate(Floor floor, EditSession session, RegenerationCause cause) {
	Clipboard clipboard = floor.getClipboard();
	
	Region region = clipboard.getRegion();
	World world = region.getWorld();
	WorldData data = world.getWorldData();
	
	ClipboardHolder holder = new ClipboardHolder(clipboard, data);
	
	Operation pasteOperation = holder.createPaste(session, data)
			.to(region.getMinimumPoint())
			.ignoreAirBlocks(true)
			.build();
	
	try {
		Operations.complete(pasteOperation);
	} catch (WorldEditException e) {
		throw new RuntimeException(e);
	}
}
 
Example #3
Source File: MemoryCheckingExtent.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException {
    if (super.setBlock(location, block)) {
        if (MemUtil.isMemoryLimited()) {
            if (this.player != null) {
                player.sendMessage(BBC.WORLDEDIT_CANCEL_REASON.format(BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY.s()));
                if (Perm.hasPermission(this.player, "worldedit.fast")) {
                    BBC.WORLDEDIT_OOM_ADMIN.send(this.player);
                }
            }
            WEManager.IMP.cancelEdit(this, BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY);
            return false;
        }
        return true;
    }
    return false;
}
 
Example #4
Source File: ProcessedWEExtent.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
    CompoundTag nbt = block.getNbtData();
    if (nbt != null) {
        if (!limit.MAX_BLOCKSTATES()) {
            WEManager.IMP.cancelEdit(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_TILES);
            return false;
        } else {
            if (!limit.MAX_CHANGES()) {
                WEManager.IMP.cancelEdit(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
                return false;
            }
            return extent.setBlock(x, y, z, block);
        }
    }
    if (!limit.MAX_CHANGES()) {
        WEManager.IMP.cancelEdit(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
        return false;
    } else {
        return extent.setBlock(x, y, z, block);
    }
}
 
Example #5
Source File: BrushOptionsCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"primary"},
        usage = "[brush-arguments]",
        desc = "Set the right click brush",
        help = "Set the right click brush",
        min = 1
)
public void primary(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    BaseBlock item = player.getBlockInHand();
    BrushTool tool = session.getBrushTool(player, false);
    session.setTool(item, null, player);
    String cmd = "brush " + args.getJoinedStrings(0);
    CommandEvent event = new CommandEvent(player, cmd);
    CommandManager.getInstance().handleCommandOnCurrentThread(event);
    BrushTool newTool = session.getBrushTool(item, player, false);
    if (newTool != null && tool != null) {
        newTool.setSecondary(tool.getSecondary());
    }
}
 
Example #6
Source File: SelectionCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"/hpos1"},
        usage = "",
        desc = "Set position 1 to targeted block",
        min = 0,
        max = 0
)
@CommandPermissions("worldedit.selection.hpos")
public void hpos1(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    Vector pos = player.getBlockTrace(300);

    if (pos != null) {
        if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos, ActorSelectorLimits.forActor(player))) {
            BBC.SELECTOR_ALREADY_SET.send(player);
            return;
        }

        session.getRegionSelector(player.getWorld())
                .explainPrimarySelection(player, session, pos);
    } else {
        player.printError("No block in sight!");
    }
}
 
Example #7
Source File: WorldEditBinding.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets an {@link Pattern} from a {@link ArgumentStack}.
 *
 * @param context the context
 * @return a pattern
 * @throws ParameterException on error
 * @throws WorldEditException on error
 */
@BindingMatch(type = Pattern.class,
        behavior = BindingBehavior.CONSUMES,
        consumedCount = 1)
public Pattern getPattern(ArgumentStack context) throws ParameterException, WorldEditException {
    Actor actor = context.getContext().getLocals().get(Actor.class);
    ParserContext parserContext = new ParserContext();
    parserContext.setActor(context.getContext().getLocals().get(Actor.class));
    if (actor instanceof Entity) {
        Extent extent = ((Entity) actor).getExtent();
        if (extent instanceof World) {
            parserContext.setWorld((World) extent);
        }
    }
    parserContext.setSession(worldEdit.getSessionManager().get(actor));
    try {
        return worldEdit.getPatternFactory().parseFromInput(context.next(), parserContext);
    } catch (NoMatchException e) {
        throw new ParameterException(e.getMessage(), e);
    }
}
 
Example #8
Source File: SelectionCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"/hpos2"},
        usage = "",
        desc = "Set position 2 to targeted block",
        min = 0,
        max = 0
)
@CommandPermissions("worldedit.selection.hpos")
public void hpos2(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    Vector pos = player.getBlockTrace(300);

    if (pos != null) {
        if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) {
            BBC.SELECTOR_ALREADY_SET.send(player);
            return;
        }

        session.getRegionSelector(player.getWorld())
                .explainSecondarySelection(player, session, pos);
    } else {
        player.printError("No block in sight!");
    }
}
 
Example #9
Source File: BrushOptionsCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
            aliases = {"/listbrush"},
            desc = "List saved brushes",
            usage = "[mine|<filter>] [page=1]",
            min = 0,
            max = -1,
            flags = "dnp",
            help = "List all brushes in the brush directory\n" +
                    " -p <page> prints the requested page\n"
    )
    @CommandPermissions("worldedit.brush.list")
    public void list(Actor actor, CommandContext args, @Switch('p') @Optional("1") int page) throws WorldEditException {
        String baseCmd = Commands.getAlias(BrushCommands.class, "brush") + " " + Commands.getAlias(BrushOptionsCommands.class, "loadbrush");
        File dir = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes");
        UtilityCommands.list(dir, actor, args, page, null, true, baseCmd);
//                new RunnableVal2<Message, String[]>() {
//            @Override
//            public void run(Message msg, String[] info) {
//
//            }
//        });
    }
 
Example #10
Source File: WorldEditBinding.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets an {@link BaseBlock} from a {@link ArgumentStack}.
 *
 * @param context the context
 * @return a pattern
 * @throws ParameterException on error
 * @throws WorldEditException on error
 */
@BindingMatch(type = BaseBlock.class,
        behavior = BindingBehavior.CONSUMES,
        consumedCount = 1)
public BaseBlock getBaseBlock(ArgumentStack context) throws ParameterException, WorldEditException {
    Actor actor = context.getContext().getLocals().get(Actor.class);
    ParserContext parserContext = new ParserContext();
    parserContext.setActor(context.getContext().getLocals().get(Actor.class));
    if (actor instanceof Entity) {
        Extent extent = ((Entity) actor).getExtent();
        if (extent instanceof World) {
            parserContext.setWorld((World) extent);
        }
    }
    parserContext.setSession(worldEdit.getSessionManager().get(actor));
    try {
        return worldEdit.getBlockFactory().parseFromInput(context.next(), parserContext);
    } catch (NoMatchException e) {
        throw new ParameterException(e.getMessage(), e);
    }
}
 
Example #11
Source File: WorldEditCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"threads"},
        usage = "",
        desc = "Print all thread stacks",
        min = 0,
        max = 0
)
@CommandPermissions("worldedit.threads")
public void threads(Actor actor) throws WorldEditException {
    Map<Thread, StackTraceElement[]> stacks = Thread.getAllStackTraces();
    for (Map.Entry<Thread, StackTraceElement[]> entry : stacks.entrySet()) {
        Thread thread = entry.getKey();
        actor.printDebug("--------------------------------------------------------------------------------------------");
        actor.printDebug("Thread: " + thread.getName() + " | Id: " + thread.getId() + " | Alive: " + thread.isAlive());
        for (StackTraceElement elem : entry.getValue()) {
            actor.printDebug(elem.toString());
        }
    }
}
 
Example #12
Source File: SelectionCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"toggleeditwand"},
        usage = "",
        desc = "Toggle functionality of the edit wand",
        min = 0,
        max = 0
)
@CommandPermissions("worldedit.wand.toggle")
public void toggleWand(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    session.setToolControl(!session.isToolControlEnabled());

    if (session.isToolControlEnabled()) {
        BBC.SELECTION_WAND_ENABLE.m().send(player);
    } else {
        BBC.SELECTION_WAND_DISABLE.send(player);
    }
}
 
Example #13
Source File: OptionsCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"/gmask", "gmask", "globalmask", "/globalmask"},
        usage = "[mask]",
        help = "The global destination mask applies to all edits you do and masks based on the destination blocks (i.e. the blocks in the world).",
        desc = "Set the global mask",
        min = 0,
        max = -1
)
@CommandPermissions({"worldedit.global-mask", "worldedit.mask.global"})
public void gmask(Player player, LocalSession session, EditSession editSession, @Optional CommandContext context) throws WorldEditException {
    if (context == null || context.argsLength() == 0) {
        session.setMask((Mask) null);
        BBC.MASK_DISABLED.send(player);
    } else {
        ParserContext parserContext = new ParserContext();
        parserContext.setActor(player);
        parserContext.setWorld(player.getWorld());
        parserContext.setSession(session);
        parserContext.setExtent(editSession);
        Mask mask = worldEdit.getMaskFactory().parseFromInput(context.getJoinedStrings(0), parserContext);
        session.setMask(mask);
        BBC.MASK.send(player);
    }
}
 
Example #14
Source File: FloodFillTool.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
    World world = (World) clicked.getExtent();

    int initialType = world.getBlockType(clicked.toVector());

    if (initialType == BlockID.AIR) {
        return true;
    }

    if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
        return true;
    }

    EditSession editSession = session.createEditSession(player);

    try {
        recurse(server, editSession, world, clicked.toVector().toBlockVector(),
                clicked.toVector(), range, initialType, new HashSet<BlockVector>());
    } catch (WorldEditException e) {
        throw new RuntimeException(e);
    }
    editSession.flushQueue();
    session.remember(editSession);
    return true;
}
 
Example #15
Source File: MCAWorld.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean clearContainerBlockContents(Vector position) {
    BaseBlock block = extent.getLazyBlock(position);
    if (block.hasNbtData()) {
        Map<String, Tag> nbt = ReflectionUtils.getMap(block.getNbtData().getValue());
        if (nbt.containsKey("Items")) {
            nbt.put("Items", new ListTag(CompoundTag.class, new ArrayList<CompoundTag>()));
            try {
                extent.setBlock(position, block);
            } catch (WorldEditException e) {
                e.printStackTrace();
            }
        }
    }
    return true;
}
 
Example #16
Source File: VisualExtent.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
    BaseBlock previous = super.getLazyBlock(x, y, z);
    int cx = x >> 4;
    int cz = z >> 4;
    long chunkPair = MathMan.pairInt(cx, cz);
    VisualChunk chunk = chunks.get(chunkPair);
    if (previous.equals(block)) {
        if (chunk != null) {
            chunk.unset(x, y, z);
        }
        return false;
    } else {
        if (chunk == null) {
            chunk = new VisualChunk(cx, cz);
            chunks.put(chunkPair, chunk);
        }
        chunk.setBlock(x, y, z, block.getId(), block.getData());
        return true;
    }
}
 
Example #17
Source File: BrushOptionsCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"secondary"},
        usage = "[brush-arguments]",
        desc = "Set the left click brush",
        help = "Set the left click brush",
        min = 1
)
public void secondary(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    BaseBlock item = player.getBlockInHand();
    BrushTool tool = session.getBrushTool(player, false);
    session.setTool(item, null, player);
    String cmd = "brush " + args.getJoinedStrings(0);
    CommandEvent event = new CommandEvent(player, cmd);
    CommandManager.getInstance().handleCommandOnCurrentThread(event);
    BrushTool newTool = session.getBrushTool(item, player, false);
    if (newTool != null && tool != null) {
        newTool.setPrimary(tool.getPrimary());
    }
}
 
Example #18
Source File: BrushOptionsCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"scroll"},
        usage = "[none|clipboard|mask|pattern|range|size|visual|target|targetoffset]",
        desc = "Toggle between different target modes",
        min = 1,
        max = -1
)
public void scroll(Player player, EditSession editSession, LocalSession session, @Optional @Switch('h') boolean offHand, CommandContext args) throws WorldEditException {
    BrushTool bt = session.getBrushTool(player, false);
    if (bt == null) {
        BBC.BRUSH_NONE.send(player);
        return;
    }
    BrushSettings settings = offHand ? bt.getOffHand() : bt.getContext();
    ScrollAction action = ScrollAction.fromArguments(bt, player, session, args.getJoinedStrings(0), true);
    settings.setScrollAction(action);
    if (args.getString(0).equalsIgnoreCase("none")) {
        BBC.BRUSH_SCROLL_ACTION_UNSET.send(player);
    } else if (action != null) {
        String full = args.getJoinedStrings(0);
        settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, full);
        BBC.BRUSH_SCROLL_ACTION_SET.send(player, full);
    }
    bt.update();
}
 
Example #19
Source File: WorldEditBinding.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets an {@link Mask} from a {@link ArgumentStack}.
 *
 * @param context the context
 * @return a pattern
 * @throws ParameterException on error
 * @throws WorldEditException on error
 */
@BindingMatch(type = Mask.class,
        behavior = BindingBehavior.CONSUMES,
        consumedCount = 1)
public Mask getMask(ArgumentStack context) throws ParameterException, WorldEditException {
    Actor actor = context.getContext().getLocals().get(Actor.class);
    ParserContext parserContext = new ParserContext();
    parserContext.setActor(context.getContext().getLocals().get(Actor.class));
    if (actor instanceof Entity) {
        Extent extent = ((Entity) actor).getExtent();
        if (extent instanceof World) {
            parserContext.setWorld((World) extent);
        }
    }
    parserContext.setSession(worldEdit.getSessionManager().get(actor));
    try {
        return worldEdit.getMaskFactory().parseFromInput(context.next(), parserContext);
    } catch (NoMatchException e) {
        throw new ParameterException(e.getMessage(), e);
    }
}
 
Example #20
Source File: NavigationCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"descend", "desc"},
        usage = "[# of floors]",
        desc = "Go down a floor",
        min = 0,
        max = 1
)
@CommandPermissions("worldedit.navigation.descend")
public void descend(Player player, @Optional("1") int levelsToDescend) throws WorldEditException {
    int descentLevels = 0;
    while (player.descendLevel()) {
        ++descentLevels;
        if (levelsToDescend == descentLevels) {
            break;
        }
    }
    if (descentLevels == 0) {
        BBC.DESCEND_FAIL.send(player);
    } else {
        if (descentLevels == 1) {
            BBC.DESCEND_SINGULAR.send(player);
        } else {
            BBC.DESCEND_PLURAL.send(player, descentLevels);
        }
    }
}
 
Example #21
Source File: WorldEditCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"update"},
        usage = "",
        desc = "Update the plugin",
        min = 0,
        max = 0
)
public void update(FawePlayer fp) throws WorldEditException {
    if (Fawe.get().getUpdater().installUpdate(fp)) {
        TaskManager.IMP.sync(() -> {
            fp.executeCommand("restart");
            return null;
        });
        fp.sendMessage(BBC.getPrefix() + "Please restart to finish installing the update");
    } else {
        fp.sendMessage(BBC.getPrefix() + "No update is pending");
    }
}
 
Example #22
Source File: NavigationCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"up"},
        usage = "<number>",
        desc = "Go upwards some distance",
        flags = "fg",
        min = 1,
        max = 1
)
@CommandPermissions("worldedit.navigation.up")
@Logging(POSITION)
public void up(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    final int distance = args.getInteger(0);

    final boolean alwaysGlass = getAlwaysGlass(args);
    if (player.ascendUpwards(distance, alwaysGlass)) {
        BBC.WHOOSH.send(player);
    } else {
        BBC.UP_FAIL.send(player);
    }
}
 
Example #23
Source File: MutableEntityChange.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void undo(UndoContext context) throws WorldEditException {
    if (!create) {
        create(context);
    } else {
        delete(context);
    }
}
 
Example #24
Source File: WorldWrapper.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean queueBlockBreakEffect(Platform server, Vector position, int blockId, double priority) {
    try {
        return setBlock(position, EditSession.nullBlock, true);
    } catch (WorldEditException e) {
        e.printStackTrace();
        return false;
    }
}
 
Example #25
Source File: RegionMaskTestFunction.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean apply(Vector position) throws WorldEditException {
    if (mask.test(position)) {
        return pass.apply(position);
    } else {
        return fail.apply(position);
    }
}
 
Example #26
Source File: ToolCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Command(
        aliases = {"repl"},
        usage = "<block>",
        desc = "Block replacer tool",
        min = 1,
        max = 1
)
@CommandPermissions("worldedit.tool.replacer")
public void repl(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    BaseBlock targetBlock = we.getBlock(player, args.getString(0));
    session.setTool(new BlockReplacer(targetBlock), player);
    BBC.TOOL_REPL.send(player, ItemType.toHeldName(player.getItemInHand()));
}
 
Example #27
Source File: NavigationCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Command(
        aliases = {"jumpto", "j"},
        usage = "[world,x,y,z]",
        desc = "Teleport to a location" +
        		"Flags:\n" + 
        		"  -f forces the specified position to be used",
        flags = "f",
        min = 0,
        max = 1
)
@CommandPermissions("worldedit.navigation.jumpto.command")
public void jumpTo(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    WorldVector pos;
    if (args.argsLength() == 1) {
        String arg = args.getString(0);
        String[] split = arg.split(",");
        World world = FaweAPI.getWorld(split[0]);
        if (world != null && split.length == 4 && MathMan.isInteger(split[1]) && MathMan.isInteger(split[2]) && MathMan.isInteger(split[3])) {
            pos = new WorldVector((LocalWorld) world, Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]));
        } else {
            BBC.SELECTOR_INVALID_COORDINATES.send(player, args.getString(0));
            return;
        }
    } else {
        pos = player.getSolidBlockTrace(300);
    }
    if (pos != null) {
        if(args.hasFlag('f')) player.setPosition(pos); else player.findFreePosition(pos);
        BBC.POOF.send(player);
    } else {
        BBC.NO_BLOCK.send(player);
    }
}
 
Example #28
Source File: ToolCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Command(
        aliases = {"farwand"},
        usage = "",
        desc = "Wand at a distance tool",
        min = 0,
        max = 0
)
@CommandPermissions("worldedit.tool.farwand")
public void farwand(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    session.setTool(new DistanceWand(), player);
    BBC.TOOL_FARWAND.send(player, ItemType.toHeldName(player.getItemInHand()));
}
 
Example #29
Source File: MaskedFaweQueue.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
    if (region.contains(x, y, z)) {
        return super.setBlock(x, y, z, block);
    }
    return false;
}
 
Example #30
Source File: OptionsCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Command(
        aliases = {"/fast"},
        usage = "[on|off]",
        desc = "Toggles FAWE undo",
        min = 0,
        max = 1
)
@CommandPermissions("worldedit.fast")
public void fast(Player player, LocalSession session, CommandContext args) throws WorldEditException {

    String newState = args.getString(0, null);
    if (session.hasFastMode()) {
        if ("on".equals(newState)) {
            BBC.FAST_ENABLED.send(player);
            return;
        }

        session.setFastMode(false);
        BBC.FAST_DISABLED.send(player);
    } else {
        if ("off".equals(newState)) {
            BBC.FAST_DISABLED.send(player);
            return;
        }

        session.setFastMode(true);
        BBC.FAST_ENABLED.send(player);
    }
}