mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
update adapter and platform manager
This commit is contained in:
@ -72,6 +72,28 @@ public class ApplyBrushCommands {
|
||||
.ofTypes(ImmutableList.of(Key.of(double.class)))
|
||||
.build();
|
||||
|
||||
public static void register(CommandManagerService service, CommandManager commandManager, CommandRegistrationHandler registration) {
|
||||
commandManager.register("apply", builder -> {
|
||||
builder.description(TextComponent.of("Apply brush, apply a function to every block"));
|
||||
builder.action(org.enginehub.piston.Command.Action.NULL_ACTION);
|
||||
|
||||
CommandManager manager = service.newCommandManager();
|
||||
registration.register(
|
||||
manager,
|
||||
ApplyBrushCommandsRegistration.builder(),
|
||||
new ApplyBrushCommands()
|
||||
);
|
||||
|
||||
builder.condition(new PermissionCondition(ImmutableSet.of("worldedit.brush.apply")));
|
||||
|
||||
builder.addParts(REGION_FACTORY, RADIUS);
|
||||
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TextComponent.of("Type of brush to use"))
|
||||
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
|
||||
.required()
|
||||
.build());
|
||||
});
|
||||
}
|
||||
|
||||
private void setApplyBrush(CommandParameters parameters, Player player, LocalSession localSession,
|
||||
Contextual<? extends RegionFunction> generatorFactory) throws WorldEditException {
|
||||
double radius = requireNonNull(RADIUS.value(parameters).asSingle(double.class));
|
||||
|
@ -56,7 +56,9 @@ import com.boydti.fawe.object.brush.heightmap.ScalableHeightMap;
|
||||
import com.boydti.fawe.object.brush.heightmap.ScalableHeightMap.Shape;
|
||||
import com.boydti.fawe.object.brush.sweep.SweepBrush;
|
||||
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
||||
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
||||
import com.boydti.fawe.object.mask.IdMask;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.boydti.fawe.util.image.ImageUtil;
|
||||
@ -67,6 +69,7 @@ import com.sk89q.worldedit.EmptyClipboardException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.command.factory.TreeGeneratorFactory;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
||||
@ -112,13 +115,19 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
@ -930,6 +939,91 @@ public class BrushCommands {
|
||||
new Deform("y+=1"), shape, "worldedit.brush.lower");
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "savebrush",
|
||||
aliases = {"save"},
|
||||
desc = "Save your current brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.save")
|
||||
public void saveBrush(Player player, LocalSession session, 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.imp().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 PGZIPOutputStream(new FileOutputStream(file)))) {
|
||||
out.writeUTF(tool.toString());
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
BBC.SCHEMATIC_SAVED.send(player, name);
|
||||
} else {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "loadbrush",
|
||||
aliases = {"load"},
|
||||
desc = "Load a brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.load")
|
||||
public void loadBrush(Player player, LocalSession session, String name)
|
||||
throws WorldEditException, IOException {
|
||||
name = FileSystems.getDefault().getPath(name).getFileName().toString();
|
||||
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes");
|
||||
name = name.endsWith(".jsgz") ? name : name + ".jsgz";
|
||||
File file = new File(folder, player.getUniqueId() + File.separator + name);
|
||||
if (!file.exists()) {
|
||||
file = new File(folder, name);
|
||||
}
|
||||
if (!file.exists()) {
|
||||
File[] files = folder.listFiles(pathname -> false);
|
||||
BBC.BRUSH_NOT_FOUND.send(player, name);
|
||||
return;
|
||||
}
|
||||
try (DataInputStream in = new DataInputStream(
|
||||
new GZIPInputStream(new FileInputStream(file)))) {
|
||||
String json = in.readUTF();
|
||||
BrushTool tool = BrushTool.fromString(player, session, json);
|
||||
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(item, tool, player);
|
||||
BBC.BRUSH_EQUIPPED.send(player, name);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
BBC.BRUSH_INCOMPATIBLE.send(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/listbrush",
|
||||
desc = "List saved brushes",
|
||||
descFooter = "List all brushes in the brush directory"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.list")
|
||||
public void list(Actor actor, InjectedValueAccess args,
|
||||
@ArgFlag(name = 'p', desc = "Prints the requested page", def = "0")
|
||||
int page) throws WorldEditException {
|
||||
String baseCmd = "/brush loadbrush";
|
||||
File dir = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes");
|
||||
// TODO NOT IMPLEMENTED
|
||||
// UtilityCommands.list(dir, actor, args, page, null, true, baseCmd);
|
||||
}
|
||||
|
||||
static void setOperationBasedBrush(Player player, LocalSession session, Expression radius,
|
||||
Contextual<? extends Operation> factory,
|
||||
RegionFactory shape,
|
||||
|
@ -1,491 +0,0 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.brush.BrushSettings;
|
||||
import com.boydti.fawe.object.brush.TargetMode;
|
||||
import com.boydti.fawe.object.brush.scroll.ScrollAction;
|
||||
import com.boydti.fawe.object.brush.visualization.VisualMode;
|
||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.command.argument.Arguments;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.annotation.Range;
|
||||
import com.sk89q.worldedit.internal.command.CommandArgParser;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
|
||||
/**
|
||||
* Tool commands.
|
||||
*/
|
||||
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class BrushOptionsCommands {
|
||||
|
||||
private WorldEdit worldEdit;
|
||||
|
||||
public BrushOptionsCommands(WorldEdit worldEdit) {
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "savebrush",
|
||||
aliases = {"save"},
|
||||
desc = "Save your current brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.save")
|
||||
public void saveBrush(Player player, LocalSession session, 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.imp().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 PGZIPOutputStream(new FileOutputStream(file)))) {
|
||||
out.writeUTF(tool.toString());
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
BBC.SCHEMATIC_SAVED.send(player, name);
|
||||
} else {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "loadbrush",
|
||||
aliases = {"load"},
|
||||
desc = "Load a brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.load")
|
||||
public void loadBrush(Player player, LocalSession session, String name)
|
||||
throws WorldEditException, IOException {
|
||||
name = FileSystems.getDefault().getPath(name).getFileName().toString();
|
||||
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes");
|
||||
name = name.endsWith(".jsgz") ? name : name + ".jsgz";
|
||||
File file = new File(folder, player.getUniqueId() + File.separator + name);
|
||||
if (!file.exists()) {
|
||||
file = new File(folder, name);
|
||||
}
|
||||
if (!file.exists()) {
|
||||
File[] files = folder.listFiles(pathname -> false);
|
||||
BBC.BRUSH_NOT_FOUND.send(player, name);
|
||||
return;
|
||||
}
|
||||
try (DataInputStream in = new DataInputStream(
|
||||
new GZIPInputStream(new FileInputStream(file)))) {
|
||||
String json = in.readUTF();
|
||||
BrushTool tool = BrushTool.fromString(player, session, json);
|
||||
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(item, tool, player);
|
||||
BBC.BRUSH_EQUIPPED.send(player, name);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
BBC.BRUSH_INCOMPATIBLE.send(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/listbrush",
|
||||
desc = "List saved brushes",
|
||||
descFooter = "List all brushes in the brush directory"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.list")
|
||||
public void list(Actor actor, InjectedValueAccess args,
|
||||
@ArgFlag(name = 'p', desc = "Prints the requested page", def = "0")
|
||||
int page) throws WorldEditException {
|
||||
String baseCmd = "/brush loadbrush";
|
||||
File dir = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes");
|
||||
// TODO NOT IMPLEMENTED
|
||||
// UtilityCommands.list(dir, actor, args, page, null, true, baseCmd);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "none",
|
||||
aliases = {"/none"},
|
||||
desc = "Unbind a bound tool from your current item"
|
||||
)
|
||||
public void none(Player player, LocalSession session) throws WorldEditException {
|
||||
session.setTool(player, null);
|
||||
BBC.TOOL_NONE.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/",
|
||||
aliases = {","},
|
||||
desc = "Toggle the super pickaxe function"
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe")
|
||||
public void togglePickaxe(Player player, LocalSession session,
|
||||
@Arg(desc = "state", def = "on") String state) throws WorldEditException {
|
||||
if (session.hasSuperPickAxe()) {
|
||||
if ("on".equals(state)) {
|
||||
BBC.SUPERPICKAXE_ENABLED.send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
session.disableSuperPickAxe();
|
||||
BBC.SUPERPICKAXE_DISABLED.send(player);
|
||||
} else {
|
||||
if ("off".equals(state)) {
|
||||
|
||||
BBC.SUPERPICKAXE_DISABLED.send(player);
|
||||
return;
|
||||
}
|
||||
session.enableSuperPickAxe();
|
||||
BBC.SUPERPICKAXE_ENABLED.send(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "primary",
|
||||
desc = "Set the right click brush",
|
||||
descFooter = "Set the right click brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.primary")
|
||||
public void primary(Player player, LocalSession session,
|
||||
@Arg(desc = "The brush command", variable = true) List<String> commandStr) throws WorldEditException {
|
||||
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
session.setTool(item, null, player);
|
||||
String cmd = "brush " + StringMan.join(commandStr, " ");
|
||||
CommandEvent event = new CommandEvent(player, cmd);
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
BrushTool newTool = session.getBrushTool(item, player, false);
|
||||
if (newTool != null && tool != null) {
|
||||
newTool.setSecondary(tool.getSecondary());
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "secondary",
|
||||
desc = "Set the left click brush",
|
||||
descFooter = "Set the left click brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.secondary")
|
||||
public void secondary(Player player, LocalSession session,
|
||||
@Arg(desc = "The brush command", variable = true) List<String> commandStr)
|
||||
throws WorldEditException {
|
||||
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
session.setTool(item, null, player);
|
||||
String cmd = "brush " + StringMan.join(commandStr, " ");
|
||||
CommandEvent event = new CommandEvent(player, cmd);
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
BrushTool newTool = session.getBrushTool(item, player, false);
|
||||
if (newTool != null && tool != null) {
|
||||
newTool.setPrimary(tool.getPrimary());
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "visualize",
|
||||
aliases = {"visual", "vis"},
|
||||
desc = "Toggle between different visualization modes",
|
||||
descFooter = "Toggle between different visualization modes\n" +
|
||||
"0 = No visualization\n" +
|
||||
"1 = Single block at target position\n" +
|
||||
"2 = Glass showing what blocks will be changed"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.visualize")
|
||||
public void visual(Player player, LocalSession session, @Arg(name = "mode", desc = "int", def = "0") @Range(min = 0, max = 2) int mode)
|
||||
throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
return;
|
||||
}
|
||||
VisualMode[] modes = VisualMode.values();
|
||||
VisualMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)];
|
||||
tool.setVisualMode(player, newMode);
|
||||
BBC.BRUSH_VISUAL_MODE_SET.send(player, newMode);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "target",
|
||||
aliases = {"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) {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
return;
|
||||
}
|
||||
TargetMode[] modes = TargetMode.values();
|
||||
TargetMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)];
|
||||
tool.setTargetMode(newMode);
|
||||
BBC.BRUSH_TARGET_MODE_SET.send(player, newMode);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "targetmask",
|
||||
aliases = {"tarmask", "tm"},
|
||||
desc = "Set the targeting mask"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.targetmask")
|
||||
public void targetMask(Player player, EditSession editSession, LocalSession session, @Arg(desc = "The destination mask", def = "") Mask maskOpt) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
return;
|
||||
}
|
||||
tool.setTraceMask(maskOpt);
|
||||
BBC.BRUSH_TARGET_MASK_SET.send(player, maskOpt.toString());
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "targetoffset",
|
||||
aliases = {"to"},
|
||||
desc = "Set the targeting mask"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.targetoffset")
|
||||
public void targetOffset(Player player, EditSession editSession, LocalSession session,
|
||||
int offset) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
return;
|
||||
}
|
||||
tool.setTargetOffset(offset);
|
||||
BBC.BRUSH_TARGET_OFFSET_SET.send(player, offset);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "scroll",
|
||||
desc = "Toggle between different target modes"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.scroll")
|
||||
public void scroll(Player player, EditSession editSession, LocalSession session,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
@Arg(desc = "Target Modes")
|
||||
String modes,
|
||||
@Arg(desc = "The scroll action", variable = true)
|
||||
List<String> commandStr) throws WorldEditException {
|
||||
// TODO NOT IMPLEMENTED Convert ScrollAction to an argument converter
|
||||
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, StringMan.join(commandStr, " "), true);
|
||||
settings.setScrollAction(action);
|
||||
if (modes.equalsIgnoreCase("none")) {
|
||||
BBC.BRUSH_SCROLL_ACTION_UNSET.send(player);
|
||||
} else if (action != null) {
|
||||
settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, modes);
|
||||
BBC.BRUSH_SCROLL_ACTION_SET.send(player, modes);
|
||||
}
|
||||
bt.update();
|
||||
}
|
||||
|
||||
@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, EditSession editSession,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
@Arg(desc = "The destination mask", def = "")
|
||||
Mask maskArg,
|
||||
Arguments arguments)
|
||||
throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
if (maskArg == null) {
|
||||
BBC.BRUSH_MASK_DISABLED.send(player);
|
||||
tool.setMask(null);
|
||||
return;
|
||||
}
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
||||
System.out.println(lastArg + " TODO check this is not the whole command");
|
||||
settings.addSetting(BrushSettings.SettingType.MASK, lastArg);
|
||||
settings.setMask(maskArg);
|
||||
tool.update();
|
||||
BBC.BRUSH_MASK.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "smask",
|
||||
aliases = {"/smask", "/sourcemask", "sourcemask"},
|
||||
desc = "Set the brush source mask",
|
||||
descFooter = "Set the brush source mask"
|
||||
)
|
||||
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
|
||||
public void smask(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The destination mask", def = "")
|
||||
Mask maskArg,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
if (maskArg == null) {
|
||||
BBC.BRUSH_SOURCE_MASK_DISABLED.send(player);
|
||||
tool.setSourceMask(null);
|
||||
return;
|
||||
}
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
||||
settings.addSetting(BrushSettings.SettingType.SOURCE_MASK, lastArg);
|
||||
settings.setSourceMask(maskArg);
|
||||
tool.update();
|
||||
BBC.BRUSH_SOURCE_MASK.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "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 = "TODO")
|
||||
boolean offHand,
|
||||
Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
if (transform == null) {
|
||||
BBC.BRUSH_TRANSFORM_DISABLED.send(player);
|
||||
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();
|
||||
BBC.BRUSH_TRANSFORM.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "mat",
|
||||
aliases = {"material"},
|
||||
desc = "Set the brush material"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.material")
|
||||
public void material(Player player, EditSession editSession, LocalSession session,
|
||||
@Arg(desc = "brush material pattern", def = "") Pattern patternOpt,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
if (patternOpt == null) {
|
||||
BBC.BRUSH_MATERIAL.send(player);
|
||||
tool.setFill(null);
|
||||
return;
|
||||
}
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
settings.setFill(patternOpt);
|
||||
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
||||
settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
|
||||
tool.update();
|
||||
BBC.BRUSH_MATERIAL.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "range",
|
||||
desc = "Set the brush range"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.range")
|
||||
public void range(Player player, LocalSession session,
|
||||
@Arg(desc = "Range")
|
||||
int range) throws WorldEditException {
|
||||
range = Math.max(0, Math.min(256, range));
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
tool.setRange(range);
|
||||
BBC.BRUSH_RANGE.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "size",
|
||||
desc = "Set the brush size"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.size")
|
||||
public void size(Player player, LocalSession session,
|
||||
@Arg(desc = "The size of the brush", def = "5")
|
||||
int radius,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
settings.setSize(radius);
|
||||
tool.update();
|
||||
BBC.BRUSH_SIZE.send(player);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,448 +1,448 @@
|
||||
//package com.sk89q.worldedit.command;
|
||||
//
|
||||
//import com.boydti.fawe.object.mask.AdjacentAnyMask;
|
||||
//import com.boydti.fawe.object.mask.AdjacentMask;
|
||||
//import com.boydti.fawe.object.mask.AngleMask;
|
||||
//import com.boydti.fawe.object.mask.BiomeMask;
|
||||
//import com.boydti.fawe.object.mask.BlockLightMask;
|
||||
//import com.boydti.fawe.object.mask.BrightnessMask;
|
||||
//import com.boydti.fawe.object.mask.DataMask;
|
||||
//import com.boydti.fawe.object.mask.ExtremaMask;
|
||||
//import com.boydti.fawe.object.mask.IdDataMask;
|
||||
//import com.boydti.fawe.object.mask.IdMask;
|
||||
//import com.boydti.fawe.object.mask.LightMask;
|
||||
//import com.boydti.fawe.object.mask.OpacityMask;
|
||||
//import com.boydti.fawe.object.mask.ROCAngleMask;
|
||||
//import com.boydti.fawe.object.mask.RadiusMask;
|
||||
//import com.boydti.fawe.object.mask.RandomMask;
|
||||
//import com.boydti.fawe.object.mask.SimplexMask;
|
||||
//import com.boydti.fawe.object.mask.SkyLightMask;
|
||||
//import com.boydti.fawe.object.mask.SurfaceMask;
|
||||
//import com.boydti.fawe.object.mask.WallMask;
|
||||
//import com.boydti.fawe.object.mask.XAxisMask;
|
||||
//import com.boydti.fawe.object.mask.YAxisMask;
|
||||
//import com.boydti.fawe.object.mask.ZAxisMask;
|
||||
//import com.sk89q.worldedit.IncompleteRegionException;
|
||||
//import com.sk89q.worldedit.LocalSession;
|
||||
//import com.sk89q.worldedit.WorldEdit;
|
||||
//import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
//import com.sk89q.worldedit.entity.Player;
|
||||
//import com.sk89q.worldedit.extent.Extent;
|
||||
//import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
//import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
//import com.sk89q.worldedit.function.mask.ExpressionMask;
|
||||
//import com.sk89q.worldedit.function.mask.Mask;
|
||||
//import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
//import com.sk89q.worldedit.function.mask.MaskUnion;
|
||||
//import com.sk89q.worldedit.function.mask.Masks;
|
||||
//import com.sk89q.worldedit.function.mask.OffsetMask;
|
||||
//import com.sk89q.worldedit.function.mask.RegionMask;
|
||||
//import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||
//import com.sk89q.worldedit.internal.expression.Expression;
|
||||
//import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
//import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
|
||||
//import com.sk89q.worldedit.math.BlockVector3;
|
||||
//import com.sk89q.worldedit.math.Vector3;
|
||||
//import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
//import com.sk89q.worldedit.session.request.RequestSelection;
|
||||
//import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
//import org.enginehub.piston.annotation.Command;
|
||||
//import org.enginehub.piston.annotation.CommandContainer;
|
||||
//import org.enginehub.piston.annotation.param.Arg;
|
||||
//import org.enginehub.piston.annotation.param.Switch;
|
||||
//
|
||||
////@Command(aliases = {"masks"},
|
||||
//// desc = "Help for the various masks. [More Info](https://git.io/v9r4K)",
|
||||
//// descFooter = "Masks determine if a block can be placed\n" +
|
||||
//// " - Use [brackets] for arguments\n" +
|
||||
//// " - Use , to OR multiple\n" +
|
||||
//// " - Use & to AND multiple\n" +
|
||||
//// "e.g. >[stone,dirt],#light[0][5],$jungle\n" +
|
||||
//// "More Info: https://git.io/v9r4K"
|
||||
////)
|
||||
//@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
//public class MaskCommands {
|
||||
// private final WorldEdit worldEdit;
|
||||
//
|
||||
// public MaskCommands(WorldEdit worldEdit) {
|
||||
// this.worldEdit = worldEdit;
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#simplex",
|
||||
// desc = "Use simplex noise as the mask"
|
||||
// )
|
||||
// public Mask simplex(double scale, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// scale = 1d / Math.max(1, scale);
|
||||
// minInt = (minInt - 50) / 50;
|
||||
// maxInt = (maxInt - 50) / 50;
|
||||
// return new SimplexMask(scale, minInt, maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#light",
|
||||
// desc = "Restrict to specific light levels"
|
||||
// )
|
||||
// public Mask light(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// return new LightMask(extent, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#false",
|
||||
// desc = "Always false"
|
||||
// )
|
||||
// public Mask falseMask(Extent extent) {
|
||||
// return Masks.alwaysFalse();
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#true",
|
||||
// desc = "Always true"
|
||||
// )
|
||||
// public Mask trueMask(Extent extent) {
|
||||
// return Masks.alwaysTrue();
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#skylight",
|
||||
// desc = "Restrict to specific sky light levels"
|
||||
// )
|
||||
// public Mask skylight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// return new SkyLightMask(extent, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#blocklight",
|
||||
// aliases = {"#emittedlight"},
|
||||
// desc = "Restrict to specific block light levels"
|
||||
// )
|
||||
// public Mask blocklight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// return new BlockLightMask(extent, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#opacity",
|
||||
// desc = "Restrict to specific opacity levels"
|
||||
// )
|
||||
// public Mask opacity(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// return new OpacityMask(extent, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#brightness",
|
||||
// desc = "Restrict to specific block brightness"
|
||||
// )
|
||||
// public Mask brightness(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// return new BrightnessMask(extent, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#offset",
|
||||
// desc = "Offset a mask"
|
||||
// )
|
||||
// public Mask offset(double x, double y, double z, Mask mask) {
|
||||
// return new OffsetMask(mask, BlockVector3.at(x, y, z));
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#haslight",
|
||||
// desc = "Restricts to blocks with light (sky or emitted)"
|
||||
// )
|
||||
// public Mask haslight(Extent extent) {
|
||||
// return new LightMask(extent, 1, Integer.MAX_VALUE);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#nolight",
|
||||
// desc = "Restrict to blocks without light (sky or emitted)"
|
||||
// )
|
||||
// public Mask nolight(Extent extent) {
|
||||
// return new LightMask(extent, 0, 0);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#existing",
|
||||
// desc = "If there is a non air block"
|
||||
// )
|
||||
// public Mask existing(Extent extent) {
|
||||
// return new ExistingBlockMask(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#solid",
|
||||
// desc = "If there is a solid block"
|
||||
// )
|
||||
// public Mask solid(Extent extent) {
|
||||
// return new SolidBlockMask(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#liquid",
|
||||
// desc = "If there is a solid block"
|
||||
// )
|
||||
// public Mask liquid(Extent extent) {
|
||||
// return new BlockMaskBuilder().addAll(b -> b.getMaterial().isLiquid()).build(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#dregion",
|
||||
// aliases = {"#dselection", "#dsel"},
|
||||
// desc = "inside the player's selection"
|
||||
// )
|
||||
// public Mask dregion() {
|
||||
// return new RegionMask(new RequestSelection());
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#region",
|
||||
// aliases = {"#selection", "#sel"},
|
||||
// desc = "inside the provided selection"
|
||||
// )
|
||||
// public Mask selection(Player player, LocalSession session) throws IncompleteRegionException {
|
||||
// return new RegionMask(session.getSelection(player.getWorld()).clone());
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#xaxis",
|
||||
// desc = "Restrict to initial x axis"
|
||||
// )
|
||||
// public Mask xaxis() {
|
||||
// return new XAxisMask();
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#yaxis",
|
||||
// desc = "Restrict to initial y axis"
|
||||
// )
|
||||
// public Mask yaxis() {
|
||||
// return new YAxisMask();
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#zaxis",
|
||||
// desc = "Restrict to initial z axis"
|
||||
// )
|
||||
// public Mask zaxis() {
|
||||
// return new ZAxisMask();
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#id",
|
||||
// desc = "Restrict to initial id"
|
||||
// )
|
||||
// public Mask id(Extent extent) {
|
||||
// return new IdMask(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#data",
|
||||
// desc = "Restrict to initial data"
|
||||
// )
|
||||
// public Mask data(Extent extent) {
|
||||
// return new DataMask(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#iddata",
|
||||
// desc = "Restrict to initial block id and data"
|
||||
// )
|
||||
// public Mask iddata(Extent extent) {
|
||||
// return new IdDataMask(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#air",
|
||||
// desc = "Restrict to types of air"
|
||||
// )
|
||||
// public Mask air(Extent extent) {
|
||||
// return new BlockMaskBuilder().addAll(b -> b.getMaterial().isAir()).build(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#wall",
|
||||
// desc = "Restrict to walls (any block n,e,s,w of air)"
|
||||
// )
|
||||
// public Mask wall(Extent extent) {
|
||||
// Mask blockMask = air(extent);
|
||||
// return new MaskUnion(new ExistingBlockMask(extent), new WallMask(blockMask, 1, 8));
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#surface",
|
||||
// desc = "Restrict to surfaces (any solid block touching air)"
|
||||
// )
|
||||
// public Mask surface(Extent extent) {
|
||||
// return new SurfaceMask(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "\\",
|
||||
// aliases = {"/", "#angle", "#\\", "#/"},
|
||||
// desc = "Restrict to specific terrain angle",
|
||||
// descFooter = "Restrict to specific terrain angle\n" +
|
||||
// "The -o flag will only overlay\n" +
|
||||
// "Example: /[0d][45d]\n" +
|
||||
// "Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" +
|
||||
// "Example: /[3][20]\n" +
|
||||
// "Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below"
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.object.mask.AdjacentAnyMask;
|
||||
import com.boydti.fawe.object.mask.AdjacentMask;
|
||||
import com.boydti.fawe.object.mask.AngleMask;
|
||||
import com.boydti.fawe.object.mask.BiomeMask;
|
||||
import com.boydti.fawe.object.mask.BlockLightMask;
|
||||
import com.boydti.fawe.object.mask.BrightnessMask;
|
||||
import com.boydti.fawe.object.mask.DataMask;
|
||||
import com.boydti.fawe.object.mask.ExtremaMask;
|
||||
import com.boydti.fawe.object.mask.IdDataMask;
|
||||
import com.boydti.fawe.object.mask.IdMask;
|
||||
import com.boydti.fawe.object.mask.LightMask;
|
||||
import com.boydti.fawe.object.mask.OpacityMask;
|
||||
import com.boydti.fawe.object.mask.ROCAngleMask;
|
||||
import com.boydti.fawe.object.mask.RadiusMask;
|
||||
import com.boydti.fawe.object.mask.RandomMask;
|
||||
import com.boydti.fawe.object.mask.SimplexMask;
|
||||
import com.boydti.fawe.object.mask.SkyLightMask;
|
||||
import com.boydti.fawe.object.mask.SurfaceMask;
|
||||
import com.boydti.fawe.object.mask.WallMask;
|
||||
import com.boydti.fawe.object.mask.XAxisMask;
|
||||
import com.boydti.fawe.object.mask.YAxisMask;
|
||||
import com.boydti.fawe.object.mask.ZAxisMask;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.ExpressionMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.function.mask.MaskUnion;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.mask.OffsetMask;
|
||||
import com.sk89q.worldedit.function.mask.RegionMask;
|
||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
import com.sk89q.worldedit.session.request.RequestSelection;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
//@Command(aliases = {"masks"},
|
||||
// desc = "Help for the various masks. [More Info](https://git.io/v9r4K)",
|
||||
// descFooter = "Masks determine if a block can be placed\n" +
|
||||
// " - Use [brackets] for arguments\n" +
|
||||
// " - Use , to OR multiple\n" +
|
||||
// " - Use & to AND multiple\n" +
|
||||
// "e.g. >[stone,dirt],#light[0][5],$jungle\n" +
|
||||
// "More Info: https://git.io/v9r4K"
|
||||
//)
|
||||
// public Mask angle(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) throws ExpressionException {
|
||||
// double y1, y2;
|
||||
// boolean override;
|
||||
// if (maxStr.endsWith("d")) {
|
||||
// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||
// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||
// y1 = Math.tan(y1d * (Math.PI / 180));
|
||||
// y2 = Math.tan(y2d * (Math.PI / 180));
|
||||
// } else {
|
||||
// y1 = Expression.compile(minStr).evaluate();
|
||||
// y2 = Expression.compile(maxStr).evaluate();
|
||||
// }
|
||||
// return new AngleMask(extent, y1, y2, overlay, distanceOpt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "(",
|
||||
// aliases = {")", "#roc", "#(", "#)"},
|
||||
// desc = "Restrict to near specific terrain slope rate of change",
|
||||
// descFooter = "Restrict to near specific terrain slope rate of change\n" +
|
||||
// "The -o flag will only overlay\n" +
|
||||
// "Example: ([0d][45d][5]\n" +
|
||||
// "Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" +
|
||||
// "Note: Use negatives for decreasing slope"
|
||||
//)
|
||||
// public Mask roc(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
|
||||
// double y1, y2;
|
||||
// boolean override;
|
||||
// if (maxStr.endsWith("d")) {
|
||||
// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||
// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||
// y1 = Math.tan(y1d * (Math.PI / 180));
|
||||
// y2 = Math.tan(y2d * (Math.PI / 180));
|
||||
// } else {
|
||||
// y1 = Expression.compile(minStr).evaluate();
|
||||
// y2 = Expression.compile(maxStr).evaluate();
|
||||
// }
|
||||
// return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "^",
|
||||
// aliases = {"#extrema", "#^"},
|
||||
// desc = "Restrict to near specific terrain extrema",
|
||||
// descFooter = "Restrict to near specific terrain extrema\n" +
|
||||
// "The -o flag will only overlay\n" +
|
||||
// "Example: ([0d][45d][5]\n" +
|
||||
// "Explanation: Restrict to near 45 degrees of local maxima\n" +
|
||||
// "Note: Use negatives for local minima"
|
||||
//)
|
||||
// public Mask extrema(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
|
||||
// double y1, y2;
|
||||
// boolean override;
|
||||
// if (maxStr.endsWith("d")) {
|
||||
// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||
// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||
// y1 = Math.tan(y1d * (Math.PI / 180));
|
||||
// y2 = Math.tan(y2d * (Math.PI / 180));
|
||||
// } else {
|
||||
// y1 = Expression.compile(minStr).evaluate();
|
||||
// y2 = Expression.compile(maxStr).evaluate();
|
||||
// }
|
||||
// return new ExtremaMask(extent, y1, y2, overlay, distanceOpt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "{",
|
||||
// aliases = {"#{"},
|
||||
// desc = "Restricts blocks to within a specific radius range of the initial block"
|
||||
//)
|
||||
// public Mask radius(@Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
|
||||
// return new RadiusMask((int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "|",
|
||||
// aliases = {"#|", "#side"},
|
||||
// desc = "sides with a specific number of other blocks"
|
||||
//)
|
||||
// public Mask wall(Mask mask, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
|
||||
// return new WallMask(mask, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "~",
|
||||
// aliases = {"#~", "#adjacent"},
|
||||
// desc = "Adjacent to a specific number of other blocks"
|
||||
//)
|
||||
// public Mask adjacent(Mask mask, @Arg(name = "min", desc = "double", def = "-1") double min, @Arg(name = "max", desc = "double", def = "-1") double max) throws ExpressionException {
|
||||
// if (min == -1 && max == -1) {
|
||||
// min = 1;
|
||||
// max = 8;
|
||||
// } else if (max == -1) max = min;
|
||||
// if (max >= 8 && min == 1) {
|
||||
// return new AdjacentAnyMask(mask);
|
||||
// }
|
||||
// return new AdjacentMask(mask, (int) min, (int) max);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "<",
|
||||
// aliases = {"#<", "#below"},
|
||||
// desc = "below a specific block"
|
||||
//)
|
||||
// public Mask below(Mask mask) throws ExpressionException {
|
||||
// OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, 1, 0));
|
||||
// return new MaskIntersection(offsetMask, Masks.negate(mask));
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = ">",
|
||||
// aliases = {"#>", "#above"},
|
||||
// desc = "above a specific block"
|
||||
//)
|
||||
// public Mask above(Mask mask) throws ExpressionException {
|
||||
// OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, -1, 0));
|
||||
// return new MaskIntersection(offsetMask, Masks.negate(mask));
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "$",
|
||||
// aliases = {"#biome", "#$"},
|
||||
// desc = "in a specific biome",
|
||||
// descFooter = "in a specific biome. For a list of biomes use //biomelist"
|
||||
//)
|
||||
// public Mask biome(Extent extent, BiomeType biome) throws ExpressionException {
|
||||
// return new BiomeMask(extent, biome);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "%",
|
||||
// aliases = {"#%", "#percent"},
|
||||
// desc = "percentage chance"
|
||||
//)
|
||||
// public Mask random(double chance) throws ExpressionException {
|
||||
// chance = chance / 100;
|
||||
// return new RandomMask(chance);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "=",
|
||||
// aliases = {"#=", "#expression"},
|
||||
// desc = "expression mask"
|
||||
//)
|
||||
// public Mask expression(Extent extent, String input) throws ExpressionException {
|
||||
// Expression exp = Expression.compile(input, "x", "y", "z");
|
||||
// ExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
|
||||
// exp.setEnvironment(env);
|
||||
// return new ExpressionMask(exp);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "!",
|
||||
// aliases = {"#not", "#negate", "#!"},
|
||||
// desc = "Negate another mask"
|
||||
//)
|
||||
// public Mask expression(Mask mask) throws ExpressionException {
|
||||
// return Masks.negate(mask);
|
||||
// }
|
||||
//}
|
||||
@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class MaskCommands {
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
public MaskCommands(WorldEdit worldEdit) {
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#simplex",
|
||||
desc = "Use simplex noise as the mask"
|
||||
)
|
||||
public Mask simplex(double scale, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
scale = 1d / Math.max(1, scale);
|
||||
minInt = (minInt - 50) / 50;
|
||||
maxInt = (maxInt - 50) / 50;
|
||||
return new SimplexMask(scale, minInt, maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#light",
|
||||
desc = "Restrict to specific light levels"
|
||||
)
|
||||
public Mask light(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
return new LightMask(extent, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#false",
|
||||
desc = "Always false"
|
||||
)
|
||||
public Mask falseMask(Extent extent) {
|
||||
return Masks.alwaysFalse();
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#true",
|
||||
desc = "Always true"
|
||||
)
|
||||
public Mask trueMask(Extent extent) {
|
||||
return Masks.alwaysTrue();
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#skylight",
|
||||
desc = "Restrict to specific sky light levels"
|
||||
)
|
||||
public Mask skylight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
return new SkyLightMask(extent, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#blocklight",
|
||||
aliases = {"#emittedlight"},
|
||||
desc = "Restrict to specific block light levels"
|
||||
)
|
||||
public Mask blocklight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
return new BlockLightMask(extent, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#opacity",
|
||||
desc = "Restrict to specific opacity levels"
|
||||
)
|
||||
public Mask opacity(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
return new OpacityMask(extent, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#brightness",
|
||||
desc = "Restrict to specific block brightness"
|
||||
)
|
||||
public Mask brightness(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
return new BrightnessMask(extent, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#offset",
|
||||
desc = "Offset a mask"
|
||||
)
|
||||
public Mask offset(double x, double y, double z, Mask mask) {
|
||||
return new OffsetMask(mask, BlockVector3.at(x, y, z));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#haslight",
|
||||
desc = "Restricts to blocks with light (sky or emitted)"
|
||||
)
|
||||
public Mask haslight(Extent extent) {
|
||||
return new LightMask(extent, 1, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#nolight",
|
||||
desc = "Restrict to blocks without light (sky or emitted)"
|
||||
)
|
||||
public Mask nolight(Extent extent) {
|
||||
return new LightMask(extent, 0, 0);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#existing",
|
||||
desc = "If there is a non air block"
|
||||
)
|
||||
public Mask existing(Extent extent) {
|
||||
return new ExistingBlockMask(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#solid",
|
||||
desc = "If there is a solid block"
|
||||
)
|
||||
public Mask solid(Extent extent) {
|
||||
return new SolidBlockMask(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#liquid",
|
||||
desc = "If there is a solid block"
|
||||
)
|
||||
public Mask liquid(Extent extent) {
|
||||
return new BlockMaskBuilder().addAll(b -> b.getMaterial().isLiquid()).build(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#dregion",
|
||||
aliases = {"#dselection", "#dsel"},
|
||||
desc = "inside the player's selection"
|
||||
)
|
||||
public Mask dregion() {
|
||||
return new RegionMask(new RequestSelection());
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#region",
|
||||
aliases = {"#selection", "#sel"},
|
||||
desc = "inside the provided selection"
|
||||
)
|
||||
public Mask selection(Player player, LocalSession session) throws IncompleteRegionException {
|
||||
return new RegionMask(session.getSelection(player.getWorld()).clone());
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#xaxis",
|
||||
desc = "Restrict to initial x axis"
|
||||
)
|
||||
public Mask xaxis() {
|
||||
return new XAxisMask();
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#yaxis",
|
||||
desc = "Restrict to initial y axis"
|
||||
)
|
||||
public Mask yaxis() {
|
||||
return new YAxisMask();
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#zaxis",
|
||||
desc = "Restrict to initial z axis"
|
||||
)
|
||||
public Mask zaxis() {
|
||||
return new ZAxisMask();
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#id",
|
||||
desc = "Restrict to initial id"
|
||||
)
|
||||
public Mask id(Extent extent) {
|
||||
return new IdMask(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#data",
|
||||
desc = "Restrict to initial data"
|
||||
)
|
||||
public Mask data(Extent extent) {
|
||||
return new DataMask(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#iddata",
|
||||
desc = "Restrict to initial block id and data"
|
||||
)
|
||||
public Mask iddata(Extent extent) {
|
||||
return new IdDataMask(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#air",
|
||||
desc = "Restrict to types of air"
|
||||
)
|
||||
public Mask air(Extent extent) {
|
||||
return new BlockMaskBuilder().addAll(b -> b.getMaterial().isAir()).build(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#wall",
|
||||
desc = "Restrict to walls (any block n,e,s,w of air)"
|
||||
)
|
||||
public Mask wall(Extent extent) {
|
||||
Mask blockMask = air(extent);
|
||||
return new MaskUnion(new ExistingBlockMask(extent), new WallMask(blockMask, 1, 8));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#surface",
|
||||
desc = "Restrict to surfaces (any solid block touching air)"
|
||||
)
|
||||
public Mask surface(Extent extent) {
|
||||
return new SurfaceMask(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "\\",
|
||||
aliases = {"/", "#angle", "#\\", "#/"},
|
||||
desc = "Restrict to specific terrain angle",
|
||||
descFooter = "Restrict to specific terrain angle\n" +
|
||||
"The -o flag will only overlay\n" +
|
||||
"Example: /[0d][45d]\n" +
|
||||
"Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" +
|
||||
"Example: /[3][20]\n" +
|
||||
"Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below"
|
||||
)
|
||||
public Mask angle(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) throws ExpressionException {
|
||||
double y1, y2;
|
||||
boolean override;
|
||||
if (maxStr.endsWith("d")) {
|
||||
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||
y1 = Math.tan(y1d * (Math.PI / 180));
|
||||
y2 = Math.tan(y2d * (Math.PI / 180));
|
||||
} else {
|
||||
y1 = Expression.compile(minStr).evaluate();
|
||||
y2 = Expression.compile(maxStr).evaluate();
|
||||
}
|
||||
return new AngleMask(extent, y1, y2, overlay, distanceOpt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "(",
|
||||
aliases = {")", "#roc", "#(", "#)"},
|
||||
desc = "Restrict to near specific terrain slope rate of change",
|
||||
descFooter = "Restrict to near specific terrain slope rate of change\n" +
|
||||
"The -o flag will only overlay\n" +
|
||||
"Example: ([0d][45d][5]\n" +
|
||||
"Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" +
|
||||
"Note: Use negatives for decreasing slope"
|
||||
)
|
||||
public Mask roc(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
|
||||
double y1, y2;
|
||||
boolean override;
|
||||
if (maxStr.endsWith("d")) {
|
||||
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||
y1 = Math.tan(y1d * (Math.PI / 180));
|
||||
y2 = Math.tan(y2d * (Math.PI / 180));
|
||||
} else {
|
||||
y1 = Expression.compile(minStr).evaluate();
|
||||
y2 = Expression.compile(maxStr).evaluate();
|
||||
}
|
||||
return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "^",
|
||||
aliases = {"#extrema", "#^"},
|
||||
desc = "Restrict to near specific terrain extrema",
|
||||
descFooter = "Restrict to near specific terrain extrema\n" +
|
||||
"The -o flag will only overlay\n" +
|
||||
"Example: ([0d][45d][5]\n" +
|
||||
"Explanation: Restrict to near 45 degrees of local maxima\n" +
|
||||
"Note: Use negatives for local minima"
|
||||
)
|
||||
public Mask extrema(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
|
||||
double y1, y2;
|
||||
boolean override;
|
||||
if (maxStr.endsWith("d")) {
|
||||
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||
y1 = Math.tan(y1d * (Math.PI / 180));
|
||||
y2 = Math.tan(y2d * (Math.PI / 180));
|
||||
} else {
|
||||
y1 = Expression.compile(minStr).evaluate();
|
||||
y2 = Expression.compile(maxStr).evaluate();
|
||||
}
|
||||
return new ExtremaMask(extent, y1, y2, overlay, distanceOpt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "{",
|
||||
aliases = {"#{"},
|
||||
desc = "Restricts blocks to within a specific radius range of the initial block"
|
||||
)
|
||||
public Mask radius(@Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
|
||||
return new RadiusMask((int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "|",
|
||||
aliases = {"#|", "#side"},
|
||||
desc = "sides with a specific number of other blocks"
|
||||
)
|
||||
public Mask wall(Mask mask, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
|
||||
return new WallMask(mask, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "~",
|
||||
aliases = {"#~", "#adjacent"},
|
||||
desc = "Adjacent to a specific number of other blocks"
|
||||
)
|
||||
public Mask adjacent(Mask mask, @Arg(name = "min", desc = "double", def = "-1") double min, @Arg(name = "max", desc = "double", def = "-1") double max) throws ExpressionException {
|
||||
if (min == -1 && max == -1) {
|
||||
min = 1;
|
||||
max = 8;
|
||||
} else if (max == -1) max = min;
|
||||
if (max >= 8 && min == 1) {
|
||||
return new AdjacentAnyMask(mask);
|
||||
}
|
||||
return new AdjacentMask(mask, (int) min, (int) max);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "<",
|
||||
aliases = {"#<", "#below"},
|
||||
desc = "below a specific block"
|
||||
)
|
||||
public Mask below(Mask mask) throws ExpressionException {
|
||||
OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, 1, 0));
|
||||
return new MaskIntersection(offsetMask, Masks.negate(mask));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = ">",
|
||||
aliases = {"#>", "#above"},
|
||||
desc = "above a specific block"
|
||||
)
|
||||
public Mask above(Mask mask) throws ExpressionException {
|
||||
OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, -1, 0));
|
||||
return new MaskIntersection(offsetMask, Masks.negate(mask));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "$",
|
||||
aliases = {"#biome", "#$"},
|
||||
desc = "in a specific biome",
|
||||
descFooter = "in a specific biome. For a list of biomes use //biomelist"
|
||||
)
|
||||
public Mask biome(Extent extent, BiomeType biome) throws ExpressionException {
|
||||
return new BiomeMask(extent, biome);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "%",
|
||||
aliases = {"#%", "#percent"},
|
||||
desc = "percentage chance"
|
||||
)
|
||||
public Mask random(double chance) throws ExpressionException {
|
||||
chance = chance / 100;
|
||||
return new RandomMask(chance);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "=",
|
||||
aliases = {"#=", "#expression"},
|
||||
desc = "expression mask"
|
||||
)
|
||||
public Mask expression(Extent extent, String input) throws ExpressionException {
|
||||
Expression exp = Expression.compile(input, "x", "y", "z");
|
||||
ExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
|
||||
exp.setEnvironment(env);
|
||||
return new ExpressionMask(exp);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "!",
|
||||
aliases = {"#not", "#negate", "#!"},
|
||||
desc = "Negate another mask"
|
||||
)
|
||||
public Mask expression(Mask mask) throws ExpressionException {
|
||||
return Masks.negate(mask);
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,28 @@ public class PaintBrushCommands {
|
||||
.ofTypes(ImmutableList.of(Key.of(double.class)))
|
||||
.build();
|
||||
|
||||
public static void register(CommandManagerService service, CommandManager commandManager, CommandRegistrationHandler registration) {
|
||||
commandManager.register("paint", builder -> {
|
||||
builder.description(TextComponent.of("Paint brush, apply a function to a surface"));
|
||||
builder.action(org.enginehub.piston.Command.Action.NULL_ACTION);
|
||||
|
||||
CommandManager manager = service.newCommandManager();
|
||||
registration.register(
|
||||
manager,
|
||||
PaintBrushCommandsRegistration.builder(),
|
||||
new PaintBrushCommands()
|
||||
);
|
||||
|
||||
builder.condition(new PermissionCondition(ImmutableSet.of("worldedit.brush.paint")));
|
||||
|
||||
builder.addParts(REGION_FACTORY, RADIUS, DENSITY);
|
||||
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TextComponent.of("Type of brush to use"))
|
||||
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
|
||||
.required()
|
||||
.build());
|
||||
});
|
||||
}
|
||||
|
||||
private void setPaintBrush(CommandParameters parameters, Player player, LocalSession localSession,
|
||||
Contextual<? extends RegionFunction> generatorFactory) throws WorldEditException {
|
||||
double radius = requireNonNull(RADIUS.value(parameters).asSingle(double.class));
|
||||
|
@ -20,14 +20,26 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.brush.BrushSettings;
|
||||
import com.boydti.fawe.object.brush.InspectBrush;
|
||||
import com.boydti.fawe.object.brush.TargetMode;
|
||||
import com.boydti.fawe.object.brush.scroll.ScrollAction;
|
||||
import com.boydti.fawe.object.brush.visualization.VisualMode;
|
||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.command.argument.Arguments;
|
||||
import com.sk89q.worldedit.command.tool.BlockDataCyler;
|
||||
import com.sk89q.worldedit.command.tool.BlockReplacer;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.command.tool.DistanceWand;
|
||||
import com.sk89q.worldedit.command.tool.FloatingTreeRemover;
|
||||
import com.sk89q.worldedit.command.tool.FloodFillTool;
|
||||
@ -39,7 +51,12 @@ import com.sk89q.worldedit.command.tool.TreePlanter;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.annotation.Range;
|
||||
import com.sk89q.worldedit.internal.command.CommandArgParser;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
@ -47,6 +64,9 @@ import com.sk89q.worldedit.world.item.ItemType;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class ToolCommands {
|
||||
@ -56,16 +76,6 @@ public class ToolCommands {
|
||||
this.we = we;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "none",
|
||||
desc = "Unbind a bound tool from your current item"
|
||||
)
|
||||
public void none(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
session.setTool(player, null);
|
||||
player.print("Tool unbound from your current item.");
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/selwand",
|
||||
aliases = "selwand",
|
||||
|
@ -19,18 +19,38 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.brush.BrushSettings;
|
||||
import com.boydti.fawe.object.brush.TargetMode;
|
||||
import com.boydti.fawe.object.brush.scroll.ScrollAction;
|
||||
import com.boydti.fawe.object.brush.visualization.VisualMode;
|
||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.command.argument.Arguments;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.annotation.Range;
|
||||
import com.sk89q.worldedit.internal.command.CommandArgParser;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Tool commands.
|
||||
@ -44,97 +64,349 @@ public class ToolUtilCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/",
|
||||
aliases = { "," },
|
||||
desc = "Toggle the super pickaxe function"
|
||||
name = "mask",
|
||||
aliases = {"/mask"},
|
||||
desc = "Set the brush destination mask"
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe")
|
||||
public void togglePickaxe(Player player, LocalSession session,
|
||||
@Arg(desc = "The new super pickaxe state", def = "")
|
||||
Boolean superPickaxe) {
|
||||
boolean hasSuperPickAxe = session.hasSuperPickAxe();
|
||||
if (superPickaxe != null && superPickaxe == hasSuperPickAxe) {
|
||||
player.printError("Super pickaxe already " + (superPickaxe ? "enabled" : "disabled") + ".");
|
||||
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
|
||||
public void mask(Player player, LocalSession session,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
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(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
if (hasSuperPickAxe) {
|
||||
session.disableSuperPickAxe();
|
||||
player.print("Super pickaxe disabled.");
|
||||
} else {
|
||||
session.enableSuperPickAxe();
|
||||
player.print("Super pickaxe enabled.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "mask",
|
||||
desc = "Set the brush mask"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.mask")
|
||||
public void mask(Player player, LocalSession session,
|
||||
@Arg(desc = "The mask to set", def = "")
|
||||
Mask maskOpt) throws WorldEditException {
|
||||
session.getBrushTool(player).setMask(maskOpt);
|
||||
if (maskOpt == null) {
|
||||
player.print("Brush mask disabled.");
|
||||
} else {
|
||||
player.print("Brush mask set.");
|
||||
BBC.BRUSH_MASK_DISABLED.send(player);
|
||||
tool.setMask(null);
|
||||
return;
|
||||
}
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
||||
System.out.println(lastArg + " TODO check this is not the whole command");
|
||||
settings.addSetting(BrushSettings.SettingType.MASK, lastArg);
|
||||
settings.setMask(maskOpt);
|
||||
tool.update();
|
||||
BBC.BRUSH_MASK.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "material",
|
||||
aliases = { "/material" },
|
||||
desc = "Set the brush material"
|
||||
name = "material",
|
||||
aliases = {"mat", "/material", "pattern"},
|
||||
desc = "Set the brush material"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.material")
|
||||
public void material(Player player, LocalSession session,
|
||||
@Arg(desc = "The pattern of blocks to use")
|
||||
Pattern pattern) throws WorldEditException {
|
||||
session.getBrushTool(player).setFill(pattern);
|
||||
player.print("Brush material set.");
|
||||
@Arg(desc = "brush material pattern", def = "") Pattern patternOpt,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
if (patternOpt == null) {
|
||||
BBC.BRUSH_MATERIAL.send(player);
|
||||
tool.setFill(null);
|
||||
return;
|
||||
}
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
settings.setFill(patternOpt);
|
||||
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
||||
settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
|
||||
tool.update();
|
||||
BBC.BRUSH_MATERIAL.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "range",
|
||||
desc = "Set the brush range"
|
||||
name = "range",
|
||||
desc = "Set the brush range"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.range")
|
||||
public void range(Player player, LocalSession session,
|
||||
@Arg(desc = "The range of the brush")
|
||||
int range) throws WorldEditException {
|
||||
session.getBrushTool(player).setRange(range);
|
||||
player.print("Brush range set.");
|
||||
@Arg(desc = "Range")
|
||||
int range) throws WorldEditException {
|
||||
range = Math.max(0, Math.min(256, range));
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
tool.setRange(range);
|
||||
BBC.BRUSH_RANGE.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "size",
|
||||
desc = "Set the brush size"
|
||||
name = "size",
|
||||
desc = "Set the brush size"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.size")
|
||||
public void size(Player player, LocalSession session,
|
||||
@Arg(desc = "The size of the brush")
|
||||
int size) throws WorldEditException {
|
||||
we.checkMaxBrushRadius(size);
|
||||
|
||||
session.getBrushTool(player).setSize(size);
|
||||
player.print("Brush size set.");
|
||||
@Arg(desc = "The size of the brush", def = "5")
|
||||
int radius,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand) throws WorldEditException {
|
||||
we.checkMaxBrushRadius(radius);
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
settings.setSize(radius);
|
||||
tool.update();
|
||||
BBC.BRUSH_SIZE.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "tracemask",
|
||||
aliases = {"tarmask", "tm", "targetmask"},
|
||||
desc = "Set the mask used to stop tool traces"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.tracemask")
|
||||
public void traceMask(Player player, LocalSession session,
|
||||
@Arg(desc = "The trace mask to set", def = "")
|
||||
Mask maskOpt) throws WorldEditException {
|
||||
session.getBrushTool(player).setTraceMask(maskOpt);
|
||||
if (maskOpt == null) {
|
||||
player.print("Trace mask disabled.");
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
return;
|
||||
}
|
||||
tool.setTraceMask(maskOpt);
|
||||
BBC.BRUSH_TARGET_MASK_SET.send(player, maskOpt.toString());
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "none",
|
||||
aliases = {"/none"},
|
||||
desc = "Unbind a bound tool from your current item"
|
||||
)
|
||||
public void none(Player player, LocalSession session) throws WorldEditException {
|
||||
session.setTool(player, null);
|
||||
BBC.TOOL_NONE.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/",
|
||||
aliases = {","},
|
||||
desc = "Toggle the super pickaxe function"
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe")
|
||||
public void togglePickaxe(Player player, LocalSession session,
|
||||
@Arg(desc = "state", def = "on") String state) throws WorldEditException {
|
||||
if (session.hasSuperPickAxe()) {
|
||||
if ("on".equals(state)) {
|
||||
BBC.SUPERPICKAXE_ENABLED.send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
session.disableSuperPickAxe();
|
||||
BBC.SUPERPICKAXE_DISABLED.send(player);
|
||||
} else {
|
||||
player.print("Trace mask set.");
|
||||
if ("off".equals(state)) {
|
||||
|
||||
BBC.SUPERPICKAXE_DISABLED.send(player);
|
||||
return;
|
||||
}
|
||||
session.enableSuperPickAxe();
|
||||
BBC.SUPERPICKAXE_ENABLED.send(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "primary",
|
||||
desc = "Set the right click brush",
|
||||
descFooter = "Set the right click brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.primary")
|
||||
public void primary(Player player, LocalSession session,
|
||||
@Arg(desc = "The brush command", variable = true) List<String> commandStr) throws WorldEditException {
|
||||
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
session.setTool(item, null, player);
|
||||
String cmd = "brush " + StringMan.join(commandStr, " ");
|
||||
CommandEvent event = new CommandEvent(player, cmd);
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
BrushTool newTool = session.getBrushTool(item, player, false);
|
||||
if (newTool != null && tool != null) {
|
||||
newTool.setSecondary(tool.getSecondary());
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "secondary",
|
||||
desc = "Set the left click brush",
|
||||
descFooter = "Set the left click brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.secondary")
|
||||
public void secondary(Player player, LocalSession session,
|
||||
@Arg(desc = "The brush command", variable = true) List<String> commandStr)
|
||||
throws WorldEditException {
|
||||
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
session.setTool(item, null, player);
|
||||
String cmd = "brush " + StringMan.join(commandStr, " ");
|
||||
CommandEvent event = new CommandEvent(player, cmd);
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
BrushTool newTool = session.getBrushTool(item, player, false);
|
||||
if (newTool != null && tool != null) {
|
||||
newTool.setPrimary(tool.getPrimary());
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "visualize",
|
||||
aliases = {"visual", "vis"},
|
||||
desc = "Toggle between different visualization modes",
|
||||
descFooter = "Toggle between different visualization modes\n" +
|
||||
"0 = No visualization\n" +
|
||||
"1 = Single block at target position\n" +
|
||||
"2 = Glass showing what blocks will be changed"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.visualize")
|
||||
public void visual(Player player, LocalSession session, @Arg(name = "mode", desc = "int", def = "0") @Range(min = 0, max = 2) int mode)
|
||||
throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
return;
|
||||
}
|
||||
VisualMode[] modes = VisualMode.values();
|
||||
VisualMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)];
|
||||
tool.setVisualMode(player, newMode);
|
||||
BBC.BRUSH_VISUAL_MODE_SET.send(player, newMode);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "target",
|
||||
aliases = {"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) {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
return;
|
||||
}
|
||||
TargetMode[] modes = TargetMode.values();
|
||||
TargetMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)];
|
||||
tool.setTargetMode(newMode);
|
||||
BBC.BRUSH_TARGET_MODE_SET.send(player, newMode);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "targetoffset",
|
||||
aliases = {"to"},
|
||||
desc = "Set the targeting mask"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.targetoffset")
|
||||
public void targetOffset(Player player, EditSession editSession, LocalSession session,
|
||||
int offset) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
return;
|
||||
}
|
||||
tool.setTargetOffset(offset);
|
||||
BBC.BRUSH_TARGET_OFFSET_SET.send(player, offset);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "scroll",
|
||||
desc = "Toggle between different target modes"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.scroll")
|
||||
public void scroll(Player player, EditSession editSession, LocalSession session,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
@Arg(desc = "Target Modes")
|
||||
String modes,
|
||||
@Arg(desc = "The scroll action", variable = true)
|
||||
List<String> commandStr) throws WorldEditException {
|
||||
// TODO NOT IMPLEMENTED Convert ScrollAction to an argument converter
|
||||
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, StringMan.join(commandStr, " "), true);
|
||||
settings.setScrollAction(action);
|
||||
if (modes.equalsIgnoreCase("none")) {
|
||||
BBC.BRUSH_SCROLL_ACTION_UNSET.send(player);
|
||||
} else if (action != null) {
|
||||
settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, modes);
|
||||
BBC.BRUSH_SCROLL_ACTION_SET.send(player, modes);
|
||||
}
|
||||
bt.update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Command(
|
||||
name = "smask",
|
||||
aliases = {"/smask", "/sourcemask", "sourcemask"},
|
||||
desc = "Set the brush source mask",
|
||||
descFooter = "Set the brush source mask"
|
||||
)
|
||||
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
|
||||
public void smask(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The destination mask", def = "")
|
||||
Mask maskArg,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
if (maskArg == null) {
|
||||
BBC.BRUSH_SOURCE_MASK_DISABLED.send(player);
|
||||
tool.setSourceMask(null);
|
||||
return;
|
||||
}
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
||||
settings.addSetting(BrushSettings.SettingType.SOURCE_MASK, lastArg);
|
||||
settings.setSourceMask(maskArg);
|
||||
tool.update();
|
||||
BBC.BRUSH_SOURCE_MASK.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "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 = "TODO")
|
||||
boolean offHand,
|
||||
Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
if (transform == null) {
|
||||
BBC.BRUSH_TRANSFORM_DISABLED.send(player);
|
||||
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();
|
||||
BBC.BRUSH_TRANSFORM.send(player);
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public final class RegistryConverter<V extends Keyed> implements ArgumentConvert
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void register(CommandManager commandManager) {
|
||||
ImmutableList.of(
|
||||
BlockTypes.class,
|
||||
BlockType.class,
|
||||
BlockCategory.class,
|
||||
ItemType.class,
|
||||
ItemCategory.class,
|
||||
|
Reference in New Issue
Block a user