@@ -52,7 +48,7 @@ public final class NBTInputStream implements Closeable {
/**
* Creates a new {@code NBTInputStream}, which will source its data
* from the specified input stream.
- *
+ *
* @param is the input stream
* @throws IOException if an I/O error occurs
*/
@@ -64,13 +60,9 @@ public final class NBTInputStream implements Closeable {
this.is = dis;
}
- public DataInputStream getInputStream() {
- return is;
- }
-
/**
* Reads an NBT tag from the stream.
- *
+ *
* @return The tag that was read.
* @throws IOException if an I/O error occurs.
*/
@@ -78,19 +70,9 @@ public final class NBTInputStream implements Closeable {
return readNamedTag(0);
}
- /**
- * Reads an NBT map from the stream.
- *
- * @return The map that was read.
- * @throws IOException if an I/O error occurs.
- */
- public NamedData readNamedData() throws IOException {
- return readNamedData(0);
- }
-
/**
* Reads an NBT from the stream.
- *
+ *
* @param depth the depth of this tag
* @return The tag that was read.
* @throws IOException if an I/O error occurs.
@@ -100,21 +82,11 @@ public final class NBTInputStream implements Closeable {
return new NamedTag(readNamedTagName(type), readTagPayload(type, depth));
}
- private NamedData readNamedData(int depth) throws IOException {
- int type = is.readByte();
- return new NamedData(readNamedTagName(type), readDataPayload(type, depth));
- }
-
public Tag readTag() throws IOException {
int type = is.readByte();
return readTagPayload(type, 0);
}
- public Object readData() throws IOException {
- int type = is.readByte();
- return readDataPayload(type, 0);
- }
-
public void readNamedTagLazy(Function getReader) throws IOException {
int type = is.readByte();
String name = readNamedTagName(type);
@@ -522,13 +494,13 @@ public final class NBTInputStream implements Closeable {
/**
* Reads the payload of a tag given the type.
- *
+ *
* @param type the type
* @param depth the depth
* @return the tag
* @throws IOException if an I/O error occurs.
*/
- public Tag readTagPayload(int type, int depth) throws IOException {
+ private Tag readTagPayload(int type, int depth) throws IOException {
switch (type) {
case NBTConstants.TYPE_END:
if (depth == 0) {
@@ -598,11 +570,11 @@ public final class NBTInputStream implements Closeable {
}
case NBTConstants.TYPE_LONG_ARRAY: {
length = is.readInt();
- long[] data = new long[length];
+ long[] longData = new long[length];
for (int i = 0; i < length; i++) {
- data[i] = is.readLong();
+ longData[i] = is.readLong();
}
- return new LongArrayTag(data);
+ return new LongArrayTag(longData);
}
default:
throw new IOException("Invalid tag type: " + type + ".");
diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java
index 7ad1a8142..0a2b3353e 100644
--- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java
+++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java
@@ -21,7 +21,6 @@ package com.sk89q.jnbt;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.boydti.fawe.object.io.LittleEndianOutputStream;
import java.io.Closeable;
import java.io.DataOutput;
import java.io.DataOutputStream;
@@ -34,7 +33,7 @@ import java.util.Map;
/**
* This class writes NBT, or Named Binary Tag
* {@code Tag} objects to an underlying {@code OutputStream}.
- *
+ *
*
@@ -49,7 +48,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
/**
* Creates a new {@code NBTOutputStream}, which will write data to the
* specified underlying output stream.
- *
+ *
* @param os
* The output stream.
* @throws IOException
@@ -67,15 +66,9 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
return os;
}
- public void setLittleEndian() {
- if (!(os instanceof LittleEndianOutputStream)) {
- this.os = new LittleEndianOutputStream((OutputStream) os);
- }
- }
-
/**
* Writes a tag.
- *
+ *
* @param tag
* The tag to write.
* @throws IOException
@@ -86,10 +79,16 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
checkNotNull(tag);
int type = NBTUtils.getTypeCode(tag.getClass());
- writeNamedTagName(name, type);
+ byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
+
+ os.writeByte(type);
+ os.writeShort(nameBytes.length);
+ os.write(nameBytes);
+
if (type == NBTConstants.TYPE_END) {
throw new IOException("Named TAG_End not permitted.");
}
+
writeTagPayload(tag);
}
@@ -149,16 +148,6 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
}
}
- public void writeNamedTag(String name, long[] data) throws IOException {
- checkNotNull(name);
- int type = NBTConstants.TYPE_LONG_ARRAY;
- writeNamedTagName(name, type);
- os.writeInt(data.length);
- for (long aData : data) {
- os.writeLong(aData);
- }
- }
-
public void writeNamedEmptyList(String name) throws IOException {
writeNamedEmptyList(name, NBTConstants.TYPE_COMPOUND);
}
@@ -171,6 +160,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
public void writeNamedTagName(String name, int type) throws IOException {
byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
+
os.writeByte(type);
os.writeShort(nameBytes.length);
os.write(nameBytes);
@@ -201,7 +191,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
/**
* Writes tag payload.
- *
+ *
* @param tag
* The tag.
* @throws IOException
@@ -256,7 +246,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
/**
* Writes a {@code TAG_Byte} tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
@@ -268,7 +258,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
/**
* Writes a {@code TAG_Byte_Array} tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
@@ -282,7 +272,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
/**
* Writes a {@code TAG_Compound} tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
@@ -292,12 +282,12 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
for (Map.Entry entry : tag.getValue().entrySet()) {
writeNamedTag(entry.getKey(), entry.getValue());
}
- os.writeByte(NBTConstants.TYPE_END); // end tag - better way?
+ os.writeByte((byte) 0); // end tag - better way?
}
/**
* Writes a {@code TAG_List} tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
@@ -324,7 +314,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
/**
* Writes a {@code TAG_String} tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
@@ -338,7 +328,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
/**
* Writes a {@code TAG_Double} tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
@@ -350,7 +340,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
/**
* Writes a {@code TAG_Float} tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
@@ -362,7 +352,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
/**
* Writes a {@code TAG_Long} tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
@@ -374,7 +364,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
/**
* Writes a {@code TAG_Int} tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
@@ -386,7 +376,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
/**
* Writes a {@code TAG_Short} tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
@@ -398,19 +388,19 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
/**
* Writes a {@code TAG_Empty} tag.
- *
+ *
* @param tag the tag
*/
private void writeEndTagPayload(EndTag tag) {
/* empty */
}
-
+
private void writeIntArrayTagPayload(IntArrayTag tag) throws IOException {
int[] data = tag.getValue();
os.writeInt(data.length);
for (int aData : data) {
os.writeInt(aData);
- }
+ }
}
private void writeLongArrayTagPayload(LongArrayTag tag) throws IOException {
@@ -505,4 +495,4 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
public void flush() throws IOException {
if (os instanceof Flushable) ((Flushable) os).flush();
}
-}
\ No newline at end of file
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java
index 6ff25faa7..47d501f09 100644
--- a/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java
+++ b/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java
@@ -26,12 +26,9 @@ public abstract class Tag {
/**
* Gets the value of this tag.
- *
+ *
* @return the value
*/
public abstract Object getValue();
- public Object getRaw() {
- return getValue();
- }
-}
\ No newline at end of file
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SuggestedRange.java b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SuggestedRange.java
deleted file mode 100644
index 98aa1f63e..000000000
--- a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SuggestedRange.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.sk89q.minecraft.util.commands;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(RetentionPolicy.RUNTIME)
-public @interface SuggestedRange {
- /**
- * The minimum value that the number can be at, inclusive.
- *
- * @return the minimum value
- */
- double min() default Double.MIN_VALUE;
-
- /**
- * The maximum value that the number can be at, inclusive.
- *
- * @return the maximum value
- */
- double max() default Double.MAX_VALUE;
-}
diff --git a/worldedit-core/src/main/java/com/sk89q/util/ReflectionUtil.java b/worldedit-core/src/main/java/com/sk89q/util/ReflectionUtil.java
index 1cabccdb5..e9f0e3401 100644
--- a/worldedit-core/src/main/java/com/sk89q/util/ReflectionUtil.java
+++ b/worldedit-core/src/main/java/com/sk89q/util/ReflectionUtil.java
@@ -26,6 +26,7 @@ public final class ReflectionUtil {
private ReflectionUtil() {
}
+ @SuppressWarnings("unchecked")
public static T getField(Object from, String name) {
if (from instanceof Class)
return getField((Class) from, null, name);
@@ -34,12 +35,12 @@ public final class ReflectionUtil {
}
@SuppressWarnings("unchecked")
- public static T getField(Class checkClass, Object obj, String name) {
+ public static T getField(Class checkClass, Object from, String name) {
do {
try {
Field field = checkClass.getDeclaredField(name);
field.setAccessible(true);
- return (T) field.get(obj);
+ return (T) field.get(from);
} catch (NoSuchFieldException | IllegalAccessException ignored) {
}
} while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null));
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java
deleted file mode 100644
index e27c6be2a..000000000
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
- * WorldEdit, a Minecraft world manipulation toolkit
- * Copyright (C) sk89q
- * Copyright (C) WorldEdit team and contributors
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package com.sk89q.worldedit;
-
-import com.boydti.fawe.object.schematic.Schematic;
-import com.sk89q.worldedit.command.ClipboardCommands;
-import com.sk89q.worldedit.command.FlattenedClipboardTransform;
-import com.sk89q.worldedit.command.SchematicCommands;
-import com.sk89q.worldedit.extent.Extent;
-import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
-import com.sk89q.worldedit.extent.clipboard.Clipboard;
-import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
-import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
-import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
-import com.sk89q.worldedit.function.operation.Operations;
-import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.math.transform.AffineTransform;
-import com.sk89q.worldedit.regions.CuboidRegion;
-import com.sk89q.worldedit.regions.Region;
-import com.sk89q.worldedit.util.Countable;
-import com.sk89q.worldedit.util.Direction;
-import com.sk89q.worldedit.world.DataException;
-import com.sk89q.worldedit.world.block.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockState;
-import com.sk89q.worldedit.world.block.BlockStateHolder;
-import com.sk89q.worldedit.world.block.BlockTypes;
-import com.sk89q.worldedit.world.registry.LegacyMapper;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * The clipboard remembers the state of a cuboid region.
- *
- * @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 {
-
- /**
- * An enum of possible flip directions.
- */
- public enum FlipDirection {
- NORTH_SOUTH(Direction.NORTH),
- WEST_EAST(Direction.WEST),
- UP_DOWN(Direction.UP),
- ;
- private final Direction direction;
- FlipDirection(Direction direction) {
- this.direction = direction;
- }
- }
-
- private BlockArrayClipboard clipboard;
- private AffineTransform transform;
- public BlockVector3 size;
-
- /**
- * Constructs the clipboard.
- *
- * @param size the dimensions of the clipboard (should be at least 1 on every dimension)
- */
- public CuboidClipboard(BlockVector3 size) {
- checkNotNull(size);
- this.size = size;
- this.clipboard = this.init(BlockVector3.ZERO, BlockVector3.ZERO);
- }
-
- public CuboidClipboard(BlockArrayClipboard clipboard) {
- this.clipboard = clipboard;
- this.size = clipboard.getDimensions();
- }
-
- /**
- * Constructs the clipboard.
- *
- * @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(BlockVector3 size, BlockVector3 origin) {
- checkNotNull(size);
- checkNotNull(origin);
- this.size = size;
- this.clipboard = init(BlockVector3.ZERO, origin);
- }
-
- /**
- * Constructs the clipboard.
- *
- * @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(BlockVector3 size, BlockVector3 origin, BlockVector3 offset) {
- checkNotNull(size);
- checkNotNull(origin);
- checkNotNull(offset);
- this.size = size;
- this.clipboard = this.init(offset, origin);
- }
-
- /* ------------------------------------------------------------------------------------------------------------- */
-
- private BlockArrayClipboard init(BlockVector3 offset, BlockVector3 min) {
- BlockVector3 origin = min.subtract(offset);
- CuboidRegion region = new CuboidRegion(min, min.add(size).subtract(BlockVector3.ONE));
- BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
- clipboard.setOrigin(origin);
- return clipboard;
- }
-
- /* ------------------------------------------------------------------------------------------------------------- */
-
- public BaseBlock getBlock(BlockVector3 position) {
- return getBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ());
- }
-
-
- public BaseBlock getBlock(int x, int y, int z) {
-// return adapt(clipboard.IMP.getBlock(x, y, z));
- return clipboard.IMP.getBlock(x, y, z);
- }
-
- public BaseBlock getLazyBlock(BlockVector3 position) {
- return getBlock(position);
- }
-
- public void setBlock(BlockVector3 location, BaseBlock block) {
- setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
- }
-
- public boolean setBlock(int x, int y, int z, BaseBlock block) {
- return setBlock(x, y, z, block);
- }
-
- public boolean setBlock(int x, int y, int z, BlockState block) {
- return clipboard.IMP.setBlock(x, y, z, block);
- }
-
- /**
- * Get the width (X-direction) of the clipboard.
- *
- * @return width
- */
- public int getWidth() {
- return size.getBlockX();
- }
-
- /**
- * Get the length (Z-direction) of the clipboard.
- *
- * @return length
- */
- public int getLength() {
- return size.getBlockZ();
- }
-
- /**
- * Get the height (Y-direction) of the clipboard.
- *
- * @return height
- */
- public int getHeight() {
- return size.getBlockY();
- }
-
- /**
- * Rotate the clipboard in 2D. It can only rotate by angles divisible by 90.
- *
- * @param angle in degrees
- */
- @SuppressWarnings("deprecation")
- public void rotate2D(int angle) {
- AffineTransform newTransform = new AffineTransform().rotateY(-angle);
- this.transform = transform == null ? newTransform : newTransform.combine(transform);
- }
-
- /**
- * Flip the clipboard.
- *
- * @param dir direction to flip
- */
- public void flip(FlipDirection dir) {
- flip(dir, false);
- }
-
- /**
- * Flip the clipboard.
- *
- * @param dir direction to flip
- * @param aroundPlayer flip the offset around the player
- */
- @SuppressWarnings("deprecation")
- public void flip(FlipDirection dir, boolean aroundPlayer) {
- checkNotNull(dir);
- Direction direction = dir.direction;
- AffineTransform newTransform = new AffineTransform().scale(direction.toVector().abs().multiply(-2).add(1, 1, 1));
- this.transform = transform == null ? newTransform : newTransform.combine(transform);
- }
-
- /**
- * Copies blocks to the clipboard.
- *
- * @param editSession the EditSession from which to take the blocks
- */
- public void copy(EditSession editSession) {
- for (int x = 0; x < size.getBlockX(); ++x) {
- for (int y = 0; y < size.getBlockY(); ++y) {
- for (int z = 0; z < size.getBlockZ(); ++z) {
- setBlock(x, y, z, editSession.getBlock(BlockVector3.at(x, y, z).add(getOrigin())));
- }
- }
- }
- }
-
- /**
- * Copies blocks to the clipboard.
- *
- * @param editSession The EditSession from which to take the blocks
- * @param region A region that further constrains which blocks to take.
- */
- public void copy(EditSession editSession, Region region) {
- for (int x = 0; x < size.getBlockX(); ++x) {
- for (int y = 0; y < size.getBlockY(); ++y) {
- for (int z = 0; z < size.getBlockZ(); ++z) {
- final BlockVector3 pt = BlockVector3.at(x, y, z).add(getOrigin());
- if (region.contains(pt)) {
- setBlock(x, y, z, editSession.getBlock(pt));
- } else {
- setBlock(x, y, z, (BlockState)null);
- }
- }
- }
- }
- }
-
- /**
- * Paste the clipboard at the given location using the given {@code EditSession}.
- *
- *
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.
- *
- * @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, BlockVector3 newOrigin, boolean noAir) throws MaxChangedBlocksException {
- paste(editSession, newOrigin, noAir, false);
- }
-
- /**
- * Paste the clipboard at the given location using the given {@code EditSession}.
- *
- *
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.
- *
- * @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, BlockVector3 newOrigin, boolean noAir, boolean entities) throws MaxChangedBlocksException {
- new Schematic(clipboard).paste(editSession, newOrigin, false, !noAir, entities, transform);
- editSession.flushQueue();
- }
-
- /**
- * Paste the clipboard at the given location using the given {@code EditSession}.
- *
- *
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.
- *
- * @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, BlockVector3 newOrigin, boolean noAir) throws MaxChangedBlocksException {
- paste(editSession, newOrigin, noAir, false);
- }
-
- /**
- * Get the block at the given position.
- *
- *
If the position is out of bounds, air will be returned.
- *
- * @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
- */
- @Deprecated
- public BaseBlock getPoint(BlockVector3 position) throws ArrayIndexOutOfBoundsException {
- final BaseBlock block = getBlock(position);
- if (block == null) {
- return BlockTypes.AIR.getDefaultState().toBaseBlock();
- }
-
- return block;
- }
-
- /**
- * 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 BlockVector3 getOrigin() {
- return clipboard.getMinimumPoint();
- }
-
- /**
- * 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(BlockVector3 origin) {
- checkNotNull(origin);
- setOriginAndOffset(getOffset(), origin);
- }
-
- public void setOriginAndOffset(BlockVector3 offset, BlockVector3 min) {
- BlockVector3 origin = min.subtract(offset);
- CuboidRegion region = new CuboidRegion(min, min.add(size).subtract(BlockVector3.ONE));
- clipboard.setRegion(region);
- clipboard.setOrigin(origin);
- }
-
- /**
- * Get the offset of the player to the clipboard's minimum point
- * (minimum X, Y, Z coordinates).
- *
- *
The offset is inverse (multiplied by -1).
- *
- * @return the offset the offset
- */
- public BlockVector3 getOffset() {
- BlockVector3 min = clipboard.getMinimumPoint();
- BlockVector3 origin = clipboard.getOrigin();
- BlockVector3 offset = min.subtract(origin);
- return offset;
- }
-
- /**
- * Set the offset of the player to the clipboard's minimum point
- * (minimum X, Y, Z coordinates).
- *
- *
The offset is inverse (multiplied by -1).
- *
- * @param offset the new offset
- */
- public void setOffset(BlockVector3 offset) {
- checkNotNull(offset);
- setOriginAndOffset(offset, getOrigin());
- }
-
- /**
- * Get the dimensions of the clipboard.
- *
- * @return the dimensions, where (1, 1, 1) is 1 wide, 1 across, 1 deep
- */
- public BlockVector3 getSize() {
- return size;
- }
-
- /**
- * Saves the clipboard data to a .schematic-format file.
- *
- * @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 ClipboardFormat#SCHEMATIC}
- */
- @Deprecated
- public void saveSchematic(File path) throws IOException, DataException {
- checkNotNull(path);
- if (transform != null && !transform.isIdentity()) {
- final FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform);
- BlockArrayClipboard target = new BlockArrayClipboard(result.getTransformedRegion(), UUID.randomUUID());
- target.setOrigin(clipboard.getOrigin());
- Operations.completeLegacy(result.copyTo(target));
- this.clipboard = target;
- }
- new Schematic(clipboard).save(path, BuiltInClipboardFormat.SPONGE_SCHEMATIC);
- }
-
- /**
- * Load a .schematic file into a clipboard.
- *
- * @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 ClipboardFormat#SCHEMATIC}
- */
- @Deprecated
- public static CuboidClipboard loadSchematic(File path) throws DataException, IOException {
- checkNotNull(path);
- return new CuboidClipboard((BlockVector3) BuiltInClipboardFormat.MCEDIT_SCHEMATIC.load(path).getClipboard());
- }
-
- /**
- * Get the block distribution inside a clipboard.
- *
- * @return a block distribution
- */
- public List> getBlockDistribution() {
- List> distribution = new ArrayList<>();
- List> distr = clipboard.getBlockDistributionWithData(clipboard.getRegion());
- for (Countable item : distr) {
- BlockStateHolder state = item.getID();
- int[] legacyId = LegacyMapper.getInstance().getLegacyFromBlock(state.toImmutableState());
- if (legacyId[0] != 0) distribution.add(new Countable<>(legacyId[0], item.getAmount()));
- }
- return distribution;
- }
-
- /**
- * Get the block distribution inside a clipboard with data values.
- *
- * @return a block distribution
- */
- public List> getBlockDistributionWithData() {
- List> distribution = new ArrayList<>();
- List> distr = clipboard.getBlockDistributionWithData(clipboard.getRegion());
- for (Countable item : distr) {
- distribution.add(new Countable<>(item.getID().toBaseBlock(), item.getAmount()));
- }
- return distribution;
- }
-}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java
index c0776f995..1f65c6a19 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java
@@ -21,14 +21,11 @@ package com.sk89q.worldedit.blocks;
import com.google.common.collect.Maps;
import com.sk89q.worldedit.registry.state.Property;
-import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import java.util.Collection;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
/**
* Block-related utility methods.
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java
index c4921a110..74dd69885 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java
@@ -23,10 +23,12 @@ import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Commands;
import com.boydti.fawe.object.visitor.Fast2DIterator;
import com.boydti.fawe.util.chat.Message;
+
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.REGION;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
@@ -62,8 +64,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
-
/**
* Implements biome-related commands such as "/biomelist".
*/
@@ -84,10 +84,10 @@ public class BiomeCommands extends MethodCommands {
}
@Command(
- aliases = {"biomelist", "biomels"},
- usage = "[page]",
- desc = "Gets all biomes available.",
- max = 1
+ aliases = { "biomelist", "biomels" },
+ usage = "[page]",
+ desc = "Gets all biomes available.",
+ max = 1
)
@CommandPermissions("worldedit.biome.list")
public void biomeList(Player player, CommandContext args) throws WorldEditException {
@@ -127,15 +127,15 @@ public class BiomeCommands extends MethodCommands {
}
@Command(
- aliases = {"biomeinfo"},
- flags = "pt",
- desc = "Get the biome of the targeted block.",
- help =
- "Get the biome of the block.\n" +
- "By default use all the blocks contained in your selection.\n" +
- "-t use the block you are looking at.\n" +
- "-p use the block you are currently in",
- max = 0
+ aliases = { "biomeinfo" },
+ flags = "pt",
+ desc = "Get the biome of the targeted block.",
+ help =
+ "Get the biome of the block.\n" +
+ "By default use all the blocks contained in your selection.\n" +
+ "-t use the block you are looking at.\n" +
+ "-p use the block you are currently in",
+ max = 0
)
@CommandPermissions("worldedit.biome.info")
public void biomeInfo(Player player, LocalSession session, final EditSession editSession, CommandContext args) throws WorldEditException {
@@ -192,24 +192,33 @@ public class BiomeCommands extends MethodCommands {
Collections.sort(distribution);
for (Countable c : distribution) {
BiomeData data = biomeRegistry.getData(c.getID());
- String str = String.format("%-7s (%.3f%%) %s #%d",
- String.valueOf(c.getAmount()),
- c.getAmount() / (double) size * 100,
- data == null ? "Unknown" : data.getName(),
- c.getID().getInternalId());
+ String str;
+ if (data == null) {
+ str = String.format("%-7s (%.3f%%) %s #%d",
+ String.valueOf(c.getAmount()),
+ c.getAmount() / (double) size * 100,
+ "Unknown",
+ c.getID().getInternalId());
+ } else {
+ str = String.format("%-7s (%.3f%%) %s #%d",
+ String.valueOf(c.getAmount()),
+ c.getAmount() / (double) size * 100,
+ data.getName(),
+ c.getID().getInternalId());
+ }
player.print(str);
}
}
@Command(
- aliases = {"/setbiome"},
+ aliases = { "/setbiome" },
usage = "",
flags = "p",
desc = "Sets the biome of the player's current block or region.",
help =
"Set the biome of the region.\n" +
- "By default use all the blocks contained in your selection.\n" +
- "-p use the block you are currently in"
+ "By default use all the blocks contained in your selection.\n" +
+ "-p use the block you are currently in"
)
@Logging(REGION)
@CommandPermissions("worldedit.biome.set")
@@ -220,7 +229,7 @@ public class BiomeCommands extends MethodCommands {
Mask2D mask2d = mask != null ? mask.toMask2D() : null;
if (atPosition) {
- region = new CuboidRegion(player.getLocation().toBlockPoint(), player.getLocation().toBlockPoint());
+ region = new CuboidRegion(player.getLocation().toVector().toBlockPoint(), player.getLocation().toVector().toBlockPoint());
} else {
region = session.getSelection(world);
}
@@ -236,4 +245,5 @@ public class BiomeCommands extends MethodCommands {
if (!player.hasPermission("fawe.tips"))
BBC.TIP_BIOME_PATTERN.or(BBC.TIP_BIOME_MASK).send(player);
}
+
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/SelectionCommand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/SelectionCommand.java
index abc20a451..77c94a3d6 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/SelectionCommand.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/SelectionCommand.java
@@ -183,6 +183,4 @@ public class SelectionCommand extends SimpleCommand {
return locals.get(Actor.class).hasPermission(permission);
}
-
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ShapedBrushCommand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ShapedBrushCommand.java
index 3de5dc6ed..98daedde2 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ShapedBrushCommand.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ShapedBrushCommand.java
@@ -19,8 +19,6 @@
package com.sk89q.worldedit.command.composition;
-import com.boydti.fawe.config.BBC;
-
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.minecraft.util.commands.CommandException;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java
index b6d7c7838..5e644fd86 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java
@@ -1,15 +1,32 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
+import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
-import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.util.Location;
-import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
@@ -30,11 +47,11 @@ public class AreaPickaxe implements BlockTool {
}
@Override
- public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
+ public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
int ox = clicked.getBlockX();
int oy = clicked.getBlockY();
int oz = clicked.getBlockZ();
- BlockType initialType = clicked.getExtent().getBlock(clicked.toBlockPoint()).getBlockType();
+ BlockType initialType = clicked.getExtent().getBlock(clicked.toVector().toBlockPoint()).getBlockType();
if (initialType.getMaterial().isAir()) {
return true;
@@ -45,23 +62,29 @@ public class AreaPickaxe implements BlockTool {
}
try (EditSession editSession = session.createEditSession(player)) {
+ editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
+
try {
- editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
for (int x = ox - range; x <= ox + range; ++x) {
for (int z = oz - range; z <= oz + range; ++z) {
for (int y = oy + range; y >= oy - range; --y) {
- if (initialType.equals(editSession.getLazyBlock(x, y, z))) {
+ BlockVector3 pos = BlockVector3.at(x, y, z);
+ if (editSession.getLazyBlock(pos).getBlockType() != initialType) {
continue;
}
- editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());
+ editSession.setBlock(pos, BlockTypes.AIR.getDefaultState());
}
}
}
editSession.flushQueue();
+ } catch (MaxChangedBlocksException e) {
+ player.printError("Max blocks change limit reached.");
} finally {
session.remember(editSession);
}
}
+
return true;
}
+
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java
index d4405fe55..5f87f9097 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java
@@ -56,8 +56,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
World world = (World) clicked.getExtent();
-// BlockStateHolder block = world.getBlock(clicked);
- BlockVector3 blockPoint = clicked.toBlockPoint();
+ BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
BlockState block = world.getBlock(blockPoint);
if (!config.allowedDataCycleBlocks.isEmpty()
@@ -68,42 +67,43 @@ public class BlockDataCyler implements DoubleActionBlockTool {
}
if (block.getStates().keySet().isEmpty()) {
- BBC.BLOCK_CYCLER_CANNOT_CYCLE.send(player);
+ BBC.BLOCK_CYCLER_CANNOT_CYCLE.send(player);
} else {
- Property> currentProperty = selectedProperties.get(player.getUniqueId());
+ Property> currentProperty = selectedProperties.get(player.getUniqueId());
- if (currentProperty == null || (forward && block.getState(currentProperty) == null)) {
- currentProperty = block.getStates().keySet().stream().findFirst().get();
- selectedProperties.put(player.getUniqueId(), currentProperty);
- }
+ if (currentProperty == null || (forward && block.getState(currentProperty) == null)) {
+ currentProperty = block.getStates().keySet().stream().findFirst().get();
+ selectedProperties.put(player.getUniqueId(), currentProperty);
+ }
- if (forward) {
- block.getState(currentProperty);
- int index = currentProperty.getValues().indexOf(block.getState(currentProperty));
- index = (index + 1) % currentProperty.getValues().size();
- @SuppressWarnings("unchecked")
- Property
*/
public class BlockTypeMask extends AbstractExtentMask {
+
private final boolean[] types;
- protected BlockTypeMask(Extent extent, boolean[] types) {
- super(extent);
- this.types = types;
- }
-
- public BlockTypeMask(Extent extent, BlockType... types) {
- super(extent);
- this.types = new boolean[BlockTypes.size()];
- for (BlockType type : types) this.types[type.getInternalId()] = true;
- }
-
/**
* Create a new block mask.
*
@@ -59,7 +50,24 @@ public class BlockTypeMask extends AbstractExtentMask {
* @param blocks a list of blocks to match
*/
public BlockTypeMask(Extent extent, Collection blocks) {
- this(extent, blocks.toArray(new BlockType[blocks.size()]));
+ this(extent, blocks.toArray(new BlockType[0]));
+ }
+
+ /**
+ * Create a new block mask.
+ *
+ * @param extent the extent
+ * @param block an array of blocks to match
+ */
+ public BlockTypeMask(Extent extent, BlockType... block) {
+ super(extent);
+ this.types = new boolean[BlockTypes.size()];
+ for (BlockType type : block) this.types[type.getInternalId()] = true;
+ }
+
+ protected BlockTypeMask(Extent extent, boolean[] types) {
+ super(extent);
+ this.types = types;
}
/**
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java
index 38b3783b1..1283b0bb2 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java
@@ -25,9 +25,6 @@ import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.sk89q.worldedit.function.mask.Masks.negate;
-
/**
* Tests whether a given vector meets a criteria.
*/
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java
index c1e1f0623..051f904f8 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java
@@ -104,7 +104,8 @@ public class MaskIntersection extends AbstractMask {
Set optimized = new HashSet<>();
Set> failedCombines = new HashSet<>();
// Combine the masks
- while (combine(pairingFunction(), failedCombines));
+ while (combine(pairingFunction(), failedCombines)) {
+ }
// Optimize / combine
do optimizeMasks(optimized);
while (combine(pairingFunction(), failedCombines));
@@ -122,7 +123,7 @@ public class MaskIntersection extends AbstractMask {
outer:
for (Mask mask : masks) {
for (Mask other : masks) {
- AbstractMap.SimpleEntry pair = new AbstractMap.SimpleEntry(mask, other);
+ AbstractMap.SimpleEntry pair = new AbstractMap.SimpleEntry<>(mask, other);
if (failedCombines.contains(pair)) continue;
Mask combined = pairing.apply(pair);
if (combined != null) {
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java
index eace7259c..3023c62ce 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java
@@ -16,6 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
+
package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java
index e8514dafc..ea5fd15b3 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java
@@ -2,7 +2,6 @@ package com.sk89q.worldedit.function.mask;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
public class SingleBlockStateMask extends AbstractExtentMask {
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java
index 2f26b1aed..a16c0109a 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java
@@ -2,7 +2,6 @@ package com.sk89q.worldedit.function.mask;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java
index 464c892ba..28bd3a04a 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java
@@ -1,29 +1,25 @@
package com.sk89q.worldedit.function.operation;
import com.sk89q.worldedit.WorldEditException;
-import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
+
import java.util.List;
public class BackwardsExtentBlockCopy implements Operation {
private final Region region;
private final Transform transform;
- private final Extent destination;
- private final Extent source;
private final RegionFunction function;
private final BlockVector3 origin;
// private Vector mutable = new MutableBlockVector3();
- public BackwardsExtentBlockCopy(Extent source, Region region, Extent destination, BlockVector3 origin, Transform transform, RegionFunction function) {
- this.source = source;
+ BackwardsExtentBlockCopy(Region region, BlockVector3 origin, Transform transform, RegionFunction function) {
this.region = region;
- this.destination = destination;
this.transform = transform;
this.function = function;
this.origin = origin;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java
index 5f62a6f8d..8836187b6 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java
@@ -299,7 +299,7 @@ public class ForwardExtentCopy implements Operation {
if (copyBiomes && (!(source instanceof BlockArrayClipboard) || ((BlockArrayClipboard) source).IMP.hasBiomes())) {
copy = CombinedRegionFunction.combine(copy, new BiomeCopy(source, finalDest));
}
- blockCopy = new BackwardsExtentBlockCopy(transExt, region, finalDest, from, transform, copy);
+ blockCopy = new BackwardsExtentBlockCopy(region, from, transform, copy);
} else {
transExt = new PositionTransformExtent(finalDest, currentTransform);
transExt.setOrigin(from);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java
index 8a797f5cd..8edd7942c 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java
@@ -4,11 +4,9 @@ import com.sk89q.minecraft.util.commands.Link;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.UtilityCommands;
import com.sk89q.worldedit.extent.Extent;
-import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockState;
+import com.sk89q.worldedit.world.block.BlockStateHolder;
/**
* Returns a {@link BlockStateHolder} for a given position.
@@ -29,4 +27,4 @@ public interface FawePattern extends Pattern {
*/
@Override
boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException;
-}
\ No newline at end of file
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java
index d20eb733d..e20007841 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java
@@ -20,8 +20,7 @@
package com.sk89q.worldedit.function.visitor;
import com.boydti.fawe.object.HasFaweQueue;
-import com.sk89q.worldedit.function.RegionFunction;
-import com.sk89q.worldedit.function.mask.Mask;
+
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.function.RegionFunction;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityCreate.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityCreate.java
index 8aeecfbeb..583887f19 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityCreate.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityCreate.java
@@ -19,14 +19,14 @@
package com.sk89q.worldedit.history.change;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.history.UndoContext;
import com.sk89q.worldedit.util.Location;
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* Logs the creation of an entity and removes the entity upon undo.
*/
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityRemove.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityRemove.java
index 08b1ea21c..076023794 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityRemove.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityRemove.java
@@ -19,14 +19,14 @@
package com.sk89q.worldedit.history.change;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.history.UndoContext;
import com.sk89q.worldedit.util.Location;
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* Tracks the removal of an entity.
*/
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ArrayListHistory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ArrayListHistory.java
index ec06c27b5..d014835d3 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ArrayListHistory.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ArrayListHistory.java
@@ -70,4 +70,4 @@ public class ArrayListHistory implements ChangeSet {
return changes.size();
}
-}
\ No newline at end of file
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ChangeSet.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ChangeSet.java
index 24c4c3fe0..003a007b6 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ChangeSet.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ChangeSet.java
@@ -77,4 +77,4 @@ public interface ChangeSet {
*/
int size();
-}
\ No newline at end of file
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java
index ed65dc8fb..63945769e 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java
@@ -70,7 +70,7 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv
Logging loggingAnnotation = method.getAnnotation(Logging.class);
Logging.LogMode logMode;
StringBuilder builder = new StringBuilder();
-
+
if (loggingAnnotation == null) {
logMode = null;
} else {
@@ -96,15 +96,15 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv
}
builder.append(": ").append(context.getCommand());
-
+
if (context.argsLength() > 0) {
builder.append(" ").append(context.getJoinedStrings(0));
}
-
+
if (logMode != null && sender.isPlayer()) {
- Vector3 position = player.getLocation();
+ Vector3 position = player.getLocation().toVector();
LocalSession session = worldEdit.getSessionManager().get(player);
-
+
switch (logMode) {
case PLACEMENT:
try {
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java
index 061bfab72..2656039ce 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java
@@ -20,6 +20,7 @@
package com.sk89q.worldedit.internal.command;
import com.boydti.fawe.util.MathMan;
+
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
@@ -36,14 +37,12 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask;
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.math.BlockVector3;
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.ArgumentStack;
import com.sk89q.worldedit.util.command.parametric.BindingBehavior;
-import com.sk89q.worldedit.util.command.parametric.BindingHelper;
import com.sk89q.worldedit.util.command.parametric.BindingMatch;
import com.sk89q.worldedit.util.command.parametric.ParameterException;
import com.sk89q.worldedit.world.World;
@@ -99,7 +98,7 @@ public class WorldEditBinding {
* @throws ParameterException on other error
*/
@BindingMatch(type = EditSession.class,
- behavior = BindingBehavior.PROVIDES)
+ behavior = BindingBehavior.PROVIDES)
public EditSession getEditSession(ArgumentStack context) throws ParameterException {
Player sender = getPlayer(context);
LocalSession session = worldEdit.getSessionManager().get(sender);
@@ -118,7 +117,7 @@ public class WorldEditBinding {
* @throws ParameterException on error
*/
@BindingMatch(type = LocalSession.class,
- behavior = BindingBehavior.PROVIDES)
+ behavior = BindingBehavior.PROVIDES)
public LocalSession getLocalSession(ArgumentStack context) throws ParameterException {
Player sender = getPlayer(context);
return worldEdit.getSessionManager().get(sender);
@@ -150,7 +149,7 @@ public class WorldEditBinding {
* @throws ParameterException on error
*/
@BindingMatch(type = Player.class,
- behavior = BindingBehavior.PROVIDES)
+ behavior = BindingBehavior.PROVIDES)
public Player getPlayer(ArgumentStack context) throws ParameterException {
Actor sender = context.getContext().getLocals().get(Actor.class);
if (sender == null) {
@@ -166,7 +165,7 @@ public class WorldEditBinding {
* Gets an {@link BaseBlock} from a {@link ArgumentStack}.
*
* @param context the context
- * @return a block state
+ * @return a pattern
* @throws ParameterException on error
* @throws WorldEditException on error
*/
@@ -200,8 +199,8 @@ public class WorldEditBinding {
}
@BindingMatch(type = {BaseBlock.class, BlockState.class, BlockStateHolder.class},
- behavior = BindingBehavior.CONSUMES,
- consumedCount = 1)
+ behavior = BindingBehavior.CONSUMES,
+ consumedCount = 1)
public BaseBlock getBaseBlock(ArgumentStack context) throws ParameterException, WorldEditException {
return getBlockState(context).toBaseBlock();
}
@@ -244,8 +243,8 @@ public class WorldEditBinding {
* @throws WorldEditException on error
*/
@BindingMatch(type = Pattern.class,
- behavior = BindingBehavior.CONSUMES,
- consumedCount = 1)
+ behavior = BindingBehavior.CONSUMES,
+ consumedCount = 1)
public Pattern getPattern(ArgumentStack context) throws ParameterException, WorldEditException {
Actor actor = context.getContext().getLocals().get(Actor.class);
ParserContext parserContext = new ParserContext();
@@ -273,8 +272,8 @@ public class WorldEditBinding {
* @throws WorldEditException on error
*/
@BindingMatch(type = Mask.class,
- behavior = BindingBehavior.CONSUMES,
- consumedCount = 1)
+ behavior = BindingBehavior.CONSUMES,
+ consumedCount = 1)
public Mask getMask(ArgumentStack context) throws ParameterException, WorldEditException {
Actor actor = context.getContext().getLocals().get(Actor.class);
ParserContext parserContext = new ParserContext();
@@ -377,6 +376,4 @@ public class WorldEditBinding {
}
}
-
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java
index 3237eb686..85b401c09 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java
@@ -45,22 +45,22 @@ import java.util.concurrent.TimeoutException;
/**
* Compiles and evaluates expressions.
- *
Supported functions: abs, acos, asin, atan, atan2, cbrt, ceil, cos, cosh,
* exp, floor, ln, log, log10, max, max, min, min, rint, round, sin, sinh,
* sqrt, tan, tanh and more. (See the Functions class or the wiki)
- *
+ *
*
Constants: e, pi
- *
+ *
*
To compile an equation, run
* {@code Expression.compile("expression here", "var1", "var2"...)}.
* If you wish to run the equation multiple times, you can then optimize it,
@@ -70,7 +70,7 @@ import java.util.concurrent.TimeoutException;
* To query variables after evaluation, you can use
* {@link #getVariable(String, boolean)}. To get a value out of these, use
* {@link Variable#getValue()}.
- *
+ *
*
Variables are also supported and can be set either by passing values
* to {@link #evaluate(double...)}.
*/
@@ -146,6 +146,7 @@ public class Expression {
((Variable) invokable).value = values[i];
}
+
try {
if (timeout < 0) {
return evaluateRoot();
@@ -236,6 +237,4 @@ public class Expression {
this.environment = environment;
}
-
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/For.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/For.java
index e660daacd..6334a7350 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/For.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/For.java
@@ -1,9 +1,32 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
package com.sk89q.worldedit.internal.expression.runtime;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.parser.ParserException;
+/**
+ * A Java/C-style for loop.
+ */
public class For extends Node {
+
RValue init;
RValue condition;
RValue increment;
@@ -11,34 +34,35 @@ public class For extends Node {
public For(int position, RValue init, RValue condition, RValue increment, RValue body) {
super(position);
+
this.init = init;
this.condition = condition;
this.increment = increment;
this.body = body;
}
+ @Override
public double getValue() throws EvaluationException {
-
int iterations = 0;
- double ret = 0.0D;
- this.init.getValue();
+ double ret = 0.0;
- for(; this.condition.getValue() > 0.0D; this.increment.getValue()) {
-
- if(iterations > 256) {
- throw new EvaluationException(this.getPosition(), "Loop exceeded 256 iterations.");
+ for (init.getValue(); condition.getValue() > 0; increment.getValue()) {
+ if (iterations > 256) {
+ throw new EvaluationException(getPosition(), "Loop exceeded 256 iterations.");
}
-
- if(Thread.interrupted()){
- throw new EvaluationException(this.getPosition(), "Thread has been interrupted.");
+ if (Thread.interrupted()) {
+ throw new EvaluationException(getPosition(), "Calculations exceeded time limit.");
}
++iterations;
try {
- ret = this.body.getValue();
- } catch (BreakException var5) {
- if(!var5.doContinue) {
- return ret;
+ ret = body.getValue();
+ } catch (BreakException e) {
+ if (e.doContinue) {
+ //noinspection UnnecessaryContinue
+ continue;
+ } else {
+ break;
}
}
}
@@ -46,30 +70,38 @@ public class For extends Node {
return ret;
}
+ @Override
public char id() {
return 'F';
}
+ @Override
public String toString() {
- return "for (" + this.init + "; " + this.condition + "; " + this.increment + ") { " + this.body + " }";
+ return "for (" + init + "; " + condition + "; " + increment + ") { " + body + " }";
}
+ @Override
public RValue optimize() throws EvaluationException {
final RValue newCondition = condition.optimize();
+
if (newCondition instanceof Constant && newCondition.getValue() <= 0) {
// If the condition is always false, the loop can be flattened.
// So we run the init part and then return 0.0.
return new Sequence(getPosition(), init, new Constant(getPosition(), 0.0)).optimize();
}
+
+ //return new Sequence(getPosition(), init.optimize(), new While(getPosition(), condition, new Sequence(getPosition(), body, increment), false)).optimize();
return new For(getPosition(), init.optimize(), newCondition, increment.optimize(), body.optimize());
}
+ @Override
public RValue bindVariables(Expression expression, boolean preferLValue) throws ParserException {
- this.init = this.init.bindVariables(expression, false);
- this.condition = this.condition.bindVariables(expression, false);
- this.increment = this.increment.bindVariables(expression, false);
- this.body = this.body.bindVariables(expression, false);
+ init = init.bindVariables(expression, false);
+ condition = condition.bindVariables(expression, false);
+ increment = increment.bindVariables(expression, false);
+ body = body.bindVariables(expression, false);
+
return this;
}
-}
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Function.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Function.java
index f2d9090e0..f94eba3cd 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Function.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Function.java
@@ -21,6 +21,7 @@ package com.sk89q.worldedit.internal.expression.runtime;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.parser.ParserException;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.InvocationTargetException;
@@ -36,8 +37,7 @@ public class Function extends Node {
* for the same inputs and on functions with side-effects.
*/
@Retention(RetentionPolicy.RUNTIME)
- public @interface Dynamic {
- }
+ public @interface Dynamic { }
public final Method method;
public final RValue[] args;
@@ -121,5 +121,4 @@ public class Function extends Node {
return this;
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java
index 088cef4c2..d2aede416 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java
@@ -19,14 +19,13 @@
package com.sk89q.worldedit.internal.expression.runtime;
-
-import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.runtime.Function.Dynamic;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.noise.PerlinNoise;
import com.sk89q.worldedit.math.noise.RidgedMultiFractalNoise;
import com.sk89q.worldedit.math.noise.VoronoiNoise;
+
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
@@ -125,13 +124,11 @@ public final class Functions {
}
private static final Map> functions = new HashMap<>();
-
static {
for (Method method : Functions.class.getMethods()) {
try {
addFunction(method);
- } catch (IllegalArgumentException ignored) {
- }
+ } catch (IllegalArgumentException ignored) { }
}
}
@@ -141,10 +138,7 @@ public final class Functions {
Overload overload = new Overload(method);
- List overloads = functions.get(methodName);
- if (overloads == null) {
- functions.put(methodName, overloads = new ArrayList<>());
- }
+ List overloads = functions.computeIfAbsent(methodName, k -> new ArrayList<>());
overloads.add(overload);
}
@@ -256,6 +250,7 @@ public final class Functions {
return Math.log10(x.getValue());
}
+
public static double rotate(LValue x, LValue y, RValue angle) throws EvaluationException {
final double f = angle.getValue();
@@ -327,26 +322,26 @@ public final class Functions {
@Dynamic
public static double closest(RValue x, RValue y, RValue z, RValue index, RValue count, RValue stride) throws EvaluationException {
return findClosest(
- Expression.getInstance().getFunctions().megabuf,
- x.getValue(),
- y.getValue(),
- z.getValue(),
- (int) index.getValue(),
- (int) count.getValue(),
- (int) stride.getValue()
+ Expression.getInstance().getFunctions().megabuf,
+ x.getValue(),
+ y.getValue(),
+ z.getValue(),
+ (int) index.getValue(),
+ (int) count.getValue(),
+ (int) stride.getValue()
);
}
@Dynamic
public static double gclosest(RValue x, RValue y, RValue z, RValue index, RValue count, RValue stride) throws EvaluationException {
return findClosest(
- gmegabuf,
- x.getValue(),
- y.getValue(),
- z.getValue(),
- (int) index.getValue(),
- (int) count.getValue(),
- (int) stride.getValue()
+ gmegabuf,
+ x.getValue(),
+ y.getValue(),
+ z.getValue(),
+ (int) index.getValue(),
+ (int) count.getValue(),
+ (int) stride.getValue()
);
}
@@ -355,11 +350,11 @@ public final class Functions {
double minDistanceSquared = Double.MAX_VALUE;
for (int i = 0; i < count; ++i) {
- double currentX = getBufferItem(megabuf, index + 0) - x;
- double currentY = getBufferItem(megabuf, index + 1) - y;
- double currentZ = getBufferItem(megabuf, index + 2) - z;
+ double currentX = getBufferItem(megabuf, index+0) - x;
+ double currentY = getBufferItem(megabuf, index+1) - y;
+ double currentZ = getBufferItem(megabuf, index+2) - z;
- double currentDistanceSquared = currentX * currentX + currentY * currentY + currentZ * currentZ;
+ double currentDistanceSquared = currentX*currentX + currentY*currentY + currentZ*currentZ;
if (currentDistanceSquared < minDistanceSquared) {
minDistanceSquared = currentDistanceSquared;
@@ -489,5 +484,4 @@ public final class Functions {
return queryInternal(type, data, typeId, dataValue);
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java
index c96a1d183..575bb9550 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java
@@ -19,7 +19,6 @@
package com.sk89q.worldedit.internal.registry;
-import com.google.common.collect.Lists;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java
index f0f7b67fb..3a2e3af39 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java
@@ -117,34 +117,4 @@ public final class MathUtils {
public static double roundHalfUp(double value) {
return Math.signum(value) * Math.round(Math.abs(value));
}
-
- /**
- * Returns the midpoint Vector3 of the two given Vector3's.
- *
- * @param first Vector3
- * @param second Vector3
- * @return midpoint Vector3
- */
- public static Vector3 midpoint(Vector3 v1, Vector3 v2) {
- return Vector3.at(
- (v1.getX() + v2.getX()) / 2,
- (v1.getY() + v2.getY()) / 2,
- (v1.getZ() + v2.getZ()) / 2
- );
- }
-
- /**
- * Returns the midpoint BlockVector3 of the two given BlockVector3's.
- *
- * @param first BlockVector3
- * @param second BlockVector3
- * @return midpoint BlockVector3
- */
- public static BlockVector3 midpoint(BlockVector3 v1, BlockVector3 v2) {
- return BlockVector3.at(
- (v1.getBlockX() + v2.getBlockX()) / 2,
- (v1.getBlockY() + v2.getBlockY()) / 2,
- (v1.getBlockZ() + v2.getBlockZ()) / 2
- );
- }
-}
\ No newline at end of file
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2.java
index 13bcb5cd4..bc71607c2 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2.java
@@ -2,12 +2,7 @@ package com.sk89q.worldedit.math;
public class MutableBlockVector2 extends BlockVector2 {
- private static ThreadLocal MUTABLE_CACHE = new ThreadLocal() {
- @Override
- protected MutableBlockVector2 initialValue() {
- return new MutableBlockVector2();
- }
- };
+ private static ThreadLocal MUTABLE_CACHE = ThreadLocal.withInitial(() -> new MutableBlockVector2());
public static MutableBlockVector2 get(int x, int z) {
return MUTABLE_CACHE.get().setComponents(x, z);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java
index 89ee154f5..88eb28a71 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java
@@ -2,12 +2,7 @@ package com.sk89q.worldedit.math;
public class MutableBlockVector3 extends BlockVector3 {
- private static ThreadLocal MUTABLE_CACHE = new ThreadLocal() {
- @Override
- protected MutableBlockVector3 initialValue() {
- return new MutableBlockVector3();
- }
- };
+ private static ThreadLocal MUTABLE_CACHE = ThreadLocal.withInitial(() -> new MutableBlockVector3());
public static MutableBlockVector3 get(int x, int y, int z) {
return MUTABLE_CACHE.get().setComponents(x, y, z);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java
index e1810a4b6..27edc3437 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java
@@ -1,7 +1,5 @@
package com.sk89q.worldedit.math;
-import javax.annotation.Nullable;
-
public class MutableVector3 extends Vector3 {
public MutableVector3() {}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java
index d6ace915e..83399b20a 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java
@@ -20,6 +20,8 @@
package com.sk89q.worldedit.math.convolution;
import com.boydti.fawe.object.visitor.Fast2DIterator;
+
+import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.mask.Mask;
@@ -34,8 +36,6 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Iterator;
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* Allows applications of Kernels onto the region's height map.
*
@@ -167,7 +167,6 @@ public class HeightMap {
BlockVector3 minY = region.getMinimumPoint();
int originX = minY.getBlockX();
- int originY = minY.getBlockY();
int originZ = minY.getBlockZ();
int maxY = region.getMaximumPoint().getBlockY();
@@ -177,10 +176,10 @@ public class HeightMap {
BlockStateHolder tmpBlock = BlockTypes.AIR.getDefaultState();
- // Apply heightmap
int maxY4 = maxY << 4;
int index = 0;
+ // Apply heightmap
for (int z = 0; z < height; ++z) {
int zr = z + originZ;
for (int x = 0; x < width; ++x) {
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java
index b5447ed5e..772e18616 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java
@@ -22,21 +22,17 @@
package com.sk89q.worldedit.math.interpolation;
import static com.google.common.base.Preconditions.checkNotNull;
-
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.math.Vector3;
import java.util.Collections;
import java.util.List;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* A Kochanek-Bartels interpolation; continuous in the 2nd derivative.
- *
- *
Supports {@link Node#tension tension}, {@link Node#bias bias} and
- * {@link Node#continuity continuity} parameters per {@link Node}.
+ *
+ *
Supports Node#tension tension, Node#bias bias and
+ * Node#continuity continuity parameters per {@link Node}.
*/
public class KochanekBartelsInterpolation implements Interpolation {
@@ -48,7 +44,7 @@ public class KochanekBartelsInterpolation implements Interpolation {
private double scaling;
public KochanekBartelsInterpolation() {
- setNodes(Collections.emptyList());
+ setNodes(Collections.emptyList());
}
@Override
@@ -86,14 +82,14 @@ public class KochanekBartelsInterpolation implements Interpolation {
}
// Kochanek-Bartels tangent coefficients
- final double ta = (1 - tensionA) * (1 + biasA) * (1 + continuityA) / 2; // Factor for lhs of d[i]
- final double tb = (1 - tensionA) * (1 - biasA) * (1 - continuityA) / 2; // Factor for rhs of d[i]
- final double tc = (1 - tensionB) * (1 + biasB) * (1 - continuityB) / 2; // Factor for lhs of d[i+1]
- final double td = (1 - tensionB) * (1 - biasB) * (1 + continuityB) / 2; // Factor for rhs of d[i+1]
+ final double ta = (1-tensionA)*(1+biasA)*(1+continuityA)/2; // Factor for lhs of d[i]
+ final double tb = (1-tensionA)*(1-biasA)*(1-continuityA)/2; // Factor for rhs of d[i]
+ final double tc = (1-tensionB)*(1+biasB)*(1-continuityB)/2; // Factor for lhs of d[i+1]
+ final double td = (1-tensionB)*(1-biasB)*(1+continuityB)/2; // Factor for rhs of d[i+1]
- coeffA[i] = linearCombination(i, -ta, ta - tb - tc + 2, tb + tc - td - 2, td);
- coeffB[i] = linearCombination(i, 2 * ta, -2 * ta + 2 * tb + tc - 3, -2 * tb - tc + td + 3, -td);
- coeffC[i] = linearCombination(i, -ta, ta - tb, tb, 0);
+ coeffA[i] = linearCombination(i, -ta, ta- tb-tc+2, tb+tc-td-2, td);
+ coeffB[i] = linearCombination(i, 2*ta, -2*ta+2*tb+tc-3, -2*tb-tc+td+3, -td);
+ coeffC[i] = linearCombination(i, -ta, ta- tb , tb , 0);
//coeffD[i] = linearCombination(i, 0, 1, 0, 0);
coeffD[i] = retrieve(i); // this is an optimization
}
@@ -105,10 +101,10 @@ public class KochanekBartelsInterpolation implements Interpolation {
* Returns the linear combination of the given coefficients with the nodes adjacent to baseIndex.
*
* @param baseIndex node index
- * @param f1 coefficient for baseIndex-1
- * @param f2 coefficient for baseIndex
- * @param f3 coefficient for baseIndex+1
- * @param f4 coefficient for baseIndex+2
+ * @param f1 coefficient for baseIndex-1
+ * @param f2 coefficient for baseIndex
+ * @param f3 coefficient for baseIndex+1
+ * @param f4 coefficient for baseIndex+2
* @return linear combination of nodes[n-1..n+2] with f1..4
*/
private Vector3 linearCombination(int baseIndex, double f1, double f2, double f3, double f4) {
@@ -116,6 +112,7 @@ public class KochanekBartelsInterpolation implements Interpolation {
final Vector3 r2 = retrieve(baseIndex ).multiply(f2);
final Vector3 r3 = retrieve(baseIndex + 1).multiply(f3);
final Vector3 r4 = retrieve(baseIndex + 2).multiply(f4);
+
return r1.add(r2).add(r3).add(r4);
}
@@ -130,7 +127,7 @@ public class KochanekBartelsInterpolation implements Interpolation {
return fastRetrieve(0);
if (index >= nodes.size())
- return fastRetrieve(nodes.size() - 1);
+ return fastRetrieve(nodes.size()-1);
return fastRetrieve(index);
}
@@ -184,7 +181,7 @@ public class KochanekBartelsInterpolation implements Interpolation {
final Vector3 b = coeffB[index];
final Vector3 c = coeffC[index];
- return a.multiply(1.5 * position - 3.0 * index).add(b).multiply(2.0 * position).add(a.multiply(1.5 * index).subtract(b).multiply(2.0 * index)).add(c).multiply(scaling);
+ return a.multiply(1.5*position - 3.0*index).add(b).multiply(2.0*position).add(a.multiply(1.5*index).subtract(b).multiply(2.0*index)).add(c).multiply(scaling);
}
@Override
@@ -212,19 +209,19 @@ public class KochanekBartelsInterpolation implements Interpolation {
*/
private double arcLengthRecursive(int indexLeft, double remainderLeft, int indexRight, double remainderRight) {
switch (indexRight - indexLeft) {
- case 0:
- return arcLengthRecursive(indexLeft, remainderLeft, remainderRight);
+ case 0:
+ return arcLengthRecursive(indexLeft, remainderLeft, remainderRight);
- case 1:
- // This case is merely a speed-up for a very common case
- return
- arcLengthRecursive(indexLeft, remainderLeft, 1.0) +
- arcLengthRecursive(indexRight, 0.0, remainderRight);
+ case 1:
+ // This case is merely a speed-up for a very common case
+ return
+ arcLengthRecursive(indexLeft, remainderLeft, 1.0) +
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
- default:
- return
- arcLengthRecursive(indexLeft, remainderLeft, indexRight - 1, 1.0) +
- arcLengthRecursive(indexRight, 0.0, remainderRight);
+ default:
+ return
+ arcLengthRecursive(indexLeft, remainderLeft, indexRight - 1, 1.0) +
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
}
}
@@ -236,9 +233,9 @@ public class KochanekBartelsInterpolation implements Interpolation {
final int nPoints = 8;
double accum = a.multiply(remainderLeft).add(b).multiply(remainderLeft).add(c).length() / 2.0;
- for (int i = 1; i < nPoints - 1; ++i) {
+ for (int i = 1; i < nPoints-1; ++i) {
double t = ((double) i) / nPoints;
- t = (remainderRight - remainderLeft) * t + remainderLeft;
+ t = (remainderRight-remainderLeft)*t + remainderLeft;
accum += a.multiply(t).add(b).multiply(t).add(c).length();
}
@@ -259,5 +256,4 @@ public class KochanekBartelsInterpolation implements Interpolation {
return (int) Math.floor(position);
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java
index c29190b77..3a020653e 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java
@@ -38,7 +38,7 @@ public class Node {
private double continuity;
public Node() {
- this(Vector3.at(0, 0, 0));
+ this(Vector3.ZERO);
}
public Node(Node other) {
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java
index d51436598..b4810b98c 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java
@@ -1,17 +1,34 @@
+/*
+ * WorldEdit, a Minecraft world manipulation toolkit
+ * Copyright (C) sk89q
+ * Copyright (C) WorldEdit team and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
package com.sk89q.worldedit.math.transform;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.MathUtils;
+import com.sk89q.worldedit.math.Vector3;
+
import java.io.IOException;
import java.io.Serializable;
-import com.sk89q.worldedit.math.MutableBlockVector3;
-import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.math.MathUtils;
-import com.sk89q.worldedit.math.MutableVector3;
-import com.sk89q.worldedit.math.Vector3;
-
/**
* An affine transform.
- *
+ *
*
This class is from the
* JavaGeom project,
* which is licensed under LGPL v2.1.
@@ -153,7 +170,7 @@ public class AffineTransform implements Transform, Serializable {
*
* @return the determinant of the transform.
*/
- public double determinant() {
+ private double determinant() {
return m00 * (m11 * m22 - m12 * m21) - m01 * (m10 * m22 - m20 * m12)
+ m02 * (m10 * m21 - m20 * m11);
}
@@ -336,4 +353,4 @@ public class AffineTransform implements Transform, Serializable {
}
-}
\ No newline at end of file
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/RoundedTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/RoundedTransform.java
index 7ba7abb25..91d347f7c 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/RoundedTransform.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/RoundedTransform.java
@@ -1,11 +1,9 @@
package com.sk89q.worldedit.math.transform;
-import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
public class RoundedTransform implements Transform{
private final Transform transform;
-// private MutableBlockVector3 mutable = new MutableBlockVector3();
public RoundedTransform(Transform transform) {
this.transform = transform;
@@ -19,9 +17,6 @@ public class RoundedTransform implements Transform{
@Override
public Vector3 apply(Vector3 input) {
Vector3 val = transform.apply(input);
-// mutable.mutX((int) Math.floor(val.getX() + 0.5));
-// mutable.mutY((int) Math.floor(val.getY() + 0.5));
-// mutable.mutZ((int) Math.floor(val.getZ() + 0.5));
return Vector3.at(Math.floor(val.getX() + 0.5), Math.floor(val.getY() + 0.5), Math.floor(val.getY() + 0.5));
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java
index 828f8b7ea..5d0412259 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java
@@ -43,7 +43,7 @@ public final class Transforms {
public static Location transform(Location location, Transform transform) {
checkNotNull(location);
checkNotNull(transform);
- return new Location(location.getExtent(), transform.apply(location), location.getDirection());
+ return new Location(location.getExtent(), transform.apply(location.toVector()), location.getDirection());
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java
index 90892ed12..2a22a9669 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java
@@ -166,7 +166,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
hasY = true;
maxY = y;
}
-
+
@Override
public BlockVector3 getMinimumPoint() {
return center.toVector2().subtract(getRadius()).toVector3(minY).toBlockPoint();
@@ -381,4 +381,5 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
int maxY = extent.getMaximumPoint().getBlockY();
return new CylinderRegion(center, radiusVec, minY, maxY);
}
+
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java
index de2a3dea0..58e1d2197 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java
@@ -24,7 +24,11 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.world.World;
-import java.util.*;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
/**
* A region that contains no points.
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java
index 051731cdc..e0524774b 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java
@@ -54,7 +54,7 @@ public interface RegionSelector {
/**
* Called when the first point is selected.
- *
+ *
* @param position the position
* @return true if something changed
*/
@@ -62,7 +62,7 @@ public interface RegionSelector {
/**
* Called when the second point is selected.
- *
+ *
* @param position the position
* @return true if something changed
*/
@@ -70,7 +70,7 @@ public interface RegionSelector {
/**
* Tell the player information about his/her primary selection.
- *
+ *
* @param actor the actor
* @param session the session
* @param position position
@@ -97,7 +97,7 @@ public interface RegionSelector {
/**
* Get the primary position.
- *
+ *
* @return the primary position
* @throws IncompleteRegionException thrown if a region has not been fully defined
*/
@@ -105,7 +105,7 @@ public interface RegionSelector {
/**
* Get the selection.
- *
+ *
* @return the created region
* @throws IncompleteRegionException thrown if a region has not been fully defined
*/
@@ -113,21 +113,21 @@ public interface RegionSelector {
/**
* Get the region even if it's not fully defined.
- *
+ *
* @return an incomplete region object that is incomplete
*/
Region getIncompleteRegion();
/**
* Returns whether the region has been fully defined.
- *
+ *
* @return true if a selection is available
*/
boolean isDefined();
/**
* Get the number of blocks inside the region.
- *
+ *
* @return number of blocks, or -1 if undefined
*/
int getArea();
@@ -144,25 +144,16 @@ public interface RegionSelector {
/**
* Get a lowercase name of this region selector type.
- *
+ *
* @return a lower case name of the type
*/
String getTypeName();
/**
* Get lines of information about the selection.
- *
+ *
* @return a list of lines describing the region
*/
List getInformationLines();
- /**
- * Get the verticies
- * @return
- * @throws IncompleteRegionException
- */
- default List getVerticies() throws IncompleteRegionException {
- return Collections.singletonList(getPrimaryPosition());
- }
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java
index 92242baa0..3adbf9444 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java
@@ -20,8 +20,8 @@
package com.sk89q.worldedit.regions.selector;
import com.boydti.fawe.config.BBC;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.extension.platform.Actor;
@@ -37,11 +37,13 @@ import com.sk89q.worldedit.regions.polyhedron.Triangle;
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
import com.sk89q.worldedit.world.World;
-import java.util.*;
import javax.annotation.Nullable;
-
-
-import static com.google.common.base.Preconditions.checkNotNull;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
/**
* Creates a {@code ConvexPolyhedralRegion} from a user's selections.
@@ -108,11 +110,6 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
}
}
- @Override
- public List getVerticies() {
- return new ArrayList<>(region.getVertices());
- }
-
@Nullable
@Override
public World getWorld() {
@@ -279,5 +276,4 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
}
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java
index c98a118c0..99b7027af 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java
@@ -22,14 +22,12 @@ package com.sk89q.worldedit.regions.selector;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Commands;
import com.boydti.fawe.util.chat.Message;
+
+import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.SelectionCommands;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.sk89q.worldedit.IncompleteRegionException;
-import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.internal.cui.CUIRegion;
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
@@ -39,13 +37,10 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
import com.sk89q.worldedit.world.World;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+
import javax.annotation.Nullable;
-
-
-import static com.google.common.base.Preconditions.checkNotNull;
+import java.util.ArrayList;
+import java.util.List;
/**
* Creates a {@code CuboidRegion} from a user's selections.
@@ -96,6 +91,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
position1 = oldRegion.getMinimumPoint();
position2 = oldRegion.getMaximumPoint();
}
+
region.setPos1(position1);
region.setPos2(position2);
}
@@ -103,7 +99,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
/**
* Create a new region selector with the given two positions.
*
- * @param world the world
+ * @param world the world
* @param position1 position 1
* @param position2 position 2
*/
@@ -117,11 +113,6 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
region.setPos2(position2);
}
- @Override
- public List getVerticies() {
- return Arrays.asList(position1, position2);
- }
-
@Nullable
@Override
public World getWorld() {
@@ -317,5 +308,4 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
return "cuboid";
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java
index aa6f48da3..8394e8d54 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java
@@ -20,8 +20,8 @@
package com.sk89q.worldedit.regions.selector;
import com.boydti.fawe.config.BBC;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.extension.platform.Actor;
@@ -38,13 +38,11 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
import com.sk89q.worldedit.world.World;
+
+import javax.annotation.Nullable;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
-import javax.annotation.Nullable;
-
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* Creates a {@code CylinderRegionSelector} from a user's selections.
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java
index 31b7d5077..5d1215dac 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java
@@ -20,8 +20,8 @@
package com.sk89q.worldedit.regions.selector;
import com.boydti.fawe.config.BBC;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.extension.platform.Actor;
@@ -35,12 +35,10 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
import com.sk89q.worldedit.world.World;
+
+import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
-import javax.annotation.Nullable;
-
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* Creates a {@code EllipsoidRegionSelector} from a user's selections.
@@ -251,5 +249,4 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
return region.getCenter().toBlockPoint();
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java
index 79f2fcbba..8e7898990 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java
@@ -142,5 +142,4 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
explainRegionAdjust(player, session);
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java
index 70ac199a2..deaeafb10 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java
@@ -20,8 +20,8 @@
package com.sk89q.worldedit.regions.selector;
import com.boydti.fawe.config.BBC;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.extension.platform.Actor;
@@ -36,13 +36,11 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
import com.sk89q.worldedit.world.World;
+
+import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import javax.annotation.Nullable;
-
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* Creates a {@code Polygonal2DRegion} from a user's selections.
@@ -114,7 +112,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
*/
public Polygonal2DRegionSelector(@Nullable World world, List points, int minY, int maxY) {
checkNotNull(points);
-
+
final BlockVector2 pos2D = points.get(0);
pos1 = BlockVector3.at(pos2D.getX(), minY, pos2D.getZ());
region = new Polygonal2DRegion(world, points, minY, maxY);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java
index 3c3316af9..de1324852 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java
@@ -79,17 +79,17 @@ public abstract class ArbitraryBiomeShape {
*
* @param x X coordinate to be queried
* @param z Z coordinate to be queried
- * @param defaultBiomeType The default biome for the current column.
+ * @param defaultBaseBiome The default biome for the current column.
* @return material to place or null to not place anything.
*/
- protected abstract BiomeType getBiome(int x, int z, BiomeType defaultBiomeType);
+ protected abstract BiomeType getBiome(int x, int z, BiomeType defaultBaseBiome);
- private BiomeType getBiomeCached(int x, int z, BiomeType biomeType) {
+ private BiomeType getBiomeCached(int x, int z, BiomeType baseBiome) {
final int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ;
final BiomeType cacheEntry = cache[index];
if (cacheEntry == null) {// unknown, fetch material
- final BiomeType material = getBiome(x, z, biomeType);
+ final BiomeType material = getBiome(x, z, baseBiome);
if (material == null) {
// outside
cache[index] = BiomeTypes.THE_VOID;
@@ -108,13 +108,13 @@ public abstract class ArbitraryBiomeShape {
return cacheEntry;
}
- private boolean isInsideCached(int x, int z, BiomeType biomeType) {
+ private boolean isInsideCached(int x, int z, BiomeType baseBiome) {
final int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ;
final BiomeType cacheEntry = cache[index];
if (cacheEntry == null) {
// unknown block, meaning they must be outside the extent at this stage, but might still be inside the shape
- return getBiomeCached(x, z, biomeType) != null;
+ return getBiomeCached(x, z, baseBiome) != null;
}
return cacheEntry != BiomeTypes.THE_VOID;
@@ -124,11 +124,11 @@ public abstract class ArbitraryBiomeShape {
* Generates the shape.
*
* @param editSession The EditSession to use.
- * @param biomeType The default biome type.
+ * @param baseBiome The default biome type.
* @param hollow Specifies whether to generate a hollow shape.
* @return number of affected blocks.
*/
- public int generate(EditSession editSession, BiomeType biomeType, boolean hollow) {
+ public int generate(EditSession editSession, BiomeType baseBiome, boolean hollow) {
int affected = 0;
for (BlockVector2 position : getExtent()) {
@@ -136,7 +136,7 @@ public abstract class ArbitraryBiomeShape {
int z = position.getBlockZ();
if (!hollow) {
- final BiomeType material = getBiome(x, z, biomeType);
+ final BiomeType material = getBiome(x, z, baseBiome);
if (material != null && material != BiomeTypes.THE_VOID) {
editSession.getWorld().setBiome(position, material);
++affected;
@@ -145,26 +145,26 @@ public abstract class ArbitraryBiomeShape {
continue;
}
- final BiomeType material = getBiomeCached(x, z, biomeType);
+ final BiomeType material = getBiomeCached(x, z, baseBiome);
if (material == null) {
continue;
}
boolean draw = false;
do {
- if (!isInsideCached(x + 1, z, biomeType)) {
+ if (!isInsideCached(x + 1, z, baseBiome)) {
draw = true;
break;
}
- if (!isInsideCached(x - 1, z, biomeType)) {
+ if (!isInsideCached(x - 1, z, baseBiome)) {
draw = true;
break;
}
- if (!isInsideCached(x, z + 1, biomeType)) {
+ if (!isInsideCached(x, z + 1, baseBiome)) {
draw = true;
break;
}
- if (!isInsideCached(x, z - 1, biomeType)) {
+ if (!isInsideCached(x, z - 1, baseBiome)) {
draw = true;
break;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java
index ed3d1f6af..49a6486a4 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java
@@ -27,10 +27,10 @@ import com.sk89q.worldedit.math.MutableVector3;
import com.sk89q.worldedit.math.Vector3;
public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
+
private final Vector3 unit;
private final Vector3 zero2;
private Vector3 current = new MutableVector3(Vector3.ZERO);
- private EditSession editSession;
private Extent extent;
public WorldEditExpressionEnvironment(EditSession editSession, Vector3 unit, Vector3 zero) {
@@ -90,5 +90,4 @@ public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
this.current = current;
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java
index 295fff2b0..f9edfc255 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java
@@ -65,4 +65,5 @@ public class Registry implements Iterable {
public Iterator iterator() {
return this.map.values().iterator();
}
+
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/ClipboardHolder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/ClipboardHolder.java
index 17296b717..a4d6b5631 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/ClipboardHolder.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/ClipboardHolder.java
@@ -33,6 +33,7 @@ import java.util.List;
* Holds the clipboard and the current transform on the clipboard.
*/
public class ClipboardHolder {
+
private Clipboard clipboard;
private Transform transform = new Identity();
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/DelegateClipboardHolder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/DelegateClipboardHolder.java
deleted file mode 100644
index 622e3313f..000000000
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/DelegateClipboardHolder.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.sk89q.worldedit.session;
-
-import com.sk89q.worldedit.extent.Extent;
-import com.sk89q.worldedit.extent.clipboard.Clipboard;
-import com.sk89q.worldedit.math.transform.Transform;
-
-public class DelegateClipboardHolder extends ClipboardHolder {
- private final ClipboardHolder parent;
-
- public DelegateClipboardHolder(ClipboardHolder holder) {
- super(holder.getClipboard());
- this.parent = holder;
- }
-
- @Override
- public Clipboard getClipboard() {
- return parent.getClipboard();
- }
-
- @Override
- public void setTransform(Transform transform) {
- parent.setTransform(transform);
- }
-
- @Override
- public Transform getTransform() {
- return parent.getTransform();
- }
-
- @Override
- public PasteBuilder createPaste(Extent targetExtent) {
- return parent.createPaste(targetExtent);
- }
-
- @Override
- public void close() {
- parent.close();
- }
-}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java
index bfc82f5c6..9e0e25f84 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java
@@ -20,9 +20,9 @@
package com.sk89q.worldedit.session;
import com.boydti.fawe.util.MaskTraverser;
-import com.sk89q.worldedit.EditSession;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkNotNull;
+import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
@@ -35,9 +35,6 @@ import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.transform.Transform;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* Builds an operation to paste the contents of a clipboard.
*/
@@ -56,10 +53,10 @@ public class PasteBuilder {
/**
* Create a new instance.
*
- * @param holder the clipboard holder
- * @param targetExtent an extent
+ * @param holder the clipboard holder
+ * @param targetExtent an extent
*/
- public PasteBuilder(ClipboardHolder holder, Extent targetExtent) {
+ PasteBuilder(ClipboardHolder holder, Extent targetExtent) {
checkNotNull(holder);
checkNotNull(targetExtent);
this.clipboard = holder.getClipboard();
@@ -134,5 +131,4 @@ public class PasteBuilder {
return copy;
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java
index 9948350fd..a29b48d59 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java
@@ -23,7 +23,11 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import javax.annotation.Nullable;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Optional;
+import java.util.OptionalInt;
/**
* A collection of cardinal, ordinal, and secondary-ordinal directions.
@@ -65,7 +69,7 @@ public enum Direction {
private final BlockVector3 blockPoint;
private static HashMap map = new HashMap<>();
-
+
static {
for (Direction dir : Direction.values()) {
map.put(dir.name(), dir);
@@ -80,11 +84,11 @@ public enum Direction {
this.left = left;
this.right = right;
}
-
+
public static Direction get(CharSequence sequence) {
return map.get(sequence.toString());
}
-
+
public Direction getLeft() {
return left != -1 ? values()[left] : null;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java
index 820d813d3..73a2efe88 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java
@@ -38,8 +38,7 @@ import javax.annotation.Nullable;
*/
public class TargetBlock {
- private final World world;
-
+ private World world;
private int maxDistance;
private double checkDistance, curDistance;
private BlockVector3 targetPos = BlockVector3.ZERO;
@@ -122,7 +121,7 @@ public class TargetBlock {
this.checkDistance = checkDistance;
this.curDistance = 0;
xRotation = (xRotation + 90) % 360;
- yRotation *= -1;
+ yRotation = yRotation * -1;
double h = (checkDistance * Math.cos(Math.toRadians(yRotation)));
@@ -145,15 +144,15 @@ public class TargetBlock {
boolean searchForLastBlock = true;
Location lastBlock = null;
while (getNextBlock() != null) {
- if (stopMask.test(targetPos)) {
- break;
- } else {
+ if (!stopMask.test(targetPos)) {
if (searchForLastBlock) {
lastBlock = getCurrentBlock();
if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) {
searchForLastBlock = false;
}
}
+ } else {
+ break;
}
}
Location currentBlock = getCurrentBlock();
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/SimpleCommandMapping.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/SimpleCommandMapping.java
index d3ca796a6..a468eea05 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/SimpleCommandMapping.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/SimpleCommandMapping.java
@@ -95,6 +95,4 @@ public class SimpleCommandMapping implements CommandMapping {
'}';
}
-
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/SimpleDispatcher.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/SimpleDispatcher.java
index 6f6c32048..949869cdd 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/SimpleDispatcher.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/SimpleDispatcher.java
@@ -20,13 +20,15 @@
package com.sk89q.worldedit.util.command;
import com.boydti.fawe.Fawe;
-import com.boydti.fawe.config.BBC;
import com.boydti.fawe.util.StringMan;
+
import com.google.common.base.Joiner;
+import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
import com.sk89q.minecraft.util.commands.WrappedCommandException;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -117,7 +119,7 @@ public class SimpleDispatcher implements Dispatcher {
throw new CommandPermissionsException();
}
- String[] split = arguments.split(" ", -1);
+ String[] split = CommandContext.split(arguments);
Set aliases = getPrimaryAliases();
if (aliases.isEmpty()) {
@@ -147,7 +149,7 @@ public class SimpleDispatcher implements Dispatcher {
@Override
public List getSuggestions(String arguments, CommandLocals locals) throws CommandException {
- String[] split = arguments.split(" ", -1);
+ String[] split = CommandContext.split(arguments);
if (split.length <= 1) {
String prefix = split.length > 0 ? split[0] : "";
@@ -189,4 +191,5 @@ public class SimpleDispatcher implements Dispatcher {
// Checking every perm in the class here was unnecessarily stupid
return true;
}
+
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/fluent/DispatcherNode.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/fluent/DispatcherNode.java
index 6725a0283..4786e5f3e 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/fluent/DispatcherNode.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/fluent/DispatcherNode.java
@@ -20,14 +20,15 @@
package com.sk89q.worldedit.util.command.fluent;
import com.boydti.fawe.config.Commands;
+
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.worldedit.util.command.CallableProcessor;
import com.sk89q.worldedit.util.command.CommandCallable;
import com.sk89q.worldedit.util.command.Dispatcher;
import com.sk89q.worldedit.util.command.SimpleDispatcher;
import com.sk89q.worldedit.util.command.parametric.ParametricBuilder;
+
import javax.annotation.Nullable;
-import java.lang.annotation.Annotation;
/**
* A collection of commands.
@@ -41,12 +42,12 @@ public class DispatcherNode {
/**
* Create a new instance.
*
- * @param graph the root fluent graph object
- * @param parent the parent node, or null
+ * @param graph the root fluent graph object
+ * @param parent the parent node, or null
* @param dispatcher the dispatcher for this node
*/
- public DispatcherNode(CommandGraph graph, DispatcherNode parent,
- SimpleDispatcher dispatcher) {
+ DispatcherNode(CommandGraph graph, DispatcherNode parent,
+ SimpleDispatcher dispatcher) {
this.graph = graph;
this.parent = parent;
this.dispatcher = dispatcher;
@@ -54,7 +55,7 @@ public class DispatcherNode {
/**
* Set the description.
- *
+ *
*
This can only be used on {@link DispatcherNode}s returned by
* {@link #group(String...)}.
*
@@ -70,7 +71,7 @@ public class DispatcherNode {
* Register a command with this dispatcher.
*
* @param callable the executor
- * @param alias the list of aliases, where the first alias is the primary one
+ * @param alias the list of aliases, where the first alias is the primary one
*/
public DispatcherNode register(CommandCallable callable, String... alias) {
dispatcher.registerCommand(callable, alias);
@@ -145,7 +146,7 @@ public class DispatcherNode {
/**
* Create a new command that will contain sub-commands.
- *
+ *
*
The object returned by this method can be used to add sub-commands. To
* return to this "parent" context, use {@link DispatcherNode#graph()}.
*
@@ -155,8 +156,7 @@ public class DispatcherNode {
public DispatcherNode group(String... alias) {
SimpleDispatcher command = new SimpleDispatcher();
getDispatcher().registerCommand(command, alias);
- DispatcherNode res = new DispatcherNode(graph, this, command);
- return res;
+ return new DispatcherNode(graph, this, command);
}
/**
@@ -191,5 +191,4 @@ public class DispatcherNode {
return dispatcher;
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/AParametricCallable.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/AParametricCallable.java
index 91abf5dff..2fe586e81 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/AParametricCallable.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/AParametricCallable.java
@@ -40,7 +40,7 @@ public abstract class AParametricCallable implements CommandCallable {
* @param existing the existing scoped context
* @return the context to use
*/
- public static ArgumentStack getScopedContext(Parameter parameter, ArgumentStack existing) {
+ static ArgumentStack getScopedContext(Parameter parameter, ArgumentStack existing) {
if (parameter.getFlag() != null) {
CommandContext context = existing.getContext();
@@ -213,7 +213,6 @@ public abstract class AParametricCallable implements CommandCallable {
CommandContext context = new CommandContext(split, getValueFlags(), !arguments.endsWith(" "), locals);
ContextArgumentStack scoped = new ContextArgumentStack(context);
- SuggestionContext suggestable = context.getSuggestionContext();
List suggestions = new ArrayList<>(2);
ParameterData parameter = null;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ArgumentStack.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ArgumentStack.java
index fbcc9ec3c..b3345f3a4 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ArgumentStack.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ArgumentStack.java
@@ -91,8 +91,4 @@ public interface ArgumentStack {
* @return the consumed arguments
*/
String reset();
-
- static Class inject0() {
- return ArgumentStack.class;
- }
-}
\ No newline at end of file
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingHelper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingHelper.java
index 1d45d0b32..c37839c72 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingHelper.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingHelper.java
@@ -20,6 +20,7 @@
package com.sk89q.worldedit.util.command.parametric;
import com.boydti.fawe.util.StringMan;
+
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.worldedit.util.command.binding.Range;
import com.sk89q.worldedit.util.command.binding.Validate;
@@ -29,53 +30,51 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* A binding helper that uses the {@link BindingMatch} annotation to make
* writing bindings extremely easy.
- *
+ *
*
Methods must have the following and only the following parameters:
- *
+ *
*
*
A {@link ArgumentStack}
*
A {@link Annotation} if there is a classifier set
- *
A {@link Annotation}[]
+ *
A {@link Annotation}[]
* if there {@link BindingMatch#provideModifiers()} is true
*
- *
+ *
*
Methods may throw any exception. Exceptions may be converted using a
* {@link ExceptionConverter} registered with the {@link ParametricBuilder}.
*/
-@Deprecated
public class BindingHelper implements Binding {
-
+
private final List bindings;
private final Type[] types;
-
+
/**
* Create a new instance.
*/
public BindingHelper() {
List bindings = new ArrayList<>();
List types = new ArrayList<>();
-
+
for (Method method : this.getClass().getMethods()) {
BindingMatch info = method.getAnnotation(BindingMatch.class);
if (info != null) {
Class extends Annotation> classifier = null;
-
+
// Set classifier
if (!info.classifier().equals(Annotation.class)) {
classifier = info.classifier();
types.add(classifier);
}
-
+
for (Type t : info.type()) {
Type type = null;
-
+
// Set type
if (!t.equals(Class.class)) {
type = t;
@@ -83,32 +82,32 @@ public class BindingHelper implements Binding {
types.add(type); // Only if there is no classifier set!
}
}
-
+
// Check to see if at least one is set
if (type == null && classifier == null) {
throw new RuntimeException(
"A @BindingMatch needs either a type or classifier set");
}
-
+
BindingMap.BoundMethod handler = new BindingMap.BoundMethod(info, type, classifier, method, this);
bindings.add(handler);
}
}
}
-
+
Collections.sort(bindings);
-
+
this.bindings = bindings;
-
+
Type[] typesArray = new Type[types.size()];
types.toArray(typesArray);
this.types = typesArray;
-
+
}
-
+
/**
* Match a {@link BindingMatch} according to the given parameter.
- *
+ *
* @param parameter the parameter
* @return a binding
*/
@@ -116,7 +115,7 @@ public class BindingHelper implements Binding {
for (BindingMap.BoundMethod binding : bindings) {
Annotation classifer = parameter.getClassifier();
Type type = parameter.getType();
-
+
if (binding.classifier != null) {
if (classifer != null && classifer.annotationType().equals(binding.classifier)) {
if (binding.type == null || binding.type.equals(type)) {
@@ -127,7 +126,7 @@ public class BindingHelper implements Binding {
return binding;
}
}
-
+
throw new RuntimeException("Unknown type");
}
@@ -152,27 +151,27 @@ public class BindingHelper implements Binding {
BindingMap.BoundMethod binding = match(parameter);
List args = new ArrayList<>();
args.add(scoped);
-
+
if (binding.classifier != null) {
args.add(parameter.getClassifier());
}
-
+
if (binding.annotation.provideModifiers()) {
args.add(parameter.getModifiers());
}
-
+
if (onlyConsume && binding.annotation.behavior() == BindingBehavior.PROVIDES) {
return null; // Nothing to consume, nothing to do
}
-
+
Object[] argsArray = new Object[args.size()];
args.toArray(argsArray);
-
+
try {
return binding.method.invoke(this, argsArray);
} catch (IllegalArgumentException e) {
throw new RuntimeException(
- "Processing of classifier " + parameter.getClassifier() +
+ "Processing of classifier " + parameter.getClassifier() +
" and type " + parameter.getType() + " failed for method\n" +
binding.method + "\nbecause the parameters for that method are wrong", e);
} catch (IllegalAccessException e) {
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingMatch.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingMatch.java
index a76be395b..cc89f3c74 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingMatch.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingMatch.java
@@ -31,39 +31,39 @@ import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface BindingMatch {
-
+
/**
* The classifier.
- *
+ *
* @return the classifier, or {@link Annotation} if not set
*/
Class extends Annotation> classifier() default Annotation.class;
-
+
/**
* The type.
- *
+ *
* @return the type, or {@link Class} if not set
*/
Class>[] type() default Class.class;
/**
* The binding behavior.
- *
+ *
* @return the behavior
*/
BindingBehavior behavior();
-
+
/**
* Get the number of arguments that this binding consumes.
- *
+ *
* @return -1 if unknown or irrelevant
*/
int consumedCount() default -1;
-
+
/**
* Set whether an array of modifier annotations is provided in the list of
* arguments.
- *
+ *
* @return true to provide modifiers
*/
boolean provideModifiers() default false;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ContextArgumentStack.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ContextArgumentStack.java
index b963c6cfe..4f5b9986d 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ContextArgumentStack.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ContextArgumentStack.java
@@ -124,7 +124,6 @@ public class ContextArgumentStack implements ArgumentStack {
*
*
The marked position initially starts at 0.
*/
- @Override
public void mark() {
markedIndex = index;
}
@@ -137,7 +136,6 @@ public class ContextArgumentStack implements ArgumentStack {
*
* @return the consumed arguments
*/
- @Override
public String reset() {
String value = (index - 1 > markedIndex) ? context.getString(markedIndex, index - 1) : "";
index = markedIndex;
@@ -177,6 +175,4 @@ public class ContextArgumentStack implements ArgumentStack {
return context;
}
-
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/FaweParanamer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/FaweParanamer.java
index 4dbcd491a..7c69e59bd 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/FaweParanamer.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/FaweParanamer.java
@@ -32,11 +32,9 @@ package com.sk89q.worldedit.util.command.parametric;
import com.thoughtworks.paranamer.CachingParanamer;
+import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Parameter;
/**
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/FunctionParametricCallable.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/FunctionParametricCallable.java
index dff7acf2d..3a062d2cf 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/FunctionParametricCallable.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/FunctionParametricCallable.java
@@ -1,15 +1,31 @@
package com.sk89q.worldedit.util.command.parametric;
-import com.boydti.fawe.config.BBC;
import com.boydti.fawe.util.StringMan;
+
import com.google.common.primitives.Chars;
-import com.sk89q.minecraft.util.commands.*;
-import com.sk89q.worldedit.util.command.*;
+import com.sk89q.minecraft.util.commands.Command;
+import com.sk89q.minecraft.util.commands.CommandContext;
+import com.sk89q.minecraft.util.commands.CommandException;
+import com.sk89q.minecraft.util.commands.CommandLocals;
+import com.sk89q.minecraft.util.commands.CommandPermissionsException;
+import com.sk89q.minecraft.util.commands.WrappedCommandException;
+import com.sk89q.worldedit.util.command.CommandCallable;
+import com.sk89q.worldedit.util.command.InvalidUsageException;
+import com.sk89q.worldedit.util.command.MissingParameterException;
+import com.sk89q.worldedit.util.command.Parameter;
+import com.sk89q.worldedit.util.command.SimpleDescription;
+import com.sk89q.worldedit.util.command.UnconsumedParameterException;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.function.Function;
public class FunctionParametricCallable extends AParametricCallable {
@@ -33,48 +49,46 @@ public class FunctionParametricCallable extends AParametricCallable {
this.group = group;
List paramParsables = new ArrayList<>();
+ Map unqualified = new HashMap<>();
+ for (Type type : builder.getBindings().getTypes()) {
+ String typeStr = type.getTypeName();
+ unqualified.put(typeStr, type);
+ unqualified.put(typeStr.substring(typeStr.lastIndexOf('.') + 1), type);
+ }
{
- Map unqualified = new HashMap<>();
- for (Type type : builder.getBindings().getTypes()) {
- String typeStr = type.getTypeName();
- unqualified.put(typeStr, type);
- unqualified.put(typeStr.substring(typeStr.lastIndexOf('.') + 1), type);
- }
- {
- Object[] param = null; // name | type | optional value
- boolean checkEq = false;
- int checkEqI = 0;
- for (String arg : arguments) {
- if (arg.equals("=")) {
- checkEqI++;
- checkEq = true;
- } else if (param == null || !checkEq) {
- if (param != null) paramParsables.add(param);
- param = new Object[3];
- param[0] = arg;
- if (arg.length() == 1 && command.flags().contains(arg)) {
- param[1] = Boolean.class;
- } else {
- param[1] = String.class;
- }
- param[2] = null;
+ Object[] param = null; // name | type | optional value
+ boolean checkEq = false;
+ int checkEqI = 0;
+ for (String arg : arguments) {
+ if (arg.equals("=")) {
+ checkEqI++;
+ checkEq = true;
+ } else if (param == null || !checkEq) {
+ if (param != null) paramParsables.add(param);
+ param = new Object[3];
+ param[0] = arg;
+ if (arg.length() == 1 && command.flags().contains(arg)) {
+ param[1] = Boolean.class;
+ } else {
+ param[1] = String.class;
+ }
+ param[2] = null;
+ checkEqI = 0;
+ checkEq = false;
+ } else {
+ if (checkEqI == 1) {
+ param[1] = unqualified.getOrDefault(arg, String.class);
+ checkEq = false;
+ } else if (checkEqI == 2) {
+ char c = arg.charAt(0);
+ if (c == '\'' || c == '"') arg = arg.substring(1, arg.length() - 1);
+ param[2] = arg;
checkEqI = 0;
checkEq = false;
- } else {
- if (checkEqI == 1) {
- param[1] = unqualified.getOrDefault(arg, String.class);
- checkEq = false;
- } else if (checkEqI == 2) {
- char c = arg.charAt(0);
- if (c == '\'' || c == '"') arg = arg.substring(1, arg.length() - 1);
- param[2] = arg;
- checkEqI = 0;
- checkEq = false;
- }
}
}
- if (param != null) paramParsables.add(param);
}
+ if (param != null) paramParsables.add(param);
}
parameters = new ParameterData[paramParsables.size()];
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParameterData.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParameterData.java
index f902ae4bd..67d5025b3 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParameterData.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParameterData.java
@@ -24,12 +24,9 @@ import com.sk89q.worldedit.util.command.binding.PrimitiveBindings;
import com.sk89q.worldedit.util.command.binding.Range;
import com.sk89q.worldedit.util.command.binding.Text;
-import javax.xml.ws.Provider;
import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
-import java.util.concurrent.Callable;
import java.util.function.Supplier;
/**
@@ -62,7 +59,7 @@ public class ParameterData extends SimpleParameter {
/**
* Set the main type of this parameter.
- *
+ *
*
The type is normally that is used to determine which binding is used
* for a particular method's parameter.
*
@@ -84,7 +81,7 @@ public class ParameterData extends SimpleParameter {
/**
* Get the classifier annotation.
- *
+ *
*
Normally, the type determines what binding is called, but classifiers
* take precedence if one is found (and registered with
* {@link ParametricBuilder#addBinding(Binding, Type...)}).
@@ -107,7 +104,7 @@ public class ParameterData extends SimpleParameter {
/**
* Get a list of modifier annotations.
- *
+ *
*
Modifier annotations are not considered in the process of choosing a binding
* for a method parameter, but they can be used to modify the behavior of a binding.
* An example of a modifier annotation is {@link Range}, which can restrict
@@ -120,7 +117,7 @@ public class ParameterData extends SimpleParameter {
return modifiers;
}
- public T getModifier(Class annotatedType) {
+ T getModifier(Class annotatedType) {
for (Annotation annotation : getModifiers()) {
if (annotation.getClass() == annotatedType) return (T) annotation;
}
@@ -141,7 +138,7 @@ public class ParameterData extends SimpleParameter {
*
* @return -1 if unknown or unavailable
*/
- public int getConsumedCount() {
+ int getConsumedCount() {
return getBinding().getConsumedCount(this);
}
@@ -150,7 +147,7 @@ public class ParameterData extends SimpleParameter {
*
* @return true if this parameter is entered by the user.
*/
- public boolean isUserInput() {
+ boolean isUserInput() {
return getBinding().getBehavior(this) != BindingBehavior.PROVIDES;
}
@@ -159,7 +156,7 @@ public class ParameterData extends SimpleParameter {
*
* @return true if this parameter consumes non-flag arguments
*/
- public boolean isNonFlagConsumer() {
+ boolean isNonFlagConsumer() {
return getBinding().getBehavior(this) != BindingBehavior.PROVIDES && !isValueFlag();
}
@@ -167,7 +164,7 @@ public class ParameterData extends SimpleParameter {
* Validate this parameter and its binding.
*/
public void validate(Method method, int parameterIndex) throws ParametricException {
- validate(() -> method.toGenericString(), parameterIndex);
+ validate(method::toGenericString, parameterIndex);
}
public void validate(Supplier method, int parameterIndex) throws ParametricException {
@@ -206,5 +203,4 @@ public class ParameterData extends SimpleParameter {
}
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricBuilder.java
index 43f809dd5..e2bd3f99a 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricBuilder.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricBuilder.java
@@ -20,20 +20,16 @@
package com.sk89q.worldedit.util.command.parametric;
import com.boydti.fawe.command.FawePrimitiveBinding;
-import com.boydti.fawe.command.MaskBinding;
-import com.boydti.fawe.command.PatternBinding;
import com.boydti.fawe.config.Commands;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
import com.google.common.collect.ImmutableBiMap.Builder;
import com.sk89q.minecraft.util.commands.Command;
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.WorldEdit;
import com.sk89q.worldedit.command.MethodCommands;
-import com.sk89q.worldedit.internal.command.ActorAuthorizer;
-import com.sk89q.worldedit.internal.command.CommandLoggingHandler;
-import com.sk89q.worldedit.internal.command.UserCommandCompleter;
-import com.sk89q.worldedit.internal.command.WorldEditBinding;
import com.sk89q.worldedit.util.auth.Authorizer;
import com.sk89q.worldedit.util.auth.NullAuthorizer;
import com.sk89q.worldedit.util.command.CallableProcessor;
@@ -46,15 +42,11 @@ import com.sk89q.worldedit.util.command.binding.PrimitiveBindings;
import com.sk89q.worldedit.util.command.binding.StandardBindings;
import com.sk89q.worldedit.util.command.binding.Switch;
import com.thoughtworks.paranamer.Paranamer;
+
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* Creates commands using annotations placed on methods and individual parameters of
@@ -68,13 +60,12 @@ public class ParametricBuilder {
private final BindingMap bindings;
private final Paranamer paranamer = new FaweParanamer();
private final List invokeListeners = new ArrayList<>();
- private final List exceptionConverters = new ArrayList<>();
private Authorizer authorizer = new NullAuthorizer();
private CommandCompleter defaultCompleter = new NullCompleter();
/**
* Create a new builder.
- *
+ *
*
This method will install {@link PrimitiveBindings} and
* {@link StandardBindings} and default bindings.
*/
@@ -86,12 +77,12 @@ public class ParametricBuilder {
/**
* Add a binding for a given type or classifier (annotation).
- *
+ *
*
Whenever a method parameter is encountered, a binding must be found for it
* so that it can be called later to consume the stack of arguments provided by
* the user and return an object that is later passed to
* {@link Method#invoke(Object, Object...)}.
- *
+ *
*
Normally, a {@link Type} is used to discern between different bindings, but
* if this is not specific enough, an annotation can be defined and used. This
* makes it a "classifier" and it will take precedence over the base type. For
@@ -102,9 +93,8 @@ public class ParametricBuilder {
* the {@link String} type.
*
* @param binding the binding
- * @param type a list of types (if specified) to override the binding's types
+ * @param type a list of types (if specified) to override the binding's types
*/
- @Deprecated
public void addBinding(Binding binding, Type... type) {
this.bindings.add(binding);
}
@@ -119,50 +109,37 @@ public class ParametricBuilder {
/**
* Attach an invocation listener.
- *
+ *
*
Invocation handlers are called in order that their listeners are
* registered with a {@link ParametricBuilder}. It is not guaranteed that
* a listener may be called, in the case of a {@link CommandException} being
* thrown at any time before the appropriate listener or handler is called.
* It is possible for a
- * {@link com.sk89q.worldedit.util.command.parametric.InvokeHandler#preInvoke(Object, Method, com.sk89q.worldedit.util.command.parametric.ParameterData[], Object[], CommandContext)} to
+ * {@link InvokeHandler#preInvoke(Object, Method, ParameterData[], Object[], CommandContext)} to
* be called for a invocation handler, but not the associated
- * {@link com.sk89q.worldedit.util.command.parametric.InvokeHandler#postInvoke(Object, Method, com.sk89q.worldedit.util.command.parametric.ParameterData[], Object[], CommandContext)}.
An example of an invocation listener is one to handle
* {@link CommandPermissions}, by first checking to see if permission is available
- * in a {@link com.sk89q.worldedit.util.command.parametric.InvokeHandler#preInvoke(Object, Method, com.sk89q.worldedit.util.command.parametric.ParameterData[], Object[], CommandContext)}
+ * in a {@link InvokeHandler#preInvoke(Object, Method, ParameterData[], Object[], CommandContext)}
* call. If permission is not found, then an appropriate {@link CommandException}
* can be thrown to cease invocation.
*
* @param listener the listener
- * @see com.sk89q.worldedit.util.command.parametric.InvokeHandler the handler
+ * @see InvokeHandler the handler
*/
public void addInvokeListener(InvokeListener listener) {
invokeListeners.add(listener);
}
- /**
- * Attach an exception converter to this builder in order to wrap unknown
- * {@link Throwable}s into known {@link CommandException}s.
- *
- *
Exception converters are called in order that they are registered.
- *
- * @param converter the converter
- * @see ExceptionConverter for an explanation
- */
- public void addExceptionConverter(ExceptionConverter converter) {
- exceptionConverters.add(converter);
- }
-
/**
* Build a list of commands from methods specially annotated with {@link Command}
* (and other relevant annotations) and register them all with the given
* {@link Dispatcher}.
*
* @param dispatcher the dispatcher to register commands with
- * @param object the object contain the methods
- * @throws com.sk89q.worldedit.util.command.parametric.ParametricException thrown if the commands cannot be registered
+ * @param object the object contain the methods
+ * @throws ParametricException thrown if the commands cannot be registered
*/
public void registerMethodsAsCommands(Dispatcher dispatcher, Object object) throws ParametricException {
registerMethodsAsCommands(dispatcher, object, null);
@@ -204,8 +181,8 @@ public class ParametricBuilder {
/**
* Build a {@link CommandCallable} for the given method.
*
- * @param object the object to be invoked on
- * @param method the method to invoke
+ * @param object the object to be invoked on
+ * @param method the method to invoke
* @param definition the command definition annotation
* @return the command executor
* @throws ParametricException thrown on an error
@@ -229,7 +206,7 @@ public class ParametricBuilder {
*
* @return the paranamer
*/
- public Paranamer getParanamer() {
+ Paranamer getParanamer() {
return paranamer;
}
@@ -247,19 +224,10 @@ public class ParametricBuilder {
*
* @return a list of invocation listeners
*/
- public List getInvokeListeners() {
+ List getInvokeListeners() {
return invokeListeners;
}
- /**
- * Get the list of exception converters.
- *
- * @return a list of exception converters
- */
- public List getExceptionConverters() {
- return exceptionConverters;
- }
-
/**
* Get the authorizer.
*
@@ -300,6 +268,4 @@ public class ParametricBuilder {
this.defaultCompleter = defaultCompleter;
}
-
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricCallable.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricCallable.java
index 493d5f1d8..c5bc616b4 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricCallable.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricCallable.java
@@ -19,8 +19,6 @@
package com.sk89q.worldedit.util.command.parametric;
-import com.boydti.fawe.command.SuggestInputParseException;
-import com.boydti.fawe.config.BBC;
import com.google.common.primitives.Chars;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
@@ -28,7 +26,6 @@ import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
-import com.sk89q.minecraft.util.commands.SuggestionContext;
import com.sk89q.minecraft.util.commands.WrappedCommandException;
import com.sk89q.worldedit.util.command.CommandCallable;
import com.sk89q.worldedit.util.command.InvalidUsageException;
@@ -37,6 +34,7 @@ import com.sk89q.worldedit.util.command.Parameter;
import com.sk89q.worldedit.util.command.SimpleDescription;
import com.sk89q.worldedit.util.command.UnconsumedParameterException;
import com.sk89q.worldedit.util.command.binding.Switch;
+
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -66,13 +64,13 @@ public class ParametricCallable extends AParametricCallable {
/**
* Create a new instance.
*
- * @param builder the parametric builder
- * @param object the object to invoke on
- * @param method the method to invoke
+ * @param builder the parametric builder
+ * @param object the object to invoke on
+ * @param method the method to invoke
* @param definition the command definition annotation
* @throws ParametricException thrown on an error
*/
- public ParametricCallable(ParametricBuilder builder, Object object, Method method, Command definition) throws ParametricException {
+ ParametricCallable(ParametricBuilder builder, Object object, Method method, Command definition) throws ParametricException {
this.builder = builder;
this.object = object;
this.method = method;
@@ -80,7 +78,6 @@ public class ParametricCallable extends AParametricCallable {
Annotation[][] annotations = method.getParameterAnnotations();
String[] names = builder.getParanamer().lookupParameterNames(method, false);
Type[] types = method.getGenericParameterTypes();
-
parameters = new ParameterData[types.length];
List userParameters = new ArrayList<>();
@@ -112,7 +109,7 @@ public class ParametricCallable extends AParametricCallable {
if (value.length > 0) {
parameter.setDefaultValue(value);
}
- // Special annotation bindings
+ // Special annotation bindings
} else if (parameter.getBinding() == null) {
parameter.setBinding(builder.getBindings());
parameter.setClassifier(annotation);
@@ -147,10 +144,10 @@ public class ParametricCallable extends AParametricCallable {
if (parameter.getConsumedCount() < 0) {
throw new ParametricException(
"Found an parameter using the binding " +
- parameter.getBinding().getClass().getCanonicalName() +
- "\nthat does not know how many arguments it consumes, but " +
- "it follows an optional parameter\nMethod: " +
- method.toGenericString());
+ parameter.getBinding().getClass().getCanonicalName() +
+ "\nthat does not know how many arguments it consumes, but " +
+ "it follows an optional parameter\nMethod: " +
+ method.toGenericString());
}
}
}
@@ -208,7 +205,7 @@ public class ParametricCallable extends AParametricCallable {
locals.putIfAbsent(CommandCallable.class, this);
String calledCommand = parentCommands.length > 0 ? parentCommands[parentCommands.length - 1] : "_";
- String[] split = (calledCommand + " " + stringArguments).split(" ", -1);
+ String[] split = CommandContext.split(calledCommand + " " + stringArguments);
CommandContext context = new CommandContext(split, getValueFlags(), false, locals);
// Provide help if -? is specified
@@ -271,14 +268,14 @@ public class ParametricCallable extends AParametricCallable {
}
return result;
} catch (MissingParameterException e) {
- throw new InvalidUsageException("Too few parameters!", this, true);
+ throw new InvalidUsageException("Too few parameters!", this);
} catch (UnconsumedParameterException e) {
- throw new InvalidUsageException("Too many parameters! Unused parameters: " + e.getUnconsumed(), this, true);
+ throw new InvalidUsageException("Too many parameters! Unused parameters: " + e.getUnconsumed(), this);
} catch (ParameterException e) {
assert parameter != null;
String name = parameter.getName();
- throw new InvalidUsageException("For parameter '" + name + "': " + e.getMessage(), this, true);
+ throw new InvalidUsageException("For parameter '" + name + "': " + e.getMessage(), this);
} catch (InvocationTargetException e) {
if (e.getCause() instanceof CommandException) {
throw (CommandException) e.getCause();
@@ -344,12 +341,12 @@ public class ParametricCallable extends AParametricCallable {
/**
* Generate a name for a parameter.
*
- * @param type the type
+ * @param type the type
* @param classifier the classifier
- * @param index the index
+ * @param index the index
* @return a generated name
*/
- public static String generateName(Type type, Annotation classifier, int index) {
+ private static String generateName(Type type, Annotation classifier, int index) {
if (classifier != null) {
return classifier.annotationType().getSimpleName().toLowerCase();
} else {
@@ -361,5 +358,4 @@ public class ParametricCallable extends AParametricCallable {
}
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/StringArgumentStack.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/StringArgumentStack.java
index 0b6524aa3..894aeb329 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/StringArgumentStack.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/StringArgumentStack.java
@@ -20,8 +20,8 @@
package com.sk89q.worldedit.util.command.parametric;
import com.sk89q.minecraft.util.commands.CommandContext;
-import com.sk89q.worldedit.util.command.MissingParameterException;
import com.sk89q.util.StringUtil;
+import com.sk89q.worldedit.util.command.MissingParameterException;
/**
* A virtual scope that does not actually read from the underlying
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/Fragment.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/Fragment.java
index f7034093e..94ba7f20a 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/Fragment.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/Fragment.java
@@ -25,12 +25,12 @@ package com.sk89q.worldedit.util.formatting;
public class Fragment {
private final StringBuilder builder = new StringBuilder();
-
- public Fragment() {
+
+ Fragment() {
}
public Fragment append(String str) {
- builder.append(str);
+ builder.append(Style.stripColor(str));
return this;
}
@@ -88,5 +88,5 @@ public class Fragment {
public String toString() {
return builder.toString();
}
-
+
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandListBox.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandListBox.java
index b2dbac493..9df10e637 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandListBox.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandListBox.java
@@ -38,7 +38,7 @@ public class CommandListBox extends MessageBox {
return appendCommand(alias, description, true);
}
- public CommandListBox appendCommand(String alias, String description, boolean allowed) {
+ CommandListBox appendCommand(String alias, String description, boolean allowed) {
if (!first) {
getContents().newLine();
}
@@ -47,5 +47,4 @@ public class CommandListBox extends MessageBox {
return this;
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandUsageBox.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandUsageBox.java
index e4935cb16..7f350edf4 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandUsageBox.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandUsageBox.java
@@ -20,6 +20,8 @@
package com.sk89q.worldedit.util.formatting.component;
import com.boydti.fawe.config.BBC;
+
+import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.worldedit.extension.platform.CommandManager;
import com.sk89q.worldedit.util.command.CommandCallable;
@@ -27,15 +29,11 @@ import com.sk89q.worldedit.util.command.CommandMapping;
import com.sk89q.worldedit.util.command.Description;
import com.sk89q.worldedit.util.command.Dispatcher;
import com.sk89q.worldedit.util.command.PrimaryAliasComparator;
-import com.sk89q.worldedit.util.formatting.Style;
import com.sk89q.worldedit.util.formatting.StyledFragment;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+
import javax.annotation.Nullable;
-
-
-import static com.google.common.base.Preconditions.checkNotNull;
+import java.util.ArrayList;
+import java.util.List;
/**
* A box to describe usage of a command.
@@ -45,7 +43,7 @@ public class CommandUsageBox extends StyledFragment {
/**
* Create a new usage box.
*
- * @param command the command to describe
+ * @param command the command to describe
* @param commandString the command that was used, such as "/we" or "/brush sphere"
*/
public CommandUsageBox(CommandCallable command, String commandString) {
@@ -55,9 +53,9 @@ public class CommandUsageBox extends StyledFragment {
/**
* Create a new usage box.
*
- * @param command the command to describe
+ * @param command the command to describe
* @param commandString the command that was used, such as "/we" or "/brush sphere"
- * @param locals list of locals to use
+ * @param locals list of locals to use
*/
public CommandUsageBox(CommandCallable command, String commandString, @Nullable CommandLocals locals) {
checkNotNull(command);
@@ -74,7 +72,7 @@ public class CommandUsageBox extends StyledFragment {
String prefix = !commandString.isEmpty() ? commandString + " " : "";
List list = new ArrayList<>(dispatcher.getCommands());
- Collections.sort(list, new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
+ list.sort(new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
for (CommandMapping mapping : list) {
boolean perm = locals == null || mapping.getCallable().testPermission(locals);
@@ -91,13 +89,11 @@ public class CommandUsageBox extends StyledFragment {
if (description.getUsage() != null) {
contents.append(new Label().append(BBC.COMMAND_SYNTAX.f(description.getUsage())));
} else {
- contents.createFragment(Style.GRAY);
contents.append(new Subtle().append("Usage information is not available."));
}
contents.newLine();
- contents.createFragment(Style.GRAY);
if (description.getHelp() != null) {
contents.append(description.getHelp());
} else if (description.getDescription() != null) {
@@ -109,6 +105,4 @@ public class CommandUsageBox extends StyledFragment {
append(box);
}
-
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/MessageBox.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/MessageBox.java
index 65bbde07a..dd8694590 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/MessageBox.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/MessageBox.java
@@ -41,6 +41,14 @@ public class MessageBox extends StyledFragment {
append(contents);
}
+ private String createBorder(int count) {
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < count; i++) {
+ builder.append("-");
+ }
+ return builder.toString();
+ }
+
/**
* Get the internal contents.
*
@@ -50,5 +58,4 @@ public class MessageBox extends StyledFragment {
return contents;
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java
index cd18a3489..e24b8a677 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java
@@ -36,7 +36,6 @@ import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nullable;
-import java.util.PriorityQueue;
/**
* An abstract implementation of {@link World}.
@@ -143,6 +142,7 @@ public abstract class AbstractWorld implements World {
this.priority = priority;
}
+ @SuppressWarnings("deprecation")
public void play() {
playEffect(position, 2001, blockType.getLegacyCombinedId() >> 4);
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java
index fa27b3d17..c3ef611d8 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java
@@ -19,11 +19,9 @@
package com.sk89q.worldedit.world;
-import com.sk89q.worldedit.*;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException;
-import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
@@ -54,7 +52,7 @@ public class NullWorld extends AbstractWorld {
private static final NullWorld INSTANCE = new NullWorld();
- public NullWorld() {
+ protected NullWorld() {
}
@Override
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java
index 400acd517..d8eec08be 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java
@@ -20,11 +20,7 @@
package com.sk89q.worldedit.world.biome;
import javax.annotation.Nullable;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
/**
* Stores a list of common Biome String IDs.
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java
index 38285926c..c5af9a99d 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java
@@ -20,21 +20,18 @@
package com.sk89q.worldedit.world.block;
import static com.google.common.base.Preconditions.checkNotNull;
-
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
-import com.sk89q.worldedit.world.registry.BlockMaterial;
-import com.sk89q.worldedit.world.registry.LegacyMapper;
-import com.sk89q.worldedit.blocks.TileEntityBlock;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
+import com.sk89q.worldedit.world.registry.BlockMaterial;
+import com.sk89q.worldedit.world.registry.LegacyMapper;
import javax.annotation.Nullable;
-
import java.util.Map;
import java.util.Objects;
@@ -48,10 +45,10 @@ import java.util.Objects;
* may be missing.
*/
public class BaseBlock implements BlockStateHolder {
+
private final BlockState blockState;
- @Nullable
- protected CompoundTag nbtData;
+ @Nullable protected CompoundTag nbtData;
@Deprecated
public BaseBlock() {
@@ -82,9 +79,7 @@ public class BaseBlock implements BlockStateHolder {
*
* @param blockState The blockstate
*/
-
public BaseBlock(BlockState blockState) {
-// this(blockState, blockState.getNbtData());
this.blockState = blockState;
}
@@ -111,7 +106,7 @@ public class BaseBlock implements BlockStateHolder {
this(getState(id, data));
}
- public static final BlockState getState(int id, int data) {
+ public static BlockState getState(int id, int data) {
BlockState blockState = LegacyMapper.getInstance().getBlockFromLegacy(id, data);
if (blockState == null) {
blockState = BlockTypes.AIR.getDefaultState();
@@ -138,6 +133,42 @@ public class BaseBlock implements BlockStateHolder {
this(other.toImmutableState(), other.getNbtData());
}
+ /**
+ * Gets a map of state to statevalue
+ *
+ * @return The state map
+ */
+ @Override
+ public Map, Object> getStates() {
+ return toImmutableState().getStates();
+ }
+
+ @Override
+ public BlockType getBlockType() {
+ return this.blockState.getBlockType();
+ }
+
+ @Override
+ public BaseBlock with(Property property, V value) {
+ return toImmutableState().with(property, value).toBaseBlock(getNbtData());
+ }
+
+ /**
+ * Gets the State for this Block.
+ *
+ * @param property The state to get the value for
+ * @return The state value
+ */
+ @Override
+ public V getState(Property property) {
+ return toImmutableState().getState(property);
+ }
+
+ @Override
+ public boolean hasNbtData() {
+ return getNbtData() != null;
+ }
+
@Override
public String getNbtId() {
CompoundTag nbtData = getNbtData();
@@ -180,11 +211,6 @@ public class BaseBlock implements BlockStateHolder {
return this.blockState.equalsFuzzy(otherBlock.blockState) && Objects.equals(getNbtData(), otherBlock.getNbtData());
}
- @Override
- public final BlockState toImmutableState() {
- return blockState;
- }
-
@Override
public int getInternalId() {
return blockState.getInternalId();
@@ -196,17 +222,24 @@ public class BaseBlock implements BlockStateHolder {
}
@Override
- public BlockType getBlockType() {
- return blockState.getBlockType();
+ public int getOrdinal() {
+ return blockState.getOrdinal();
}
- public BlockType getType() {
- return getBlockType();
+ /**
+ * Checks if the type is the same, and if the matched states are the same.
+ *
+ * @param o other block
+ * @return true if equal
+ */
+ @Override
+ public boolean equalsFuzzy(BlockStateHolder> o) {
+ return this.blockState.equalsFuzzy(o);
}
@Override
- public int getOrdinal() {
- return blockState.getOrdinal();
+ public BlockState toImmutableState() {
+ return this.blockState;
}
@Override
@@ -227,16 +260,11 @@ public class BaseBlock implements BlockStateHolder {
@Override
public int hashCode() {
- return getOrdinal();
- }
-
- @Override
- public String toString() {
- if (this.getNbtData() != null) {
- return getAsString() + " {" + String.valueOf(getNbtData()) + "}";
- } else {
- return getAsString();
+ int ret = toImmutableState().hashCode() << 3;
+ if (hasNbtData()) {
+ ret += getNbtData().hashCode();
}
+ return ret;
}
@Override
@@ -244,11 +272,6 @@ public class BaseBlock implements BlockStateHolder {
return extent.setBlock(set, this);
}
- @Override
- public boolean hasNbtData() {
- return this.nbtData != null;
- }
-
@Override
public BaseBlock withPropertyId(int propertyId) {
return getBlockType().withPropertyId(propertyId).toBaseBlock(getNbtData());
@@ -264,34 +287,23 @@ public class BaseBlock implements BlockStateHolder {
return toImmutableState().getInternalPropertiesId();
}
- @Override
- public BaseBlock with(Property property, V value) {
- return toImmutableState().with(property, value).toBaseBlock(getNbtData());
- }
-
@Override
public BaseBlock with(PropertyKey property, V value) {
return toImmutableState().with(property, value).toBaseBlock(getNbtData());
}
- @Override
- public V getState(Property property) {
- return toImmutableState().getState(property);
- }
-
@Override
public V getState(PropertyKey property) {
return toImmutableState().getState(property);
}
- @Override
- public Map, Object> getStates() {
- return toImmutableState().getStates();
- }
-
- @Override
- public boolean equalsFuzzy(BlockStateHolder o) {
- return toImmutableState().equalsFuzzy(o);
- }
+ @Override
+ public String toString() {
+ if (getNbtData() != null) {
+ return getAsString() + " {" + String.valueOf(getNbtData()) + "}";
+ } else {
+ return getAsString();
+ }
+ }
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeEnum.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeEnum.java
deleted file mode 100644
index 8e7b46314..000000000
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeEnum.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.sk89q.worldedit.world.block;
-
-public enum BlockTypeEnum {
-
-}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java
index 230b479ad..cb2d43167 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java
@@ -20,8 +20,6 @@
package com.sk89q.worldedit.world.block;
import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.collect.Maps;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
@@ -39,7 +37,7 @@ public class FuzzyBlockState extends BlockState {
private final Map props;
- public FuzzyBlockState(BlockType blockType) {
+ FuzzyBlockState(BlockType blockType) {
this(blockType.getDefaultState(), null);
}
@@ -181,4 +179,4 @@ public class FuzzyBlockState extends BlockState {
return this;
}
}
-}
\ No newline at end of file
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java
index 9d854a7af..3a2336754 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java
@@ -28,7 +28,6 @@ import com.sk89q.jnbt.NBTUtils;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
@@ -55,7 +54,7 @@ public class AnvilChunk implements Chunk {
/**
* Construct the chunk with a compound tag.
- *
+ *
* @param world the world to construct the chunk for
* @param tag the tag to read
* @throws DataException on a data error
@@ -69,19 +68,19 @@ public class AnvilChunk implements Chunk {
blocks = new byte[16][16 * 16 * 16];
blocksAdd = new byte[16][16 * 16 * 8];
data = new byte[16][16 * 16 * 8];
-
+
List sections = NBTUtils.getChildTag(rootTag.getValue(), "Sections", ListTag.class).getValue();
-
+
for (Tag rawSectionTag : sections) {
if (!(rawSectionTag instanceof CompoundTag)) {
continue;
}
-
+
CompoundTag sectionTag = (CompoundTag) rawSectionTag;
if (!sectionTag.getValue().containsKey("Y")) {
continue; // Empty section.
}
-
+
int y = NBTUtils.getChildTag(sectionTag.getValue(), "Y", ByteTag.class).getValue();
if (y < 0 || y >= 16) {
continue;
@@ -117,7 +116,7 @@ public class AnvilChunk implements Chunk {
}
}
}
-
+
private int getBlockID(BlockVector3 position) throws DataException {
int x = position.getX() - rootX * 16;
int y = position.getY();
@@ -127,14 +126,14 @@ public class AnvilChunk implements Chunk {
if (section < 0 || section >= blocks.length) {
throw new DataException("Chunk does not contain position " + position);
}
-
+
int yindex = y & 0x0F;
int index = x + (z * 16 + (yindex * 16 * 16));
-
+
try {
int addId = 0;
-
+
// The block ID is the combination of the Blocks byte array with the
// Add byte array. 'Blocks' stores the lowest 8 bits of a block's ID, and
// 'Add' stores the highest 4 bits of the ID. The first block is stored
@@ -144,7 +143,7 @@ public class AnvilChunk implements Chunk {
} else {
addId = (blocksAdd[section][index >> 1] & 0xF0) << 4;
}
-
+
return (blocks[section][index] & 0xFF) + addId;
} catch (IndexOutOfBoundsException e) {
throw new DataException("Chunk does not contain position " + position);
@@ -158,7 +157,7 @@ public class AnvilChunk implements Chunk {
int section = y >> 4;
int yIndex = y & 0x0F;
-
+
if (section < 0 || section >= blocks.length) {
throw new DataException("Chunk does not contain position " + position);
}
@@ -264,10 +263,12 @@ public class AnvilChunk implements Chunk {
}
if (state.getMaterial().hasContainer()) {
CompoundTag tileEntity = getBlockTileEntity(position);
+
if (tileEntity != null) {
return state.toBaseBlock(tileEntity);
}
}
+
return state.toBaseBlock();
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java
index ba5473839..c9e52424e 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java
@@ -54,7 +54,7 @@ public class AnvilChunk13 implements Chunk {
/**
* Construct the chunk with a compound tag.
- *
+ *
* @param tag the tag to read
* @throws DataException on a data error
*/
@@ -159,13 +159,14 @@ public class AnvilChunk13 implements Chunk {
* @throws DataException
*/
private void populateTileEntities() throws DataException {
- tileEntities = new HashMap<>();
if (!rootTag.getValue().containsKey("TileEntities")) {
return;
}
List tags = NBTUtils.getChildTag(rootTag.getValue(),
"TileEntities", ListTag.class).getValue();
+ tileEntities = new HashMap<>();
+
for (Tag tag : tags) {
if (!(tag instanceof CompoundTag)) {
throw new InvalidFormatException("CompoundTag expected in TileEntities");
@@ -221,6 +222,7 @@ public class AnvilChunk13 implements Chunk {
BlockState[] sectionBlocks = blocks[section];
BlockState state = sectionBlocks != null ? sectionBlocks[(yIndex << 8) | (z << 4) | x] : BlockTypes.AIR.getDefaultState();
+
if (state.getMaterial().hasContainer()) {
CompoundTag tileEntity = getBlockTileEntity(position);
return state.toBaseBlock(tileEntity);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java
index 6987622d3..01c721bc2 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java
@@ -20,7 +20,6 @@
package com.sk89q.worldedit.world.chunk;
import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.block.BaseBlock;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java
index 04f90411a..dfeeccca9 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java
@@ -61,7 +61,7 @@ public class OldChunk implements Chunk {
*/
public OldChunk(World world, CompoundTag tag) throws DataException {
rootTag = tag;
-
+
blocks = NBTUtils.getChildTag(rootTag.getValue(), "Blocks", ByteArrayTag.class).getValue();
data = NBTUtils.getChildTag(rootTag.getValue(), "Data", ByteArrayTag.class).getValue();
rootX = NBTUtils.getChildTag(rootTag.getValue(), "xPos", IntTag.class).getValue();
@@ -191,6 +191,7 @@ public class OldChunk implements Chunk {
return state.toBaseBlock(tileEntity);
}
}
+
return state.toBaseBlock();
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategory.java
index 1b0e4bd1e..c5efdb4b9 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategory.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategory.java
@@ -34,7 +34,6 @@ import java.util.Set;
public class ItemCategory extends Category {
public static final NamespacedRegistry REGISTRY = new NamespacedRegistry<>("item tag");
- private int internalId;
public ItemCategory(final String id) {
super(id);
@@ -57,5 +56,4 @@ public class ItemCategory extends Category {
public boolean contains(BaseItem baseItem) {
return this.getAll().contains(baseItem.getType());
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java
index a599d6a38..48170fe3f 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java
@@ -100,21 +100,17 @@ public class ItemType implements RegistryItem {
}
return this.blockType;
}
-
+
public void setBlockType(BlockType blockType) {
this.blockType = blockType;
}
-
+
public BaseItem getDefaultState() {
if (defaultState == null) {
this.defaultState = new BaseItemStack(this);
}
return this.defaultState;
}
-
- public void setDefaultState(BaseItem defaultState) {
- this.defaultState = defaultState;
- }
@Override
public String toString() {
@@ -130,4 +126,4 @@ public class ItemType implements RegistryItem {
public boolean equals(Object obj) {
return obj instanceof ItemType && this.id.equals(((ItemType) obj).id);
}
-}
\ No newline at end of file
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java
index 2b29803b0..64f24acc7 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java
@@ -834,24 +834,16 @@ public final class ItemTypes {
}
if (!input.split("\\[", 2)[0].contains(":")) input = "minecraft:" + input;
- ItemType result = get(input);
- return result;
+ return get(input);
}
- public static final @Nullable ItemType get(String id) {
+ public static @Nullable ItemType get(final String id) {
return ItemType.REGISTRY.get(id);
}
@Deprecated
- public static final ItemType get(final int ordinal) {
+ public static ItemType get(final int ordinal) {
return ItemType.REGISTRY.getByInternalId(ordinal);
}
- public static int size() {
- return ItemType.REGISTRY.size();
- }
-
- public static Collection values() {
- return ItemType.REGISTRY.values();
- }
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java
index f7b2d5837..3d318ef01 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java
@@ -73,17 +73,14 @@ public class BundledBlockData {
private void loadFromResource() throws IOException {
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
- gsonBuilder.registerTypeAdapter(int.class, new JsonDeserializer() {
- @Override
- public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
- JsonPrimitive primitive = (JsonPrimitive) json;
- if (primitive.isString()) {
- String value = primitive.getAsString();
- if (value.charAt(0) == '#') return Integer.parseInt(value.substring(1), 16);
- return Integer.parseInt(value);
- }
- return primitive.getAsInt();
+ gsonBuilder.registerTypeAdapter(int.class, (JsonDeserializer) (json, typeOfT, context) -> {
+ JsonPrimitive primitive = (JsonPrimitive) json;
+ if (primitive.isString()) {
+ String value = primitive.getAsString();
+ if (value.charAt(0) == '#') return Integer.parseInt(value.substring(1), 16);
+ return Integer.parseInt(value);
}
+ return primitive.getAsInt();
});
Gson gson = gsonBuilder.create();
URL url = BundledBlockData.class.getResource("blocks.json");
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemRegistry.java
index ae7cb2b2b..1ab788e42 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemRegistry.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemRegistry.java
@@ -22,8 +22,6 @@ package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.world.item.ItemType;
import javax.annotation.Nullable;
-import java.util.Collection;
-import java.util.Collections;
/**
* A item registry that uses {@link BundledItemRegistry} to serve information
@@ -46,9 +44,4 @@ public class BundledItemRegistry implements ItemRegistry {
}
return null;
}
-
- @Override
- public Collection registerItems() {
- return Collections.emptyList();
- }
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java
index bc25c7cb1..c44be9b8c 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java
@@ -22,18 +22,9 @@ package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.world.item.ItemType;
import javax.annotation.Nullable;
-import java.util.Collection;
-import java.util.Collections;
public interface ItemRegistry {
- /**
- * Register all items
- */
- default Collection registerItems() {
- return Collections.emptyList();
- }
-
/**
* Gets the name for the given item.
*
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java
index d0c3f3d3a..fb7b9a83b 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java
@@ -94,7 +94,6 @@ public class LegacyMapper {
for (Map.Entry blockEntry : dataFile.blocks.entrySet()) {
try {
BlockStateHolder blockState = BlockState.get(null, blockEntry.getValue());
-// BlockState blockState = WorldEdit.getInstance().getBlockFactory().parseFromInput(blockEntry.getValue(), parserContext).toImmutableState();
BlockType type = blockState.getBlockType();
if (type.hasProperty(PropertyKey.WATERLOGGED)) {
blockState = blockState.with(PropertyKey.WATERLOGGED, false);
@@ -160,7 +159,11 @@ public class LegacyMapper {
@Nullable
public int[] getLegacyFromItem(ItemType itemType) {
Integer combinedId = getLegacyCombined(itemType);
- return combinedId == null ? null : new int[] { combinedId >> 4, combinedId & 0xF };
+ if (combinedId == null) {
+ return null;
+ } else {
+ return new int[]{combinedId >> 4, combinedId & 0xF};
+ }
}
@Nullable
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java
index 871e4fb15..319503740 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java
@@ -114,7 +114,6 @@ public abstract class ChunkStore implements Closeable {
return new OldChunk(world, tag);
}
- @Override
public void close() throws IOException {
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/weather/WeatherTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/weather/WeatherTypes.java
index 7d8cfc4b3..d7450610d 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/weather/WeatherTypes.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/weather/WeatherTypes.java
@@ -37,7 +37,6 @@ public class WeatherTypes {
private WeatherTypes() {
}
-
public static @Nullable WeatherType get(final String id) {
return WeatherType.REGISTRY.get(id);
}