geforkt von Mirrors/FastAsyncWorldEdit
Removed LocalPlayer from commands and removed various uses of old Mask and Pattern classes.
Dieser Commit ist enthalten in:
Ursprung
ec28cd626c
Commit
f64107c2c0
@ -30,13 +30,14 @@ import com.sk89q.worldedit.command.tool.Tool;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionShapeEvent;
|
||||
import com.sk89q.worldedit.masks.Mask;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.session.request.Request;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.snapshot.Snapshot;
|
||||
@ -141,6 +142,17 @@ public class LocalSession {
|
||||
* @return whether anything was undone
|
||||
*/
|
||||
public EditSession undo(BlockBag newBlockBag, LocalPlayer player) {
|
||||
return undo(newBlockBag, (Player) player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an undo.
|
||||
*
|
||||
* @param newBlockBag
|
||||
* @param player
|
||||
* @return whether anything was undone
|
||||
*/
|
||||
public EditSession undo(BlockBag newBlockBag, Player player) {
|
||||
--historyPointer;
|
||||
if (historyPointer >= 0) {
|
||||
EditSession editSession = history.get(historyPointer);
|
||||
@ -164,6 +176,17 @@ public class LocalSession {
|
||||
* @return whether anything was redone
|
||||
*/
|
||||
public EditSession redo(BlockBag newBlockBag, LocalPlayer player) {
|
||||
return redo(newBlockBag, (Player) player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a redo
|
||||
*
|
||||
* @param newBlockBag
|
||||
* @param player
|
||||
* @return whether anything was redone
|
||||
*/
|
||||
public EditSession redo(BlockBag newBlockBag, Player player) {
|
||||
if (historyPointer < history.size()) {
|
||||
EditSession editSession = history.get(historyPointer);
|
||||
EditSession newEditSession = WorldEdit.getInstance().getEditSessionFactory()
|
||||
@ -577,7 +600,7 @@ public class LocalSession {
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void dispatchCUISetup(LocalPlayer player) {
|
||||
public void dispatchCUISetup(Player player) {
|
||||
if (selector != null) {
|
||||
dispatchCUISelection(player);
|
||||
}
|
||||
@ -588,7 +611,7 @@ public class LocalSession {
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void dispatchCUISelection(LocalPlayer player) {
|
||||
public void dispatchCUISelection(Player player) {
|
||||
if (!hasCUISupport) {
|
||||
return;
|
||||
}
|
||||
@ -732,9 +755,6 @@ public class LocalSession {
|
||||
getBlockChangeLimit(), blockBag, player);
|
||||
editSession.setFastMode(fastMode);
|
||||
Request.request().setEditSession(editSession);
|
||||
if (mask != null && player instanceof LocalPlayer) {
|
||||
mask.prepare(this, (LocalPlayer) player, null);
|
||||
}
|
||||
editSession.setMask(mask);
|
||||
|
||||
return editSession;
|
||||
@ -775,4 +795,15 @@ public class LocalSession {
|
||||
public void setMask(Mask mask) {
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a mask.
|
||||
*
|
||||
* @param mask mask or null
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setMask(com.sk89q.worldedit.masks.Mask mask) {
|
||||
setMask(mask != null ? Masks.wrap(mask) : null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public class WorldEdit {
|
||||
* @deprecated use {@link #getSessionManager()}
|
||||
*/
|
||||
@Deprecated
|
||||
public LocalSession getSession(LocalPlayer player) {
|
||||
public LocalSession getSession(Player player) {
|
||||
return sessions.get(player);
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ public class WorldEdit {
|
||||
* @deprecated use {@link #getSessionManager()}
|
||||
*/
|
||||
@Deprecated
|
||||
public void removeSession(LocalPlayer player) {
|
||||
public void removeSession(Player player) {
|
||||
sessions.remove(player);
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ public class WorldEdit {
|
||||
* @deprecated use {@link #getSessionManager()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean hasSession(LocalPlayer player) {
|
||||
public boolean hasSession(Player player) {
|
||||
return sessions.contains(player);
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ public class WorldEdit {
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
public BaseBlock getBlock(LocalPlayer player, String arg, boolean allAllowed) throws WorldEditException {
|
||||
public BaseBlock getBlock(Player player, String arg, boolean allAllowed) throws WorldEditException {
|
||||
return getBlock(player, arg, allAllowed, false);
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ public class WorldEdit {
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
public BaseBlock getBlock(LocalPlayer player, String arg, boolean allAllowed, boolean allowNoData) throws WorldEditException {
|
||||
public BaseBlock getBlock(Player player, String arg, boolean allAllowed, boolean allowNoData) throws WorldEditException {
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
@ -240,7 +240,7 @@ public class WorldEdit {
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
public BaseBlock getBlock(LocalPlayer player, String id) throws WorldEditException {
|
||||
public BaseBlock getBlock(Player player, String id) throws WorldEditException {
|
||||
return getBlock(player, id, false);
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ public class WorldEdit {
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public Set<BaseBlock> getBlocks(LocalPlayer player, String list, boolean allAllowed, boolean allowNoData) throws WorldEditException {
|
||||
public Set<BaseBlock> getBlocks(Player player, String list, boolean allAllowed, boolean allowNoData) throws WorldEditException {
|
||||
String[] items = list.split(",");
|
||||
Set<BaseBlock> blocks = new HashSet<BaseBlock>();
|
||||
for (String id : items) {
|
||||
@ -263,7 +263,7 @@ public class WorldEdit {
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public Set<BaseBlock> getBlocks(LocalPlayer player, String list, boolean allAllowed) throws WorldEditException {
|
||||
public Set<BaseBlock> getBlocks(Player player, String list, boolean allAllowed) throws WorldEditException {
|
||||
return getBlocks(player, list, allAllowed, false);
|
||||
}
|
||||
|
||||
@ -272,7 +272,7 @@ public class WorldEdit {
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public Set<BaseBlock> getBlocks(LocalPlayer player, String list) throws WorldEditException {
|
||||
public Set<BaseBlock> getBlocks(Player player, String list) throws WorldEditException {
|
||||
return getBlocks(player, list, false);
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ public class WorldEdit {
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public Set<Integer> getBlockIDs(LocalPlayer player, String list, boolean allBlocksAllowed) throws WorldEditException {
|
||||
public Set<Integer> getBlockIDs(Player player, String list, boolean allBlocksAllowed) throws WorldEditException {
|
||||
String[] items = list.split(",");
|
||||
Set<Integer> blocks = new HashSet<Integer>();
|
||||
for (String s : items) {
|
||||
@ -295,7 +295,7 @@ public class WorldEdit {
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public Pattern getBlockPattern(LocalPlayer player, String input) throws WorldEditException {
|
||||
public Pattern getBlockPattern(Player player, String input) throws WorldEditException {
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
@ -308,7 +308,7 @@ public class WorldEdit {
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public Mask getBlockMask(LocalPlayer player, LocalSession session, String input) throws WorldEditException {
|
||||
public Mask getBlockMask(Player player, LocalSession session, String input) throws WorldEditException {
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
@ -330,8 +330,7 @@ public class WorldEdit {
|
||||
* @return a file
|
||||
* @throws FilenameException thrown if the filename is invalid
|
||||
*/
|
||||
public File getSafeSaveFile(LocalPlayer player, File dir, String filename, String defaultExt, String... extensions)
|
||||
throws FilenameException {
|
||||
public File getSafeSaveFile(Player player, File dir, String filename, String defaultExt, String... extensions) throws FilenameException {
|
||||
return getSafeFile(player, dir, filename, defaultExt, extensions, true);
|
||||
}
|
||||
|
||||
@ -349,8 +348,7 @@ public class WorldEdit {
|
||||
* @return a file
|
||||
* @throws FilenameException thrown if the filename is invalid
|
||||
*/
|
||||
public File getSafeOpenFile(LocalPlayer player, File dir, String filename, String defaultExt, String... extensions)
|
||||
throws FilenameException {
|
||||
public File getSafeOpenFile(Player player, File dir, String filename, String defaultExt, String... extensions) throws FilenameException {
|
||||
return getSafeFile(player, dir, filename, defaultExt, extensions, false);
|
||||
}
|
||||
|
||||
@ -366,9 +364,7 @@ public class WorldEdit {
|
||||
* @return a file
|
||||
* @throws FilenameException thrown if the filename is invalid
|
||||
*/
|
||||
private File getSafeFile(LocalPlayer player, File dir, String filename,
|
||||
String defaultExt, String[] extensions, boolean isSave)
|
||||
throws FilenameException {
|
||||
private File getSafeFile(Player player, File dir, String filename, String defaultExt, String[] extensions, boolean isSave) throws FilenameException {
|
||||
if (extensions != null && (extensions.length == 1 && extensions[0] == null)) extensions = null;
|
||||
|
||||
File f;
|
||||
@ -411,7 +407,7 @@ public class WorldEdit {
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaximumPolygonalPoints(LocalPlayer player) {
|
||||
public int getMaximumPolygonalPoints(Player player) {
|
||||
if (player.hasPermission("worldedit.limit.unrestricted") || getConfiguration().maxPolygonalPoints < 0) {
|
||||
return getConfiguration().defaultMaxPolygonalPoints;
|
||||
}
|
||||
@ -423,7 +419,7 @@ public class WorldEdit {
|
||||
return Math.min(getConfiguration().defaultMaxPolygonalPoints, getConfiguration().maxPolygonalPoints);
|
||||
}
|
||||
|
||||
public int getMaximumPolyhedronPoints(LocalPlayer player) {
|
||||
public int getMaximumPolyhedronPoints(Player player) {
|
||||
if (player.hasPermission("worldedit.limit.unrestricted") || getConfiguration().maxPolyhedronPoints < 0) {
|
||||
return getConfiguration().defaultMaxPolyhedronPoints;
|
||||
}
|
||||
@ -586,9 +582,7 @@ public class WorldEdit {
|
||||
* @return a direction vector
|
||||
* @throws UnknownDirectionException thrown if the direction is not known
|
||||
*/
|
||||
public Vector getDiagonalDirection(LocalPlayer player, String dirStr)
|
||||
throws UnknownDirectionException {
|
||||
|
||||
public Vector getDiagonalDirection(Player player, String dirStr) throws UnknownDirectionException {
|
||||
return getPlayerDirection(player, dirStr.toLowerCase()).vector();
|
||||
}
|
||||
|
||||
@ -600,8 +594,7 @@ public class WorldEdit {
|
||||
* @return a direction vector
|
||||
* @throws UnknownDirectionException thrown if the direction is not known
|
||||
*/
|
||||
public FlipDirection getFlipDirection(LocalPlayer player, String dirStr) throws UnknownDirectionException {
|
||||
|
||||
public FlipDirection getFlipDirection(Player player, String dirStr) throws UnknownDirectionException {
|
||||
final PlayerDirection dir = getPlayerDirection(player, dirStr);
|
||||
switch (dir) {
|
||||
case WEST:
|
||||
@ -624,7 +617,7 @@ public class WorldEdit {
|
||||
/**
|
||||
* Flush a block bag's changes to a player.
|
||||
*
|
||||
* @param player the player
|
||||
* @param actor the actor
|
||||
* @param editSession the edit session
|
||||
*/
|
||||
public void flushBlockBag(Actor actor, EditSession editSession) {
|
||||
@ -668,7 +661,7 @@ public class WorldEdit {
|
||||
* @param player the player
|
||||
*/
|
||||
@Deprecated
|
||||
public void handleDisconnect(LocalPlayer player) {
|
||||
public void handleDisconnect(Player player) {
|
||||
forgetPlayer(player);
|
||||
}
|
||||
|
||||
@ -677,7 +670,7 @@ public class WorldEdit {
|
||||
*
|
||||
* @param player the player
|
||||
*/
|
||||
public void markExpire(LocalPlayer player) {
|
||||
public void markExpire(Player player) {
|
||||
sessions.markforExpiration(player);
|
||||
}
|
||||
|
||||
@ -686,7 +679,7 @@ public class WorldEdit {
|
||||
*
|
||||
* @param player the player
|
||||
*/
|
||||
public void forgetPlayer(LocalPlayer player) {
|
||||
public void forgetPlayer(Player player) {
|
||||
sessions.remove(player);
|
||||
}
|
||||
|
||||
@ -703,7 +696,7 @@ public class WorldEdit {
|
||||
* @param player the player
|
||||
* @return true if the swing was handled
|
||||
*/
|
||||
public boolean handleArmSwing(LocalPlayer player) {
|
||||
public boolean handleArmSwing(Player player) {
|
||||
PlayerInputEvent event = new PlayerInputEvent(player, InputType.PRIMARY);
|
||||
getEventBus().post(event);
|
||||
return event.isCancelled();
|
||||
@ -715,7 +708,7 @@ public class WorldEdit {
|
||||
* @param player the player
|
||||
* @return true if the right click was handled
|
||||
*/
|
||||
public boolean handleRightClick(LocalPlayer player) {
|
||||
public boolean handleRightClick(Player player) {
|
||||
PlayerInputEvent event = new PlayerInputEvent(player, InputType.SECONDARY);
|
||||
getEventBus().post(event);
|
||||
return event.isCancelled();
|
||||
@ -728,7 +721,7 @@ public class WorldEdit {
|
||||
* @param clicked the clicked block
|
||||
* @return false if you want the action to go through
|
||||
*/
|
||||
public boolean handleBlockRightClick(LocalPlayer player, WorldVector clicked) {
|
||||
public boolean handleBlockRightClick(Player player, WorldVector clicked) {
|
||||
BlockInteractEvent event = new BlockInteractEvent(player, clicked.toLocation(), OPEN);
|
||||
getEventBus().post(event);
|
||||
return event.isCancelled();
|
||||
@ -741,7 +734,7 @@ public class WorldEdit {
|
||||
* @param clicked the clicked block
|
||||
* @return false if you want the action to go through
|
||||
*/
|
||||
public boolean handleBlockLeftClick(LocalPlayer player, WorldVector clicked) {
|
||||
public boolean handleBlockLeftClick(Player player, WorldVector clicked) {
|
||||
BlockInteractEvent event = new BlockInteractEvent(player, clicked.toLocation(), HIT);
|
||||
getEventBus().post(event);
|
||||
return event.isCancelled();
|
||||
@ -753,7 +746,7 @@ public class WorldEdit {
|
||||
* @param split
|
||||
* @return whether the command was processed
|
||||
*/
|
||||
public boolean handleCommand(LocalPlayer player, String[] split) {
|
||||
public boolean handleCommand(Player player, String[] split) {
|
||||
CommandEvent event = new CommandEvent(player, split);
|
||||
getEventBus().post(event);
|
||||
return event.isCancelled();
|
||||
@ -771,7 +764,7 @@ public class WorldEdit {
|
||||
* @param args arguments for the script
|
||||
* @throws WorldEditException
|
||||
*/
|
||||
public void runScript(LocalPlayer player, File f, String[] args) throws WorldEditException {
|
||||
public void runScript(Player player, File f, String[] args) throws WorldEditException {
|
||||
Request.reset();
|
||||
|
||||
String filename = f.getPath();
|
||||
@ -809,9 +802,8 @@ public class WorldEdit {
|
||||
return;
|
||||
}
|
||||
|
||||
LocalSession session = getSession(player);
|
||||
CraftScriptContext scriptContext =
|
||||
new CraftScriptContext(this, getServer(), getConfiguration(), session, player, args);
|
||||
LocalSession session = getSessionManager().get(player);
|
||||
CraftScriptContext scriptContext = new CraftScriptContext(this, getServer(), getConfiguration(), session, player, args);
|
||||
|
||||
CraftScriptEngine engine = null;
|
||||
|
||||
|
@ -160,7 +160,9 @@ public class BrushCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.smooth")
|
||||
public void smoothBrush(Player player, LocalSession session, EditSession editSession,
|
||||
@Optional("2") double radius, @Optional("4") int iterations, @Switch('n') boolean naturalBlocksOnly) throws WorldEditException {
|
||||
@Optional("2") double radius, @Optional("4") int iterations, @Switch('n')
|
||||
boolean naturalBlocksOnly) throws WorldEditException {
|
||||
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
|
||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||
@ -227,8 +229,7 @@ public class BrushCommands {
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.butcher")
|
||||
public void butcherBrush(CommandContext args, LocalSession session, Player player, EditSession editSession) throws WorldEditException {
|
||||
|
||||
public void butcherBrush(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
|
||||
double radius = args.argsLength() > 0 ? args.getDouble(0) : 5;
|
||||
|
@ -24,6 +24,7 @@ import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.math.MathUtils;
|
||||
import com.sk89q.worldedit.world.storage.LegacyChunkStore;
|
||||
import com.sk89q.worldedit.world.storage.McRegionChunkStore;
|
||||
@ -33,18 +34,19 @@ import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
|
||||
/**
|
||||
* Chunk tools.
|
||||
*
|
||||
* @author sk89q
|
||||
* Commands for working with chunks.
|
||||
*/
|
||||
public class ChunkCommands {
|
||||
private final WorldEdit we;
|
||||
|
||||
public ChunkCommands(WorldEdit we) {
|
||||
this.we = we;
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
public ChunkCommands(WorldEdit worldEdit) {
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -55,9 +57,7 @@ public class ChunkCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.chunkinfo")
|
||||
public void chunkInfo(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
public void chunkInfo(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
Vector pos = player.getBlockIn();
|
||||
int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
|
||||
int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
|
||||
@ -81,9 +81,7 @@ public class ChunkCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.listchunks")
|
||||
public void listChunks(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
public void listChunks(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
|
||||
|
||||
for (Vector2D chunk : chunks) {
|
||||
@ -100,11 +98,9 @@ public class ChunkCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.delchunks")
|
||||
@Logging(REGION)
|
||||
public void deleteChunks(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
public void deleteChunks(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
player.print("Note that this command does not yet support the mcregion format.");
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
|
||||
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
|
||||
FileOutputStream out = null;
|
||||
@ -139,7 +135,7 @@ public class ChunkCommands {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException ie) { }
|
||||
} catch (IOException ignored) { }
|
||||
}
|
||||
}
|
||||
} else if (config.shellSaveType.equalsIgnoreCase("bash")) {
|
||||
@ -171,7 +167,7 @@ public class ChunkCommands {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException ie) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -179,4 +175,5 @@ public class ChunkCommands {
|
||||
player.printError("Shell script type must be configured: 'bat' or 'bash' expected.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,28 +19,40 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.*;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
|
||||
/**
|
||||
* Clipboard commands.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class ClipboardCommands {
|
||||
private final WorldEdit we;
|
||||
|
||||
public ClipboardCommands(WorldEdit we) {
|
||||
this.we = we;
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public ClipboardCommands(WorldEdit worldEdit) {
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -55,9 +67,7 @@ public class ClipboardCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.copy")
|
||||
public void copy(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
public void copy(Player player, LocalSession session, EditSession editSession, @Switch('e') boolean copyEntities) throws WorldEditException {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector max = region.getMaximumPoint();
|
||||
@ -73,11 +83,12 @@ public class ClipboardCommands {
|
||||
clipboard.copy(editSession, region);
|
||||
}
|
||||
|
||||
if (args.hasFlag('e')) {
|
||||
if (copyEntities) {
|
||||
for (LocalEntity entity : player.getWorld().getEntities(region)) {
|
||||
clipboard.storeEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
session.setClipboard(clipboard);
|
||||
|
||||
player.print("Block(s) copied.");
|
||||
@ -97,16 +108,9 @@ public class ClipboardCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.cut")
|
||||
@Logging(REGION)
|
||||
public void cut(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
BaseBlock block = new BaseBlock(BlockID.AIR);
|
||||
public void cut(Player player, LocalSession session, EditSession editSession, @Optional("air") BaseBlock block, @Switch('e') boolean copyEntities) throws WorldEditException {
|
||||
World world = player.getWorld();
|
||||
|
||||
if (args.argsLength() > 0) {
|
||||
block = we.getBlock(player, args.getString(0));
|
||||
}
|
||||
|
||||
Region region = session.getSelection(world);
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector max = region.getMaximumPoint();
|
||||
@ -122,13 +126,14 @@ public class ClipboardCommands {
|
||||
clipboard.copy(editSession, region);
|
||||
}
|
||||
|
||||
if (args.hasFlag('e')) {
|
||||
if (copyEntities) {
|
||||
LocalEntity[] entities = world.getEntities(region);
|
||||
for (LocalEntity entity : entities) {
|
||||
clipboard.storeEntity(entity);
|
||||
}
|
||||
world.killEntities(entities);
|
||||
}
|
||||
|
||||
session.setClipboard(clipboard);
|
||||
|
||||
editSession.setBlocks(region, block);
|
||||
@ -151,8 +156,7 @@ public class ClipboardCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.paste")
|
||||
@Logging(PLACEMENT)
|
||||
public void paste(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void paste(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
boolean atOrigin = args.hasFlag('o');
|
||||
boolean pasteNoAir = args.hasFlag('a');
|
||||
@ -194,8 +198,7 @@ public class ClipboardCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.rotate")
|
||||
public void rotate(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void rotate(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
int angle = args.getInteger(0);
|
||||
|
||||
@ -221,12 +224,8 @@ public class ClipboardCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.flip")
|
||||
public void flip(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
CuboidClipboard.FlipDirection dir = we.getFlipDirection(player,
|
||||
args.argsLength() > 0 ? args.getString(0).toLowerCase() : "me");
|
||||
|
||||
public void flip(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
CuboidClipboard.FlipDirection dir = worldEdit.getFlipDirection(player, args.argsLength() > 0 ? args.getString(0).toLowerCase() : "me");
|
||||
CuboidClipboard clipboard = session.getClipboard();
|
||||
clipboard.flip(dir, args.hasFlag('p'));
|
||||
player.print("Clipboard flipped.");
|
||||
@ -241,9 +240,8 @@ public class ClipboardCommands {
|
||||
)
|
||||
@Deprecated
|
||||
@CommandPermissions("worldedit.clipboard.load")
|
||||
public void load(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
player.printError("This command is no longer used. See //schematic load.");
|
||||
public void load(Actor actor) {
|
||||
actor.printError("This command is no longer used. See //schematic load.");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -255,9 +253,8 @@ public class ClipboardCommands {
|
||||
)
|
||||
@Deprecated
|
||||
@CommandPermissions("worldedit.clipboard.save")
|
||||
public void save(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
player.printError("This command is no longer used. See //schematic save.");
|
||||
public void save(Actor actor) {
|
||||
actor.printError("This command is no longer used. See //schematic save.");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -268,9 +265,7 @@ public class ClipboardCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.clear")
|
||||
public void clearClipboard(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
public void clearClipboard(Player player, LocalSession session, EditSession editSession) throws WorldEditException {
|
||||
session.setClipboard(null);
|
||||
player.print("Clipboard cleared.");
|
||||
}
|
||||
|
@ -24,19 +24,28 @@ import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.ItemType;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.masks.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* General WorldEdit commands.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class GeneralCommands {
|
||||
private final WorldEdit we;
|
||||
|
||||
public GeneralCommands(WorldEdit we) {
|
||||
this.we = we;
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public GeneralCommands(WorldEdit worldEdit) {
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -47,10 +56,9 @@ public class GeneralCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.limit")
|
||||
public void limit(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void limit(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
boolean mayDisable = player.hasPermission("worldedit.limit.unrestricted");
|
||||
|
||||
int limit = Math.max(-1, args.getInteger(0));
|
||||
@ -78,8 +86,7 @@ public class GeneralCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.fast")
|
||||
public void fast(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void fast(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
String newState = args.getString(0, null);
|
||||
if (session.hasFastMode()) {
|
||||
@ -109,13 +116,11 @@ public class GeneralCommands {
|
||||
max = -1
|
||||
)
|
||||
@CommandPermissions("worldedit.global-mask")
|
||||
public void gmask(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
if (args.argsLength() == 0) {
|
||||
session.setMask(null);
|
||||
public void gmask(Player player, LocalSession session, EditSession editSession, @Optional Mask mask) throws WorldEditException {
|
||||
if (mask == null) {
|
||||
session.setMask((Mask) null);
|
||||
player.print("Global mask disabled.");
|
||||
} else {
|
||||
Mask mask = we.getBlockMask(player, session, args.getJoinedStrings(0));
|
||||
session.setMask(mask);
|
||||
player.print("Global mask set.");
|
||||
}
|
||||
@ -128,8 +133,7 @@ public class GeneralCommands {
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
public void togglePlace(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void togglePlace(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
if (session.togglePlacementPosition()) {
|
||||
player.print("Now placing at pos #1.");
|
||||
|
@ -19,41 +19,46 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.BiomeType;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
import com.sk89q.worldedit.util.command.binding.Range;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.binding.Text;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.*;
|
||||
|
||||
/**
|
||||
* Generation commands.
|
||||
*
|
||||
* @author sk89q
|
||||
* Commands for the generation of shapes and other objects.
|
||||
*/
|
||||
public class GenerationCommands {
|
||||
private final WorldEdit we;
|
||||
|
||||
public GenerationCommands(WorldEdit we) {
|
||||
this.we = we;
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public GenerationCommands(WorldEdit worldEdit) {
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/hcyl" },
|
||||
usage = "<block> <radius>[,<radius>] [height]",
|
||||
usage = "<pattern> <radius>[,<radius>] [height]",
|
||||
desc = "Generates a hollow cylinder.",
|
||||
help =
|
||||
"Generates a hollow cylinder.\n" +
|
||||
@ -65,40 +70,14 @@ public class GenerationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.cylinder")
|
||||
@Logging(PLACEMENT)
|
||||
public void hcyl(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||
String[] radiuses = args.getString(1).split(",");
|
||||
final double radiusX, radiusZ;
|
||||
switch (radiuses.length) {
|
||||
case 1:
|
||||
radiusX = radiusZ = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
radiusX = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||
radiusZ = Math.max(1, Double.parseDouble(radiuses[1]));
|
||||
break;
|
||||
|
||||
default:
|
||||
player.printError("You must either specify 1 or 2 radius values.");
|
||||
return;
|
||||
}
|
||||
int height = args.argsLength() > 2 ? args.getInteger(2) : 1;
|
||||
|
||||
we.checkMaxRadius(radiusX);
|
||||
we.checkMaxRadius(radiusZ);
|
||||
we.checkMaxRadius(height);
|
||||
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
int affected = editSession.makeCylinder(pos, block, radiusX, radiusZ, height, false);
|
||||
player.print(affected + " block(s) have been created.");
|
||||
public void hcyl(Player player, LocalSession session, EditSession editSession, Pattern pattern, String radiusString, @Optional("1") int height) throws WorldEditException {
|
||||
cyl(player, session, editSession, pattern, radiusString, height, true);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/cyl" },
|
||||
usage = "<block> <radius>[,<radius>] [height]",
|
||||
flags = "h",
|
||||
desc = "Generates a cylinder.",
|
||||
help =
|
||||
"Generates a cylinder.\n" +
|
||||
@ -110,34 +89,30 @@ public class GenerationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.cylinder")
|
||||
@Logging(PLACEMENT)
|
||||
public void cyl(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||
String[] radiuses = args.getString(1).split(",");
|
||||
public void cyl(Player player, LocalSession session, EditSession editSession, Pattern pattern, String radiusString, @Optional("1") int height, @Switch('h') boolean hollow) throws WorldEditException {
|
||||
String[] radii = radiusString.split(",");
|
||||
final double radiusX, radiusZ;
|
||||
switch (radiuses.length) {
|
||||
switch (radii.length) {
|
||||
case 1:
|
||||
radiusX = radiusZ = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||
radiusX = radiusZ = Math.max(1, Double.parseDouble(radii[0]));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
radiusX = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||
radiusZ = Math.max(1, Double.parseDouble(radiuses[1]));
|
||||
radiusX = Math.max(1, Double.parseDouble(radii[0]));
|
||||
radiusZ = Math.max(1, Double.parseDouble(radii[1]));
|
||||
break;
|
||||
|
||||
default:
|
||||
player.printError("You must either specify 1 or 2 radius values.");
|
||||
return;
|
||||
}
|
||||
int height = args.argsLength() > 2 ? args.getInteger(2) : 1;
|
||||
|
||||
we.checkMaxRadius(radiusX);
|
||||
we.checkMaxRadius(radiusZ);
|
||||
we.checkMaxRadius(height);
|
||||
worldEdit.checkMaxRadius(radiusX);
|
||||
worldEdit.checkMaxRadius(radiusZ);
|
||||
worldEdit.checkMaxRadius(height);
|
||||
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
int affected = editSession.makeCylinder(pos, block, radiusX, radiusZ, height, true);
|
||||
int affected = editSession.makeCylinder(pos, Patterns.wrap(pattern), radiusX, radiusZ, height, !hollow);
|
||||
player.print(affected + " block(s) have been created.");
|
||||
}
|
||||
|
||||
@ -155,52 +130,14 @@ public class GenerationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.sphere")
|
||||
@Logging(PLACEMENT)
|
||||
public void hsphere(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
final Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||
String[] radiuses = args.getString(1).split(",");
|
||||
final double radiusX, radiusY, radiusZ;
|
||||
switch (radiuses.length) {
|
||||
case 1:
|
||||
radiusX = radiusY = radiusZ = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
radiusX = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||
radiusY = Math.max(1, Double.parseDouble(radiuses[1]));
|
||||
radiusZ = Math.max(1, Double.parseDouble(radiuses[2]));
|
||||
break;
|
||||
|
||||
default:
|
||||
player.printError("You must either specify 1 or 3 radius values.");
|
||||
return;
|
||||
}
|
||||
|
||||
we.checkMaxRadius(radiusX);
|
||||
we.checkMaxRadius(radiusY);
|
||||
we.checkMaxRadius(radiusZ);
|
||||
|
||||
final boolean raised;
|
||||
if (args.argsLength() > 2) {
|
||||
raised = args.getString(2).equalsIgnoreCase("true") || args.getString(2).equalsIgnoreCase("yes");
|
||||
} else {
|
||||
raised = false;
|
||||
}
|
||||
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
if (raised) {
|
||||
pos = pos.add(0, radiusY, 0);
|
||||
}
|
||||
|
||||
int affected = editSession.makeSphere(pos, block, radiusX, radiusY, radiusZ, false);
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
public void hsphere(Player player, LocalSession session, EditSession editSession, Pattern pattern, String radiusString, @Optional("false") boolean raised) throws WorldEditException {
|
||||
sphere(player, session, editSession, pattern, radiusString, raised, true);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/sphere" },
|
||||
usage = "<block> <radius>[,<radius>,<radius>] [raised?]",
|
||||
flags = "h",
|
||||
desc = "Generates a filled sphere.",
|
||||
help =
|
||||
"Generates a filled sphere.\n" +
|
||||
@ -212,21 +149,18 @@ public class GenerationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.sphere")
|
||||
@Logging(PLACEMENT)
|
||||
public void sphere(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||
String[] radiuses = args.getString(1).split(",");
|
||||
public void sphere(Player player, LocalSession session, EditSession editSession, Pattern pattern, String radiusString, @Optional("false") boolean raised, @Switch('h') boolean hollow) throws WorldEditException {
|
||||
String[] radii = radiusString.split(",");
|
||||
final double radiusX, radiusY, radiusZ;
|
||||
switch (radiuses.length) {
|
||||
switch (radii.length) {
|
||||
case 1:
|
||||
radiusX = radiusY = radiusZ = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||
radiusX = radiusY = radiusZ = Math.max(1, Double.parseDouble(radii[0]));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
radiusX = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||
radiusY = Math.max(1, Double.parseDouble(radiuses[1]));
|
||||
radiusZ = Math.max(1, Double.parseDouble(radiuses[2]));
|
||||
radiusX = Math.max(1, Double.parseDouble(radii[0]));
|
||||
radiusY = Math.max(1, Double.parseDouble(radii[1]));
|
||||
radiusZ = Math.max(1, Double.parseDouble(radii[2]));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -234,23 +168,16 @@ public class GenerationCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
we.checkMaxRadius(radiusX);
|
||||
we.checkMaxRadius(radiusY);
|
||||
we.checkMaxRadius(radiusZ);
|
||||
|
||||
final boolean raised;
|
||||
if (args.argsLength() > 2) {
|
||||
raised = args.getString(2).equalsIgnoreCase("true") || args.getString(2).equalsIgnoreCase("yes");
|
||||
} else {
|
||||
raised = false;
|
||||
}
|
||||
worldEdit.checkMaxRadius(radiusX);
|
||||
worldEdit.checkMaxRadius(radiusY);
|
||||
worldEdit.checkMaxRadius(radiusZ);
|
||||
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
if (raised) {
|
||||
pos = pos.add(0, radiusY, 0);
|
||||
}
|
||||
|
||||
int affected = editSession.makeSphere(pos, block, radiusX, radiusY, radiusZ, true);
|
||||
int affected = editSession.makeSphere(pos, Patterns.wrap(pattern), radiusX, radiusY, radiusZ, !hollow);
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
}
|
||||
@ -265,22 +192,9 @@ public class GenerationCommands {
|
||||
@CommandPermissions("worldedit.generation.forest")
|
||||
@Logging(POSITION)
|
||||
@SuppressWarnings("deprecation")
|
||||
public void forestGen(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 10;
|
||||
TreeGenerator.TreeType type = args.argsLength() > 1 ?
|
||||
TreeGenerator.lookup(args.getString(1))
|
||||
: TreeGenerator.TreeType.TREE;
|
||||
double density = args.argsLength() > 2 ? args.getDouble(2) / 100 : 0.05;
|
||||
|
||||
if (type == null) {
|
||||
player.printError("Tree type '" + args.getString(1) + "' is unknown.");
|
||||
return;
|
||||
}
|
||||
|
||||
int affected = editSession.makeForest(session.getPlacementPosition(player),
|
||||
size, density, new TreeGenerator(type));
|
||||
public void forestGen(Player player, LocalSession session, EditSession editSession, @Optional("10") int size, @Optional("tree") TreeType type, @Optional("5") double density) throws WorldEditException {
|
||||
density = density / 100;
|
||||
int affected = editSession.makeForest(session.getPlacementPosition(player), size, density, new TreeGenerator(type));
|
||||
player.print(affected + " trees created.");
|
||||
}
|
||||
|
||||
@ -293,39 +207,11 @@ public class GenerationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.pumpkins")
|
||||
@Logging(POSITION)
|
||||
public void pumpkins(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 10;
|
||||
|
||||
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(player), size);
|
||||
public void pumpkins(Player player, LocalSession session, EditSession editSession, @Optional("10") int apothem) throws WorldEditException {
|
||||
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(player), apothem);
|
||||
player.print(affected + " pumpkin patches created.");
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/pyramid" },
|
||||
usage = "<block> <size>",
|
||||
desc = "Generate a filled pyramid",
|
||||
min = 2,
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.pyramid")
|
||||
@Logging(PLACEMENT)
|
||||
public void pyramid(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||
int size = Math.max(1, args.getInteger(1));
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
int affected = editSession.makePyramid(pos, block, size, true);
|
||||
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/hpyramid" },
|
||||
usage = "<block> <size>",
|
||||
@ -335,17 +221,24 @@ public class GenerationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.pyramid")
|
||||
@Logging(PLACEMENT)
|
||||
public void hpyramid(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void hollowPyramid(Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size) throws WorldEditException {
|
||||
pyramid(player, session, editSession, pattern, size, true);
|
||||
}
|
||||
|
||||
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||
int size = Math.max(1, args.getInteger(1));
|
||||
@Command(
|
||||
aliases = { "/pyramid" },
|
||||
usage = "<block> <size>",
|
||||
flags = "h",
|
||||
desc = "Generate a filled pyramid",
|
||||
min = 2,
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.pyramid")
|
||||
@Logging(PLACEMENT)
|
||||
public void pyramid(Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow) throws WorldEditException {
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
int affected = editSession.makePyramid(pos, block, size, false);
|
||||
|
||||
worldEdit.checkMaxRadius(size);
|
||||
int affected = editSession.makePyramid(pos, Patterns.wrap(pattern), size, !hollow);
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
}
|
||||
@ -371,26 +264,25 @@ public class GenerationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.shape")
|
||||
@Logging(ALL)
|
||||
public void generate(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
final Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||
final Region region = session.getSelection(player.getWorld());
|
||||
|
||||
final boolean hollow = args.hasFlag('h');
|
||||
|
||||
final String expression = args.getJoinedStrings(1);
|
||||
public void generate(Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
Pattern pattern,
|
||||
@Text String expression,
|
||||
@Switch('h') boolean hollow,
|
||||
@Switch('r') boolean useRawCoords,
|
||||
@Switch('o') boolean offset,
|
||||
@Switch('c') boolean offsetCenter) throws WorldEditException {
|
||||
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
|
||||
if (args.hasFlag('r')) {
|
||||
if (useRawCoords) {
|
||||
zero = Vector.ZERO;
|
||||
unit = Vector.ONE;
|
||||
} else if (args.hasFlag('o')) {
|
||||
} else if (offset) {
|
||||
zero = session.getPlacementPosition(player);
|
||||
unit = Vector.ONE;
|
||||
} else if (args.hasFlag('c')) {
|
||||
} else if (offsetCenter) {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
|
||||
@ -409,7 +301,7 @@ public class GenerationCommands {
|
||||
}
|
||||
|
||||
try {
|
||||
final int affected = editSession.makeShape(region, zero, unit, pattern, expression, hollow);
|
||||
final int affected = editSession.makeShape(region, zero, unit, Patterns.wrap(pattern), expression, hollow);
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
} catch (ExpressionException e) {
|
||||
@ -438,26 +330,24 @@ public class GenerationCommands {
|
||||
)
|
||||
@CommandPermissions({"worldedit.generation.shape", "worldedit.biome.set"})
|
||||
@Logging(ALL)
|
||||
public void generateBiome(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
final BiomeType target = we.getServer().getBiomes().get(args.getString(0));
|
||||
final Region region = session.getSelection(player.getWorld());
|
||||
|
||||
final boolean hollow = args.hasFlag('h');
|
||||
|
||||
final String expression = args.getJoinedStrings(1);
|
||||
|
||||
public void generateBiome(Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
BiomeType target,
|
||||
@Text String expression,
|
||||
@Switch('h') boolean hollow,
|
||||
@Switch('r') boolean useRawCoords,
|
||||
@Switch('o') boolean offset,
|
||||
@Switch('c') boolean offsetCenter) throws WorldEditException {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
|
||||
if (args.hasFlag('r')) {
|
||||
if (useRawCoords) {
|
||||
zero = Vector.ZERO;
|
||||
unit = Vector.ONE;
|
||||
} else if (args.hasFlag('o')) {
|
||||
} else if (offset) {
|
||||
zero = session.getPlacementPosition(player);
|
||||
unit = Vector.ONE;
|
||||
} else if (args.hasFlag('c')) {
|
||||
} else if (offsetCenter) {
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
|
||||
@ -483,4 +373,5 @@ public class GenerationCommands {
|
||||
player.printError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,17 +23,25 @@ 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.entity.Player;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* History little commands.
|
||||
*
|
||||
* @author sk89q
|
||||
* Commands to undo, redo, and clear history.
|
||||
*/
|
||||
public class HistoryCommands {
|
||||
private final WorldEdit we;
|
||||
|
||||
public HistoryCommands(WorldEdit we) {
|
||||
this.we = we;
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public HistoryCommands(WorldEdit worldEdit) {
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -44,9 +52,7 @@ public class HistoryCommands {
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.history.undo")
|
||||
public void undo(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
public void undo(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
int times = Math.max(1, args.getInteger(0, 1));
|
||||
for (int i = 0; i < times; ++i) {
|
||||
EditSession undone;
|
||||
@ -54,7 +60,7 @@ public class HistoryCommands {
|
||||
undone = session.undo(session.getBlockBag(player), player);
|
||||
} else {
|
||||
player.checkPermission("worldedit.history.undo.other");
|
||||
LocalSession sess = we.getSession(args.getString(1));
|
||||
LocalSession sess = worldEdit.getSession(args.getString(1));
|
||||
if (sess == null) {
|
||||
player.printError("Unable to find session for " + args.getString(1));
|
||||
break;
|
||||
@ -63,7 +69,7 @@ public class HistoryCommands {
|
||||
}
|
||||
if (undone != null) {
|
||||
player.print("Undo successful.");
|
||||
we.flushBlockBag(player, undone);
|
||||
worldEdit.flushBlockBag(player, undone);
|
||||
} else {
|
||||
player.printError("Nothing left to undo.");
|
||||
break;
|
||||
@ -79,8 +85,7 @@ public class HistoryCommands {
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.history.redo")
|
||||
public void redo(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void redo(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
int times = Math.max(1, args.getInteger(0, 1));
|
||||
|
||||
@ -90,7 +95,7 @@ public class HistoryCommands {
|
||||
redone = session.redo(session.getBlockBag(player), player);
|
||||
} else {
|
||||
player.checkPermission("worldedit.history.redo.other");
|
||||
LocalSession sess = we.getSession(args.getString(1));
|
||||
LocalSession sess = worldEdit.getSession(args.getString(1));
|
||||
if (sess == null) {
|
||||
player.printError("Unable to find session for " + args.getString(1));
|
||||
break;
|
||||
@ -99,7 +104,7 @@ public class HistoryCommands {
|
||||
}
|
||||
if (redone != null) {
|
||||
player.print("Redo successful.");
|
||||
we.flushBlockBag(player, redone);
|
||||
worldEdit.flushBlockBag(player, redone);
|
||||
} else {
|
||||
player.printError("Nothing left to redo.");
|
||||
}
|
||||
@ -114,10 +119,9 @@ public class HistoryCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.history.clear")
|
||||
public void clearHistory(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
public void clearHistory(Player player, LocalSession session, EditSession editSession) throws WorldEditException {
|
||||
session.clearHistory();
|
||||
player.print("History cleared.");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,31 +19,32 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
|
||||
|
||||
/**
|
||||
* Navigation commands.
|
||||
*
|
||||
* @author sk89q
|
||||
* Commands for moving the player around.
|
||||
*/
|
||||
public class NavigationCommands {
|
||||
@SuppressWarnings("unused")
|
||||
private final WorldEdit we;
|
||||
|
||||
public NavigationCommands(WorldEdit we) {
|
||||
this.we = we;
|
||||
@SuppressWarnings("unused")
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public NavigationCommands(WorldEdit worldEdit) {
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -54,9 +55,7 @@ public class NavigationCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.unstuck")
|
||||
public void unstuck(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
public void unstuck(Player player) throws WorldEditException {
|
||||
player.print("There you go!");
|
||||
player.findFreePosition();
|
||||
}
|
||||
@ -69,8 +68,7 @@ public class NavigationCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.ascend")
|
||||
public void ascend(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void ascend(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
int levelsToAscend = 0;
|
||||
if (args.argsLength() == 0) {
|
||||
levelsToAscend = 1;
|
||||
@ -96,8 +94,7 @@ public class NavigationCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.descend")
|
||||
public void descend(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void descend(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
int levelsToDescend = 0;
|
||||
if (args.argsLength() == 0) {
|
||||
levelsToDescend = 1;
|
||||
@ -125,8 +122,7 @@ public class NavigationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.ceiling")
|
||||
@Logging(POSITION)
|
||||
public void ceiling(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void ceiling(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
final int clearance = args.argsLength() > 0 ?
|
||||
Math.max(0, args.getInteger(0)) : 0;
|
||||
@ -147,8 +143,7 @@ public class NavigationCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.thru.command")
|
||||
public void thru(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void thru(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
if (player.passThroughForwardWall(6)) {
|
||||
player.print("Whoosh!");
|
||||
} else {
|
||||
@ -164,8 +159,7 @@ public class NavigationCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.jumpto.command")
|
||||
public void jumpTo(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void jumpTo(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
WorldVector pos = player.getSolidBlockTrace(300);
|
||||
if (pos != null) {
|
||||
@ -186,8 +180,7 @@ public class NavigationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.up")
|
||||
@Logging(POSITION)
|
||||
public void up(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void up(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
final int distance = args.getInteger(0);
|
||||
|
||||
@ -206,7 +199,7 @@ public class NavigationCommands {
|
||||
* @return true, if glass should always be put under the player
|
||||
*/
|
||||
private boolean getAlwaysGlass(CommandContext args) {
|
||||
final LocalConfiguration config = we.getConfiguration();
|
||||
final LocalConfiguration config = worldEdit.getConfiguration();
|
||||
|
||||
final boolean forceFlight = args.hasFlag('f');
|
||||
final boolean forceGlass = args.hasFlag('g');
|
||||
|
@ -20,50 +20,61 @@
|
||||
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.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
||||
import com.sk89q.worldedit.math.convolution.HeightMap;
|
||||
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.GroundFunction;
|
||||
import com.sk89q.worldedit.function.generator.FloraGenerator;
|
||||
import com.sk89q.worldedit.function.generator.ForestGenerator;
|
||||
import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
||||
import com.sk89q.worldedit.masks.Mask;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
||||
import com.sk89q.worldedit.math.convolution.HeightMap;
|
||||
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
||||
import com.sk89q.worldedit.math.noise.RandomNoise;
|
||||
import com.sk89q.worldedit.regions.ConvexPolyhedralRegion;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.math.noise.RandomNoise;
|
||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
import com.sk89q.worldedit.util.command.binding.Range;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.binding.Text;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.*;
|
||||
import static com.sk89q.worldedit.regions.Regions.*;
|
||||
|
||||
/**
|
||||
* Region related commands.
|
||||
*
|
||||
* @author sk89q
|
||||
* Commands that operate on regions.
|
||||
*/
|
||||
public class RegionCommands {
|
||||
private final WorldEdit we;
|
||||
|
||||
public RegionCommands(WorldEdit we) {
|
||||
this.we = we;
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public RegionCommands(WorldEdit worldEdit) {
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -75,20 +86,8 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.set")
|
||||
@Logging(REGION)
|
||||
public void set(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||
|
||||
int affected;
|
||||
|
||||
if (pattern instanceof SingleBlockPattern) {
|
||||
affected = editSession.setBlocks(session.getSelection(player.getWorld()),
|
||||
((SingleBlockPattern) pattern).getBlock());
|
||||
} else {
|
||||
affected = editSession.setBlocks(session.getSelection(player.getWorld()), pattern);
|
||||
}
|
||||
|
||||
public void set(Player player, LocalSession session, EditSession editSession, Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.setBlocks(session.getSelection(player.getWorld()), Patterns.wrap(pattern));
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
}
|
||||
|
||||
@ -107,24 +106,21 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.line")
|
||||
@Logging(REGION)
|
||||
public void line(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void line(Player player, EditSession editSession,
|
||||
@Selection Region region,
|
||||
Pattern pattern,
|
||||
@Optional("0") @Range(min = 0) int thickness,
|
||||
@Switch('h') boolean shell) throws WorldEditException {
|
||||
|
||||
Region region = session.getSelection(session.getSelectionWorld());
|
||||
if (!(region instanceof CuboidRegion)) {
|
||||
player.printError("Invalid region type");
|
||||
return;
|
||||
}
|
||||
if (args.argsLength() < 2 ? false : args.getDouble(1) < 0) {
|
||||
player.printError("Invalid thickness. Must not be negative");
|
||||
player.printError("//line only works with cuboid selections");
|
||||
return;
|
||||
}
|
||||
|
||||
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||
CuboidRegion cuboidregion = (CuboidRegion) region;
|
||||
Vector pos1 = cuboidregion.getPos1();
|
||||
Vector pos2 = cuboidregion.getPos2();
|
||||
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, args.argsLength() < 2 ? 0 : args.getDouble(1), !args.hasFlag('h'));
|
||||
int blocksChanged = editSession.drawLine(Patterns.wrap(pattern), pos1, pos2, thickness, !shell);
|
||||
|
||||
player.print(blocksChanged + " block(s) have been changed.");
|
||||
}
|
||||
@ -144,24 +140,20 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.curve")
|
||||
@Logging(REGION)
|
||||
public void curve(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
Region region = session.getSelection(session.getSelectionWorld());
|
||||
public void curve(Player player, EditSession editSession,
|
||||
@Selection Region region,
|
||||
Pattern pattern,
|
||||
@Optional("0") @Range(min = 0) int thickness,
|
||||
@Switch('h') boolean shell) throws WorldEditException {
|
||||
if (!(region instanceof ConvexPolyhedralRegion)) {
|
||||
player.printError("Invalid region type");
|
||||
return;
|
||||
}
|
||||
if (args.argsLength() < 2 ? false : args.getDouble(1) < 0) {
|
||||
player.printError("Invalid thickness. Must not be negative");
|
||||
player.printError("//line only works with convex polyhedral selections");
|
||||
return;
|
||||
}
|
||||
|
||||
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
|
||||
List<Vector> vectors = new ArrayList<Vector>(cpregion.getVertices());
|
||||
|
||||
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, args.argsLength() < 2 ? 0 : args.getDouble(1), !args.hasFlag('h'));
|
||||
int blocksChanged = editSession.drawSpline(Patterns.wrap(pattern), vectors, 0, 0, 0, 10, thickness, !shell);
|
||||
|
||||
player.print(blocksChanged + " block(s) have been changed.");
|
||||
}
|
||||
@ -176,27 +168,11 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.replace")
|
||||
@Logging(REGION)
|
||||
public void replace(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
Set<BaseBlock> from;
|
||||
Pattern to;
|
||||
if (args.argsLength() == 1) {
|
||||
from = null;
|
||||
to = we.getBlockPattern(player, args.getString(0));
|
||||
} else {
|
||||
from = we.getBlocks(player, args.getString(0), true, !args.hasFlag('f'));
|
||||
to = we.getBlockPattern(player, args.getString(1));
|
||||
public void replace(Player player, EditSession editSession, @Selection Region region, @Optional Mask from, Pattern to) throws WorldEditException {
|
||||
if (from == null) {
|
||||
from = new ExistingBlockMask(editSession);
|
||||
}
|
||||
|
||||
final int affected;
|
||||
if (to instanceof SingleBlockPattern) {
|
||||
affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from,
|
||||
((SingleBlockPattern) to).getBlock());
|
||||
} else {
|
||||
affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from, to);
|
||||
}
|
||||
|
||||
int affected = editSession.replaceBlocks(region, from, Patterns.wrap(to));
|
||||
player.print(affected + " block(s) have been replaced.");
|
||||
}
|
||||
|
||||
@ -209,20 +185,9 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.overlay")
|
||||
@Logging(REGION)
|
||||
public void overlay(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
Pattern pat = we.getBlockPattern(player, args.getString(0));
|
||||
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
int affected = 0;
|
||||
if (pat instanceof SingleBlockPattern) {
|
||||
affected = editSession.overlayCuboidBlocks(region,
|
||||
((SingleBlockPattern) pat).getBlock());
|
||||
} else {
|
||||
affected = editSession.overlayCuboidBlocks(region, pat);
|
||||
}
|
||||
player.print(affected + " block(s) have been overlayed.");
|
||||
public void overlay(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.overlayCuboidBlocks(region, Patterns.wrap(pattern));
|
||||
player.print(affected + " block(s) have been overlaid.");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -234,12 +199,8 @@ public class RegionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.region.center")
|
||||
public void center(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
|
||||
int affected = editSession.center(region, pattern);
|
||||
public void center(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.center(region, Patterns.wrap(pattern));
|
||||
player.print("Center set ("+ affected + " blocks changed)");
|
||||
}
|
||||
|
||||
@ -252,12 +213,9 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.naturalize")
|
||||
@Logging(REGION)
|
||||
public void naturalize(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
public void naturalize(Player player, EditSession editSession, @Selection Region region) throws WorldEditException {
|
||||
int affected = editSession.naturalizeCuboidBlocks(region);
|
||||
player.print(affected + " block(s) have been naturalized.");
|
||||
player.print(affected + " block(s) have been made to look more natural.");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -269,20 +227,8 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.walls")
|
||||
@Logging(REGION)
|
||||
public void walls(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
final Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||
final int affected;
|
||||
final Region region = session.getSelection(player.getWorld());
|
||||
if (!(region instanceof CuboidRegion)) {
|
||||
affected = editSession.makeWalls(region, pattern);
|
||||
} else if (pattern instanceof SingleBlockPattern) {
|
||||
affected = editSession.makeCuboidWalls(region, ((SingleBlockPattern) pattern).getBlock());
|
||||
} else {
|
||||
affected = editSession.makeCuboidWalls(region, pattern);
|
||||
}
|
||||
|
||||
public void walls(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.makeCuboidWalls(region, Patterns.wrap(pattern));
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
}
|
||||
|
||||
@ -295,20 +241,8 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.faces")
|
||||
@Logging(REGION)
|
||||
public void faces(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
final Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||
final int affected;
|
||||
final Region region = session.getSelection(player.getWorld());
|
||||
if (!(region instanceof CuboidRegion)) {
|
||||
affected = editSession.makeFaces(region, pattern);
|
||||
} else if (pattern instanceof SingleBlockPattern) {
|
||||
affected = editSession.makeCuboidFaces(region, ((SingleBlockPattern) pattern).getBlock());
|
||||
} else {
|
||||
affected = editSession.makeCuboidFaces(region, pattern);
|
||||
}
|
||||
|
||||
public void faces(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.makeCuboidFaces(region, Patterns.wrap(pattern));
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
}
|
||||
|
||||
@ -325,15 +259,8 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.smooth")
|
||||
@Logging(REGION)
|
||||
public void smooth(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
int iterations = 1;
|
||||
if (args.argsLength() > 0) {
|
||||
iterations = args.getInteger(0);
|
||||
}
|
||||
|
||||
HeightMap heightMap = new HeightMap(editSession, session.getSelection(player.getWorld()), args.hasFlag('n'));
|
||||
public void smooth(Player player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Switch('n') boolean affectNatural) throws WorldEditException {
|
||||
HeightMap heightMap = new HeightMap(editSession, region, affectNatural);
|
||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
||||
int affected = heightMap.applyFilter(filter, iterations);
|
||||
player.print("Terrain's height map smoothed. " + affected + " block(s) changed.");
|
||||
@ -354,28 +281,18 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.move")
|
||||
@Logging(ORIENTATION_REGION)
|
||||
public void move(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void move(Player player, EditSession editSession, LocalSession session,
|
||||
@Selection Region region,
|
||||
@Optional("1") @Range(min = 1) int count,
|
||||
@Optional(Direction.AIM) @Direction Vector direction,
|
||||
@Optional("air") BaseBlock replace,
|
||||
@Switch('s') boolean moveSelection) throws WorldEditException {
|
||||
|
||||
int count = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
|
||||
Vector dir = we.getDirection(player,
|
||||
args.argsLength() > 1 ? args.getString(1).toLowerCase() : "me");
|
||||
BaseBlock replace;
|
||||
int affected = editSession.moveRegion(region, direction, count, true, replace);
|
||||
|
||||
// Replacement block argument
|
||||
if (args.argsLength() > 2) {
|
||||
replace = we.getBlock(player, args.getString(2));
|
||||
} else {
|
||||
replace = new BaseBlock(BlockID.AIR);
|
||||
}
|
||||
|
||||
int affected = editSession.moveRegion(session.getSelection(player.getWorld()),
|
||||
dir, count, true, replace);
|
||||
|
||||
if (args.hasFlag('s')) {
|
||||
if (moveSelection) {
|
||||
try {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
region.shift(dir.multiply(count));
|
||||
region.shift(direction.multiply(count));
|
||||
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
@ -402,22 +319,19 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.stack")
|
||||
@Logging(ORIENTATION_REGION)
|
||||
public void stack(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void stack(Player player, EditSession editSession, LocalSession session,
|
||||
@Selection Region region,
|
||||
@Optional("1") @Range(min = 1) int count,
|
||||
@Optional(Direction.AIM) @Direction Vector direction,
|
||||
@Switch('s') boolean moveSelection,
|
||||
@Switch('a') boolean ignoreAirBlocks) throws WorldEditException {
|
||||
int affected = editSession.stackCuboidRegion(region, direction, count, !ignoreAirBlocks);
|
||||
|
||||
int count = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
|
||||
Vector dir = we.getDiagonalDirection(player,
|
||||
args.argsLength() > 1 ? args.getString(1).toLowerCase() : "me");
|
||||
|
||||
int affected = editSession.stackCuboidRegion(session.getSelection(player.getWorld()),
|
||||
dir, count, !args.hasFlag('a'));
|
||||
|
||||
if (args.hasFlag('s')) {
|
||||
if (ignoreAirBlocks) {
|
||||
try {
|
||||
final Region region = session.getSelection(player.getWorld());
|
||||
final Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint());
|
||||
|
||||
final Vector shiftVector = dir.multiply(count * (Math.abs(dir.dot(size)) + 1));
|
||||
final Vector shiftVector = direction.multiply(count * (Math.abs(direction.dot(size)) + 1));
|
||||
region.shift(shiftVector);
|
||||
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
@ -443,14 +357,14 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.regen")
|
||||
@Logging(REGION)
|
||||
public void regenerateChunk(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
public void regenerateChunk(Player player, LocalSession session, EditSession editSession, @Selection Region region) throws WorldEditException {
|
||||
Mask mask = session.getMask();
|
||||
session.setMask(null);
|
||||
try {
|
||||
session.setMask((Mask) null);
|
||||
player.getWorld().regenerate(region, editSession);
|
||||
} finally {
|
||||
session.setMask(mask);
|
||||
}
|
||||
player.print("Region regenerated.");
|
||||
}
|
||||
|
||||
@ -469,20 +383,18 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.deform")
|
||||
@Logging(ALL)
|
||||
public void deform(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
final Region region = session.getSelection(player.getWorld());
|
||||
|
||||
final String expression = args.getJoinedStrings(0);
|
||||
|
||||
public void deform(Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Text String expression,
|
||||
@Switch('r') boolean useRawCoords,
|
||||
@Switch('o') boolean offset) throws WorldEditException {
|
||||
final Vector zero;
|
||||
Vector unit;
|
||||
|
||||
if (args.hasFlag('r')) {
|
||||
if (useRawCoords) {
|
||||
zero = Vector.ZERO;
|
||||
unit = Vector.ONE;
|
||||
} else if (args.hasFlag('o')) {
|
||||
} else if (offset) {
|
||||
zero = session.getPlacementPosition(player);
|
||||
unit = Vector.ONE;
|
||||
} else {
|
||||
@ -519,14 +431,12 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.hollow")
|
||||
@Logging(REGION)
|
||||
public void hollow(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
final int thickness = args.argsLength() >= 1 ? Math.max(1, args.getInteger(0)) : 1;
|
||||
final Pattern pattern = args.argsLength() >= 2 ? we.getBlockPattern(player, args.getString(1)) : new SingleBlockPattern(new BaseBlock(BlockID.AIR));
|
||||
|
||||
final int affected = editSession.hollowOutRegion(session.getSelection(player.getWorld()), thickness, pattern);
|
||||
public void hollow(Player player, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Optional("0") @Range(min = 0) int thickness,
|
||||
@Optional("air") Pattern pattern) throws WorldEditException {
|
||||
|
||||
int affected = editSession.hollowOutRegion(region, thickness, Patterns.wrap(pattern));
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
}
|
||||
|
||||
@ -539,18 +449,8 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.forest")
|
||||
@Logging(REGION)
|
||||
public void forest(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
TreeGenerator.TreeType type = args.argsLength() > 0 ? TreeGenerator.lookup(args.getString(0)) : TreeGenerator.TreeType.TREE;
|
||||
double density = args.argsLength() > 1 ? args.getDouble(1) / 100 : 0.05;
|
||||
|
||||
if (type == null) {
|
||||
player.printError("Tree type '" + args.getString(0) + "' is unknown.");
|
||||
return;
|
||||
}
|
||||
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
|
||||
public void forest(Player player, EditSession editSession, @Selection Region region, @Optional("tree") TreeType type, @Optional("5") double density) throws WorldEditException {
|
||||
density = density / 100;
|
||||
ForestGenerator generator = new ForestGenerator(editSession, new TreeGenerator(type));
|
||||
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
|
||||
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
|
||||
@ -569,10 +469,8 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.flora")
|
||||
@Logging(REGION)
|
||||
public void flora(CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException {
|
||||
double density = args.argsLength() > 0 ? args.getDouble(0) / 100 : 0.1;
|
||||
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
public void flora(Player player, EditSession editSession, @Selection Region region, @Optional("10") double density) throws WorldEditException {
|
||||
density = density / 100;
|
||||
FloraGenerator generator = new FloraGenerator(editSession);
|
||||
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
|
||||
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
|
||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.command;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.*;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.schematic.SchematicFormat;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
@ -31,16 +32,23 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Commands related to schematics
|
||||
*
|
||||
* @see com.sk89q.worldedit.command.ClipboardCommands#schematic()
|
||||
* Commands that work with schematic files.
|
||||
*/
|
||||
public class SchematicCommands {
|
||||
private final WorldEdit we;
|
||||
|
||||
public SchematicCommands(WorldEdit we) {
|
||||
this.we = we;
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public SchematicCommands(WorldEdit worldEdit) {
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -56,10 +64,9 @@ public class SchematicCommands {
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions({"worldedit.clipboard.load", "worldedit.schematic.load"}) // TODO: Remove 'clipboard' perm
|
||||
public void load(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void load(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
String fileName;
|
||||
String formatName;
|
||||
|
||||
@ -70,8 +77,8 @@ public class SchematicCommands {
|
||||
formatName = args.getString(0);
|
||||
fileName = args.getString(1);
|
||||
}
|
||||
File dir = we.getWorkingDirectoryFile(config.saveDir);
|
||||
File f = we.getSafeOpenFile(player, dir, fileName, "schematic", "schematic");
|
||||
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
File f = worldEdit.getSafeOpenFile(player, dir, fileName, "schematic", "schematic");
|
||||
|
||||
if (!f.exists()) {
|
||||
player.printError("Schematic " + fileName + " does not exist!");
|
||||
@ -121,10 +128,9 @@ public class SchematicCommands {
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions({"worldedit.clipboard.save", "worldedit.schematic.save"}) // TODO: Remove 'clipboard' perm
|
||||
public void save(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException, CommandException {
|
||||
public void save(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException, CommandException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
SchematicFormat format;
|
||||
if (args.argsLength() == 1) {
|
||||
if (SchematicFormat.getFormats().size() == 1) {
|
||||
@ -143,8 +149,8 @@ public class SchematicCommands {
|
||||
|
||||
String filename = args.getString(args.argsLength() - 1);
|
||||
|
||||
File dir = we.getWorkingDirectoryFile(config.saveDir);
|
||||
File f = we.getSafeSaveFile(player, dir, filename, "schematic", "schematic");
|
||||
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
File f = worldEdit.getSafeSaveFile(player, dir, filename, "schematic", "schematic");
|
||||
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkdir()) {
|
||||
@ -181,14 +187,13 @@ public class SchematicCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.schematic.delete")
|
||||
public void delete(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void delete(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
String filename = args.getString(0);
|
||||
|
||||
File dir = we.getWorkingDirectoryFile(config.saveDir);
|
||||
File f = we.getSafeSaveFile(player, dir, filename, "schematic", "schematic");
|
||||
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
File f = worldEdit.getSafeSaveFile(player, dir, filename, "schematic", "schematic");
|
||||
|
||||
if (!f.exists()) {
|
||||
player.printError("Schematic " + filename + " does not exist!");
|
||||
@ -239,7 +244,7 @@ public class SchematicCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.schematic.list")
|
||||
public void list(Actor actor, CommandContext args) throws WorldEditException {
|
||||
File dir = we.getWorkingDirectoryFile(we.getConfiguration().saveDir);
|
||||
File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().saveDir);
|
||||
File[] files = dir.listFiles(new FileFilter(){
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
|
@ -19,24 +19,36 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import java.io.File;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.*;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL;
|
||||
|
||||
/**
|
||||
* Scripting commands.
|
||||
*
|
||||
* @author sk89q
|
||||
* Commands related to scripting.
|
||||
*/
|
||||
public class ScriptingCommands {
|
||||
private final WorldEdit we;
|
||||
|
||||
public ScriptingCommands(WorldEdit we) {
|
||||
this.we = we;
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public ScriptingCommands(WorldEdit worldEdit) {
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -48,8 +60,7 @@ public class ScriptingCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.scripting.execute")
|
||||
@Logging(ALL)
|
||||
public void execute(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void execute(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
String[] scriptArgs = args.getSlice(1);
|
||||
String name = args.getString(0);
|
||||
@ -61,10 +72,10 @@ public class ScriptingCommands {
|
||||
|
||||
session.setLastScript(name);
|
||||
|
||||
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
|
||||
File f = we.getSafeOpenFile(player, dir, name, "js", "js");
|
||||
File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().scriptsDir);
|
||||
File f = worldEdit.getSafeOpenFile(player, dir, name, "js", "js");
|
||||
|
||||
we.runScript(player, f, scriptArgs);
|
||||
worldEdit.runScript(player, f, scriptArgs);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -76,8 +87,7 @@ public class ScriptingCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.scripting.execute")
|
||||
@Logging(ALL)
|
||||
public void executeLast(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void executeLast(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
String lastScript = session.getLastScript();
|
||||
|
||||
@ -93,9 +103,9 @@ public class ScriptingCommands {
|
||||
|
||||
String[] scriptArgs = args.getSlice(0);
|
||||
|
||||
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
|
||||
File f = we.getSafeOpenFile(player, dir, lastScript, "js", "js");
|
||||
File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().scriptsDir);
|
||||
File f = worldEdit.getSafeOpenFile(player, dir, lastScript, "js", "js");
|
||||
|
||||
we.runScript(player, f, scriptArgs);
|
||||
worldEdit.runScript(player, f, scriptArgs);
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import com.sk89q.minecraft.util.commands.CommandAlias;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.util.Countable;
|
||||
import com.sk89q.worldedit.CuboidClipboard;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
@ -76,8 +77,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(POSITION)
|
||||
@CommandPermissions("worldedit.selection.pos")
|
||||
public void pos1(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void pos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
Vector pos;
|
||||
|
||||
@ -111,8 +111,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(POSITION)
|
||||
@CommandPermissions("worldedit.selection.pos")
|
||||
public void pos2(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void pos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
Vector pos;
|
||||
if (args.argsLength() == 1) {
|
||||
@ -146,8 +145,7 @@ public class SelectionCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.selection.hpos")
|
||||
public void hpos1(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void hpos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
Vector pos = player.getBlockTrace(300);
|
||||
|
||||
@ -173,8 +171,7 @@ public class SelectionCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.selection.hpos")
|
||||
public void hpos2(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void hpos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
Vector pos = player.getBlockTrace(300);
|
||||
|
||||
@ -210,8 +207,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(POSITION)
|
||||
@CommandPermissions("worldedit.selection.chunk")
|
||||
public void chunk(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void chunk(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
final Vector min;
|
||||
final Vector max;
|
||||
@ -274,8 +270,7 @@ public class SelectionCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.wand")
|
||||
public void wand(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void wand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
player.giveItem(we.getConfiguration().wandItem, 1);
|
||||
player.print("Left click: select pos #1; Right click: select pos #2");
|
||||
@ -289,8 +284,7 @@ public class SelectionCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.wand.toggle")
|
||||
public void toggleWand(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void toggleWand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
session.setToolControl(!session.isToolControlEnabled());
|
||||
|
||||
@ -310,8 +304,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.expand")
|
||||
public void expand(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void expand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
// Special syntax (//expand vert) to expand the selection between
|
||||
// sky and bedrock.
|
||||
@ -406,8 +399,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.contract")
|
||||
public void contract(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void contract(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
List<Vector> dirs = new ArrayList<Vector>();
|
||||
int change = args.getInteger(0);
|
||||
@ -482,8 +474,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.shift")
|
||||
public void shift(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void shift(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
List<Vector> dirs = new ArrayList<Vector>();
|
||||
int change = args.getInteger(0);
|
||||
@ -531,8 +522,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.outset")
|
||||
public void outset(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void outset(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
region.expand(getChangesForEachDir(args));
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
@ -555,8 +545,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.inset")
|
||||
public void inset(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void inset(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
region.contract(getChangesForEachDir(args));
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
@ -592,8 +581,7 @@ public class SelectionCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.selection.size")
|
||||
public void size(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
if (args.hasFlag('c')) {
|
||||
CuboidClipboard clipboard = session.getClipboard();
|
||||
@ -637,8 +625,7 @@ public class SelectionCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.analysis.count")
|
||||
public void count(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void count(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
boolean useData = args.hasFlag('d');
|
||||
if (args.getString(0).contains(":")) {
|
||||
@ -668,8 +655,7 @@ public class SelectionCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.analysis.distr")
|
||||
public void distr(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void distr(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
int size;
|
||||
boolean useData = args.hasFlag('d');
|
||||
@ -730,8 +716,7 @@ public class SelectionCommands {
|
||||
min = 0,
|
||||
max = 1
|
||||
)
|
||||
public void select(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void select(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
final World world = player.getWorld();
|
||||
if (args.argsLength() == 0) {
|
||||
|
@ -21,6 +21,15 @@
|
||||
|
||||
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.entity.Player;
|
||||
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
|
||||
import com.sk89q.worldedit.world.snapshot.Snapshot;
|
||||
import com.sk89q.worldedit.world.storage.MissingWorldException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
@ -28,13 +37,6 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
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.world.storage.MissingWorldException;
|
||||
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
|
||||
import com.sk89q.worldedit.world.snapshot.Snapshot;
|
||||
|
||||
/**
|
||||
* Snapshot commands.
|
||||
@ -59,8 +61,7 @@ public class SnapshotCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.snapshots.list")
|
||||
public void list(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void list(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
@ -110,8 +111,7 @@ public class SnapshotCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.snapshots.restore")
|
||||
public void use(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void use(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
@ -154,8 +154,7 @@ public class SnapshotCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.snapshots.restore")
|
||||
public void sel(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void sel(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (config.snapshotRepo == null) {
|
||||
@ -202,8 +201,7 @@ public class SnapshotCommands {
|
||||
max = -1
|
||||
)
|
||||
@CommandPermissions("worldedit.snapshots.restore")
|
||||
public void before(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void before(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
@ -242,8 +240,7 @@ public class SnapshotCommands {
|
||||
max = -1
|
||||
)
|
||||
@CommandPermissions("worldedit.snapshots.restore")
|
||||
public void after(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void after(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
|
@ -19,30 +19,25 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
|
||||
import com.sk89q.worldedit.world.snapshot.Snapshot;
|
||||
import com.sk89q.worldedit.world.snapshot.SnapshotRestore;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
import com.sk89q.worldedit.world.storage.MissingWorldException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.minecraft.util.commands.NestedCommand;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
import com.sk89q.worldedit.world.storage.MissingWorldException;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
|
||||
import com.sk89q.worldedit.world.snapshot.Snapshot;
|
||||
import com.sk89q.worldedit.world.snapshot.SnapshotRestore;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
|
||||
public class SnapshotUtilCommands {
|
||||
|
||||
@ -63,8 +58,7 @@ public class SnapshotUtilCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.snapshots.restore")
|
||||
public void restore(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void restore(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
|
@ -22,15 +22,11 @@ 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.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.command.tool.AreaPickaxe;
|
||||
import com.sk89q.worldedit.command.tool.RecursivePickaxe;
|
||||
import com.sk89q.worldedit.command.tool.SinglePickaxe;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
|
||||
public class SuperPickaxeCommands {
|
||||
private final WorldEdit we;
|
||||
@ -47,8 +43,7 @@ public class SuperPickaxeCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe")
|
||||
public void single(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void single(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
session.setSuperPickaxe(new SinglePickaxe());
|
||||
session.enableSuperPickAxe();
|
||||
@ -63,8 +58,7 @@ public class SuperPickaxeCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe.area")
|
||||
public void area(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void area(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
int range = args.getInteger(0);
|
||||
@ -87,8 +81,7 @@ public class SuperPickaxeCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe.recursive")
|
||||
public void recursive(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void recursive(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
double range = args.getDouble(0);
|
||||
|
@ -26,6 +26,7 @@ import com.sk89q.minecraft.util.commands.NestedCommand;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.ItemType;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.command.tool.*;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
@ -44,8 +45,7 @@ public class ToolCommands {
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
public void none(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void none(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
session.setTool(player.getItemInHand(), null);
|
||||
player.print("Tool unbound from your current item.");
|
||||
@ -59,8 +59,7 @@ public class ToolCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.info")
|
||||
public void info(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void info(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
session.setTool(player.getItemInHand(), new QueryTool());
|
||||
player.print("Info tool bound to "
|
||||
@ -76,8 +75,7 @@ public class ToolCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.tree")
|
||||
@SuppressWarnings("deprecation")
|
||||
public void tree(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void tree(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
TreeGenerator.TreeType type = args.argsLength() > 0 ?
|
||||
type = TreeGenerator.lookup(args.getString(0))
|
||||
@ -101,8 +99,7 @@ public class ToolCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.replacer")
|
||||
public void repl(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void repl(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
BaseBlock targetBlock = we.getBlock(player, args.getString(0));
|
||||
session.setTool(player.getItemInHand(), new BlockReplacer(targetBlock));
|
||||
@ -118,8 +115,7 @@ public class ToolCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.data-cycler")
|
||||
public void cycler(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void cycler(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
session.setTool(player.getItemInHand(), new BlockDataCyler());
|
||||
player.print("Block data cycler tool bound to "
|
||||
@ -134,8 +130,7 @@ public class ToolCommands {
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.flood-fill")
|
||||
public void floodFill(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void floodFill(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
int range = args.getInteger(1);
|
||||
@ -159,8 +154,7 @@ public class ToolCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.deltree")
|
||||
public void deltree(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void deltree(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
session.setTool(player.getItemInHand(), new FloatingTreeRemover());
|
||||
player.print("Floating tree remover tool bound to "
|
||||
@ -175,8 +169,7 @@ public class ToolCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.farwand")
|
||||
public void farwand(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void farwand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
session.setTool(player.getItemInHand(), new DistanceWand());
|
||||
player.print("Far wand tool bound to " + ItemType.toHeldName(player.getItemInHand()) + ".");
|
||||
@ -190,8 +183,7 @@ public class ToolCommands {
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.lrbuild")
|
||||
public void longrangebuildtool(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void longrangebuildtool(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
BaseBlock secondary = we.getBlock(player, args.getString(0));
|
||||
BaseBlock primary = we.getBlock(player, args.getString(1));
|
||||
|
@ -46,8 +46,7 @@ public class ToolUtilCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe")
|
||||
public void togglePickaxe(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void togglePickaxe(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
String newState = args.getString(0, null);
|
||||
if (session.hasSuperPickAxe()) {
|
||||
@ -108,8 +107,7 @@ public class ToolUtilCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.range")
|
||||
public void range(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void range(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
int range = args.getInteger(0);
|
||||
session.getBrushTool(player.getItemInHand()).setRange(range);
|
||||
player.print("Brush range set.");
|
||||
@ -123,8 +121,7 @@ public class ToolUtilCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.size")
|
||||
public void size(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
int radius = args.getInteger(0);
|
||||
we.checkMaxBrushRadius(radius);
|
||||
|
@ -63,8 +63,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.fill")
|
||||
@Logging(PLACEMENT)
|
||||
public void fill(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void fill(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||
double radius = Math.max(1, args.getDouble(1));
|
||||
@ -92,8 +91,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.fill.recursive")
|
||||
@Logging(PLACEMENT)
|
||||
public void fillr(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void fillr(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||
double radius = Math.max(1, args.getDouble(1));
|
||||
@ -121,8 +119,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.drain")
|
||||
@Logging(PLACEMENT)
|
||||
public void drain(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void drain(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
double radius = Math.max(0, args.getDouble(0));
|
||||
we.checkMaxRadius(radius);
|
||||
@ -140,8 +137,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.fixlava")
|
||||
@Logging(PLACEMENT)
|
||||
public void fixLava(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void fixLava(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
double radius = Math.max(0, args.getDouble(0));
|
||||
we.checkMaxRadius(radius);
|
||||
@ -159,8 +155,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.fixwater")
|
||||
@Logging(PLACEMENT)
|
||||
public void fixWater(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void fixWater(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
double radius = Math.max(0, args.getDouble(0));
|
||||
we.checkMaxRadius(radius);
|
||||
@ -178,8 +173,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.removeabove")
|
||||
@Logging(PLACEMENT)
|
||||
public void removeAbove(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void removeAbove(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
|
||||
we.checkMaxRadius(size);
|
||||
@ -200,8 +194,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.removebelow")
|
||||
@Logging(PLACEMENT)
|
||||
public void removeBelow(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void removeBelow(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
|
||||
we.checkMaxRadius(size);
|
||||
@ -221,8 +214,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.removenear")
|
||||
@Logging(PLACEMENT)
|
||||
public void removeNear(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void removeNear(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
BaseBlock block = we.getBlock(player, args.getString(0), true);
|
||||
int size = Math.max(1, args.getInteger(1, 50));
|
||||
@ -242,8 +234,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.replacenear")
|
||||
@Logging(PLACEMENT)
|
||||
public void replaceNear(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void replaceNear(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
int size = Math.max(1, args.getInteger(0));
|
||||
int affected;
|
||||
@ -279,8 +270,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.snow")
|
||||
@Logging(PLACEMENT)
|
||||
public void snow(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void snow(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
|
||||
|
||||
@ -297,8 +287,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.thaw")
|
||||
@Logging(PLACEMENT)
|
||||
public void thaw(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void thaw(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
|
||||
|
||||
@ -316,8 +305,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.green")
|
||||
@Logging(PLACEMENT)
|
||||
public void green(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void green(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
final double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
|
||||
final boolean onlyNormalDirt = !args.hasFlag('f');
|
||||
@ -335,8 +323,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.extinguish")
|
||||
@Logging(PLACEMENT)
|
||||
public void extinguish(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void extinguish(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
|
@ -23,6 +23,7 @@ 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.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
@ -87,8 +88,7 @@ public class WorldEditCommands {
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
public void cui(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void cui(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
session.setCUISupport(true);
|
||||
session.dispatchCUISetup(player);
|
||||
}
|
||||
@ -100,8 +100,7 @@ public class WorldEditCommands {
|
||||
min = 1,
|
||||
max = 1
|
||||
)
|
||||
public void tz(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
public void tz(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
TimeZone tz = TimeZone.getTimeZone(args.getString(0));
|
||||
session.setTimezone(tz);
|
||||
player.print("Timezone set for this session to: " + tz.getDisplayName());
|
||||
|
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldedit.internal.command;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
@ -29,8 +30,12 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
import com.sk89q.worldedit.util.command.parametric.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Binds standard WorldEdit classes such as {@link Player} and {@link LocalSession}.
|
||||
*/
|
||||
@ -137,22 +142,25 @@ public class WorldEditBinding extends BindingHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an {@link Player} from a {@link ArgumentStack}.
|
||||
* Gets an {@link BaseBlock} from a {@link ArgumentStack}.
|
||||
*
|
||||
* @param context the context
|
||||
* @return a local player
|
||||
* @return a pattern
|
||||
* @throws ParameterException on error
|
||||
* @throws WorldEditException on error
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@BindingMatch(type = LocalPlayer.class,
|
||||
behavior = BindingBehavior.PROVIDES)
|
||||
public Player getLocalPlayer(ArgumentStack context) throws ParameterException {
|
||||
Player player = getPlayer(context);
|
||||
if (player instanceof LocalPlayer) {
|
||||
return (LocalPlayer) player;
|
||||
} else {
|
||||
throw new ParameterException("This command/function needs to be updated to take 'Player' rather than 'LocalPlayer'");
|
||||
@BindingMatch(type = BaseBlock.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1)
|
||||
public BaseBlock getBaseBlock(ArgumentStack context) throws ParameterException, WorldEditException {
|
||||
Actor actor = context.getContext().getLocals().get(Actor.class);
|
||||
ParserContext parserContext = new ParserContext();
|
||||
parserContext.setActor(context.getContext().getLocals().get(Actor.class));
|
||||
if (actor instanceof Entity) {
|
||||
parserContext.setWorld(((Entity) actor).getWorld());
|
||||
}
|
||||
parserContext.setSession(worldEdit.getSessionManager().get(actor));
|
||||
return worldEdit.getBlockRegistry().parseFromInput(context.next(), parserContext);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,4 +226,58 @@ public class WorldEditBinding extends BindingHelper {
|
||||
return worldEdit.getDirection(sender, context.next());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an {@link TreeType} from a {@link ArgumentStack}.
|
||||
*
|
||||
* @param context the context
|
||||
* @return a pattern
|
||||
* @throws ParameterException on error
|
||||
* @throws WorldEditException on error
|
||||
*/
|
||||
@BindingMatch(type = TreeType.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1)
|
||||
public TreeType getTreeType(ArgumentStack context) throws ParameterException, WorldEditException {
|
||||
String input = context.next();
|
||||
if (input != null) {
|
||||
TreeType type = TreeGenerator.lookup(input);
|
||||
if (type != null) {
|
||||
return type;
|
||||
} else {
|
||||
throw new ParameterException(
|
||||
String.format("Can't recognize tree type '%s' -- choose from: %s", input, Arrays.toString(TreeType.values())));
|
||||
}
|
||||
} else {
|
||||
return TreeType.TREE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an {@link BiomeType} from a {@link ArgumentStack}.
|
||||
*
|
||||
* @param context the context
|
||||
* @return a pattern
|
||||
* @throws ParameterException on error
|
||||
* @throws WorldEditException on error
|
||||
*/
|
||||
@BindingMatch(type = BiomeType.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1)
|
||||
public BiomeType getBiomeType(ArgumentStack context) throws ParameterException, WorldEditException {
|
||||
String input = context.next();
|
||||
if (input != null) {
|
||||
BiomeType type = worldEdit.getServer().getBiomes().get(input);
|
||||
if (type != null) {
|
||||
return type;
|
||||
} else {
|
||||
throw new ParameterException(
|
||||
String.format("Can't recognize biome type '%s' -- use //biomelist to list available types", input));
|
||||
}
|
||||
} else {
|
||||
throw new ParameterException(
|
||||
"This command takes a 'default' biome if one is not set, except there is no particular " +
|
||||
"biome that should be 'default', so the command should not be taking a default biome");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,24 +19,18 @@
|
||||
|
||||
package com.sk89q.worldedit.scripting;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.command.InsufficientArgumentsException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import com.sk89q.worldedit.DisallowedItemException;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.FilenameException;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import com.sk89q.worldedit.UnknownItemException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.command.InsufficientArgumentsException;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
|
||||
/**
|
||||
* The context given to scripts.
|
||||
@ -48,8 +42,8 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
private String[] args;
|
||||
|
||||
public CraftScriptContext(WorldEdit controller,
|
||||
ServerInterface server, LocalConfiguration config,
|
||||
LocalSession session, LocalPlayer player, String[] args) {
|
||||
Platform server, LocalConfiguration config,
|
||||
LocalSession session, Player player, String[] args) {
|
||||
super(controller, server, config, session, player);
|
||||
this.args = args;
|
||||
}
|
||||
@ -74,7 +68,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public LocalPlayer getPlayer() {
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
@ -20,24 +20,25 @@
|
||||
package com.sk89q.worldedit.scripting;
|
||||
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
|
||||
public abstract class CraftScriptEnvironment {
|
||||
|
||||
protected WorldEdit controller;
|
||||
protected LocalPlayer player;
|
||||
protected Player player;
|
||||
protected LocalConfiguration config;
|
||||
protected LocalSession session;
|
||||
protected ServerInterface server;
|
||||
protected Platform server;
|
||||
|
||||
public CraftScriptEnvironment(WorldEdit controller, ServerInterface server,
|
||||
LocalConfiguration config, LocalSession session, LocalPlayer player) {
|
||||
public CraftScriptEnvironment(WorldEdit controller, Platform server, LocalConfiguration config, LocalSession session, Player player) {
|
||||
this.controller = controller;
|
||||
this.player = player;
|
||||
this.config = config;
|
||||
this.server = server;
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren