Search in sources :

Example 36 with CommandPermissions

use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.

the class HistoryCommands method undo.

@Command(name = "undo", aliases = { "/undo" }, desc = "Undoes the last action (from history)")
@CommandPermissions({ "worldedit.history.undo", "worldedit.history.undo.self" })
public void undo(Actor actor, LocalSession session, @Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of undoes to perform", def = "1") int times, @Arg(name = "player", desc = "Undo this player's operations", def = "") String playerName) throws WorldEditException {
    times = Math.max(1, times);
    LocalSession undoSession = session;
    // FAWE start - Add fastmode check
    if (session.hasFastMode()) {
        actor.print(Caption.of("fawe.worldedit.history.command.undo.disabled"));
        return;
    }
    // FAWE end
    if (playerName != null) {
        actor.checkPermission("worldedit.history.undo.other");
        undoSession = worldEdit.getSessionManager().findByName(playerName);
        if (undoSession == null) {
            actor.print(Caption.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
            return;
        }
    }
    int timesUndone = 0;
    for (int i = 0; i < times; ++i) {
        BlockBag blockBag = actor instanceof Player ? undoSession.getBlockBag((Player) actor) : null;
        EditSession undone = undoSession.undo(blockBag, actor);
        if (undone != null) {
            timesUndone++;
            worldEdit.flushBlockBag(actor, undone);
        } else {
            break;
        }
    }
    if (timesUndone > 0) {
        actor.print(Caption.of("worldedit.undo.undone", TextComponent.of(timesUndone)));
    } else {
        actor.print(Caption.of("worldedit.undo.none"));
    }
}
Also used : Player(com.sk89q.worldedit.entity.Player) BlockBag(com.sk89q.worldedit.extent.inventory.BlockBag) LocalSession(com.sk89q.worldedit.LocalSession) EditSession(com.sk89q.worldedit.EditSession) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 37 with CommandPermissions

use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.

the class HistoryCommands method redo.

@Command(name = "redo", aliases = { "/redo" }, desc = "Redoes the last action (from history)")
@CommandPermissions({ "worldedit.history.redo", "worldedit.history.redo.self" })
public void redo(Actor actor, LocalSession session, @Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of redoes to perform", def = "1") int times, @Arg(name = "player", desc = "Redo this player's operations", def = "") String playerName) throws WorldEditException {
    times = Math.max(1, times);
    LocalSession redoSession = session;
    if (playerName != null) {
        actor.checkPermission("worldedit.history.redo.other");
        redoSession = worldEdit.getSessionManager().findByName(playerName);
        if (redoSession == null) {
            actor.print(Caption.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
            return;
        }
    }
    int timesRedone = 0;
    for (int i = 0; i < times; ++i) {
        BlockBag blockBag = actor instanceof Player ? redoSession.getBlockBag((Player) actor) : null;
        EditSession redone = redoSession.redo(blockBag, actor);
        if (redone != null) {
            timesRedone++;
            worldEdit.flushBlockBag(actor, redone);
        } else {
            break;
        }
    }
    if (timesRedone > 0) {
        actor.print(Caption.of("worldedit.redo.redone", TextComponent.of(timesRedone)));
    } else {
        actor.print(Caption.of("worldedit.redo.none"));
    }
}
Also used : Player(com.sk89q.worldedit.entity.Player) BlockBag(com.sk89q.worldedit.extent.inventory.BlockBag) LocalSession(com.sk89q.worldedit.LocalSession) EditSession(com.sk89q.worldedit.EditSession) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 38 with CommandPermissions

use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.

the class BiomeCommands method biomeList.

@Command(name = "biomelist", aliases = { "biomels", "/biomelist", "/listbiomes" }, desc = "Gets all biomes available.")
@CommandPermissions("worldedit.biome.list")
public void biomeList(Actor actor, @ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) {
    WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
        BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
        PaginationBox paginationBox = PaginationBox.fromComponents("Available Biomes", "/biomelist -p %page%", BiomeType.REGISTRY.values().stream().map(biomeType -> TextComponent.builder().append(biomeType.getId()).append(" (").append(biomeRegistry.getRichName(biomeType)).append(")").build()).collect(Collectors.toList()));
        return paginationBox.create(page);
    }, (Component) null);
}
Also used : BiomeRegistry(com.sk89q.worldedit.world.registry.BiomeRegistry) PaginationBox(com.sk89q.worldedit.util.formatting.component.PaginationBox) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 39 with CommandPermissions

use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.

the class BrushCommands method cylinderBrush.

@Command(name = "cylinder", aliases = { "cyl", "c" }, desc = "Choose the cylinder brush")
@CommandPermissions("worldedit.brush.cylinder")
public void cylinderBrush(InjectedValueAccess context, @Arg(desc = "The pattern of blocks to set") Pattern pattern, @Arg(desc = "The radius of the cylinder", def = "2") Expression radius, @Arg(desc = "The height of the cylinder", def = "1") int height, // FAWE start - hcyl thickness
@Arg(desc = "The thickness of the cylinder. Requires -h switch be given. 0 creates a standard hollow cylinder.", def = "0") double thickness, // FAWE end
@Switch(name = 'h', desc = "Create hollow cylinders instead") boolean hollow) throws WorldEditException {
    worldEdit.checkMaxBrushRadius(radius);
    worldEdit.checkMaxBrushRadius(height);
    BrushSettings settings;
    if (hollow) {
        // FAWE start - hcyl thickness
        settings = set(context, new HollowCylinderBrush(height, thickness), "worldedit.brush.cylinder");
    // FAWE end
    } else {
        settings = set(context, new CylinderBrush(height), "worldedit.brush.cylinder");
    }
    settings.setSize(radius).setFill(pattern);
}
Also used : CylinderBrush(com.sk89q.worldedit.command.tool.brush.CylinderBrush) HollowCylinderBrush(com.sk89q.worldedit.command.tool.brush.HollowCylinderBrush) BrushSettings(com.fastasyncworldedit.core.command.tool.brush.BrushSettings) HollowCylinderBrush(com.sk89q.worldedit.command.tool.brush.HollowCylinderBrush) ScatterCommand(com.fastasyncworldedit.core.command.tool.brush.ScatterCommand) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 40 with CommandPermissions

use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.

the class BrushCommands method blobBrush.

@Command(name = "rock", aliases = { "blob" }, desc = "Creates a distorted sphere")
@CommandPermissions("worldedit.brush.rock")
public void blobBrush(InjectedValueAccess context, @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "radii to multiply x,y,z by", def = "10") Vector3 radius, @Arg(name = "roundness", desc = "roundness", def = "100") double sphericity, @Arg(desc = "double", def = "30") double frequency, @Arg(desc = "double", def = "50") double amplitude) throws WorldEditException {
    double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ());
    worldEdit.checkMaxBrushRadius(max);
    Brush brush = new BlobBrush(radius.divide(max), frequency / 100, amplitude / 100, sphericity / 100);
    set(context, brush, "worldedit.brush.rock").setSize(max).setFill(fill);
}
Also used : BlobBrush(com.fastasyncworldedit.core.command.tool.brush.BlobBrush) HollowSphereBrush(com.sk89q.worldedit.command.tool.brush.HollowSphereBrush) HeightBrush(com.fastasyncworldedit.core.command.tool.brush.HeightBrush) SphereBrush(com.sk89q.worldedit.command.tool.brush.SphereBrush) ScatterBrush(com.fastasyncworldedit.core.command.tool.brush.ScatterBrush) CopyPastaBrush(com.fastasyncworldedit.core.command.tool.brush.CopyPastaBrush) RaiseBrush(com.fastasyncworldedit.core.command.tool.brush.RaiseBrush) SnowSmoothBrush(com.sk89q.worldedit.command.tool.brush.SnowSmoothBrush) ClipboardBrush(com.sk89q.worldedit.command.tool.brush.ClipboardBrush) GravityBrush(com.sk89q.worldedit.command.tool.brush.GravityBrush) FlattenBrush(com.fastasyncworldedit.core.command.tool.brush.FlattenBrush) BlobBrush(com.fastasyncworldedit.core.command.tool.brush.BlobBrush) SweepBrush(com.fastasyncworldedit.core.command.tool.sweep.SweepBrush) CircleBrush(com.fastasyncworldedit.core.command.tool.brush.CircleBrush) SplatterBrush(com.fastasyncworldedit.core.command.tool.brush.SplatterBrush) CatenaryBrush(com.fastasyncworldedit.core.command.tool.brush.CatenaryBrush) RecurseBrush(com.fastasyncworldedit.core.command.tool.brush.RecurseBrush) CylinderBrush(com.sk89q.worldedit.command.tool.brush.CylinderBrush) ScatterOverlayBrush(com.fastasyncworldedit.core.command.tool.brush.ScatterOverlayBrush) StencilBrush(com.fastasyncworldedit.core.command.tool.brush.StencilBrush) LineBrush(com.fastasyncworldedit.core.command.tool.brush.LineBrush) Brush(com.sk89q.worldedit.command.tool.brush.Brush) ButcherBrush(com.sk89q.worldedit.command.tool.brush.ButcherBrush) ErodeBrush(com.fastasyncworldedit.core.command.tool.brush.ErodeBrush) SurfaceSphereBrush(com.fastasyncworldedit.core.command.tool.brush.SurfaceSphereBrush) SplineBrush(com.fastasyncworldedit.core.command.tool.brush.SplineBrush) HollowCylinderBrush(com.sk89q.worldedit.command.tool.brush.HollowCylinderBrush) SmoothBrush(com.sk89q.worldedit.command.tool.brush.SmoothBrush) LayerBrush(com.fastasyncworldedit.core.command.tool.brush.LayerBrush) CommandBrush(com.fastasyncworldedit.core.command.tool.brush.CommandBrush) ImageBrush(com.fastasyncworldedit.core.command.tool.brush.ImageBrush) ShatterBrush(com.fastasyncworldedit.core.command.tool.brush.ShatterBrush) OperationFactoryBrush(com.sk89q.worldedit.command.tool.brush.OperationFactoryBrush) ScatterCommand(com.fastasyncworldedit.core.command.tool.brush.ScatterCommand) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)133 Command (org.enginehub.piston.annotation.Command)133 Logging (com.sk89q.worldedit.command.util.Logging)47 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)34 ScatterCommand (com.fastasyncworldedit.core.command.tool.brush.ScatterCommand)25 Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)22 LocalConfiguration (com.sk89q.worldedit.LocalConfiguration)20 Region (com.sk89q.worldedit.regions.Region)19 Preload (com.sk89q.worldedit.command.util.annotation.Preload)17 File (java.io.File)17 ClipboardHolder (com.sk89q.worldedit.session.ClipboardHolder)16 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)15 MultiClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder)14 MaskTraverser (com.fastasyncworldedit.core.util.MaskTraverser)13 Mask (com.sk89q.worldedit.function.mask.Mask)11 IOException (java.io.IOException)11 BrushTool (com.sk89q.worldedit.command.tool.BrushTool)10 Player (com.sk89q.worldedit.entity.Player)10 Clipboard (com.sk89q.worldedit.extent.clipboard.Clipboard)10 Location (com.sk89q.worldedit.util.Location)10