Clean up and removal of some old exceptions.

This commit is contained in:
sk89q 2014-07-29 07:57:45 -07:00
parent 41584eee4a
commit 8834af7538
44 changed files with 1047 additions and 948 deletions

View File

@ -25,7 +25,7 @@ import com.sk89q.jnbt.NBTUtils;
import com.sk89q.jnbt.ShortTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.MobType;
import com.sk89q.worldedit.blocks.metadata.MobType;
import com.sk89q.worldedit.world.storage.InvalidFormatException;
import java.util.HashMap;

View File

@ -31,6 +31,7 @@ public class CommandContext {
protected final String command;
protected final List<String> parsedArgs;
protected final List<Integer> originalArgIndices;
protected final String[] originalArgs;
protected final Set<Character> booleanFlags = new HashSet<Character>();

View File

@ -20,11 +20,11 @@
package com.sk89q.worldedit;
/**
* Extension of Vector that supports being compared as ints (for accuracy).
*
* @author sk89q
* Extension of {@code Vector} that that compares with other instances
* using integer components.
*/
public class BlockVector extends Vector {
public static final BlockVector ZERO = new BlockVector(0, 0, 0);
public static final BlockVector UNIT_X = new BlockVector(1, 0, 0);
public static final BlockVector UNIT_Y = new BlockVector(0, 1, 0);
@ -32,55 +32,47 @@ public class BlockVector extends Vector {
public static final BlockVector ONE = new BlockVector(1, 1, 1);
/**
* Construct the Vector object.
* Construct an instance as a copy of another instance.
*
* @param pt
* @param position the other position
*/
public BlockVector(Vector pt) {
super(pt);
public BlockVector(Vector position) {
super(position);
}
/**
* Construct the Vector object.
* Construct a new instance.
*
* @param x
* @param y
* @param z
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockVector(int x, int y, int z) {
super(x, y, z);
}
/**
* Construct the Vector object.
* Construct a new instance.
*
*
* @param x
* @param y
* @param z
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockVector(float x, float y, float z) {
super(x, y, z);
}
/**
* Construct the Vector object.
* Construct a new instance.
*
*
* @param x
* @param y
* @param z
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockVector(double x, double y, double z) {
super(x, y, z);
}
/**
* Checks if another object is equivalent.
*
* @param obj
* @return whether the other object is equivalent
*/
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Vector)) {
@ -92,11 +84,6 @@ public class BlockVector extends Vector {
}
/**
* Gets the hash code.
*
* @return hash code
*/
@Override
public int hashCode() {
return ((int) x << 19) ^
@ -108,4 +95,5 @@ public class BlockVector extends Vector {
public BlockVector toBlockVector() {
return this;
}
}

View File

@ -20,76 +20,66 @@
package com.sk89q.worldedit;
/**
* Extension of Vector2D that supports being compared as ints (for accuracy).
*
* @author sk89q
* Extension of {@code Vector2D} that that compares with other instances
* using integer components.
*/
public class BlockVector2D extends Vector2D {
public static final BlockVector2D ZERO = new BlockVector2D(0, 0);
public static final BlockVector2D UNIT_X = new BlockVector2D(1, 0);
public static final BlockVector2D UNIT_Z = new BlockVector2D(0, 1);
public static final BlockVector2D ONE = new BlockVector2D(1, 1);
/**
* Construct the Vector object.
* Construct an instance from another instance.
*
* @param pt
* @param position the position to copy
*/
public BlockVector2D(Vector2D pt) {
super(pt);
public BlockVector2D(Vector2D position) {
super(position);
}
/**
* Construct the Vector object.
* Construct a new instance.
*
* @param x
* @param z
* @param x the X coordinate
* @param z the Z coordinate
*/
public BlockVector2D(int x, int z) {
super(x, z);
}
/**
* Construct the Vector object.
* Construct a new instance.
*
* @param x
* @param z
* @param x the X coordinate
* @param z the Z coordinate
*/
public BlockVector2D(float x, float z) {
super(x, z);
}
/**
* Construct the Vector object.
* Construct a new instance.
*
* @param x
* @param z
* @param x the X coordinate
* @param z the Z coordinate
*/
public BlockVector2D(double x, double z) {
super(x, z);
}
/**
* Checks if another object is equivalent.
*
* @param obj
* @return whether the other object is equivalent
*/
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Vector2D)) {
return false;
}
Vector2D other = (Vector2D) obj;
return (int) other.x == (int) this.x && (int) other.z == (int) this.z;
}
/**
* Gets the hash code.
*
* @return hash code
*/
@Override
public int hashCode() {
return (Integer.valueOf((int) x).hashCode() >> 13) ^
@ -100,4 +90,5 @@ public class BlockVector2D extends Vector2D {
public BlockVector2D toBlockVector2D() {
return this;
}
}

View File

@ -20,94 +20,89 @@
package com.sk89q.worldedit;
/**
* Extension of Vector that supports being compared as ints (for accuracy).
*
* @author sk89q
* @deprecated Replace all uses of {@link WorldVector}s with {@link Location}s
*/
@SuppressWarnings("deprecation")
@Deprecated
public class BlockWorldVector extends WorldVector {
/**
* Construct the Vector object.
* Construct an instance from another instance.
*
* @param pt
* @param position the position to copy
*/
public BlockWorldVector(WorldVector pt) {
super(pt.getWorld(), pt);
public BlockWorldVector(WorldVector position) {
super(position.getWorld(), position);
}
/**
* Construct the Vector object.
* @param world
* Construct an instance from another instance.
*
* @param pt
* @param world the world
* @param position the position to copy
*/
public BlockWorldVector(LocalWorld world, Vector pt) {
super(world, pt);
public BlockWorldVector(LocalWorld world, Vector position) {
super(world, position);
}
/**
* Construct the Vector object.
* Construct a new instance.
*
* @param world
* @param x
* @param y
* @param z
* @param world another instance
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockWorldVector(WorldVector world, int x, int y, int z) {
super(world.getWorld(), x, y, z);
}
/**
* Construct the Vector object.
* Construct a new instance.
*
* @param world
* @param v
* @param world another instance
* @param v the other vector
*/
public BlockWorldVector(WorldVector world, Vector v) {
super(world.getWorld(), v.getX(), v.getY(), v.getZ());
}
/**
* Construct the Vector object.
* Construct a new instance.
*
* @param world
* @param x
* @param y
* @param z
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockWorldVector(LocalWorld world, int x, int y, int z) {
super(world, x, y, z);
}
/**
* Construct the Vector object.
* Construct a new instance.
*
* @param world
* @param x
* @param y
* @param z
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockWorldVector(LocalWorld world, float x, float y, float z) {
super(world, x, y, z);
}
/**
* Construct the Vector object.
* Construct a new instance.
*
* @param world
* @param x
* @param y
* @param z
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockWorldVector(LocalWorld world, double x, double y, double z) {
super(world, x, y, z);
}
/**
* Checks if another object is equivalent.
*
* @param obj
* @return whether the other object is equivalent
*/
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Vector)) {
@ -119,15 +114,11 @@ public class BlockWorldVector extends WorldVector {
}
/**
* Gets the hash code.
*
* @return hash code
*/
@Override
public int hashCode() {
return (Integer.valueOf((int) x).hashCode() << 19) ^
(Integer.valueOf((int) y).hashCode() << 12) ^
Integer.valueOf((int) z).hashCode();
}
}

View File

@ -19,34 +19,65 @@
package com.sk89q.worldedit;
/**
* @deprecated Replace all uses of {@link WorldVector}s with {@link Location}s
*/
@SuppressWarnings("deprecation")
@Deprecated
public class BlockWorldVector2D extends WorldVector2D {
/**
* Construct a new instance.
*
* @param world the world
* @param x the X coordinate
* @param z the Z coordinate
*/
public BlockWorldVector2D(LocalWorld world, double x, double z) {
super(world, x, z);
}
/**
* Construct a new instance.
*
* @param world the world
* @param x the X coordinate
* @param z the Z coordinate
*/
public BlockWorldVector2D(LocalWorld world, float x, float z) {
super(world, x, z);
}
/**
* Construct a new instance.
*
* @param world the world
* @param x the X coordinate
* @param z the Z coordinate
*/
public BlockWorldVector2D(LocalWorld world, int x, int z) {
super(world, x, z);
}
public BlockWorldVector2D(LocalWorld world, Vector2D pt) {
super(world, pt);
/**
* Construct a new instance.
*
* @param world the world
* @param position a position
*/
public BlockWorldVector2D(LocalWorld world, Vector2D position) {
super(world, position);
}
/**
* Construct a new instance with X and Z set to (0, 0).
*
* @param world the world
*/
public BlockWorldVector2D(LocalWorld world) {
super(world);
}
/**
* Checks if another object is equivalent.
*
* @param obj
* @return whether the other object is equivalent
*/
@Override
public boolean equals(Object obj) {
if (!(obj instanceof WorldVector2D)) {

View File

@ -19,6 +19,18 @@
package com.sk89q.worldedit;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.command.ClipboardCommands;
import com.sk89q.worldedit.command.SchematicCommands;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.schematic.SchematicFormat;
import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.world.DataException;
import java.io.File;
import java.io.IOException;
@ -28,21 +40,29 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.schematic.SchematicFormat;
import com.sk89q.worldedit.util.Countable;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* The clipboard remembers the state of a cuboid region.
*
* @author sk89q
* @deprecated This is slowly being replaced with {@link Clipboard}, which is
* far more versatile. Transforms are supported using affine
* transformations and full entity support is provided because
* the clipboard properly implements {@link Extent}. However,
* the new clipboard class is only available in WorldEdit 6.x and
* beyond. We intend on keeping this deprecated class in WorldEdit
* for an extended amount of time so there is no rush to
* switch (but new features will not be supported). To copy between
* a clipboard and a world (or between any two {@code Extent}s),
* one can use {@link ForwardExtentCopy}. See
* {@link ClipboardCommands} and {@link SchematicCommands} for
* more information.
*/
@Deprecated
public class CuboidClipboard {
/**
* Flip direction.
* An enum of possible flip directions.
*/
public enum FlipDirection {
NORTH_SOUTH,
@ -59,9 +79,11 @@ public class CuboidClipboard {
/**
* Constructs the clipboard.
*
* @param size
* @param size the dimensions of the clipboard (should be at least 1 on every dimension)
*/
public CuboidClipboard(Vector size) {
checkNotNull(size);
this.size = size;
data = new BaseBlock[size.getBlockX()][size.getBlockY()][size.getBlockZ()];
origin = new Vector();
@ -71,10 +93,14 @@ public class CuboidClipboard {
/**
* Constructs the clipboard.
*
* @param size
* @param origin
* @param size the dimensions of the clipboard (should be at least 1 on every dimension)
* @param origin the origin point where the copy was made, which must be the
* {@link CuboidRegion#getMinimumPoint()} relative to the copy
*/
public CuboidClipboard(Vector size, Vector origin) {
checkNotNull(size);
checkNotNull(origin);
this.size = size;
data = new BaseBlock[size.getBlockX()][size.getBlockY()][size.getBlockZ()];
this.origin = origin;
@ -84,11 +110,16 @@ public class CuboidClipboard {
/**
* Constructs the clipboard.
*
* @param size
* @param origin
* @param offset
* @param size the dimensions of the clipboard (should be at least 1 on every dimension)
* @param origin the origin point where the copy was made, which must be the
* {@link CuboidRegion#getMinimumPoint()} relative to the copy
* @param offset the offset from the minimum point of the copy where the user was
*/
public CuboidClipboard(Vector size, Vector origin, Vector offset) {
checkNotNull(size);
checkNotNull(origin);
checkNotNull(offset);
this.size = size;
data = new BaseBlock[size.getBlockX()][size.getBlockY()][size.getBlockZ()];
this.origin = origin;
@ -127,6 +158,7 @@ public class CuboidClipboard {
*
* @param angle in degrees
*/
@SuppressWarnings("deprecation")
public void rotate2D(int angle) {
angle = angle % 360;
if (angle % 90 != 0) { // Can only rotate 90 degrees at the moment
@ -196,7 +228,10 @@ public class CuboidClipboard {
* @param dir direction to flip
* @param aroundPlayer flip the offset around the player
*/
@SuppressWarnings("deprecation")
public void flip(FlipDirection dir, boolean aroundPlayer) {
checkNotNull(dir);
final int width = getWidth();
final int length = getLength();
final int height = getHeight();
@ -303,7 +338,7 @@ public class CuboidClipboard {
/**
* Copies blocks to the clipboard.
*
* @param editSession The EditSession from which to take the blocks
* @param editSession the EditSession from which to take the blocks
*/
public void copy(EditSession editSession) {
for (int x = 0; x < size.getBlockX(); ++x) {
@ -337,21 +372,38 @@ public class CuboidClipboard {
}
}
public void paste(EditSession editSession, Vector newOrigin, boolean noAir)
throws MaxChangedBlocksException {
/**
* Paste the clipboard at the given location using the given {@code EditSession}.
*
* <p>This method blocks the server/game until the entire clipboard is
* pasted. In the future, {@link ForwardExtentCopy} will be recommended,
* which, if combined with the proposed operation scheduler framework,
* will not freeze the game/server.</p>
*
* @param editSession the EditSession to which blocks are to be copied to
* @param newOrigin the new origin point (must correspond to the minimum point of the cuboid)
* @param noAir true to not copy air blocks in the source
* @throws MaxChangedBlocksException thrown if too many blocks were changed
*/
public void paste(EditSession editSession, Vector newOrigin, boolean noAir) throws MaxChangedBlocksException {
paste(editSession, newOrigin, noAir, false);
}
/**
* Paste from the clipboard.
* Paste the clipboard at the given location using the given {@code EditSession}.
*
* @param editSession
* @param newOrigin Position to paste it from
* @param noAir True to not paste air
* @throws MaxChangedBlocksException
* <p>This method blocks the server/game until the entire clipboard is
* pasted. In the future, {@link ForwardExtentCopy} will be recommended,
* which, if combined with the proposed operation scheduler framework,
* will not freeze the game/server.</p>
*
* @param editSession the EditSession to which blocks are to be copied to
* @param newOrigin the new origin point (must correspond to the minimum point of the cuboid)
* @param noAir true to not copy air blocks in the source
* @param entities true to copy entities
* @throws MaxChangedBlocksException thrown if too many blocks were changed
*/
public void paste(EditSession editSession, Vector newOrigin, boolean noAir, boolean entities)
throws MaxChangedBlocksException {
public void paste(EditSession editSession, Vector newOrigin, boolean noAir, boolean entities) throws MaxChangedBlocksException {
place(editSession, newOrigin.add(offset), noAir);
if (entities) {
pasteEntities(newOrigin.add(offset));
@ -359,14 +411,19 @@ public class CuboidClipboard {
}
/**
* Places the blocks in a position from the minimum corner.
* Paste the clipboard at the given location using the given {@code EditSession}.
*
* @param editSession
* @param pos
* @param noAir
* @throws MaxChangedBlocksException
* <p>This method blocks the server/game until the entire clipboard is
* pasted. In the future, {@link ForwardExtentCopy} will be recommended,
* which, if combined with the proposed operation scheduler framework,
* will not freeze the game/server.</p>
*
* @param editSession the EditSession to which blocks are to be copied to
* @param newOrigin the new origin point (must correspond to the minimum point of the cuboid)
* @param noAir true to not copy air blocks in the source
* @throws MaxChangedBlocksException thrown if too many blocks were changed
*/
public void place(EditSession editSession, Vector pos, boolean noAir) throws MaxChangedBlocksException {
public void place(EditSession editSession, Vector newOrigin, boolean noAir) throws MaxChangedBlocksException {
for (int x = 0; x < size.getBlockX(); ++x) {
for (int y = 0; y < size.getBlockY(); ++y) {
for (int z = 0; z < size.getBlockZ(); ++z) {
@ -379,37 +436,50 @@ public class CuboidClipboard {
continue;
}
editSession.setBlock(new Vector(x, y, z).add(pos), block);
editSession.setBlock(new Vector(x, y, z).add(newOrigin), block);
}
}
}
}
public LocalEntity[] pasteEntities(Vector pos) {
/**
* Paste the stored entities to the given position.
*
* @param newOrigin the new origin
* @return a list of entities that were pasted
*/
public LocalEntity[] pasteEntities(Vector newOrigin) {
LocalEntity[] entities = new LocalEntity[this.entities.size()];
for (int i = 0; i < this.entities.size(); ++i) {
CopiedEntity copied = this.entities.get(i);
if (copied.entity.spawn(copied.entity.getPosition().setPosition(copied.relativePosition.add(pos)))) {
if (copied.entity.spawn(copied.entity.getPosition().setPosition(copied.relativePosition.add(newOrigin)))) {
entities[i] = copied.entity;
}
}
return entities;
}
/**
* Store an entity.
*
* @param entity the entity
*/
public void storeEntity(LocalEntity entity) {
this.entities.add(new CopiedEntity(entity));
}
/**
* Get one point in the copy.
* Get the block at the given position.
*
* @param The point, relative to the origin of the copy (0, 0, 0) and not to the actual copy origin.
* <p>If the position is out of bounds, air will be returned.</p>
*
* @param position the point, relative to the origin of the copy (0, 0, 0) and not to the actual copy origin
* @return air, if this block was outside the (non-cuboid) selection while copying
* @throws ArrayIndexOutOfBoundsException if the position is outside the bounds of the CuboidClipboard
* @deprecated Use {@link #getBlock(Vector)} instead
*/
public BaseBlock getPoint(Vector pos) throws ArrayIndexOutOfBoundsException {
final BaseBlock block = getBlock(pos);
public BaseBlock getPoint(Vector position) throws ArrayIndexOutOfBoundsException {
final BaseBlock block = getBlock(position);
if (block == null) {
return new BaseBlock(BlockID.AIR);
}
@ -418,30 +488,32 @@ public class CuboidClipboard {
}
/**
* Get one point in the copy.
* Get the block at the given position.
*
* @param The point, relative to the origin of the copy (0, 0, 0) and not to the actual copy origin.
* <p>If the position is out of bounds, air will be returned.</p>
*
* @param position the point, relative to the origin of the copy (0, 0, 0) and not to the actual copy origin
* @return null, if this block was outside the (non-cuboid) selection while copying
* @throws ArrayIndexOutOfBoundsException if the position is outside the bounds of the CuboidClipboard
*/
public BaseBlock getBlock(Vector pos) throws ArrayIndexOutOfBoundsException {
return data[pos.getBlockX()][pos.getBlockY()][pos.getBlockZ()];
public BaseBlock getBlock(Vector position) throws ArrayIndexOutOfBoundsException {
return data[position.getBlockX()][position.getBlockY()][position.getBlockZ()];
}
/**
* Set one point in the copy. Pass null to remove the block.
* Set the block at a position in the clipboard.
*
* @param The point, relative to the origin of the copy (0, 0, 0) and not to the actual copy origin.
* @param position the point, relative to the origin of the copy (0, 0, 0) and not to the actual copy origin.
* @throws ArrayIndexOutOfBoundsException if the position is outside the bounds of the CuboidClipboard
*/
public void setBlock(Vector pt, BaseBlock block) {
data[pt.getBlockX()][pt.getBlockY()][pt.getBlockZ()] = block;
public void setBlock(Vector position, BaseBlock block) {
data[position.getBlockX()][position.getBlockY()][position.getBlockZ()] = block;
}
/**
* Get the size of the copy.
* Get the dimensions of the clipboard.
*
* @return
* @return the dimensions, where (1, 1, 1) is 1 wide, 1 across, 1 deep
*/
public Vector getSize() {
return size;
@ -450,30 +522,37 @@ public class CuboidClipboard {
/**
* Saves the clipboard data to a .schematic-format file.
*
* @param path
* @throws IOException
* @throws DataException
* @param path the path to the file to save
* @throws IOException thrown on I/O error
* @throws DataException thrown on error writing the data for other reasons
* @deprecated use {@link SchematicFormat#MCEDIT}
*/
@Deprecated
public void saveSchematic(File path) throws IOException, DataException {
checkNotNull(path);
SchematicFormat.MCEDIT.save(this, path);
}
/**
* Load a .schematic file into a clipboard.
*
* @param path
* @return clipboard
* @throws DataException
* @throws IOException
* @param path the path to the file to load
* @return a clipboard
* @throws IOException thrown on I/O error
* @throws DataException thrown on error writing the data for other reasons
* @deprecated use {@link SchematicFormat#MCEDIT}
*/
@Deprecated
public static CuboidClipboard loadSchematic(File path)
throws DataException, IOException {
public static CuboidClipboard loadSchematic(File path) throws DataException, IOException {
checkNotNull(path);
return SchematicFormat.MCEDIT.load(path);
}
/**
* Get the origin point, which corresponds to where the copy was
* originally copied from. The origin is the lowest possible X, Y, and
* Z components of the cuboid region that was copied.
*
* @return the origin
*/
public Vector getOrigin() {
@ -481,39 +560,45 @@ public class CuboidClipboard {
}
/**
* Set the origin point, which corresponds to where the copy was
* originally copied from. The origin is the lowest possible X, Y, and
* Z components of the cuboid region that was copied.
*
* @param origin the origin to set
*/
public void setOrigin(Vector origin) {
checkNotNull(origin);
this.origin = origin;
}
/**
* @return the offset
* Get the offset of the player to the clipboard's minimum point
* (minimum X, Y, Z coordinates).
*
* <p>The offset is inverse (multiplied by -1).</p>
*
* @return the offset the offset
*/
public Vector getOffset() {
return offset;
}
/**
* @param offset
* Set the offset of the player to the clipboard's minimum point
* (minimum X, Y, Z coordinates).
*
* <p>The offset is inverse (multiplied by -1).</p>
*
* @param offset the new offset
*/
public void setOffset(Vector offset) {
this.offset = offset;
}
private class CopiedEntity {
private final LocalEntity entity;
private final Vector relativePosition;
public CopiedEntity(LocalEntity entity) {
this.entity = entity;
this.relativePosition = entity.getPosition().getPosition().subtract(getOrigin());
}
}
/**
* Get the block distribution inside a clipboard.
*
* @return
* @return a block distribution
*/
public List<Countable<Integer>> getBlockDistribution() {
List<Countable<Integer>> distribution = new ArrayList<Countable<Integer>>();
@ -553,7 +638,7 @@ public class CuboidClipboard {
/**
* Get the block distribution inside a clipboard with data values.
*
* @return
* @return a block distribution
*/
// TODO reduce code duplication
public List<Countable<BaseBlock>> getBlockDistributionWithData() {
@ -591,4 +676,18 @@ public class CuboidClipboard {
return distribution;
}
/**
* Stores a copied entity.
*/
private class CopiedEntity {
private final LocalEntity entity;
private final Vector relativePosition;
private CopiedEntity(LocalEntity entity) {
this.entity = entity;
this.relativePosition = entity.getPosition().getPosition().subtract(getOrigin());
}
}
}

View File

@ -20,11 +20,9 @@
package com.sk89q.worldedit;
/**
*
* @author sk89q
* Thrown when a disallowed item is used.
*/
public class DisallowedItemException extends WorldEditException {
private static final long serialVersionUID = -8080026411461549979L;
private String type;
@ -40,4 +38,5 @@ public class DisallowedItemException extends WorldEditException {
public String getID() {
return type;
}
}

View File

@ -88,10 +88,10 @@ import static com.sk89q.worldedit.regions.Regions.*;
/**
* An {@link Extent} that handles history, {@link BlockBag}s, change limits,
* block re-ordering, and much more. Most operations in WorldEdit use this class.
* </p>
* Most of the actual functionality is implemented with a number of other
*
* <p>Most of the actual functionality is implemented with a number of other
* {@link Extent}s that are chained together. For example, history is logged
* using the {@link ChangeSetExtent}.
* using the {@link ChangeSetExtent}.</p>
*/
@SuppressWarnings("FieldCanBeLocal")
public class EditSession implements Extent {

View File

@ -30,10 +30,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* Creates new {@link EditSession}s. To get an instance of this factory,
* use {@link WorldEdit#getEditSessionFactory()}.
* </p>
* It is no longer possible to replace the instance of this in WorldEdit
*
* <p>It is no longer possible to replace the instance of this in WorldEdit
* with a custom one. Use {@link EditSessionEvent} to override
* the creation of {@link EditSession}s.
* the creation of {@link EditSession}s.</p>
*/
public class EditSessionFactory {

View File

@ -20,10 +20,8 @@
package com.sk89q.worldedit;
/**
*
* @author Albert
* Thrown when there is no clipboard set.
*/
public class EmptyClipboardException extends WorldEditException {
private static final long serialVersionUID = -3197424556127109425L;
}

View File

@ -21,10 +21,7 @@ package com.sk89q.worldedit;
/**
* Raised when a region is not fully defined.
*
* @author sk89q
*/
public class IncompleteRegionException extends WorldEditException {
private static final long serialVersionUID = 458988897980179094L;
}

View File

@ -20,13 +20,12 @@
package com.sk89q.worldedit;
/**
*
* @author sk89q
* Thrown when an invalid item is specified.
*/
public class InvalidItemException extends DisallowedItemException {
private static final long serialVersionUID = -2739618871154124586L;
public InvalidItemException(String type, String message) {
super(type, message);
}
}

View File

@ -29,10 +29,9 @@ import java.util.Set;
/**
* Represents WorldEdit's configuration.
*
* @author sk89q
*/
public abstract class LocalConfiguration {
protected static final int[] defaultDisallowedBlocks = new int[] {
// dangerous stuff (physics/drops items)
BlockID.SAPLING,
@ -114,16 +113,17 @@ public abstract class LocalConfiguration {
public boolean allowSymlinks = false;
/**
* Loads the configuration.
* Load the configuration.
*/
public abstract void load();
/**
* Get the working directory to work from.
*
* @return
* @return a working directory
*/
public File getWorkingDirectory() {
return new File(".");
}
}

View File

@ -19,10 +19,17 @@
package com.sk89q.worldedit;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
/**
* @author zml2008
* Holds an entity.
*
* @deprecated replaced with the new entity API using {@link Entity} and {@link BaseEntity}
*/
@Deprecated
public abstract class LocalEntity {
private final Location position;
protected LocalEntity(Location position) {
@ -38,4 +45,5 @@ public abstract class LocalEntity {
}
public abstract boolean spawn(Location loc);
}

View File

@ -26,7 +26,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
/**
* Represents a player that uses WorldEdit.
*
* @deprecated Use {@link Actor} (or {@link Player}, etc.) instead (and {@link AbstractPlayerActor} to extend)
* @deprecated use {@link Actor} (or {@link Player}, etc.) instead (and {@link AbstractPlayerActor} to extend)
*/
@Deprecated
public abstract class LocalPlayer extends AbstractPlayerActor {

View File

@ -25,6 +25,7 @@ import com.sk89q.jchronic.utils.Span;
import com.sk89q.jchronic.utils.Time;
import com.sk89q.worldedit.command.tool.BlockTool;
import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
import com.sk89q.worldedit.command.tool.SinglePickaxe;
import com.sk89q.worldedit.command.tool.Tool;
import com.sk89q.worldedit.entity.Player;
@ -315,8 +316,6 @@ public class LocalSession {
return selector;
}
/**
* @deprecated use {@link #getRegionSelector(World)}
*/

View File

@ -20,10 +20,8 @@
package com.sk89q.worldedit;
/**
*
* Thrown when a maximum radius for a brush is reached.
*
*/
public class MaxBrushRadiusException extends MaxRadiusException {
private static final long serialVersionUID = 1L;
}

View File

@ -20,19 +20,29 @@
package com.sk89q.worldedit;
/**
*
* @author sk89q
* Thrown when too many blocks are changed (which may be limited
* due to the configuration).
*/
public class MaxChangedBlocksException extends WorldEditException {
private static final long serialVersionUID = -2621044030640945259L;
int maxBlocks;
/**
* Create a new instance.
*
* @param maxBlocks the maximum number of blocks that can be changed
*/
public MaxChangedBlocksException(int maxBlocks) {
this.maxBlocks = maxBlocks;
}
/**
* Get the limit.
*
* @return the maximum number of blocks that can be changed
*/
public int getBlockLimit() {
return maxBlocks;
}
}

View File

@ -20,10 +20,9 @@
package com.sk89q.worldedit;
/**
* Thrown when a maximum radius is reached.
*
* @author sk89q
* Thrown when a maximum radius is reached, such as, for example,
* in the case of a sphere command.
*/
public class MaxRadiusException extends WorldEditException {
private static final long serialVersionUID = -8405382841529528119L;
}

View File

@ -19,16 +19,34 @@
package com.sk89q.worldedit;
/**
* Raised when an item is used when a block was expected.
*/
public class NotABlockException extends WorldEditException {
/**
* Create a new instance.
*/
public NotABlockException() {
super("This item is not a block.");
}
public NotABlockException(String type) {
super("The item '"+type+"' is not a block.");
/**
* Create a new instance.
*
* @param input the input that was used
*/
public NotABlockException(String input) {
super("The item '" + input + "' is not a block.");
}
public NotABlockException(int typeId) {
super("The item with the ID "+typeId+" is not a block.");
/**
* Create a new instance.
*
* @param input the input that was used
*/
public NotABlockException(int input) {
super("The item with the ID " + input + " is not a block.");
}
}

View File

@ -19,10 +19,15 @@
package com.sk89q.worldedit;
import com.sk89q.worldedit.util.Direction;
/**
* Direction.
* The player's direction.
*
* <p>In the future, this class will be replaced with {@link Direction}.</p>
*/
public enum PlayerDirection {
NORTH(new Vector(0, 0, -1), new Vector(-1, 0, 0), true),
NORTH_EAST((new Vector(1, 0, -1)).normalize(), (new Vector(-1, 0, -1)).normalize(), false),
EAST(new Vector(1, 0, 0), new Vector(0, 0, -1), true),
@ -56,4 +61,5 @@ public enum PlayerDirection {
public boolean isOrthogonal() {
return isOrthogonal;
}
}

View File

@ -1,32 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
/**
* Thrown when an operation is run that needs an actual player, not a console.
*
*/
public class PlayerNeededException extends RuntimeException {
private static final long serialVersionUID = 1L;
public PlayerNeededException() {
super("This command cannot be run on the console.");
}
}

View File

@ -1,36 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
public class UnknownBiomeTypeException extends WorldEditException {
private static final long serialVersionUID = -6239229394330814896L;
private String typeName;
public UnknownBiomeTypeException(String typeName) {
super("Unknown " + typeName + " biome type.");
this.typeName = typeName;
}
public String getTypeName() {
return typeName;
}
}

View File

@ -20,19 +20,28 @@
package com.sk89q.worldedit;
/**
*
* @author sk89q
* Thrown when an unknown direction is specified or detected.
*/
public class UnknownDirectionException extends WorldEditException {
private static final long serialVersionUID = 5705931351293248358L;
private String dir;
/**
* Create a new instance.
*
* @param dir the input that was tried
*/
public UnknownDirectionException(String dir) {
this.dir = dir;
}
/**
* Get the direction string that was input.
*
* @return input
*/
public String getDirection() {
return dir;
}
}

View File

@ -21,19 +21,27 @@ package com.sk89q.worldedit;
/**
* Thrown when no item exist by the ID.
*
* @author sk89q
*/
public class UnknownItemException extends WorldEditException {
private static final long serialVersionUID = 2661079183700565880L;
private String type;
/**
* Create a new instance.
*
* @param type the input that was provided
*/
public UnknownItemException(String type) {
this.type = type;
}
/**
* Get the input.
*
* @return the input
*/
public String getID() {
return type;
}
}

View File

@ -19,11 +19,15 @@
package com.sk89q.worldedit;
import com.sk89q.worldedit.math.transform.AffineTransform;
import javax.annotation.Nullable;
/**
*
* @author sk89q
* An immutable 3-dimensional vector.
*/
public class Vector implements Comparable<Vector> {
public static final Vector ZERO = new Vector(0, 0, 0);
public static final Vector UNIT_X = new Vector(1, 0, 0);
public static final Vector UNIT_Y = new Vector(0, 1, 0);
@ -33,11 +37,11 @@ public class Vector implements Comparable<Vector> {
protected final double x, y, z;
/**
* Construct the Vector object.
* Construct an instance.
*
* @param x
* @param y
* @param z
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public Vector(double x, double y, double z) {
this.x = x;
@ -46,11 +50,11 @@ public class Vector implements Comparable<Vector> {
}
/**
* Construct the Vector object.
* Construct an instance.
*
* @param x
* @param y
* @param z
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public Vector(int x, int y, int z) {
this.x = (double) x;
@ -59,11 +63,11 @@ public class Vector implements Comparable<Vector> {
}
/**
* Construct the Vector object.
* Construct an instance.
*
* @param x
* @param y
* @param z
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public Vector(float x, float y, float z) {
this.x = (double) x;
@ -72,18 +76,20 @@ public class Vector implements Comparable<Vector> {
}
/**
* Construct the Vector object.
* Copy another vector.
*
* @param pt
* @param other another vector to make a copy of
*/
public Vector(Vector pt) {
this.x = pt.x;
this.y = pt.y;
this.z = pt.z;
public Vector(Vector other) {
this.x = other.x;
this.y = other.y;
this.z = other.z;
}
/**
* Construct the Vector object.
* Construct a new instance with X, Y, and Z coordinates set to 0.
*
* <p>One can also refer to a static {@link #ZERO}.</p>
*/
public Vector() {
this.x = 0;
@ -92,33 +98,37 @@ public class Vector implements Comparable<Vector> {
}
/**
* @return the x
* Get the X coordinate.
*
* @return the x coordinate
*/
public double getX() {
return x;
}
/**
* @return the x
* Get the X coordinate rounded.
*
* @return the x coordinate
*/
public int getBlockX() {
return (int) Math.round(x);
}
/**
* Set X.
* Set the X coordinate.
*
* @param x
* @return new vector
* @param x the new X
* @return a new vector
*/
public Vector setX(double x) {
return new Vector(x, y, z);
}
/**
* Set X.
* Set the X coordinate.
*
* @param x
* @param x the X coordinate
* @return new vector
*/
public Vector setX(int x) {
@ -126,315 +136,331 @@ public class Vector implements Comparable<Vector> {
}
/**
* @return the y
* Get the Y coordinate.
*
* @return the y coordinate
*/
public double getY() {
return y;
}
/**
* @return the y
* Get the Y coordinate rounded.
*
* @return the y coordinate
*/
public int getBlockY() {
return (int) Math.round(y);
}
/**
* Set Y.
* Set the Y coordinate.
*
* @param y
* @return new vector
* @param y the new Y
* @return a new vector
*/
public Vector setY(double y) {
return new Vector(x, y, z);
}
/**
* Set Y.
* Set the Y coordinate.
*
* @param y
* @return new vector
* @param y the new Y
* @return a new vector
*/
public Vector setY(int y) {
return new Vector(x, y, z);
}
/**
* @return the z
* Get the Z coordinate.
*
* @return the z coordinate
*/
public double getZ() {
return z;
}
/**
* @return the z
* Get the Z coordinate rounded.
*
* @return the z coordinate
*/
public int getBlockZ() {
return (int) Math.round(z);
}
/**
* Set Z.
* Set the Z coordinate.
*
* @param z
* @return new vector
* @param z the new Z
* @return a new vector
*/
public Vector setZ(double z) {
return new Vector(x, y, z);
}
/**
* Set Z.
* Set the Z coordinate.
*
* @param z
* @return new vector
* @param z the new Z
* @return a new vector
*/
public Vector setZ(int z) {
return new Vector(x, y, z);
}
/**
* Adds two points.
* Add another vector to this vector and return the result as a new vector.
*
* @param other
* @return New point
* @param other the other vector
* @return a new vector
*/
public Vector add(Vector other) {
return new Vector(x + other.x, y + other.y, z + other.z);
}
/**
* Adds two points.
* Add another vector to this vector and return the result as a new vector.
*
* @param x
* @param y
* @param z
* @return New point
* @param x the value to add
* @param y the value to add
* @param z the value to add
* @return a new vector
*/
public Vector add(double x, double y, double z) {
return new Vector(this.x + x, this.y + y, this.z + z);
}
/**
* Adds two points.
* Add another vector to this vector and return the result as a new vector.
*
* @param x
* @param y
* @param z
* @return New point
* @param x the value to add
* @param y the value to add
* @param z the value to add
* @return a new vector
*/
public Vector add(int x, int y, int z) {
return new Vector(this.x + x, this.y + y, this.z + z);
}
/**
* Adds points.
* Add a list of vectors to this vector and return the
* result as a new vector.
*
* @param others
* @return New point
* @param others an array of vectors
* @return a new vector
*/
public Vector add(Vector... others) {
double newX = x, newY = y, newZ = z;
for (int i = 0; i < others.length; ++i) {
newX += others[i].x;
newY += others[i].y;
newZ += others[i].z;
for (Vector other : others) {
newX += other.x;
newY += other.y;
newZ += other.z;
}
return new Vector(newX, newY, newZ);
}
/**
* Subtracts two points.
* Subtract another vector from this vector and return the result
* as a new vector.
*
* @param other
* @return New point
* @param other the other vector
* @return a new vector
*/
public Vector subtract(Vector other) {
return new Vector(x - other.x, y - other.y, z - other.z);
}
/**
* Subtract two points.
* Subtract another vector from this vector and return the result
* as a new vector.
*
* @param x
* @param y
* @param z
* @return New point
* @param x the value to subtract
* @param y the value to subtract
* @param z the value to subtract
* @return a new vector
*/
public Vector subtract(double x, double y, double z) {
return new Vector(this.x - x, this.y - y, this.z - z);
}
/**
* Subtract two points.
* Subtract another vector from this vector and return the result
* as a new vector.
*
* @param x
* @param y
* @param z
* @return New point
* @param x the value to subtract
* @param y the value to subtract
* @param z the value to subtract
* @return a new vector
*/
public Vector subtract(int x, int y, int z) {
return new Vector(this.x - x, this.y - y, this.z - z);
}
/**
* Subtract points.
* Subtract a list of vectors from this vector and return the result
* as a new vector.
*
* @param others
* @return New point
* @param others an array of vectors
* @return a new vector
*/
public Vector subtract(Vector... others) {
double newX = x, newY = y, newZ = z;
for (int i = 0; i < others.length; ++i) {
newX -= others[i].x;
newY -= others[i].y;
newZ -= others[i].z;
for (Vector other : others) {
newX -= other.x;
newY -= other.y;
newZ -= other.z;
}
return new Vector(newX, newY, newZ);
}
/**
* Component-wise multiplication
* Multiply this vector by another vector on each component.
*
* @param other
* @return New point
* @param other the other vector
* @return a new vector
*/
public Vector multiply(Vector other) {
return new Vector(x * other.x, y * other.y, z * other.z);
}
/**
* Component-wise multiplication
* Multiply this vector by another vector on each component.
*
* @param x
* @param y
* @param z
* @return New point
* @param x the value to multiply
* @param y the value to multiply
* @param z the value to multiply
* @return a new vector
*/
public Vector multiply(double x, double y, double z) {
return new Vector(this.x * x, this.y * y, this.z * z);
}
/**
* Component-wise multiplication
* Multiply this vector by another vector on each component.
*
* @param x
* @param y
* @param z
* @return New point
* @param x the value to multiply
* @param y the value to multiply
* @param z the value to multiply
* @return a new vector
*/
public Vector multiply(int x, int y, int z) {
return new Vector(this.x * x, this.y * y, this.z * z);
}
/**
* Component-wise multiplication
* Multiply this vector by zero or more vectors on each component.
*
* @param others
* @return New point
* @param others an array of vectors
* @return a new vector
*/
public Vector multiply(Vector... others) {
double newX = x, newY = y, newZ = z;
for (int i = 0; i < others.length; ++i) {
newX *= others[i].x;
newY *= others[i].y;
newZ *= others[i].z;
for (Vector other : others) {
newX *= other.x;
newY *= other.y;
newZ *= other.z;
}
return new Vector(newX, newY, newZ);
}
/**
* Scalar multiplication.
* Perform scalar multiplication and return a new vector.
*
* @param n
* @return New point
* @param n the value to multiply
* @return a new vector
*/
public Vector multiply(double n) {
return new Vector(this.x * n, this.y * n, this.z * n);
}
/**
* Scalar multiplication.
* Perform scalar multiplication and return a new vector.
*
* @param n
* @return New point
* @param n the value to multiply
* @return a new vector
*/
public Vector multiply(float n) {
return new Vector(this.x * n, this.y * n, this.z * n);
}
/**
* Scalar multiplication.
* Perform scalar multiplication and return a new vector.
*
* @param n
* @return New point
* @param n the value to multiply
* @return a new vector
*/
public Vector multiply(int n) {
return new Vector(this.x * n, this.y * n, this.z * n);
}
/**
* Component-wise division
* Divide this vector by another vector on each component.
*
* @param other
* @return New point
* @param other the other vector
* @return a new vector
*/
public Vector divide(Vector other) {
return new Vector(x / other.x, y / other.y, z / other.z);
}
/**
* Component-wise division
* Divide this vector by another vector on each component.
*
* @param x
* @param y
* @param z
* @return New point
* @param x the value to divide by
* @param y the value to divide by
* @param z the value to divide by
* @return a new vector
*/
public Vector divide(double x, double y, double z) {
return new Vector(this.x / x, this.y / y, this.z / z);
}
/**
* Component-wise division
* Divide this vector by another vector on each component.
*
* @param x
* @param y
* @param z
* @return New point
* @param x the value to divide by
* @param y the value to divide by
* @param z the value to divide by
* @return a new vector
*/
public Vector divide(int x, int y, int z) {
return new Vector(this.x / x, this.y / y, this.z / z);
}
/**
* Scalar division.
* Perform scalar division and return a new vector.
*
* @param n
* @return new point
* @param n the value to divide by
* @return a new vector
*/
public Vector divide(int n) {
return new Vector(x / n, y / n, z / n);
}
/**
* Scalar division.
* Perform scalar division and return a new vector.
*
* @param n
* @return new point
* @param n the value to divide by
* @return a new vector
*/
public Vector divide(double n) {
return new Vector(x / n, y / n, z / n);
}
/**
* Scalar division.
* Perform scalar division and return a new vector.
*
* @param n
* @return new point
* @param n the value to divide by
* @return a new vector
*/
public Vector divide(float n) {
return new Vector(x / n, y / n, z / n);
@ -450,42 +476,43 @@ public class Vector implements Comparable<Vector> {
}
/**
* Get the length^2 of the vector.
* Get the length, squared, of the vector.
*
* @return length^2
* @return length, squared
*/
public double lengthSq() {
return x * x + y * y + z * z;
}
/**
* Get the distance away from a point.
* Get the distance between this vector and another vector.
*
* @param pt
* @param other the other vector
* @return distance
*/
public double distance(Vector pt) {
return Math.sqrt(Math.pow(pt.x - x, 2) +
Math.pow(pt.y - y, 2) +
Math.pow(pt.z - z, 2));
public double distance(Vector other) {
return Math.sqrt(Math.pow(other.x - x, 2) +
Math.pow(other.y - y, 2) +
Math.pow(other.z - z, 2));
}
/**
* Get the distance away from a point, squared.
* Get the distance between this vector and another vector, squared.
*
* @param pt
* @param other the other vector
* @return distance
*/
public double distanceSq(Vector pt) {
return Math.pow(pt.x - x, 2) +
Math.pow(pt.y - y, 2) +
Math.pow(pt.z - z, 2);
public double distanceSq(Vector other) {
return Math.pow(other.x - x, 2) +
Math.pow(other.y - y, 2) +
Math.pow(other.z - z, 2);
}
/**
* Get the normalized vector.
* Get the normalized vector, which is the vector divided by its
* length, as a new vector.
*
* @return vector
* @return a new vector
*/
public Vector normalize() {
return divide(length());
@ -494,7 +521,7 @@ public class Vector implements Comparable<Vector> {
/**
* Gets the dot product of this and another vector.
*
* @param other
* @param other the other vector
* @return the dot product of this and the other vector
*/
public double dot(Vector other) {
@ -504,7 +531,7 @@ public class Vector implements Comparable<Vector> {
/**
* Gets the cross product of this and another vector.
*
* @param other
* @param other the other vector
* @return the cross product of this and the other vector
*/
public Vector cross(Vector other) {
@ -518,22 +545,21 @@ public class Vector implements Comparable<Vector> {
/**
* Checks to see if a vector is contained with another.
*
* @param min
* @param max
* @return
* @param min the minimum point (X, Y, and Z are the lowest)
* @param max the maximum point (X, Y, and Z are the lowest)
* @return true if the vector is contained
*/
public boolean containedWithin(Vector min, Vector max) {
return x >= min.x && x <= max.x
&& y >= min.y && y <= max.y
&& z >= min.z && z <= max.z;
return x >= min.x && x <= max.x && y >= min.y && y <= max.y && z >= min.z && z <= max.z;
}
/**
* Checks to see if a vector is contained with another.
* Checks to see if a vector is contained with another, comparing
* using discrete comparisons, inclusively.
*
* @param min
* @param max
* @return
* @param min the minimum point (X, Y, and Z are the lowest)
* @param max the maximum point (X, Y, and Z are the lowest)
* @return true if the vector is contained
*/
public boolean containedWithinBlock(Vector min, Vector max) {
return getBlockX() >= min.getBlockX() && getBlockX() <= max.getBlockX()
@ -544,18 +570,18 @@ public class Vector implements Comparable<Vector> {
/**
* Clamp the Y component.
*
* @param min
* @param max
* @return
* @param min the minimum value
* @param max the maximum value
* @return a new vector
*/
public Vector clampY(int min, int max) {
return new Vector(x, Math.max(min, Math.min(max, y)), z);
}
/**
* Rounds all components down.
* Floors the values of all components.
*
* @return
* @return a new vector
*/
public Vector floor() {
return new Vector(Math.floor(x), Math.floor(y), Math.floor(z));
@ -564,41 +590,43 @@ public class Vector implements Comparable<Vector> {
/**
* Rounds all components up.
*
* @return
* @return a new vector
*/
public Vector ceil() {
return new Vector(Math.ceil(x), Math.ceil(y), Math.ceil(z));
}
/**
* Rounds all components to the closest integer.<br>
*<br>
* Components < 0.5 are rounded down, otherwise up
* Rounds all components to the closest integer.
*
* @return
* <p>Components < 0.5 are rounded down, otherwise up.</p>
*
* @return a new vector
*/
public Vector round() {
return new Vector(Math.floor(x + 0.5), Math.floor(y + 0.5), Math.floor(z + 0.5));
}
/**
* Returns a vector with the absolute values of the components of this vector.
* Returns a vector with the absolute values of the components of
* this vector.
*
* @return
* @return a new vector
*/
public Vector positive() {
return new Vector(Math.abs(x), Math.abs(y), Math.abs(z));
}
/**
* 2D transformation.
* Perform a 2D transformation on this vector and return a new one.
*
* @param angle in degrees
* @param aboutX about which x coordinate to rotate
* @param aboutZ about which z coordinate to rotate
* @param translateX what to add after rotation
* @param translateZ what to add after rotation
* @return
* @return a new vector
* @see AffineTransform another method to transform vectors
*/
public Vector transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
angle = Math.toRadians(angle);
@ -614,6 +642,12 @@ public class Vector implements Comparable<Vector> {
);
}
/**
* Returns whether this vector is collinear with another vector.
*
* @param other the other vector
* @return true if collinear
*/
public boolean isCollinearWith(Vector other) {
if (x == 0 && y == 0 && z == 0) {
// this is a zero vector
@ -686,12 +720,12 @@ public class Vector implements Comparable<Vector> {
}
/**
* Get a block point from a point.
* Create a new {@code BlockVector} using the given components.
*
* @param x
* @param y
* @param z
* @return point
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
* @return a new {@code BlockVector}
*/
public static BlockVector toBlockPoint(double x, double y, double z) {
return new BlockVector(
@ -702,9 +736,9 @@ public class Vector implements Comparable<Vector> {
}
/**
* Get a block point from a point.
* Create a new {@code BlockVector} from this vector.
*
* @return point
* @return a new {@code BlockVector}
*/
public BlockVector toBlockPoint() {
return new BlockVector(
@ -715,11 +749,23 @@ public class Vector implements Comparable<Vector> {
}
/**
* Checks if another object is equivalent.
* Create a new {@code BlockVector} from this vector.
*
* @param obj
* @return whether the other object is equivalent
* @return a new {@code BlockVector}
*/
public BlockVector toBlockVector() {
return new BlockVector(this);
}
/**
* Creates a 2D vector by dropping the Y component from this vector.
*
* @return a new {@code Vector2D}
*/
public Vector2D toVector2D() {
return new Vector2D(x, z);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Vector)) {
@ -731,18 +777,16 @@ public class Vector implements Comparable<Vector> {
}
@Override
public int compareTo(Vector other) {
public int compareTo(@Nullable Vector other) {
if (other == null) {
throw new IllegalArgumentException("null not supported");
}
if (y != other.y) return Double.compare(y, other.y);
if (z != other.z) return Double.compare(z, other.z);
if (x != other.x) return Double.compare(x, other.x);
return 0;
}
/**
* Gets the hash code.
*
* @return hash code
*/
@Override
public int hashCode() {
int hash = 7;
@ -753,76 +797,53 @@ public class Vector implements Comparable<Vector> {
return hash;
}
/**
* Returns string representation "(x, y, z)".
*
* @return string
*/
@Override
public String toString() {
return "(" + x + ", " + y + ", " + z + ")";
}
/**
* Gets a BlockVector version.
*
* @return BlockVector
*/
public BlockVector toBlockVector() {
return new BlockVector(this);
}
/**
* Creates a 2D vector by dropping the Y component from this vector.
*
* @return Vector2D
*/
public Vector2D toVector2D() {
return new Vector2D(x, z);
}
/**
* Gets the minimum components of two vectors.
*
* @param v1
* @param v2
* @param v1 the first vector
* @param v2 the second vector
* @return minimum
*/
public static Vector getMinimum(Vector v1, Vector v2) {
return new Vector(
Math.min(v1.x, v2.x),
Math.min(v1.y, v2.y),
Math.min(v1.z, v2.z)
Math.min(v1.x, v2.x),
Math.min(v1.y, v2.y),
Math.min(v1.z, v2.z)
);
}
/**
* Gets the maximum components of two vectors.
*
* @param v1
* @param v2
* @param v1 the first vector
* @param v2 the second vector
* @return maximum
*/
public static Vector getMaximum(Vector v1, Vector v2) {
return new Vector(
Math.max(v1.x, v2.x),
Math.max(v1.y, v2.y),
Math.max(v1.z, v2.z)
Math.max(v1.x, v2.x),
Math.max(v1.y, v2.y),
Math.max(v1.z, v2.z)
);
}
/**
* Gets the midpoint of two vectors.
*
* @param v1
* @param v2
* @param v1 the first vector
* @param v2 the second vector
* @return maximum
*/
public static Vector getMidpoint(Vector v1, Vector v2) {
return new Vector(
(v1.x + v2.x) / 2,
(v1.y + v2.y) / 2,
(v1.z + v2.z) / 2
(v1.x + v2.x) / 2,
(v1.y + v2.y) / 2,
(v1.z + v2.z) / 2
);
}

View File

@ -19,9 +19,10 @@
package com.sk89q.worldedit;
import com.sk89q.worldedit.math.transform.AffineTransform;
/**
*
* @author sk89q
* An immutable 2-dimensional vector.
*/
public class Vector2D {
public static final Vector2D ZERO = new Vector2D(0, 0);
@ -32,10 +33,10 @@ public class Vector2D {
protected final double x, z;
/**
* Construct the Vector2D object.
* Construct an instance.
*
* @param x
* @param z
* @param x the X coordinate
* @param z the Z coordinate
*/
public Vector2D(double x, double z) {
this.x = x;
@ -43,10 +44,10 @@ public class Vector2D {
}
/**
* Construct the Vector2D object.
* Construct an instance.
*
* @param x
* @param z
* @param x the X coordinate
* @param z the Z coordinate
*/
public Vector2D(int x, int z) {
this.x = (double) x;
@ -54,10 +55,10 @@ public class Vector2D {
}
/**
* Construct the Vector2D object.
* Construct an instance.
*
* @param x
* @param z
* @param x the X coordinate
* @param z the Z coordinate
*/
public Vector2D(float x, float z) {
this.x = (double) x;
@ -65,17 +66,19 @@ public class Vector2D {
}
/**
* Construct the Vector2D object.
* Copy another vector.
*
* @param pt
* @param other the other vector
*/
public Vector2D(Vector2D pt) {
this.x = pt.x;
this.z = pt.z;
public Vector2D(Vector2D other) {
this.x = other.x;
this.z = other.z;
}
/**
* Construct the Vector2D object.
* Construct a new instance with X and Z coordinates set to 0.
*
* <p>One can also refer to a static {@link #ZERO}.</p>
*/
public Vector2D() {
this.x = 0;
@ -83,304 +86,320 @@ public class Vector2D {
}
/**
* @return the x
* Get the X coordinate.
*
* @return the x coordinate
*/
public double getX() {
return x;
}
/**
* @return the x
* Get the X coordinate rounded.
*
* @return the x coordinate
*/
public int getBlockX() {
return (int) Math.round(x);
}
/**
* Set X.
* Set the X coordinate.
*
* @param x
* @return new vector
* @param x the new X
* @return a new vector
*/
public Vector2D setX(double x) {
return new Vector2D(x, z);
}
/**
* Set X.
* Set the X coordinate.
*
* @param x
* @return new vector
* @param x the new X
* @return a new vector
*/
public Vector2D setX(int x) {
return new Vector2D(x, z);
}
/**
* @return the z
* Get the Z coordinate.
*
* @return the z coordinate
*/
public double getZ() {
return z;
}
/**
* @return the z
* Get the Z coordinate rounded.
*
* @return the z coordinate
*/
public int getBlockZ() {
return (int) Math.round(z);
}
/**
* Set Z.
* Set the Z coordinate.
*
* @param z
* @return new vector
* @param z the new Z
* @return a new vector
*/
public Vector2D setZ(double z) {
return new Vector2D(x, z);
}
/**
* Set Z.
* Set the Z coordinate.
*
* @param z
* @return new vector
* @param z the new Z
* @return a new vector
*/
public Vector2D setZ(int z) {
return new Vector2D(x, z);
}
/**
* Adds two points.
* Add another vector to this vector and return the result as a new vector.
*
* @param other
* @return New point
* @param other the other vector
* @return a new vector
*/
public Vector2D add(Vector2D other) {
return new Vector2D(x + other.x, z + other.z);
}
/**
* Adds two points.
* Add another vector to this vector and return the result as a new vector.
*
* @param x
* @param z
* @return New point
* @param x the value to add
* @param z the value to add
* @return a new vector
*/
public Vector2D add(double x, double z) {
return new Vector2D(this.x + x, this.z + z);
}
/**
* Adds two points.
* Add another vector to this vector and return the result as a new vector.
*
* @param x
* @param z
* @return New point
* @param x the value to add
* @param z the value to add
* @return a new vector
*/
public Vector2D add(int x, int z) {
return new Vector2D(this.x + x, this.z + z);
}
/**
* Adds points.
* Add a list of vectors to this vector and return the
* result as a new vector.
*
* @param others
* @return New point
* @param others an array of vectors
* @return a new vector
*/
public Vector2D add(Vector2D... others) {
double newX = x, newZ = z;
for (int i = 0; i < others.length; ++i) {
newX += others[i].x;
newZ += others[i].z;
for (Vector2D other : others) {
newX += other.x;
newZ += other.z;
}
return new Vector2D(newX, newZ);
}
/**
* Subtracts two points.
* Subtract another vector from this vector and return the result
* as a new vector.
*
* @param other
* @return New point
* @param other the other vector
* @return a new vector
*/
public Vector2D subtract(Vector2D other) {
return new Vector2D(x - other.x, z - other.z);
}
/**
* Subtract two points.
* Subtract another vector from this vector and return the result
* as a new vector.
*
* @param x
* @param z
* @return New point
* @param x the value to subtract
* @param z the value to subtract
* @return a new vector
*/
public Vector2D subtract(double x, double z) {
return new Vector2D(this.x - x, this.z - z);
}
/**
* Subtract two points.
* Subtract another vector from this vector and return the result
* as a new vector.
*
* @param x
* @param z
* @return New point
* @param x the value to subtract
* @param z the value to subtract
* @return a new vector
*/
public Vector2D subtract(int x, int z) {
return new Vector2D(this.x - x, this.z - z);
}
/**
* Subtract points.
* Subtract a list of vectors from this vector and return the result
* as a new vector.
*
* @param others
* @return New point
* @param others an array of vectors
* @return a new vector
*/
public Vector2D subtract(Vector2D... others) {
double newX = x, newZ = z;
for (int i = 0; i < others.length; ++i) {
newX -= others[i].x;
newZ -= others[i].z;
for (Vector2D other : others) {
newX -= other.x;
newZ -= other.z;
}
return new Vector2D(newX, newZ);
}
/**
* Component-wise multiplication
* Multiply this vector by another vector on each component.
*
* @param other
* @return New point
* @param other the other vector
* @return a new vector
*/
public Vector2D multiply(Vector2D other) {
return new Vector2D(x * other.x, z * other.z);
}
/**
* Component-wise multiplication
* Multiply this vector by another vector on each component.
*
* @param x
* @param z
* @return New point
* @param x the value to multiply
* @param z the value to multiply
* @return a new vector
*/
public Vector2D multiply(double x, double z) {
return new Vector2D(this.x * x, this.z * z);
}
/**
* Component-wise multiplication
* Multiply this vector by another vector on each component.
*
* @param x
* @param z
* @return New point
* @param x the value to multiply
* @param z the value to multiply
* @return a new vector
*/
public Vector2D multiply(int x, int z) {
return new Vector2D(this.x * x, this.z * z);
}
/**
* Component-wise multiplication
* Multiply this vector by zero or more vectors on each component.
*
* @param others
* @return New point
* @param others an array of vectors
* @return a new vector
*/
public Vector2D multiply(Vector2D... others) {
double newX = x, newZ = z;
for (int i = 0; i < others.length; ++i) {
newX *= others[i].x;
newZ *= others[i].z;
for (Vector2D other : others) {
newX *= other.x;
newZ *= other.z;
}
return new Vector2D(newX, newZ);
}
/**
* Scalar multiplication.
* Perform scalar multiplication and return a new vector.
*
* @param n
* @return New point
* @param n the value to multiply
* @return a new vector
*/
public Vector2D multiply(double n) {
return new Vector2D(this.x * n, this.z * n);
}
/**
* Scalar multiplication.
* Perform scalar multiplication and return a new vector.
*
* @param n
* @return New point
* @param n the value to multiply
* @return a new vector
*/
public Vector2D multiply(float n) {
return new Vector2D(this.x * n, this.z * n);
}
/**
* Scalar multiplication.
* Perform scalar multiplication and return a new vector.
*
* @param n
* @return New point
* @param n the value to multiply
* @return a new vector
*/
public Vector2D multiply(int n) {
return new Vector2D(this.x * n, this.z * n);
}
/**
* Component-wise division
* Divide this vector by another vector on each component.
*
* @param other
* @return New point
* @param other the other vector
* @return a new vector
*/
public Vector2D divide(Vector2D other) {
return new Vector2D(x / other.x, z / other.z);
}
/**
* Component-wise division
* Divide this vector by another vector on each component.
*
* @param x
* @param z
* @return New point
* @param x the value to divide by
* @param z the value to divide by
* @return a new vector
*/
public Vector2D divide(double x, double z) {
return new Vector2D(this.x / x, this.z / z);
}
/**
* Component-wise division
* Divide this vector by another vector on each component.
*
* @param x
* @param z
* @return New point
* @param x the value to divide by
* @param z the value to divide by
* @return a new vector
*/
public Vector2D divide(int x, int z) {
return new Vector2D(this.x / x, this.z / z);
}
/**
* Scalar division.
* Perform scalar division and return a new vector.
*
* @param n
* @return new point
* @param n the value to divide by
* @return a new vector
*/
public Vector2D divide(int n) {
return new Vector2D(x / n, z / n);
}
/**
* Scalar division.
* Perform scalar division and return a new vector.
*
* @param n
* @return new point
* @param n the value to divide by
* @return a new vector
*/
public Vector2D divide(double n) {
return new Vector2D(x / n, z / n);
}
/**
* Scalar division.
* Perform scalar division and return a new vector.
*
* @param n
* @return new point
* @param n the value to divide by
* @return a new vector
*/
public Vector2D divide(float n) {
return new Vector2D(x / n, z / n);
@ -396,40 +415,40 @@ public class Vector2D {
}
/**
* Get the length^2 of the vector.
* Get the length, squared, of the vector.
*
* @return length^2
* @return length, squared
*/
public double lengthSq() {
return x * x + z * z;
}
/**
* Get the distance away from a point.
* Get the distance between this vector and another vector.
*
* @param pt
* @param other the other vector
* @return distance
*/
public double distance(Vector2D pt) {
return Math.sqrt(Math.pow(pt.x - x, 2) +
Math.pow(pt.z - z, 2));
public double distance(Vector2D other) {
return Math.sqrt(Math.pow(other.x - x, 2) + Math.pow(other.z - z, 2));
}
/**
* Get the distance away from a point, squared.
* Get the distance between this vector and another vector, squared.
*
* @param pt
* @param other the other vector
* @return distance
*/
public double distanceSq(Vector2D pt) {
return Math.pow(pt.x - x, 2) +
Math.pow(pt.z - z, 2);
public double distanceSq(Vector2D other) {
return Math.pow(other.x - x, 2) +
Math.pow(other.z - z, 2);
}
/**
* Get the normalized vector.
* Get the normalized vector, which is the vector divided by its
* length, as a new vector.
*
* @return vector
* @return a new vector
*/
public Vector2D normalize() {
return divide(length());
@ -438,7 +457,7 @@ public class Vector2D {
/**
* Gets the dot product of this and another vector.
*
* @param other
* @param other the other vector
* @return the dot product of this and the other vector
*/
public double dot(Vector2D other) {
@ -448,9 +467,9 @@ public class Vector2D {
/**
* Checks to see if a vector is contained with another.
*
* @param min
* @param max
* @return
* @param min the minimum point (X, Y, and Z are the lowest)
* @param max the maximum point (X, Y, and Z are the lowest)
* @return true if the vector is contained
*/
public boolean containedWithin(Vector2D min, Vector2D max) {
return x >= min.x && x <= max.x
@ -460,9 +479,9 @@ public class Vector2D {
/**
* Checks to see if a vector is contained with another.
*
* @param min
* @param max
* @return
* @param min the minimum point (X, Y, and Z are the lowest)
* @param max the maximum point (X, Y, and Z are the lowest)
* @return true if the vector is contained
*/
public boolean containedWithinBlock(Vector2D min, Vector2D max) {
return getBlockX() >= min.getBlockX() && getBlockX() <= max.getBlockX()
@ -470,9 +489,9 @@ public class Vector2D {
}
/**
* Rounds all components down.
* Floors the values of all components.
*
* @return
* @return a new vector
*/
public Vector2D floor() {
return new Vector2D(Math.floor(x), Math.floor(z));
@ -481,41 +500,43 @@ public class Vector2D {
/**
* Rounds all components up.
*
* @return
* @return a new vector
*/
public Vector2D ceil() {
return new Vector2D(Math.ceil(x), Math.ceil(z));
}
/**
* Rounds all components to the closest integer.<br>
*<br>
* Components < 0.5 are rounded down, otherwise up
* Rounds all components to the closest integer.
*
* @return
* <p>Components < 0.5 are rounded down, otherwise up.</p>
*
* @return a new vector
*/
public Vector2D round() {
return new Vector2D(Math.floor(x + 0.5), Math.floor(z + 0.5));
}
/**
* Returns a vector with the absolute values of the components of this vector.
* Returns a vector with the absolute values of the components of
* this vector.
*
* @return
* @return a new vector
*/
public Vector2D positive() {
return new Vector2D(Math.abs(x), Math.abs(z));
}
/**
* 2D transformation.
* Perform a 2D transformation on this vector and return a new one.
*
* @param angle in degrees
* @param aboutX about which x coordinate to rotate
* @param aboutZ about which z coordinate to rotate
* @param translateX what to add after rotation
* @param translateZ what to add after rotation
* @return
* @return a new vector
* @see AffineTransform another method to transform vectors
*/
public Vector2D transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
angle = Math.toRadians(angle);
@ -529,6 +550,12 @@ public class Vector2D {
);
}
/**
* Returns whether this vector is collinear with another vector.
*
* @param other the other vector
* @return true if collinear
*/
public boolean isCollinearWith(Vector2D other) {
if (x == 0 && z == 0) {
// this is a zero vector
@ -560,20 +587,32 @@ public class Vector2D {
}
/**
* Gets a BlockVector version.
* Create a new {@code BlockVector2D} from this vector.
*
* @return BlockVector
* @return a new {@code BlockVector2D}
*/
public BlockVector2D toBlockVector2D() {
return new BlockVector2D(this);
}
/**
* Checks if another object is equivalent.
* Creates a 3D vector by adding a zero Y component to this vector.
*
* @param obj
* @return whether the other object is equivalent
* @return a new vector
*/
public Vector toVector() {
return new Vector(x, 0, z);
}
/**
* Creates a 3D vector by adding the specified Y component to this vector.
*
* @return a new vector
*/
public Vector toVector(double y) {
return new Vector(x, y, z);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Vector2D)) {
@ -585,50 +624,22 @@ public class Vector2D {
}
/**
* Gets the hash code.
*
* @return hash code
*/
@Override
public int hashCode() {
return ((new Double(x)).hashCode() >> 13) ^
(new Double(z)).hashCode();
}
/**
* Returns string representation "(x, y, z)".
*
* @return string
*/
@Override
public String toString() {
return "(" + x + ", " + z + ")";
}
/**
* Creates a 3D vector by adding a zero Y component to this vector.
*
* @return Vector
*/
public Vector toVector() {
return new Vector(x, 0, z);
}
/**
* Creates a 3D vector by adding the specified Y component to this vector.
*
* @return Vector
*/
public Vector toVector(double y) {
return new Vector(x, y, z);
}
/**
* Gets the minimum components of two vectors.
*
* @param v1
* @param v2
* @param v1 the first vector
* @param v2 the second vector
* @return minimum
*/
public static Vector2D getMinimum(Vector2D v1, Vector2D v2) {
@ -641,8 +652,8 @@ public class Vector2D {
/**
* Gets the maximum components of two vectors.
*
* @param v1
* @param v2
* @param v1 the first vector
* @param v2 the second vector
* @return maximum
*/
public static Vector2D getMaximum(Vector2D v1, Vector2D v2) {
@ -651,4 +662,5 @@ public class Vector2D {
Math.max(v1.z, v2.z)
);
}
}

View File

@ -19,12 +19,15 @@
package com.sk89q.worldedit;
import com.sk89q.worldedit.util.Direction;
/**
* Represents the adjacency of one vector to another. Works similarly to
* Bukkit's BlockFace class.
*
* @author wizjany
* @deprecated to be replaced with {@link Direction}
*/
@Deprecated
public enum VectorFace {
NORTH(-1, 0, 0),
EAST(0, 0, -1),

View File

@ -45,6 +45,10 @@ import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
import com.sk89q.worldedit.session.SessionManager;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.eventbus.EventBus;
import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
import com.sk89q.worldedit.util.io.file.FilenameException;
import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
import com.sk89q.worldedit.util.io.file.InvalidFilenameException;
import com.sk89q.worldedit.util.logging.WorldEditPrefixHandler;
import com.sk89q.worldedit.world.registry.BundledBlockData;
@ -66,16 +70,16 @@ import static com.sk89q.worldedit.event.platform.Interaction.OPEN;
/**
* The entry point and container for a working implementation of WorldEdit.
* </p>
* An instance handles event handling; block, mask, pattern, etc. registration;
*
* <p>An instance handles event handling; block, mask, pattern, etc. registration;
* the management of sessions; the creation of {@link EditSession}s; and more.
* In order to use WorldEdit, at least one {@link Platform} must be registered
* with WorldEdit using {@link PlatformManager#register(Platform)} on the
* manager retrieved using {@link WorldEdit#getPlatformManager()}.
* </p>
* An instance of WorldEdit can be retrieved using the static
* manager retrieved using {@link WorldEdit#getPlatformManager()}.</p>
*
* <p>An instance of WorldEdit can be retrieved using the static
* method {@link WorldEdit#getInstance()}, which is shared among all
* platforms within the same classloader hierarchy.
* platforms within the same classloader hierarchy.</p>
*/
public class WorldEdit {
@ -104,10 +108,10 @@ public class WorldEdit {
/**
* Gets the current instance of this class.
* </p>
* An instance will always be available, but no platform may yet be
*
* <p>An instance will always be available, but no platform may yet be
* registered with WorldEdit, meaning that a number of operations
* may fail. However, event handlers can be registered.
* may fail. However, event handlers can be registered.</p>
*
* @return an instance of WorldEdit.
*/
@ -128,8 +132,8 @@ public class WorldEdit {
/**
* Get the event bus for WorldEdit.
* </p>
* Event handlers can be registered on the event bus.
*
* <p>Event handlers can be registered on the event bus.</p>
*
* @return the event bus
*/

View File

@ -1,30 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
/**
* Raised when WorldEdit is not installed.
*
* @author sk89q
*/
public class WorldEditNotInstalled extends WorldEditException {
private static final long serialVersionUID = -4698408698930848121L;
}

View File

@ -22,9 +22,12 @@ package com.sk89q.worldedit;
/**
* Represents a WorldEdit operation.
*
* @author sk89q
* @deprecated This will be removed with no direct replacement. Please use the
* WorldEdit API.
*/
@Deprecated
public abstract class WorldEditOperation {
public abstract void run(LocalSession session,
LocalPlayer player, EditSession editSession) throws Throwable;
public abstract void run(LocalSession session, LocalPlayer player, EditSession editSession) throws Throwable;
}

View File

@ -19,11 +19,12 @@
package com.sk89q.worldedit;
/**
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
*/
@Deprecated
public class WorldVector2D extends Vector2D {
/**
* Represents the world.
*/
protected LocalWorld world;
public WorldVector2D(LocalWorld world) {

View File

@ -20,12 +20,11 @@
package com.sk89q.worldedit;
/**
* A WorldVector that emphasizes one side of the block
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
*/
@Deprecated
public class WorldVectorFace extends WorldVector {
/**
* Represents the side.
*/
private VectorFace face;
/**

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
package com.sk89q.worldedit.blocks.metadata;
/**
* Represents the possible types of mobs.

View File

@ -24,8 +24,8 @@ import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.FilenameException;
import com.sk89q.worldedit.FilenameResolutionException;
import com.sk89q.worldedit.util.io.file.FilenameException;
import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;

View File

@ -17,7 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.WorldEditException;
public class InvalidToolBindException extends WorldEditException {
private static final long serialVersionUID = -1865311004052447699L;

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.extension.factory;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.*;
import com.sk89q.worldedit.blocks.metadata.MobType;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.DisallowedUsageException;
import com.sk89q.worldedit.extension.input.InputParseException;

View File

@ -23,10 +23,14 @@ import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.ItemType;
import com.sk89q.worldedit.command.InsufficientArgumentsException;
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.util.command.parametric.ExceptionConverterHelper;
import com.sk89q.worldedit.util.command.parametric.ExceptionMatch;
import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
import com.sk89q.worldedit.util.io.file.InvalidFilenameException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -46,11 +50,6 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper {
this.worldEdit = worldEdit;
}
@ExceptionMatch
public void convert(PlayerNeededException e) throws CommandException {
throw new CommandException(e.getMessage());
}
@ExceptionMatch
public void convert(NumberFormatException e) throws CommandException {
final Matcher matcher = numberFormat.matcher(e.getMessage());

View File

@ -25,6 +25,7 @@ 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 com.sk89q.worldedit.util.io.file.FilenameException;
import java.io.File;
import java.util.ArrayList;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
package com.sk89q.worldedit.util.io.file;
public class FileSelectionAbortedException extends FilenameException {
private static final long serialVersionUID = 7377072269988014886L;

View File

@ -17,7 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
package com.sk89q.worldedit.util.io.file;
import com.sk89q.worldedit.WorldEditException;
public class FilenameException extends WorldEditException {
private static final long serialVersionUID = 6072601657326106265L;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
package com.sk89q.worldedit.util.io.file;
public class FilenameResolutionException extends FilenameException {
private static final long serialVersionUID = 4673670296313383121L;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
package com.sk89q.worldedit.util.io.file;
public class InvalidFilenameException extends FilenameException {
private static final long serialVersionUID = 7377072269988014886L;