diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java
index 9c11224c6..8f4b8e5ae 100644
--- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java
+++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java
@@ -49,7 +49,7 @@ class BukkitCommandInspector implements CommandInspector {
public String getShortText(Command command) {
CommandMapping mapping = dispatcher.get(command.getName());
if (mapping != null) {
- return mapping.getDescription().getShortDescription();
+ return mapping.getDescription().getDescription();
} else {
logger.warning("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return "Help text not available";
diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java
index 04a1e7456..3681aff06 100644
--- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java
+++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java
@@ -130,7 +130,7 @@ public class BukkitServerInterface extends ServerInterface implements MultiUserP
String[] permissionsArray = new String[permissions.size()];
permissions.toArray(permissionsArray);
- toRegister.add(new CommandInfo(description.getUsage(), description.getShortDescription(), command.getAllAliases(), inspector, permissionsArray));
+ toRegister.add(new CommandInfo(description.getUsage(), description.getDescription(), command.getAllAliases(), inspector, permissionsArray));
}
dynamicCommands.register(toRegister);
diff --git a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java
index 34bc2540c..d1db70207 100644
--- a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java
+++ b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java
@@ -66,17 +66,32 @@ public class CommandContext {
/**
* Parse the given array of arguments.
- *
+ *
*
Empty arguments are removed from the list of arguments.
- *
+ *
* @param args an array with arguments
* @param valueFlags a set containing all value flags (pass null to disable value flag parsing)
* @param allowHangingFlag true if hanging flags are allowed
* @param locals the locals, null to create empty one
* @throws CommandException thrown on a parsing error
*/
- public CommandContext(String[] args, Set valueFlags,
- boolean allowHangingFlag, CommandLocals locals) throws CommandException {
+ public CommandContext(String[] args, Set valueFlags, boolean allowHangingFlag, CommandLocals locals) throws CommandException {
+ this(args, valueFlags, allowHangingFlag, locals, true);
+ }
+
+ /**
+ * Parse the given array of arguments.
+ *
+ *
Empty arguments are removed from the list of arguments.
+ *
+ * @param args an array with arguments
+ * @param valueFlags a set containing all value flags (pass null to disable value flag parsing)
+ * @param allowHangingFlag true if hanging flags are allowed
+ * @param locals the locals, null to create empty one
+ * @param parseFlags where to parse flags
+ * @throws CommandException thrown on a parsing error
+ */
+ public CommandContext(String[] args, Set valueFlags, boolean allowHangingFlag, CommandLocals locals, boolean parseFlags) throws CommandException {
if (valueFlags == null) {
valueFlags = Collections.emptySet();
}
@@ -140,57 +155,65 @@ public class CommandContext {
this.originalArgIndices = new ArrayList(argIndexList.size());
this.parsedArgs = new ArrayList(argList.size());
- for (int nextArg = 0; nextArg < argList.size(); ) {
- // Fetch argument
- String arg = argList.get(nextArg++);
- suggestionContext = SuggestionContext.hangingValue();
+ if (parseFlags) {
+ for (int nextArg = 0; nextArg < argList.size(); ) {
+ // Fetch argument
+ String arg = argList.get(nextArg++);
+ suggestionContext = SuggestionContext.hangingValue();
- // Not a flag?
- if (arg.charAt(0) != '-' || arg.length() == 1 || !arg.matches("^-[a-zA-Z\\?]+$")) {
- if (!isHanging) {
- suggestionContext = SuggestionContext.lastValue();
- }
-
- originalArgIndices.add(argIndexList.get(nextArg - 1));
- parsedArgs.add(arg);
- continue;
- }
-
- // Handle flag parsing terminator --
- if (arg.equals("--")) {
- while (nextArg < argList.size()) {
- originalArgIndices.add(argIndexList.get(nextArg));
- parsedArgs.add(argList.get(nextArg++));
- }
- break;
- }
-
- // Go through the flag characters
- for (int i = 1; i < arg.length(); ++i) {
- char flagName = arg.charAt(i);
-
- if (valueFlags.contains(flagName)) {
- if (this.valueFlags.containsKey(flagName)) {
- throw new CommandException("Value flag '" + flagName + "' already given");
- }
-
- if (nextArg >= argList.size()) {
- if (allowHangingFlag) {
- suggestionContext = SuggestionContext.flag(flagName);
- break;
- } else {
- throw new CommandException("No value specified for the '-" + flagName + "' flag.");
- }
- }
-
- // If it is a value flag, read another argument and add it
- this.valueFlags.put(flagName, argList.get(nextArg++));
+ // Not a flag?
+ if (arg.charAt(0) != '-' || arg.length() == 1 || !arg.matches("^-[a-zA-Z\\?]+$")) {
if (!isHanging) {
- suggestionContext = SuggestionContext.flag(flagName);
+ suggestionContext = SuggestionContext.lastValue();
}
- } else {
- booleanFlags.add(flagName);
+
+ originalArgIndices.add(argIndexList.get(nextArg - 1));
+ parsedArgs.add(arg);
+ continue;
}
+
+ // Handle flag parsing terminator --
+ if (arg.equals("--")) {
+ while (nextArg < argList.size()) {
+ originalArgIndices.add(argIndexList.get(nextArg));
+ parsedArgs.add(argList.get(nextArg++));
+ }
+ break;
+ }
+
+ // Go through the flag characters
+ for (int i = 1; i < arg.length(); ++i) {
+ char flagName = arg.charAt(i);
+
+ if (valueFlags.contains(flagName)) {
+ if (this.valueFlags.containsKey(flagName)) {
+ throw new CommandException("Value flag '" + flagName + "' already given");
+ }
+
+ if (nextArg >= argList.size()) {
+ if (allowHangingFlag) {
+ suggestionContext = SuggestionContext.flag(flagName);
+ break;
+ } else {
+ throw new CommandException("No value specified for the '-" + flagName + "' flag.");
+ }
+ }
+
+ // If it is a value flag, read another argument and add it
+ this.valueFlags.put(flagName, argList.get(nextArg++));
+ if (!isHanging) {
+ suggestionContext = SuggestionContext.flag(flagName);
+ }
+ } else {
+ booleanFlags.add(flagName);
+ }
+ }
+ }
+ } else {
+ for (int i = 0; i < argList.size(); i++) {
+ String arg = argList.get(i);
+ originalArgIndices.add(argIndexList.get(i));
+ parsedArgs.add(arg);
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java
index 5cbfea2eb..e7ffcd165 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java
@@ -613,7 +613,6 @@ public class LocalSession {
* @return the tool, or {@code null}
* @throws InvalidToolBindException if the item can't be bound to that item
*/
- @Nullable
public BrushTool getBrushTool(int item) throws InvalidToolBindException {
Tool tool = getTool(item);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java
index 69c83a168..3826b19e3 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java
@@ -21,6 +21,7 @@ package com.sk89q.worldedit;
import com.sk89q.worldedit.CuboidClipboard.FlipDirection;
import com.sk89q.worldedit.blocks.BaseBlock;
+import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.extent.EditSessionEvent;
@@ -28,6 +29,7 @@ import com.sk89q.worldedit.event.platform.BlockInteractEvent;
import com.sk89q.worldedit.event.platform.InputType;
import com.sk89q.worldedit.event.platform.PlayerInputEvent;
import com.sk89q.worldedit.extension.factory.BlockFactory;
+import com.sk89q.worldedit.extension.factory.ItemFactory;
import com.sk89q.worldedit.extension.factory.MaskFactory;
import com.sk89q.worldedit.extension.factory.PatternFactory;
import com.sk89q.worldedit.extension.input.ParserContext;
@@ -95,6 +97,7 @@ public class WorldEdit {
private final SessionManager sessions = new SessionManager(this);
private final BlockFactory blockFactory = new BlockFactory(this);
+ private final ItemFactory itemFactory = new ItemFactory(this);
private final MaskFactory maskFactory = new MaskFactory(this);
private final PatternFactory patternFactory = new PatternFactory(this);
@@ -152,6 +155,16 @@ public class WorldEdit {
return blockFactory;
}
+ /**
+ * Get the item factory from which new {@link BaseItem}s can be
+ * constructed.
+ *
+ * @return the item factory
+ */
+ public ItemFactory getItemFactory() {
+ return itemFactory;
+ }
+
/**
* Get the mask factory from which new {@link com.sk89q.worldedit.function.mask.Mask}s
* can be constructed.
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java
index a6f2c2d24..67efbd716 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java
@@ -22,7 +22,12 @@ package com.sk89q.worldedit.command;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions;
-import com.sk89q.worldedit.*;
+import com.sk89q.worldedit.EditSession;
+import com.sk89q.worldedit.LocalConfiguration;
+import com.sk89q.worldedit.LocalSession;
+import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.WorldEdit;
+import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.command.tool.BrushTool;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java
index 86ee9d232..39c9ed9ac 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java
@@ -658,7 +658,7 @@ public class UtilityCommands {
builder.append(" ");
}
builder.append(mapping.getPrimaryAlias());
- box.appendCommand(builder.toString(), mapping.getDescription().getShortDescription());
+ box.appendCommand(builder.toString(), mapping.getDescription().getDescription());
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/DeformCommand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/DeformCommand.java
new file mode 100644
index 000000000..daa6d7417
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/DeformCommand.java
@@ -0,0 +1,63 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.command.composition;
+
+import com.sk89q.minecraft.util.commands.CommandException;
+import com.sk89q.minecraft.util.commands.CommandLocals;
+import com.sk89q.minecraft.util.commands.WrappedCommandException;
+import com.sk89q.worldedit.IncompleteRegionException;
+import com.sk89q.worldedit.LocalSession;
+import com.sk89q.worldedit.WorldEdit;
+import com.sk89q.worldedit.entity.Player;
+import com.sk89q.worldedit.extension.platform.Actor;
+import com.sk89q.worldedit.function.factory.Deform;
+import com.sk89q.worldedit.function.factory.Deform.Mode;
+import com.sk89q.worldedit.util.command.CommandExecutor;
+import com.sk89q.worldedit.util.command.argument.CommandArgs;
+
+public class DeformCommand extends CommandExecutor {
+
+ @Override
+ public Deform call(CommandArgs args, CommandLocals locals, String[] parentCommands) throws CommandException {
+ String expression = args.next();
+ boolean rawCoords = args.containsFlag('r');
+ boolean offset = args.containsFlag('o');
+
+ Deform deform = new Deform(expression);
+
+ if (rawCoords) {
+ deform.setMode(Mode.RAW_COORD);
+ } else if (offset) {
+ deform.setMode(Mode.OFFSET);
+ Player player = (Player) locals.get(Actor.class);
+ LocalSession session = WorldEdit.getInstance().getSessionManager().get(locals.get(Actor.class));
+ try {
+ deform.setOffset(session.getPlacementPosition(player));
+ } catch (IncompleteRegionException e) {
+ throw new WrappedCommandException(e);
+ }
+ } else {
+ deform.setMode(Mode.UNIT_CUBE);
+ }
+
+ return deform;
+ }
+
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/FillBrushCommand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/FillBrushCommand.java
new file mode 100644
index 000000000..276d7d30f
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/FillBrushCommand.java
@@ -0,0 +1,61 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.command.composition;
+
+import com.sk89q.minecraft.util.commands.CommandException;
+import com.sk89q.minecraft.util.commands.CommandLocals;
+import com.sk89q.worldedit.LocalSession;
+import com.sk89q.worldedit.WorldEdit;
+import com.sk89q.worldedit.command.tool.BrushTool;
+import com.sk89q.worldedit.command.tool.InvalidToolBindException;
+import com.sk89q.worldedit.entity.Player;
+import com.sk89q.worldedit.extension.platform.Actor;
+import com.sk89q.worldedit.function.pattern.Pattern;
+import com.sk89q.worldedit.util.command.CommandExecutor;
+import com.sk89q.worldedit.util.command.argument.CommandArgs;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class FillBrushCommand extends CommandExecutor {
+
+ private final CommandExecutor extends T> delegate;
+
+ public FillBrushCommand(CommandExecutor extends T> delegate) {
+ checkNotNull(delegate, "delegate");
+ this.delegate = delegate;
+ }
+
+ @Override
+ public T call(CommandArgs args, CommandLocals locals, String[] parentCommands) throws CommandException {
+ Pattern pattern = new PatternCommand().call(args, locals, parentCommands);
+
+ Player player = (Player) locals.get(Actor.class);
+ LocalSession session = WorldEdit.getInstance().getSessionManager().get(player);
+
+ try {
+ BrushTool tool = session.getBrushTool(player.getItemInHand());
+ tool.setFill(pattern);
+ } catch (InvalidToolBindException e) {
+ WorldEdit.getInstance().getPlatformManager().getCommandManager().getExceptionConverter().convert(e);
+ }
+
+ return delegate.call(args, locals, parentCommands);
+ }
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ForestCommand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ForestCommand.java
new file mode 100644
index 000000000..09869e62a
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ForestCommand.java
@@ -0,0 +1,23 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.command.composition;
+
+public class ForestCommand {
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ItemCommand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ItemCommand.java
new file mode 100644
index 000000000..4335ec94f
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ItemCommand.java
@@ -0,0 +1,63 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.command.composition;
+
+import com.sk89q.minecraft.util.commands.CommandException;
+import com.sk89q.minecraft.util.commands.CommandLocals;
+import com.sk89q.worldedit.LocalSession;
+import com.sk89q.worldedit.WorldEdit;
+import com.sk89q.worldedit.blocks.BaseItem;
+import com.sk89q.worldedit.entity.Entity;
+import com.sk89q.worldedit.extension.input.InputParseException;
+import com.sk89q.worldedit.extension.input.NoMatchException;
+import com.sk89q.worldedit.extension.input.ParserContext;
+import com.sk89q.worldedit.extension.platform.Actor;
+import com.sk89q.worldedit.extent.Extent;
+import com.sk89q.worldedit.util.command.CommandExecutor;
+import com.sk89q.worldedit.util.command.argument.CommandArgs;
+import com.sk89q.worldedit.world.World;
+
+public class ItemCommand extends CommandExecutor {
+
+ @Override
+ public BaseItem call(CommandArgs args, CommandLocals locals, String[] parentCommands) throws CommandException {
+ Actor actor = locals.get(Actor.class);
+ LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor);
+
+ ParserContext parserContext = new ParserContext();
+ parserContext.setActor(actor);
+ if (actor instanceof Entity) {
+ Extent extent = ((Entity) actor).getExtent();
+ if (extent instanceof World) {
+ parserContext.setWorld((World) extent);
+ }
+ }
+ parserContext.setSession(session);
+
+ try {
+ return WorldEdit.getInstance().getItemFactory().parseFromInput(args.next(), parserContext);
+ } catch (NoMatchException e) {
+ throw new CommandException(e.getMessage(), e);
+ } catch (InputParseException e) {
+ throw new CommandException(e.getMessage(), e);
+ }
+ }
+
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ItemUseCommand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ItemUseCommand.java
new file mode 100644
index 000000000..1c0558bb1
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ItemUseCommand.java
@@ -0,0 +1,81 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.command.composition;
+
+import com.google.common.base.Function;
+import com.sk89q.minecraft.util.commands.CommandException;
+import com.sk89q.minecraft.util.commands.CommandLocals;
+import com.sk89q.worldedit.EditSession;
+import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.WorldEditException;
+import com.sk89q.worldedit.blocks.BaseItem;
+import com.sk89q.worldedit.function.EditContext;
+import com.sk89q.worldedit.function.RegionFunction;
+import com.sk89q.worldedit.util.Direction;
+import com.sk89q.worldedit.util.command.CommandExecutor;
+import com.sk89q.worldedit.util.command.argument.CommandArgs;
+import com.sk89q.worldedit.world.World;
+
+import javax.annotation.Nullable;
+
+public class ItemUseCommand extends CommandExecutor> {
+
+ @Override
+ public Function call(CommandArgs args, CommandLocals locals, String[] parentCommands) throws CommandException {
+ BaseItem item = new ItemCommand().call(args, locals, parentCommands);
+ return new ItemUseFactory(item);
+ }
+
+ private static final class ItemUseFactory implements Function {
+ private final BaseItem item;
+
+ private ItemUseFactory(BaseItem item) {
+ this.item = item;
+ }
+
+ @Nullable
+ @Override
+ public RegionFunction apply(EditContext input) {
+ World world = ((EditSession) input.getDestination()).getWorld();
+ return new ItemUseFunction(world, item);
+ }
+
+ @Override
+ public String toString() {
+ return "application of the item " + item.getType() + ":" + item.getData();
+ }
+ }
+
+ private static final class ItemUseFunction implements RegionFunction {
+ private final World world;
+ private final BaseItem item;
+
+ private ItemUseFunction(World world, BaseItem item) {
+ this.world = world;
+ this.item = item;
+ }
+
+ @Override
+ public boolean apply(Vector position) throws WorldEditException {
+ return world.useItem(position, item, Direction.UP);
+ }
+ }
+
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/PatternCommand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/PatternCommand.java
new file mode 100644
index 000000000..258dd5f09
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/PatternCommand.java
@@ -0,0 +1,63 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.command.composition;
+
+import com.sk89q.minecraft.util.commands.CommandException;
+import com.sk89q.minecraft.util.commands.CommandLocals;
+import com.sk89q.worldedit.LocalSession;
+import com.sk89q.worldedit.WorldEdit;
+import com.sk89q.worldedit.entity.Entity;
+import com.sk89q.worldedit.extension.input.InputParseException;
+import com.sk89q.worldedit.extension.input.NoMatchException;
+import com.sk89q.worldedit.extension.input.ParserContext;
+import com.sk89q.worldedit.extension.platform.Actor;
+import com.sk89q.worldedit.extent.Extent;
+import com.sk89q.worldedit.function.pattern.Pattern;
+import com.sk89q.worldedit.util.command.CommandExecutor;
+import com.sk89q.worldedit.util.command.argument.CommandArgs;
+import com.sk89q.worldedit.world.World;
+
+public class PatternCommand extends CommandExecutor {
+
+ @Override
+ public Pattern call(CommandArgs args, CommandLocals locals, String[] parentCommands) throws CommandException {
+ Actor actor = locals.get(Actor.class);
+ LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor);
+
+ ParserContext parserContext = new ParserContext();
+ parserContext.setActor(actor);
+ if (actor instanceof Entity) {
+ Extent extent = ((Entity) actor).getExtent();
+ if (extent instanceof World) {
+ parserContext.setWorld((World) extent);
+ }
+ }
+ parserContext.setSession(session);
+
+ try {
+ return WorldEdit.getInstance().getPatternFactory().parseFromInput(args.next(), parserContext);
+ } catch (NoMatchException e) {
+ throw new CommandException(e.getMessage(), e);
+ } catch (InputParseException e) {
+ throw new CommandException(e.getMessage(), e);
+ }
+ }
+
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/PointGeneratorCommand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/PointGeneratorCommand.java
new file mode 100644
index 000000000..d618db25d
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/PointGeneratorCommand.java
@@ -0,0 +1,45 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.command.composition;
+
+import com.google.common.base.Function;
+import com.sk89q.minecraft.util.commands.CommandException;
+import com.sk89q.minecraft.util.commands.CommandLocals;
+import com.sk89q.worldedit.function.EditContext;
+import com.sk89q.worldedit.function.RegionFunction;
+import com.sk89q.worldedit.util.command.CommandExecutor;
+import com.sk89q.worldedit.util.command.argument.CommandArgs;
+
+public class PointGeneratorCommand extends CommandExecutor> {
+
+ @Override
+ public Function call(CommandArgs args, CommandLocals locals, String[] parentCommands) throws CommandException {
+ String type = args.next();
+
+ if (type.equalsIgnoreCase("forest") || type.equalsIgnoreCase("tree")) {
+ return new TreeGeneratorCommand().call(args, locals, parentCommands);
+ } else if (type.equalsIgnoreCase("item") || type.equalsIgnoreCase("itemstack")) {
+ return new ItemUseCommand().call(args, locals, parentCommands);
+ } else {
+ throw new CommandException("Unknown type of generator: " + type);
+ }
+ }
+
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/RegionFactoryCommand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/RegionFactoryCommand.java
new file mode 100644
index 000000000..4b152d14e
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/RegionFactoryCommand.java
@@ -0,0 +1,48 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.command.composition;
+
+import com.sk89q.minecraft.util.commands.CommandException;
+import com.sk89q.minecraft.util.commands.CommandLocals;
+import com.sk89q.worldedit.regions.factory.CuboidRegionFactory;
+import com.sk89q.worldedit.regions.factory.CylinderRegionFactory;
+import com.sk89q.worldedit.regions.factory.RegionFactory;
+import com.sk89q.worldedit.regions.factory.SphereRegionFactory;
+import com.sk89q.worldedit.util.command.CommandExecutor;
+import com.sk89q.worldedit.util.command.argument.CommandArgs;
+
+public class RegionFactoryCommand extends CommandExecutor {
+
+ @Override
+ public RegionFactory call(CommandArgs args, CommandLocals locals, String[] parentCommands) throws CommandException {
+ String type = args.next();
+
+ if (type.equals("cuboid")) {
+ return new CuboidRegionFactory();
+ } else if (type.equals("sphere")) {
+ return new SphereRegionFactory();
+ } else if (type.equals("cyl") || type.equals("cylinder")) {
+ return new CylinderRegionFactory(1); // TODO: Adjustable height
+ } else {
+ throw new CommandException("Unknown shape type: " + type);
+ }
+ }
+
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/RegionReplaceCommand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/RegionReplaceCommand.java
new file mode 100644
index 000000000..cff0e9c8a
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/RegionReplaceCommand.java
@@ -0,0 +1,35 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.command.composition;
+
+import com.sk89q.minecraft.util.commands.CommandException;
+import com.sk89q.minecraft.util.commands.CommandLocals;
+import com.sk89q.worldedit.function.factory.RegionReplace;
+import com.sk89q.worldedit.util.command.CommandExecutor;
+import com.sk89q.worldedit.util.command.argument.CommandArgs;
+
+public class RegionReplaceCommand extends CommandExecutor {
+
+ @Override
+ public RegionReplace call(CommandArgs args, CommandLocals locals, String[] parentCommands) throws CommandException {
+ return new RegionReplace();
+ }
+
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ScatterCommand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ScatterCommand.java
new file mode 100644
index 000000000..8dbc86483
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ScatterCommand.java
@@ -0,0 +1,40 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.command.composition;
+
+import com.google.common.base.Function;
+import com.sk89q.minecraft.util.commands.CommandException;
+import com.sk89q.minecraft.util.commands.CommandLocals;
+import com.sk89q.worldedit.function.EditContext;
+import com.sk89q.worldedit.function.RegionFunction;
+import com.sk89q.worldedit.function.factory.Scatter;
+import com.sk89q.worldedit.util.command.CommandExecutor;
+import com.sk89q.worldedit.util.command.argument.CommandArgs;
+
+public class ScatterCommand extends CommandExecutor {
+
+ @Override
+ public Scatter call(CommandArgs args, CommandLocals locals, String[] parentCommands) throws CommandException {
+ double density = args.nextDouble() / 100.0;
+ Function function = new PointGeneratorCommand().call(args, locals, parentCommands);
+ return new Scatter(function, density);
+ }
+
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ShapedBrushCommand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ShapedBrushCommand.java
new file mode 100644
index 000000000..62bb338bf
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ShapedBrushCommand.java
@@ -0,0 +1,114 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.sk89q.worldedit.command.composition;
+
+import com.google.common.collect.Lists;
+import com.sk89q.minecraft.util.commands.CommandException;
+import com.sk89q.minecraft.util.commands.CommandLocals;
+import com.sk89q.minecraft.util.commands.CommandPermissionsException;
+import com.sk89q.worldedit.LocalSession;
+import com.sk89q.worldedit.MaxBrushRadiusException;
+import com.sk89q.worldedit.WorldEdit;
+import com.sk89q.worldedit.command.tool.BrushTool;
+import com.sk89q.worldedit.command.tool.InvalidToolBindException;
+import com.sk89q.worldedit.command.tool.brush.OperationFactoryBrush;
+import com.sk89q.worldedit.entity.Player;
+import com.sk89q.worldedit.extension.platform.Actor;
+import com.sk89q.worldedit.function.factory.OperationFactory;
+import com.sk89q.worldedit.regions.factory.RegionFactory;
+import com.sk89q.worldedit.util.command.CommandExecutor;
+import com.sk89q.worldedit.util.command.Description;
+import com.sk89q.worldedit.util.command.Parameter;
+import com.sk89q.worldedit.util.command.SimpleDescription;
+import com.sk89q.worldedit.util.command.SimpleParameter;
+import com.sk89q.worldedit.util.command.argument.CommandArgs;
+
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class ShapedBrushCommand extends CommandExecutor