Search in sources :

Example 11 with BrushTool

use of com.sk89q.worldedit.command.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.

the class BrushCommands method saveBrush.

@Command(name = "savebrush", aliases = { "save" }, desc = "Save your current brush")
@CommandPermissions("worldedit.brush.save")
public void saveBrush(Player player, LocalSession session, @Arg(desc = "String name") String name, @Switch(name = 'g', desc = "Save the brush globally") boolean root) throws WorldEditException, IOException {
    BrushTool tool = session.getBrushTool(player);
    if (tool != null) {
        root |= name.startsWith("../");
        name = FileSystems.getDefault().getPath(name).getFileName().toString();
        File folder = MainUtil.getFile(Fawe.platform().getDirectory(), "brushes");
        name = name.endsWith(".jsgz") ? name : name + ".jsgz";
        File file;
        if (root && player.hasPermission("worldedit.brush.save.other")) {
            file = new File(folder, name);
        } else {
            file = new File(folder, player.getUniqueId() + File.separator + name);
        }
        File parent = file.getParentFile();
        if (!parent.exists()) {
            parent.mkdirs();
        }
        file.createNewFile();
        try (DataOutputStream out = new DataOutputStream(new ParallelGZIPOutputStream(new FileOutputStream(file)))) {
            out.writeUTF(tool.toString());
        } catch (Throwable e) {
            e.printStackTrace();
        }
        player.print(Caption.of("fawe.worldedit.schematic.schematic.saved", name));
    } else {
        player.print(Caption.of("fawe.worldedit.brush.brush.none"));
    }
}
Also used : BrushTool(com.sk89q.worldedit.command.tool.BrushTool) ParallelGZIPOutputStream(org.anarres.parallelgzip.ParallelGZIPOutputStream) DataOutputStream(java.io.DataOutputStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File) ScatterCommand(com.fastasyncworldedit.core.command.tool.brush.ScatterCommand) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 12 with BrushTool

use of com.sk89q.worldedit.command.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.

the class BrushCommands method set.

public BrushSettings set(InjectedValueAccess context, Brush brush, String permission) throws InvalidToolBindException {
    Player player = context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"));
    LocalSession session = player.getSession();
    BrushSettings bs = new BrushSettings();
    BrushTool tool = session.getBrushTool(player, false);
    if (tool != null) {
        BrushSettings currentContext = tool.getContext();
        if (currentContext != null) {
            Brush currentBrush = currentContext.getBrush();
            if (currentBrush != null && currentBrush.getClass() == brush.getClass()) {
                bs = currentContext;
            }
        }
    }
    Arguments arguments = context.injectedValue(Key.of(Arguments.class)).orElse(null);
    if (arguments != null) {
        String args = arguments.get();
        bs.addSetting(BrushSettings.SettingType.BRUSH, args.substring(args.indexOf(' ') + 1));
    }
    bs.addPermission(permission);
    bs.setBrush(brush);
    return process(player, arguments, bs);
}
Also used : BrushTool(com.sk89q.worldedit.command.tool.BrushTool) Player(com.sk89q.worldedit.entity.Player) LocalSession(com.sk89q.worldedit.LocalSession) Arguments(com.sk89q.worldedit.command.argument.Arguments) BrushSettings(com.fastasyncworldedit.core.command.tool.brush.BrushSettings) 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)

Example 13 with BrushTool

use of com.sk89q.worldedit.command.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.

the class ToolUtilCommands method transform.

@Command(name = "transform", aliases = { "/transform" }, desc = "Set the brush transform")
@CommandPermissions({ "worldedit.brush.options.transform", "worldedit.transform.brush" })
public void transform(Player player, LocalSession session, EditSession editSession, @Arg(desc = "The transform", def = "") ResettableExtent transform, @Switch(name = 'h', desc = "Whether the offhand should be considered or not") boolean offHand, Arguments arguments) throws WorldEditException {
    BrushTool tool = session.getBrushTool(player, false);
    if (tool == null) {
        player.print(Caption.of("fawe.worldedit.brush.brush.none"));
        return;
    }
    if (transform == null) {
        player.print(Caption.of("fawe.worldedit.brush.brush.transform.disabled"));
        tool.setTransform(null);
        return;
    }
    BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
    String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
    settings.addSetting(BrushSettings.SettingType.TRANSFORM, lastArg);
    settings.setTransform(transform);
    tool.update();
    player.print(Caption.of("fawe.worldedit.brush.brush.transform"));
}
Also used : BrushTool(com.sk89q.worldedit.command.tool.BrushTool) BrushSettings(com.fastasyncworldedit.core.command.tool.brush.BrushSettings) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 14 with BrushTool

use of com.sk89q.worldedit.command.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.

the class ToolUtilCommands method mask.

// FAWE start - destination mask > mask
@Command(name = "mask", aliases = "/mask", desc = "Set the brush destination mask")
@CommandPermissions({ "worldedit.brush.options.mask", "worldedit.mask.brush" })
public void mask(Player player, LocalSession session, @Switch(name = 'h', desc = "Whether the offhand should be considered or not") boolean offHand, @Arg(desc = "The destination mask", def = "") Mask maskOpt, Arguments arguments) throws WorldEditException {
    BrushTool tool = session.getBrushTool(player, false);
    if (tool == null) {
        player.print(Caption.of("fawe.worldedit.brush.brush.none"));
        return;
    }
    if (maskOpt == null) {
        player.print(Caption.of("worldedit.tool.mask.disabled"));
        tool.setMask(null);
    } else {
        BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
        String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
        settings.addSetting(BrushSettings.SettingType.MASK, lastArg);
        settings.setMask(maskOpt);
        tool.update();
        player.print(Caption.of("worldedit.tool.mask.set"));
    }
}
Also used : BrushTool(com.sk89q.worldedit.command.tool.BrushTool) BrushSettings(com.fastasyncworldedit.core.command.tool.brush.BrushSettings) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 15 with BrushTool

use of com.sk89q.worldedit.command.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.

the class ToolUtilCommands method target.

@Command(name = "target", aliases = { "tar", "/target", "/tar" }, desc = "Toggle between different target modes")
@CommandPermissions("worldedit.brush.target")
public void target(Player player, LocalSession session, @Arg(name = "mode", desc = "int", def = "0") int mode) throws WorldEditException {
    BrushTool tool = session.getBrushTool(player, false);
    if (tool == null) {
        player.print(Caption.of("fawe.worldedit.brush.brush.none"));
        return;
    }
    TargetMode[] modes = TargetMode.values();
    TargetMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)];
    tool.setTargetMode(newMode);
    player.print(Caption.of("fawe.worldedit.brush.brush.target.mode.set", newMode));
}
Also used : BrushTool(com.sk89q.worldedit.command.tool.BrushTool) TargetMode(com.fastasyncworldedit.core.command.tool.TargetMode) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

BrushTool (com.sk89q.worldedit.command.tool.BrushTool)17 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)10 Command (org.enginehub.piston.annotation.Command)10 BrushSettings (com.fastasyncworldedit.core.command.tool.brush.BrushSettings)6 LocalSession (com.sk89q.worldedit.LocalSession)3 OperationFactoryBrush (com.sk89q.worldedit.command.tool.brush.OperationFactoryBrush)3 BaseItem (com.sk89q.worldedit.blocks.BaseItem)2 TargetMode (com.fastasyncworldedit.core.command.tool.TargetMode)1 BlobBrush (com.fastasyncworldedit.core.command.tool.brush.BlobBrush)1 CatenaryBrush (com.fastasyncworldedit.core.command.tool.brush.CatenaryBrush)1 CircleBrush (com.fastasyncworldedit.core.command.tool.brush.CircleBrush)1 CommandBrush (com.fastasyncworldedit.core.command.tool.brush.CommandBrush)1 CopyPastaBrush (com.fastasyncworldedit.core.command.tool.brush.CopyPastaBrush)1 ErodeBrush (com.fastasyncworldedit.core.command.tool.brush.ErodeBrush)1 FlattenBrush (com.fastasyncworldedit.core.command.tool.brush.FlattenBrush)1 HeightBrush (com.fastasyncworldedit.core.command.tool.brush.HeightBrush)1 ImageBrush (com.fastasyncworldedit.core.command.tool.brush.ImageBrush)1 LayerBrush (com.fastasyncworldedit.core.command.tool.brush.LayerBrush)1 LineBrush (com.fastasyncworldedit.core.command.tool.brush.LineBrush)1 RaiseBrush (com.fastasyncworldedit.core.command.tool.brush.RaiseBrush)1