diff --git a/src/bukkit-test/java/com/sk89q/wepif/TestOfflinePermissible.java b/src/bukkit-test/java/com/sk89q/wepif/TestOfflinePermissible.java
index b309927cf..81e41e9d7 100644
--- a/src/bukkit-test/java/com/sk89q/wepif/TestOfflinePermissible.java
+++ b/src/bukkit-test/java/com/sk89q/wepif/TestOfflinePermissible.java
@@ -36,22 +36,27 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible {
private final Map
NBT data is later loaded using a call to {@link Extent#getBlock(Vector)} + * with a stored {@link Extent} and location.
+ * + *All mutators on this object will throw an + * {@link UnsupportedOperationException}.
*/ public class LazyBlock extends BaseBlock { diff --git a/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java index 78bd8c7d3..2c5a4a6b6 100644 --- a/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java @@ -33,8 +33,6 @@ import java.util.Map; /** * A mob spawner block. - * - * @author sk89q */ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock { @@ -247,6 +245,6 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock { if (spawnDataTag != null) { this.spawnData = new CompoundTag("SpawnData", spawnDataTag.getValue()); } - } + } diff --git a/src/legacy/java/com/sk89q/worldedit/blocks/NoteBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/NoteBlock.java index 0f5c819e3..ee479d4f3 100644 --- a/src/legacy/java/com/sk89q/worldedit/blocks/NoteBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/NoteBlock.java @@ -29,8 +29,6 @@ import java.util.Map; /** * A note block. - * - * @author sk89q */ public class NoteBlock extends BaseBlock implements TileEntityBlock { @@ -120,4 +118,5 @@ public class NoteBlock extends BaseBlock implements TileEntityBlock { note = ((ByteTag) t).getValue(); } } + } diff --git a/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java index e4d36c0d2..9801aebff 100644 --- a/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java @@ -28,8 +28,6 @@ import java.util.Map; /** * Represents a sign block. - * - * @author sk89q */ public class SignBlock extends BaseBlock implements TileEntityBlock { @@ -139,4 +137,5 @@ public class SignBlock extends BaseBlock implements TileEntityBlock { text[3] = ((StringTag) t).getValue(); } } + } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/BlockMask.java b/src/legacy/java/com/sk89q/worldedit/masks/BlockMask.java index f503a9e74..a6dd9ab97 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/BlockMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/BlockMask.java @@ -64,8 +64,8 @@ public class BlockMask extends AbstractMask { } @Override - public boolean matches(EditSession editSession, Vector pos) { - BaseBlock block = editSession.getBlock(pos); + public boolean matches(EditSession editSession, Vector position) { + BaseBlock block = editSession.getBlock(position); return blocks.contains(block) || blocks.contains(new BaseBlock(block.getType(), -1)); } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/BlockTypeMask.java b/src/legacy/java/com/sk89q/worldedit/masks/BlockTypeMask.java index f504193bb..5d195c4fc 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/BlockTypeMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/BlockTypeMask.java @@ -19,17 +19,18 @@ package com.sk89q.worldedit.masks; -import java.util.Set; import com.sk89q.worldedit.blocks.BaseBlock; +import java.util.Set; + /** * A filter that matches blocks based on block types. * - * @deprecated replaced by {@link #BlockMask} - * @author sk89q + * @deprecated replaced by {@link #BlockMask} */ @Deprecated public class BlockTypeMask extends BlockMask { + public BlockTypeMask() { super(); } @@ -49,4 +50,5 @@ public class BlockTypeMask extends BlockMask { public void add(int type) { add(new BaseBlock(type)); } + } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/CombinedMask.java b/src/legacy/java/com/sk89q/worldedit/masks/CombinedMask.java index a78c0cfc4..3f7a6690e 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/CombinedMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/CombinedMask.java @@ -72,9 +72,9 @@ public class CombinedMask extends AbstractMask { } @Override - public boolean matches(EditSession editSession, Vector pos) { + public boolean matches(EditSession editSession, Vector position) { for (Mask mask : masks) { - if (!mask.matches(editSession, pos)) { + if (!mask.matches(editSession, position)) { return false; } } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/DynamicRegionMask.java b/src/legacy/java/com/sk89q/worldedit/masks/DynamicRegionMask.java index c7c061a96..ebe866f57 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/DynamicRegionMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/DynamicRegionMask.java @@ -40,7 +40,7 @@ public class DynamicRegionMask extends AbstractMask { } @Override - public boolean matches(EditSession editSession, Vector pos) { - return region == null || region.contains(pos); + public boolean matches(EditSession editSession, Vector position) { + return region == null || region.contains(position); } } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/ExistingBlockMask.java b/src/legacy/java/com/sk89q/worldedit/masks/ExistingBlockMask.java index 5a559572b..487786d06 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/ExistingBlockMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/ExistingBlockMask.java @@ -29,7 +29,7 @@ import com.sk89q.worldedit.blocks.BlockID; @Deprecated public class ExistingBlockMask extends AbstractMask { @Override - public boolean matches(EditSession editSession, Vector pos) { - return editSession.getBlockType(pos) != BlockID.AIR; + public boolean matches(EditSession editSession, Vector position) { + return editSession.getBlockType(position) != BlockID.AIR; } } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/FuzzyBlockMask.java b/src/legacy/java/com/sk89q/worldedit/masks/FuzzyBlockMask.java index 8118d6308..63093624c 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/FuzzyBlockMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/FuzzyBlockMask.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.Blocks; +import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -51,15 +52,13 @@ public class FuzzyBlockMask extends AbstractMask { */ public FuzzyBlockMask(BaseBlock... block) { SetTAG_End
tag.
- *
- * @author Graham Edgecombe
- *
+ * The {@code TAG_End} tag.
*/
public final class EndTag extends Tag {
diff --git a/src/main/java/com/sk89q/jnbt/IntArrayTag.java b/src/main/java/com/sk89q/jnbt/IntArrayTag.java
index b8dced001..58b318c79 100644
--- a/src/main/java/com/sk89q/jnbt/IntArrayTag.java
+++ b/src/main/java/com/sk89q/jnbt/IntArrayTag.java
@@ -71,7 +71,7 @@ public final class IntArrayTag extends Tag {
if (name != null && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
- return "TAG_Int_Array" + append + ": " + hex.toString();
+ return "TAG_Int_Array" + append + ": " + hex;
}
}
diff --git a/src/main/java/com/sk89q/jnbt/ListTag.java b/src/main/java/com/sk89q/jnbt/ListTag.java
index 4125b43ee..b03e35d33 100644
--- a/src/main/java/com/sk89q/jnbt/ListTag.java
+++ b/src/main/java/com/sk89q/jnbt/ListTag.java
@@ -437,12 +437,9 @@ public final class ListTag extends Tag {
append = "(\"" + this.getName() + "\")";
}
StringBuilder bldr = new StringBuilder();
- bldr.append("TAG_List" + append + ": " + value.size()
- + " entries of type " + NBTUtils.getTypeName(type)
- + "\r\n{\r\n");
+ bldr.append("TAG_List").append(append).append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n");
for (Tag t : value) {
- bldr.append(" " + t.toString().replaceAll("\r\n", "\r\n ")
- + "\r\n");
+ bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
}
bldr.append("}");
return bldr.toString();
diff --git a/src/main/java/com/sk89q/jnbt/NBTConstants.java b/src/main/java/com/sk89q/jnbt/NBTConstants.java
index 7c8001b43..2ff2768ac 100644
--- a/src/main/java/com/sk89q/jnbt/NBTConstants.java
+++ b/src/main/java/com/sk89q/jnbt/NBTConstants.java
@@ -23,9 +23,6 @@ import java.nio.charset.Charset;
/**
* A class which holds constant values.
- *
- * @author Graham Edgecombe
- *
*/
public final class NBTConstants {
diff --git a/src/main/java/com/sk89q/jnbt/NBTInputStream.java b/src/main/java/com/sk89q/jnbt/NBTInputStream.java
index 1d1c5215b..31fab63a1 100644
--- a/src/main/java/com/sk89q/jnbt/NBTInputStream.java
+++ b/src/main/java/com/sk89q/jnbt/NBTInputStream.java
@@ -29,20 +29,13 @@ import java.util.List;
import java.util.Map;
/**
- *
* This class reads NBT, or Named Binary Tag
- * streams, and produces an object graph of subclasses of the Tag
+ * streams, and produces an object graph of subclasses of the {@code Tag}
* object.
- *
- * The NBT format was created by Markus Persson, and the specification may be + *
The NBT format was created by Markus Persson, and the specification may be * found at - * http://www.minecraft.net/docs/NBT.txt. - *
- * - * @author Graham Edgecombe - * + * http://www.minecraft.net/docs/NBT.txt. */ public final class NBTInputStream implements Closeable { diff --git a/src/main/java/com/sk89q/jnbt/NBTOutputStream.java b/src/main/java/com/sk89q/jnbt/NBTOutputStream.java index d9a56f666..eabc87d28 100644 --- a/src/main/java/com/sk89q/jnbt/NBTOutputStream.java +++ b/src/main/java/com/sk89q/jnbt/NBTOutputStream.java @@ -26,19 +26,12 @@ import java.io.OutputStream; import java.util.List; /** - *
* This class writes NBT, or Named Binary Tag
- * Tag
objects to an underlying OutputStream
.
- *
- * The NBT format was created by Markus Persson, and the specification may be + *
The NBT format was created by Markus Persson, and the specification may be * found at - * http://www.minecraft.net/docs/NBT.txt. - *
- * - * @author Graham Edgecombe - * + * http://www.minecraft.net/docs/NBT.txt. */ public final class NBTOutputStream implements Closeable { @@ -48,7 +41,7 @@ public final class NBTOutputStream implements Closeable { private final DataOutputStream os; /** - * Creates a newNBTOutputStream
, which will write data to the
+ * Creates a new {@code NBTOutputStream}, which will write data to the
* specified underlying output stream.
*
* @param os
@@ -137,7 +130,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
- * Writes a TAG_Byte
tag.
+ * Writes a {@code TAG_Byte} tag.
*
* @param tag
* The tag.
@@ -149,7 +142,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
- * Writes a TAG_Byte_Array
tag.
+ * Writes a {@code TAG_Byte_Array} tag.
*
* @param tag
* The tag.
@@ -163,7 +156,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
- * Writes a TAG_Compound
tag.
+ * Writes a {@code TAG_Compound} tag.
*
* @param tag
* The tag.
@@ -178,7 +171,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
- * Writes a TAG_List
tag.
+ * Writes a {@code TAG_List} tag.
*
* @param tag
* The tag.
@@ -192,13 +185,13 @@ public final class NBTOutputStream implements Closeable {
os.writeByte(NBTUtils.getTypeCode(clazz));
os.writeInt(size);
- for (int i = 0; i < size; ++i) {
- writeTagPayload(tags.get(i));
+ for (Tag tag1 : tags) {
+ writeTagPayload(tag1);
}
}
/**
- * Writes a TAG_String
tag.
+ * Writes a {@code TAG_String} tag.
*
* @param tag
* The tag.
@@ -212,7 +205,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
- * Writes a TAG_Double
tag.
+ * Writes a {@code TAG_Double} tag.
*
* @param tag
* The tag.
@@ -224,7 +217,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
- * Writes a TAG_Float
tag.
+ * Writes a {@code TAG_Float} tag.
*
* @param tag
* The tag.
@@ -236,7 +229,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
- * Writes a TAG_Long
tag.
+ * Writes a {@code TAG_Long} tag.
*
* @param tag
* The tag.
@@ -248,7 +241,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
- * Writes a TAG_Int
tag.
+ * Writes a {@code TAG_Int} tag.
*
* @param tag
* The tag.
@@ -260,7 +253,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
- * Writes a TAG_Short
tag.
+ * Writes a {@code TAG_Short} tag.
*
* @param tag
* The tag.
@@ -272,12 +265,9 @@ public final class NBTOutputStream implements Closeable {
}
/**
- * Writes a TAG_Empty
tag.
+ * Writes a {@code TAG_Empty} tag.
*
- * @param tag
- * The tag.
- * @throws IOException
- * if an I/O error occurs.
+ * @param tag the tag
*/
private void writeEndTagPayload(EndTag tag) {
/* empty */
@@ -286,11 +276,12 @@ public final class NBTOutputStream implements Closeable {
private void writeIntArrayTagPayload(IntArrayTag tag) throws IOException {
int[] data = tag.getValue();
os.writeInt(data.length);
- for (int i = 0; i < data.length; i++) {
- os.writeInt(data[i]);
+ for (int aData : data) {
+ os.writeInt(aData);
}
}
+ @Override
public void close() throws IOException {
os.close();
}
diff --git a/src/main/java/com/sk89q/jnbt/NBTUtils.java b/src/main/java/com/sk89q/jnbt/NBTUtils.java
index 20b3e5542..428ff4d86 100644
--- a/src/main/java/com/sk89q/jnbt/NBTUtils.java
+++ b/src/main/java/com/sk89q/jnbt/NBTUtils.java
@@ -20,8 +20,6 @@
package com.sk89q.jnbt;
import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.extent.Extent;
-import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.storage.InvalidFormatException;
import java.util.Map;
@@ -171,14 +169,13 @@ public final class NBTUtils {
/**
* Get child tag of a NBT structure.
*
- * @param items
- * @param key
- * @param expected
+ * @param items the map to read from
+ * @param key the key to look for
+ * @param expected the expected NBT class type
* @return child tag
* @throws InvalidFormatException
*/
- public static [-h harps] [name] [message]
.
+ * {@code [-h harps] [name] [message]}.
*
* @return Usage instructions for a command
*/
@@ -85,9 +84,10 @@ public @interface Command {
String help() default "";
/**
+ * Get whether any flag can be used.
*
- *
- * @return Whether any flag can be provided to the command, even if it is not in {@link #flags()}
+ * @return true if so
*/
boolean anyFlags() default false;
+
}
diff --git a/src/main/java/com/sk89q/minecraft/util/commands/CommandAlias.java b/src/main/java/com/sk89q/minecraft/util/commands/CommandAlias.java
index 61042b97e..59ba3e4a4 100644
--- a/src/main/java/com/sk89q/minecraft/util/commands/CommandAlias.java
+++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandAlias.java
@@ -26,16 +26,15 @@ import java.lang.annotation.RetentionPolicy;
* Any command with this annotation will run the raw command as shown in the
* thing, as long as it is registered in the current {@link CommandsManager}.
* Mostly to move commands around without breaking things.
- *
- * @author zml2008
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface CommandAlias {
/**
+ * Get the raw {@link CommandsManager}-formatted command arg array to run
*
- * @return Raw {@link CommandsManager}-formatted command arg array to run
+ * @return the command
*/
String[] value();
}
diff --git a/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java b/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java
index 7f1a4e185..34bc2540c 100644
--- a/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java
+++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java
@@ -94,7 +94,7 @@ public class CommandContext {
isHanging = false;
String arg = args[i];
- if (arg.length() == 0) {
+ if (arg.isEmpty()) {
isHanging = true;
continue;
}
@@ -127,7 +127,7 @@ public class CommandContext {
}
// In case there is an empty quoted string
- if (arg.length() == 0) {
+ if (arg.isEmpty()) {
continue;
}
// else raise exception about hanging quotes?
diff --git a/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java b/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java
index 968c31e6a..e81344e56 100644
--- a/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java
+++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java
@@ -27,8 +27,7 @@ import java.util.ListIterator;
import static com.google.common.base.Preconditions.checkNotNull;
public class CommandException extends Exception {
-
- private static final long serialVersionUID = 870638193072101739L;
+
private ListManager for handling commands. This allows you to easily process commands, - * including nested commands, by correctly annotating methods of a class.
+ * Manager for handling commands. This allows you to easily process commands, + * including nested commands, by correctly annotating methods of a class. * *To use this, it is merely a matter of registering classes containing
* the commands (as methods with the proper annotations) with the
* manager. When you want to process a command, use one of the
- * execute
methods. If something is wrong, such as incorrect
+ * {@code execute} methods. If something is wrong, such as incorrect
* usage, insufficient permissions, or a missing command altogether, an
* exception will be raised for upstream handling.
null
+ * @throws IllegalArgumentException if either String input {@code null}
*/
public static int getLevenshteinDistance(String s, String t) {
if (s == null || t == null) {
@@ -238,9 +232,9 @@ public final class StringUtil {
return n;
}
- int p[] = new int[n + 1]; // 'previous' cost array, horizontally
- int d[] = new int[n + 1]; // cost array, horizontally
- int _d[]; // placeholder to assist in swapping p and d
+ int[] p = new int[n + 1]; // 'previous' cost array, horizontally
+ int[] d = new int[n + 1]; // cost array, horizontally
+ int[] _d; // placeholder to assist in swapping p and d
// indexes into strings s and t
int i; // iterates through s
diff --git a/src/main/java/com/sk89q/util/yaml/YAMLNode.java b/src/main/java/com/sk89q/util/yaml/YAMLNode.java
index 662498b7d..ff0bda3a4 100644
--- a/src/main/java/com/sk89q/util/yaml/YAMLNode.java
+++ b/src/main/java/com/sk89q/util/yaml/YAMLNode.java
@@ -23,6 +23,7 @@ import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
+import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
@@ -30,10 +31,9 @@ import java.util.Map;
/**
* Represents a configuration node.
- *
- * @author sk89q
*/
public class YAMLNode {
+
protected MapsetProperty
.
+ * the same path. See {@code setProperty}.
*
- * @param path
- * @return
+ * @param path the path
+ * @return a node for the path
*/
public YAMLNode addNode(String path) {
MapCalling code could access sturmeh's baby eating state by using
- * getBoolean("sturmeh.eats.babies", false)
. For lists, there are
- * methods such as getStringList
that will return a type safe list.
- *
- *
- * @author sk89q
+ * {@code getBoolean("sturmeh.eats.babies", false)}. For lists, there are
+ * methods such as {@code getStringList} that will return a type safe list.
*/
public class YAMLProcessor extends YAMLNode {
+
public static final String LINE_BREAK = DumperOptions.LineBreak.getPlatformLineBreak().getString();
public static final char COMMENT_CHAR = '#';
protected final Yaml yaml;
@@ -117,7 +116,7 @@ public class YAMLProcessor extends YAMLNode {
if (stream != null) {
stream.close();
}
- } catch (IOException e) {
+ } catch (IOException ignored) {
}
}
}
@@ -156,7 +155,7 @@ public class YAMLProcessor extends YAMLNode {
/**
* Return the set header.
*
- * @return
+ * @return the header text
*/
public String getHeader() {
return header;
@@ -184,13 +183,11 @@ public class YAMLProcessor extends YAMLNode {
writer.append(header);
writer.append(LINE_BREAK);
}
- if (comments.size() == 0 || format != YAMLFormat.EXTENDED) {
+ if (comments.isEmpty() || format != YAMLFormat.EXTENDED) {
yaml.dump(root, writer);
} else {
// Iterate over each root-level property and dump
- for (Iteratornull
+ * @return the comment or {@code null}
*/
public String getComment(String key) {
return comments.get(key);
@@ -259,7 +256,7 @@ public class YAMLProcessor extends YAMLNode {
* Set a root-level comment.
*
* @param key the property key
- * @param comment the comment. May be null
, in which case the comment
+ * @param comment the comment. May be {@code null}, in which case the comment
* is removed.
*/
public void setComment(String key, String... comment) {
@@ -300,7 +297,8 @@ public class YAMLProcessor extends YAMLNode {
/**
* This method returns an empty ConfigurationNode for using as a
* default in methods that select a node from a node list.
- * @return
+ *
+ * @return a node
*/
public static YAMLNode getEmptyNode(boolean writeDefaults) {
return new YAMLNode(new LinkedHashMap
Fast mode may skip lighting checks or adjacent block + * notification.
* * @param enabled true to enable */ @@ -330,13 +335,14 @@ public class EditSession implements Extent { /** * Return fast mode status. - * - * Fast mode may skip lighting checks or adjacent block notification. + * + *Fast mode may skip lighting checks or adjacent block + * notification.
* * @return true if enabled */ public boolean hasFastMode() { - return fastModeExtent != null ? fastModeExtent.isEnabled() : false; + return fastModeExtent != null && fastModeExtent.isEnabled(); } /** @@ -369,8 +375,8 @@ public class EditSession implements Extent { /** * Get the number of blocks changed, including repeated block changes. - * - * This number may not be accurate. + * + *This number may not be accurate.
* * @return the number of block changes */ @@ -1486,15 +1492,14 @@ public class EditSession implements Extent { /** * Makes a pyramid. * - * @param pos - * @param block - * @param size - * @param filled + * @param position a position + * @param block a block + * @param size size of pyramid + * @param filled true if filled * @return number of blocks changed * @throws MaxChangedBlocksException */ - public int makePyramid(Vector pos, Pattern block, int size, - boolean filled) throws MaxChangedBlocksException { + public int makePyramid(Vector position, Pattern block, int size, boolean filled) throws MaxChangedBlocksException { int affected = 0; int height = size; @@ -1506,16 +1511,16 @@ public class EditSession implements Extent { if ((filled && z <= size && x <= size) || z == size || x == size) { - if (setBlock(pos.add(x, y, z), block)) { + if (setBlock(position.add(x, y, z), block)) { ++affected; } - if (setBlock(pos.add(-x, y, z), block)) { + if (setBlock(position.add(-x, y, z), block)) { ++affected; } - if (setBlock(pos.add(x, y, -z), block)) { + if (setBlock(position.add(x, y, -z), block)) { ++affected; } - if (setBlock(pos.add(-x, y, -z), block)) { + if (setBlock(position.add(-x, y, -z), block)) { ++affected; } } @@ -1527,21 +1532,21 @@ public class EditSession implements Extent { } /** - * Thaw. + * Thaw blocks in a radius. * - * @param pos - * @param radius + * @param position the position + * @param radius the radius * @return number of blocks affected * @throws MaxChangedBlocksException */ - public int thaw(Vector pos, double radius) + public int thaw(Vector position, double radius) throws MaxChangedBlocksException { int affected = 0; double radiusSq = radius * radius; - int ox = pos.getBlockX(); - int oy = pos.getBlockY(); - int oz = pos.getBlockZ(); + int ox = position.getBlockX(); + int oy = position.getBlockY(); + int oz = position.getBlockZ(); BaseBlock air = new BaseBlock(0); BaseBlock water = new BaseBlock(BlockID.STATIONARY_WATER); @@ -1549,7 +1554,7 @@ public class EditSession implements Extent { int ceilRadius = (int) Math.ceil(radius); for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) { for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) { - if ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) { + if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) { continue; } @@ -1586,21 +1591,20 @@ public class EditSession implements Extent { } /** - * Make snow. + * Make snow in a radius. * - * @param pos - * @param radius + * @param position a position + * @param radius a radius * @return number of blocks affected * @throws MaxChangedBlocksException */ - public int simulateSnow(Vector pos, double radius) - throws MaxChangedBlocksException { + public int simulateSnow(Vector position, double radius) throws MaxChangedBlocksException { int affected = 0; double radiusSq = radius * radius; - int ox = pos.getBlockX(); - int oy = pos.getBlockY(); - int oz = pos.getBlockZ(); + int ox = position.getBlockX(); + int oy = position.getBlockY(); + int oz = position.getBlockZ(); BaseBlock ice = new BaseBlock(BlockID.ICE); BaseBlock snow = new BaseBlock(BlockID.SNOW); @@ -1608,7 +1612,7 @@ public class EditSession implements Extent { int ceilRadius = (int) Math.ceil(radius); for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) { for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) { - if ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) { + if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) { continue; } @@ -1651,44 +1655,43 @@ public class EditSession implements Extent { } /** - * Green. + * Make dirt green. * - * @param pos - * @param radius + * @param position a position + * @param radius a radius * @return number of blocks affected * @throws MaxChangedBlocksException * @deprecated Use {@link #green(Vector, double, boolean)}. */ @Deprecated - public int green(Vector pos, double radius) - throws MaxChangedBlocksException { - return green(pos, radius, true); + public int green(Vector position, double radius) throws MaxChangedBlocksException { + return green(position, radius, true); } /** - * Green. + * Make dirt green. * - * @param pos - * @param radius + * @param position a position + * @param radius a radius * @param onlyNormalDirt only affect normal dirt (data value 0) * @return number of blocks affected * @throws MaxChangedBlocksException */ - public int green(Vector pos, double radius, boolean onlyNormalDirt) + public int green(Vector position, double radius, boolean onlyNormalDirt) throws MaxChangedBlocksException { int affected = 0; final double radiusSq = radius * radius; - final int ox = pos.getBlockX(); - final int oy = pos.getBlockY(); - final int oz = pos.getBlockZ(); + final int ox = position.getBlockX(); + final int oy = position.getBlockY(); + final int oz = position.getBlockZ(); final BaseBlock grass = new BaseBlock(BlockID.GRASS); final int ceilRadius = (int) Math.ceil(radius); for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) { for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) { - if ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) { + if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) { continue; } @@ -1758,23 +1761,22 @@ public class EditSession implements Extent { /** * Makes a forest. * - * @param basePos - * @param size - * @param density - * @param treeGenerator + * @param basePosition a position + * @param size a size + * @param density between 0 and 1, inclusive + * @param treeGenerator the tree genreator * @return number of trees created * @throws MaxChangedBlocksException */ - public int makeForest(Vector basePos, int size, double density, - TreeGenerator treeGenerator) throws MaxChangedBlocksException { + public int makeForest(Vector basePosition, int size, double density, TreeGenerator treeGenerator) throws MaxChangedBlocksException { int affected = 0; - for (int x = basePos.getBlockX() - size; x <= basePos.getBlockX() + for (int x = basePosition.getBlockX() - size; x <= basePosition.getBlockX() + size; ++x) { - for (int z = basePos.getBlockZ() - size; z <= basePos.getBlockZ() + for (int z = basePosition.getBlockZ() - size; z <= basePosition.getBlockZ() + size; ++z) { // Don't want to be in the ground - if (!getBlock(new Vector(x, basePos.getBlockY(), z)).isAir()) { + if (!getBlock(new Vector(x, basePosition.getBlockY(), z)).isAir()) { continue; } // The gods don't want a tree here @@ -1782,7 +1784,7 @@ public class EditSession implements Extent { continue; } // def 0.05 - for (int y = basePos.getBlockY(); y >= basePos.getBlockY() - 10; --y) { + for (int y = basePosition.getBlockY(); y >= basePosition.getBlockY() - 10; --y) { // Check if we hit the ground int t = getBlock(new Vector(x, y, z)).getType(); if (t == BlockID.GRASS || t == BlockID.DIRT) { @@ -1804,8 +1806,8 @@ public class EditSession implements Extent { /** * Get the block distribution inside a region. * - * @param region - * @return + * @param region a region + * @return the results */ public ListLocation
+ * Return this object as a new preferred {@code Location}
* object.
*
* @return a new location object
diff --git a/src/main/java/com/sk89q/worldedit/WorldVector2D.java b/src/main/java/com/sk89q/worldedit/WorldVector2D.java
index 72cc761f6..35a261b2a 100644
--- a/src/main/java/com/sk89q/worldedit/WorldVector2D.java
+++ b/src/main/java/com/sk89q/worldedit/WorldVector2D.java
@@ -56,12 +56,6 @@ public class WorldVector2D extends Vector2D {
return world;
}
- /**
- * Checks if another object is equivalent.
- *
- * @param obj
- * @return whether the other object is equivalent
- */
@Override
public boolean equals(Object obj) {
if (!(obj instanceof WorldVector2D)) {
diff --git a/src/main/java/com/sk89q/worldedit/WorldVectorFace.java b/src/main/java/com/sk89q/worldedit/WorldVectorFace.java
index db21a075d..306b2ea34 100644
--- a/src/main/java/com/sk89q/worldedit/WorldVectorFace.java
+++ b/src/main/java/com/sk89q/worldedit/WorldVectorFace.java
@@ -22,71 +22,32 @@ package com.sk89q.worldedit;
/**
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
*/
+@SuppressWarnings("deprecation")
@Deprecated
public class WorldVectorFace extends WorldVector {
private VectorFace face;
- /**
- * Construct the Vector object.
- *
- * @param world
- * @param x
- * @param y
- * @param z
- * @param face
- */
public WorldVectorFace(LocalWorld world, double x, double y, double z, VectorFace face) {
super(world, x, y, z);
this.face = face;
}
- /**
- * Construct the Vector object.
- *
- * @param world
- * @param x
- * @param y
- * @param z
- * @param face
- */
public WorldVectorFace(LocalWorld world, int x, int y, int z, VectorFace face) {
super(world, x, y, z);
this.face = face;
}
- /**
- * Construct the Vector object.
- *
- * @param world
- * @param x
- * @param y
- * @param z
- * @param face
- */
public WorldVectorFace(LocalWorld world, float x, float y, float z, VectorFace face) {
super(world, x, y, z);
this.face = face;
}
- /**
- * Construct the Vector object.
- *
- * @param world
- * @param pt
- * @param face
- */
public WorldVectorFace(LocalWorld world, Vector pt, VectorFace face) {
super(world, pt);
this.face = face;
}
- /**
- * Construct the Vector object.
- *
- * @param world
- * @param face
- */
public WorldVectorFace(LocalWorld world, VectorFace face) {
super(world);
this.face = face;
@@ -95,7 +56,7 @@ public class WorldVectorFace extends WorldVector {
/**
* Get the face.
*
- * @return
+ * @return the face
*/
public VectorFace getFace() {
return face;
@@ -104,7 +65,7 @@ public class WorldVectorFace extends WorldVector {
/**
* Get the WorldVector adjacent to this WorldVectorFace.
*
- * @return
+ * @return the face vector
*/
public WorldVector getFaceVector() {
return new WorldVector(getWorld(),
@@ -120,7 +81,7 @@ public class WorldVectorFace extends WorldVector {
* @param world the world in which the resulting vector should lie
* @param vector the original vector
* @param face the direction in which the face should lie
- * @return
+ * @return a face
*/
public static WorldVectorFace getWorldVectorFace(LocalWorld world, Vector vector, Vector face) {
if (vector == null || face == null) return null;
diff --git a/src/main/java/com/sk89q/worldedit/blocks/BlockData.java b/src/main/java/com/sk89q/worldedit/blocks/BlockData.java
index 8ff768d2d..f7f460892 100644
--- a/src/main/java/com/sk89q/worldedit/blocks/BlockData.java
+++ b/src/main/java/com/sk89q/worldedit/blocks/BlockData.java
@@ -971,8 +971,9 @@ public final class BlockData {
/**
* Returns the data value for the next color of cloth in the rainbow. This
* should not be used if you want to just increment the data value.
- * @param data
- * @return
+ *
+ * @param data the data value
+ * @return the next data value
*/
public static int nextClothColor(int data) {
switch (data) {
diff --git a/src/main/java/com/sk89q/worldedit/blocks/BlockType.java b/src/main/java/com/sk89q/worldedit/blocks/BlockType.java
index 0b4e662f8..4e00f8eac 100644
--- a/src/main/java/com/sk89q/worldedit/blocks/BlockType.java
+++ b/src/main/java/com/sk89q/worldedit/blocks/BlockType.java
@@ -34,10 +34,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* Block types.
- *
- * @author sk89q
*/
public enum BlockType {
+
AIR(BlockID.AIR, "Air", "air"),
STONE(BlockID.STONE, "Stone", "stone", "rock"),
GRASS(BlockID.GRASS, "Grass", "grass"),
@@ -1829,4 +1828,5 @@ public enum BlockType {
dataAttachments.put(typeDataKey(type, east), PlayerDirection.EAST);
dataAttachments.put(typeDataKey(type, south), PlayerDirection.SOUTH);
}
+
}
diff --git a/src/main/java/com/sk89q/worldedit/blocks/metadata/MobType.java b/src/main/java/com/sk89q/worldedit/blocks/metadata/MobType.java
index b498c9d7d..fbd28b32a 100644
--- a/src/main/java/com/sk89q/worldedit/blocks/metadata/MobType.java
+++ b/src/main/java/com/sk89q/worldedit/blocks/metadata/MobType.java
@@ -53,7 +53,7 @@ public enum MobType {
WOLF("Wolf"),
ZOMBIE("Zombie");
- private String name;
+ private final String name;
private MobType(String name) {
this.name = name;
@@ -62,4 +62,5 @@ public enum MobType {
public String getName() {
return name;
}
+
}
diff --git a/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java b/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java
index 19cef7ff9..4d8aa6f8f 100644
--- a/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java
+++ b/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java
@@ -173,7 +173,7 @@ public class GeneralCommands {
}
return;
- } catch (NumberFormatException e) {
+ } catch (NumberFormatException ignored) {
}
if (query.length() <= 2) {
diff --git a/src/main/java/com/sk89q/worldedit/command/InsufficientArgumentsException.java b/src/main/java/com/sk89q/worldedit/command/InsufficientArgumentsException.java
index 64649118a..796b8e645 100644
--- a/src/main/java/com/sk89q/worldedit/command/InsufficientArgumentsException.java
+++ b/src/main/java/com/sk89q/worldedit/command/InsufficientArgumentsException.java
@@ -21,14 +21,10 @@ package com.sk89q.worldedit.command;
import com.sk89q.worldedit.WorldEditException;
-/**
- *
- * @author sk89q
- */
public class InsufficientArgumentsException extends WorldEditException {
- private static final long serialVersionUID = 995264804658899764L;
public InsufficientArgumentsException(String error) {
super(error);
}
+
}
diff --git a/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java
index e4b5c4662..41799e8a0 100644
--- a/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java
+++ b/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java
@@ -65,10 +65,9 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
/**
* Selection commands.
- *
- * @author sk89q
*/
public class SelectionCommands {
+
private final WorldEdit we;
public SelectionCommands(WorldEdit we) {
diff --git a/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java b/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java
index 35641f38f..8c7676eee 100644
--- a/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java
+++ b/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java
@@ -40,10 +40,9 @@ import java.util.logging.Logger;
/**
* Snapshot commands.
- *
- * @author sk89q
*/
public class SnapshotCommands {
+
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
@@ -73,7 +72,7 @@ public class SnapshotCommands {
try {
ListBlockTool
or TraceTool
.
+ * has to implement {@code BlockTool} or {@code TraceTool}.
*/
public interface Tool {
diff --git a/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java b/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java
index aba66e9fc..71e6ea608 100644
--- a/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java
+++ b/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java
@@ -25,19 +25,19 @@ import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.function.pattern.Pattern;
/**
- * Represents a brush.
- *
- * @author sk89q
+ * A brush is a long-range build tool.
*/
public interface Brush {
+
/**
* Build the object.
*
- * @param editSession
- * @param pos
- * @param mat
- * @param size
+ * @param editSession the {@code EditSession}
+ * @param position the position
+ * @param pattern the pattern
+ * @param size the size of the brush
* @throws MaxChangedBlocksException
*/
- public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException;
+ public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException;
+
}
diff --git a/src/main/java/com/sk89q/worldedit/command/tool/brush/ButcherBrush.java b/src/main/java/com/sk89q/worldedit/command/tool/brush/ButcherBrush.java
index 637be6d2f..b949d6b0e 100644
--- a/src/main/java/com/sk89q/worldedit/command/tool/brush/ButcherBrush.java
+++ b/src/main/java/com/sk89q/worldedit/command/tool/brush/ButcherBrush.java
@@ -40,8 +40,8 @@ public class ButcherBrush implements Brush {
}
@Override
- public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
- CylinderRegion region = CylinderRegion.createRadius(editSession, pos, size);
+ public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
+ CylinderRegion region = CylinderRegion.createRadius(editSession, position, size);
List extends Entity> entities = editSession.getEntities(region);
Operations.completeLegacy(new EntityVisitor(entities.iterator(), flags.createFunction(editSession.getWorld().getWorldData().getEntityRegistry())));
}
diff --git a/src/main/java/com/sk89q/worldedit/command/tool/brush/ClipboardBrush.java b/src/main/java/com/sk89q/worldedit/command/tool/brush/ClipboardBrush.java
index 7f772239d..4417d1a35 100644
--- a/src/main/java/com/sk89q/worldedit/command/tool/brush/ClipboardBrush.java
+++ b/src/main/java/com/sk89q/worldedit/command/tool/brush/ClipboardBrush.java
@@ -42,14 +42,14 @@ public class ClipboardBrush implements Brush {
}
@Override
- public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
+ public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
Clipboard clipboard = holder.getClipboard();
Region region = clipboard.getRegion();
Vector centerOffset = region.getCenter().subtract(clipboard.getOrigin());
Operation operation = holder
.createPaste(editSession, editSession.getWorld().getWorldData())
- .to(usingOrigin ? pos : pos.subtract(centerOffset))
+ .to(usingOrigin ? position : position.subtract(centerOffset))
.ignoreAirBlocks(ignoreAirBlocks)
.build();
diff --git a/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java b/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java
index bed1416a7..31b8c9ab7 100644
--- a/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java
+++ b/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java
@@ -33,8 +33,9 @@ public class CylinderBrush implements Brush {
this.height = height;
}
- public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
- editSession.makeCylinder(pos, Patterns.wrap(mat), size, size, height, true);
+ @Override
+ public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
+ editSession.makeCylinder(position, Patterns.wrap(pattern), size, size, height, true);
}
}
diff --git a/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java b/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java
index 7e90e57bc..8331b7620 100644
--- a/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java
+++ b/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java
@@ -37,14 +37,14 @@ public class GravityBrush implements Brush {
}
@Override
- public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
+ public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
final BaseBlock air = new BaseBlock(BlockID.AIR, 0);
- final double startY = fullHeight ? editSession.getWorld().getMaxY() : pos.getBlockY() + size;
- for (double x = pos.getBlockX() + size; x > pos.getBlockX() - size; --x) {
- for (double z = pos.getBlockZ() + size; z > pos.getBlockZ() - size; --z) {
+ final double startY = fullHeight ? editSession.getWorld().getMaxY() : position.getBlockY() + size;
+ for (double x = position.getBlockX() + size; x > position.getBlockX() - size; --x) {
+ for (double z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
double y = startY;
final ListIt is strongly recommended that implementations extend from + * {@link AbstractPlatform}.
*/ public interface Platform { @@ -58,8 +58,8 @@ public interface Platform { void reload(); /** - * Schedules the giventask
to be invoked once every period
ticks
- * after an initial delay of delay
ticks.
+ * Schedules the given {@code task} to be invoked once every
+ * {@code period} ticks after an initial delay of {@code delay} ticks.
*
* @param delay Delay in server ticks before executing first repeat
* @param period Period in server ticks of the task
@@ -68,12 +68,17 @@ public interface Platform {
*/
int schedule(long delay, long period, Runnable task);
+ /**
+ * Get a list of available or loaded worlds.
+ *
+ * @return a list of worlds
+ */
List extends World> getWorlds();
/**
* Create a duplicate of the given player.
- *
- * The given player may have been provided by a different platform.
+ *
+ * The given player may have been provided by a different platform.
* * @param player the player to match * @return a matched player, otherwise null @@ -82,8 +87,8 @@ public interface Platform { /** * Create a duplicate of the given world. - * - * The given world may have been provided by a different platform. + * + *The given world may have been provided by a different platform.
* * @param world the world to match * @return a matched world, otherwise null @@ -111,9 +116,9 @@ public interface Platform { /** * Get the version of WorldEdit that this platform provides. - * - * This version should match WorldEdit releases because it may be - * checked to match. + * + *This version should match WorldEdit releases because it may be + * checked to match.
* * @return the version */ @@ -121,9 +126,9 @@ public interface Platform { /** * Get a friendly name of the platform. - * - * The name can be anything (reasonable). An example name may be - * "Bukkit" or "Forge". + * + *The name can be anything (reasonable). An example name may be + * "Bukkit" or "Forge".
* * @return the platform name */ diff --git a/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java b/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java index 297df8b1a..abdef5478 100644 --- a/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java +++ b/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java @@ -141,8 +141,8 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat } @Override - public boolean contains(Vector pt) { - return buffer.containsKey(pt.toBlockVector()); + public boolean contains(Vector position) { + return buffer.containsKey(position.toBlockVector()); } @Override diff --git a/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java b/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java index e68d5b2c0..fa7ff1929 100644 --- a/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java +++ b/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java @@ -30,8 +30,8 @@ public interface Clipboard extends Extent { /** * Get the bounding region of this extent. - * - * Implementations should return a copy of the region. + * + *Implementations should return a copy of the region.
* * @return the bounding region */ diff --git a/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java b/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java index bae3ae753..c6a17cb88 100644 --- a/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java +++ b/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java @@ -21,8 +21,6 @@ package com.sk89q.worldedit.extent.clipboard.io; import com.sk89q.jnbt.ByteArrayTag; import com.sk89q.jnbt.CompoundTag; -import com.sk89q.jnbt.DoubleTag; -import com.sk89q.jnbt.FloatTag; import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.NBTInputStream; diff --git a/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java b/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java index 7eca18d20..9cdc2b3ae 100644 --- a/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java +++ b/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java @@ -24,14 +24,11 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.world.World; import javax.annotation.Nullable; import java.util.HashMap; import java.util.Map; -import static com.google.common.base.Preconditions.checkNotNull; - /** * Applies a {@link BlockBag} to operations. */ diff --git a/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java b/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java index be421cbc2..ea9161fea 100644 --- a/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java +++ b/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java @@ -97,7 +97,7 @@ public class FastModeExtent extends AbstractDelegateExtent { return new Operation() { @Override public Operation resume(RunContext run) throws WorldEditException { - if (dirtyChunks.size() > 0) { + if (!dirtyChunks.isEmpty()) { world.fixAfterFastMode(dirtyChunks); } return null; diff --git a/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java b/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java index 91ac89c14..bd2e1c831 100644 --- a/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java +++ b/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java @@ -34,9 +34,9 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * A mask that checks whether blocks at the given positions are matched by * a block in a list. - * - * This mask checks for both an exact block ID and data value match, as well - * for a block with the same ID but a data value of -1. + * + *This mask checks for both an exact block ID and data value match, as well + * for a block with the same ID but a data value of -1.
*/ public class BlockMask extends AbstractExtentMask { diff --git a/src/main/java/com/sk89q/worldedit/function/mask/Masks.java b/src/main/java/com/sk89q/worldedit/function/mask/Masks.java index 86280cb08..b6e94adc2 100644 --- a/src/main/java/com/sk89q/worldedit/function/mask/Masks.java +++ b/src/main/java/com/sk89q/worldedit/function/mask/Masks.java @@ -200,9 +200,9 @@ public final class Masks { checkNotNull(mask); return new com.sk89q.worldedit.masks.AbstractMask() { @Override - public boolean matches(EditSession editSession, Vector pos) { + public boolean matches(EditSession editSession, Vector position) { Request.request().setEditSession(editSession); - return mask.test(pos); + return mask.test(position); } }; } diff --git a/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java b/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java index 5356f568d..5f1121eb2 100644 --- a/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java +++ b/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java @@ -103,12 +103,12 @@ public abstract class BreadthFirstSearch implements Operation { * that it has not been visited. The position passed to this method * will still be visited even if it fails * {@link #isVisitable(com.sk89q.worldedit.Vector, com.sk89q.worldedit.Vector)}. - * - * This method should be used before the search begins, because if + * + *This method should be used before the search begins, because if * the position does fail the test, and the search has already * visited it (because it is connected to another root point), * the search will mark the position as "visited" and a call to this - * method will do nothing. + * method will do nothing.
* * @param position the position */ diff --git a/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java b/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java index b09a26bee..4633afc52 100644 --- a/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java +++ b/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java @@ -89,7 +89,7 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv builder.append("WorldEdit: ").append(sender.getName()); if (sender.isPlayer()) { - builder.append(" (in \"" + player.getWorld().getName() + "\")"); + builder.append(" (in \"").append(player.getWorld().getName()).append("\")"); } builder.append(": ").append(context.getCommand()); @@ -112,15 +112,15 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv /* FALL-THROUGH */ case POSITION: - builder.append(" - Position: " + position); + builder.append(" - Position: ").append(position); break; case ALL: - builder.append(" - Position: " + position); + builder.append(" - Position: ").append(position); /* FALL-THROUGH */ case ORIENTATION_REGION: - builder.append(" - Orientation: " + player.getCardinalDirection().name()); + builder.append(" - Orientation: ").append(player.getCardinalDirection().name()); /* FALL-THROUGH */ case REGION: diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java b/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java index 09583d5bb..5a61709f3 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java @@ -65,8 +65,6 @@ import java.util.Stack; * *Variables are also supported and can be set either by passing values * to {@link #evaluate(double...)}.
- * - * @author TomyLobo */ public class Expression { diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java b/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java index 0989701b1..fc29e37d5 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java @@ -112,8 +112,7 @@ public final class ParserProcessors { default: Map{@link #iterator()} returns a special iterator that will iterate through * the iterators of each region in an undefined sequence. Some positions may * be repeated if the position is contained in more than one region, but this cannot - * be guaranteed to occur. + * be guaranteed to occur.
*/ public class RegionIntersection extends AbstractRegion { @@ -71,7 +72,7 @@ public class RegionIntersection extends AbstractRegion { public RegionIntersection(LocalWorld world, ListIf the given region is already a {@link FlatRegion}, then the region * will be cast and returned. Otherwise, a new {@link CuboidRegion} will - * be created covers the provided region's minimum and maximum extents. + * be created covers the provided region's minimum and maximum extents.
* * @param region the region * @return a flat region diff --git a/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java b/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java index b024bf867..3ffb59a03 100644 --- a/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java +++ b/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java @@ -147,8 +147,8 @@ public class TransformRegion extends AbstractRegion { } @Override - public boolean contains(Vector pt) { - return region.contains(transform.inverse().apply(pt)); + public boolean contains(Vector position) { + return region.contains(transform.inverse().apply(position)); } @Override diff --git a/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java b/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java index 39dd8886a..118681eb6 100644 --- a/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java +++ b/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java @@ -238,26 +238,21 @@ public class MCEditSchematicFormat extends SchematicFormat { blocks[index] = (byte) block.getType(); blockData[index] = (byte) block.getData(); - // Store TileEntity data - if (block instanceof TileEntityBlock) { - TileEntityBlock tileEntityBlock = block; - - // Get the list of key/values from the block - CompoundTag rawTag = tileEntityBlock.getNbtData(); - if (rawTag != null) { - Mapjava.io.File
object will be returned.
+ * On success, a {@code java.io.File} object will be returned.
*
* Use this method if you need to read a file from a directory.
* * @param folder sub-directory to look in * @param filename filename (user-submitted) - * @return + * @return a file * @throws FilenameException */ @Deprecated @@ -219,7 +215,7 @@ public class CraftScriptContext extends CraftScriptEnvironment { * Gets the path to a file for opening. This method will check to see if the * filename has valid characters and has an extension. It also prevents * directory traversal exploits by checking the root directory and the file - * directory. On success, ajava.io.File
object will be
+ * directory. On success, a {@code java.io.File} object will be
* returned.
*
* Use this method if you need to read a file from a directory.
@@ -228,12 +224,10 @@ public class CraftScriptContext extends CraftScriptEnvironment { * @param filename filename (user-submitted) * @param defaultExt default extension to append if there is none * @param exts list of extensions for file open dialog, null for no filter - * @return + * @return a file * @throws FilenameException */ - public File getSafeOpenFile(String folder, String filename, - String defaultExt, String... exts) - throws FilenameException { + public File getSafeOpenFile(String folder, String filename, String defaultExt, String... exts) throws FilenameException { File dir = controller.getWorkingDirectoryFile(folder); return controller.getSafeOpenFile(player, dir, filename, defaultExt, exts); } @@ -242,7 +236,7 @@ public class CraftScriptContext extends CraftScriptEnvironment { * Gets the path to a file for saving. This method will check to see if the * filename has valid characters and has an extension. It also prevents * directory traversal exploits by checking the root directory and the file - * directory. On success, ajava.io.File
object will be
+ * directory. On success, a {@code java.io.File} object will be
* returned.
*
* Use this method if you need to read a file from a directory.
@@ -251,13 +245,12 @@ public class CraftScriptContext extends CraftScriptEnvironment { * @param filename filename (user-submitted) * @param defaultExt default extension to append if there is none * @param exts list of extensions for file save dialog, null for no filter - * @return + * @return a file * @throws FilenameException */ - public File getSafeSaveFile(String folder, String filename, - String defaultExt, String... exts) - throws FilenameException { + public File getSafeSaveFile(String folder, String filename, String defaultExt, String... exts) throws FilenameException { File dir = controller.getWorkingDirectoryFile(folder); return controller.getSafeSaveFile(player, dir, filename, defaultExt, exts); } + } diff --git a/src/main/java/com/sk89q/worldedit/scripting/RhinoContextFactory.java b/src/main/java/com/sk89q/worldedit/scripting/RhinoContextFactory.java index 54ab0d0e6..b61edb0d3 100644 --- a/src/main/java/com/sk89q/worldedit/scripting/RhinoContextFactory.java +++ b/src/main/java/com/sk89q/worldedit/scripting/RhinoContextFactory.java @@ -25,6 +25,7 @@ import org.mozilla.javascript.ContextFactory; import org.mozilla.javascript.Scriptable; public class RhinoContextFactory extends ContextFactory { + protected int timeLimit; public RhinoContextFactory(int timeLimit) { @@ -60,8 +61,9 @@ public class RhinoContextFactory extends ContextFactory { private static class RhinoContext extends Context { long startTime; - public RhinoContext(ContextFactory factory) { + private RhinoContext(ContextFactory factory) { super(factory); } } + } diff --git a/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java b/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java index 33e7ad67a..7f3354bbc 100644 --- a/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java +++ b/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java @@ -34,14 +34,17 @@ import com.sk89q.worldedit.WorldEditException; public class RhinoCraftScriptEngine implements CraftScriptEngine { private int timeLimit; + @Override public void setTimeLimit(int milliseconds) { timeLimit = milliseconds; } + @Override public int getTimeLimit() { return timeLimit; } + @Override public Object evaluate(String script, String filename, MapIf a selection cannot be taken, then the selection will be assumed to be + * that of a {@link NullRegion}.
*/ public class RequestSelection implements Region { @@ -109,8 +109,8 @@ public class RequestSelection implements Region { } @Override - public boolean contains(Vector pt) { - return getRegion().contains(pt); + public boolean contains(Vector position) { + return getRegion().contains(position); } @Override diff --git a/src/main/java/com/sk89q/worldedit/util/Countable.java b/src/main/java/com/sk89q/worldedit/util/Countable.java index db98a832c..e1f48d135 100644 --- a/src/main/java/com/sk89q/worldedit/util/Countable.java +++ b/src/main/java/com/sk89q/worldedit/util/Countable.java @@ -19,56 +19,34 @@ package com.sk89q.worldedit.util; -/** - * - * @author sk89q - * @paramLike {@code Vectors}, {@code Locations} are immutable and mutator methods + * will create a new copy.
+ * + *At the moment, but this may change in the future, {@link #hashCode()} and * {@link #equals(Object)} are subject to minor differences caused by - * floating point errors. + * floating point errors.
*/ public class Location { diff --git a/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java b/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java index b690f8e2c..5a9a399ba 100644 --- a/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java +++ b/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java @@ -21,6 +21,11 @@ package com.sk89q.worldedit.util; +import com.sk89q.util.StringUtil; +import com.sk89q.worldedit.LocalConfiguration; +import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.world.snapshot.SnapshotRepository; + import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -31,27 +36,24 @@ import java.io.OutputStream; import java.util.HashSet; import java.util.Properties; import java.util.Set; - -import com.sk89q.util.StringUtil; -import com.sk89q.worldedit.LocalConfiguration; -import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.world.snapshot.SnapshotRepository; +import java.util.logging.Level; +import java.util.logging.Logger; /** * Simple LocalConfiguration that loads settings using - *java.util.Properties
.
- *
- * @author sk89q
+ * {@code java.util.Properties}.
*/
public class PropertiesConfiguration extends LocalConfiguration {
+ private static final Logger log = Logger.getLogger(PropertiesConfiguration.class.getCanonicalName());
+
protected Properties properties;
protected File path;
/**
* Construct the object. The configuration isn't loaded yet.
*
- * @param path
+ * @param path the path tot he configuration
*/
public PropertiesConfiguration(File path) {
this.path = path;
@@ -59,23 +61,20 @@ public class PropertiesConfiguration extends LocalConfiguration {
properties = new Properties();
}
- /**
- * Load the configuration file.
- */
@Override
public void load() {
InputStream stream = null;
try {
stream = new FileInputStream(path);
properties.load(stream);
- } catch (FileNotFoundException e) {
+ } catch (FileNotFoundException ignored) {
} catch (IOException e) {
- e.printStackTrace();
+ log.log(Level.WARNING, "Failed to read configuration", e);
} finally {
if (stream != null) {
try {
stream.close();
- } catch (IOException e) {
+ } catch (IOException ignored) {
}
}
}
@@ -115,7 +114,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
LocalSession.MAX_HISTORY_SIZE = Math.max(15, getInt("history-size", 15));
String snapshotsDir = getString("snapshots-dir", "");
- if (snapshotsDir.length() > 0) {
+ if (!snapshotsDir.isEmpty()) {
snapshotRepo = new SnapshotRepository(snapshotsDir);
}
@@ -125,14 +124,14 @@ public class PropertiesConfiguration extends LocalConfiguration {
output = new FileOutputStream(path);
properties.store(output, "Don't put comments; they get removed");
} catch (FileNotFoundException e) {
- e.printStackTrace();
+ log.log(Level.WARNING, "Failed to write configuration", e);
} catch (IOException e) {
- e.printStackTrace();
+ log.log(Level.WARNING, "Failed to write configuration", e);
} finally {
if (output != null) {
try {
output.close();
- } catch (IOException e) {
+ } catch (IOException ignored) {
}
}
}
@@ -141,9 +140,9 @@ public class PropertiesConfiguration extends LocalConfiguration {
/**
* Get a string value.
*
- * @param key
- * @param def
- * @return
+ * @param key the key
+ * @param def the default value
+ * @return the value
*/
protected String getString(String key, String def) {
if (def == null) {
@@ -161,9 +160,9 @@ public class PropertiesConfiguration extends LocalConfiguration {
/**
* Get a boolean value.
*
- * @param key
- * @param def
- * @return
+ * @param key the key
+ * @param def the default value
+ * @return the value
*/
protected boolean getBool(String key, boolean def) {
String val = properties.getProperty(key);
@@ -179,9 +178,9 @@ public class PropertiesConfiguration extends LocalConfiguration {
/**
* Get an integer value.
*
- * @param key
- * @param def
- * @return
+ * @param key the key
+ * @param def the default value
+ * @return the value
*/
protected int getInt(String key, int def) {
String val = properties.getProperty(key);
@@ -201,9 +200,9 @@ public class PropertiesConfiguration extends LocalConfiguration {
/**
* Get a double value.
*
- * @param key
- * @param def
- * @return
+ * @param key the key
+ * @param def the default value
+ * @return the value
*/
protected double getDouble(String key, double def) {
String val = properties.getProperty(key);
@@ -223,9 +222,9 @@ public class PropertiesConfiguration extends LocalConfiguration {
/**
* Get a double value.
*
- * @param key
- * @param def
- * @return
+ * @param key the key
+ * @param def the default value
+ * @return the value
*/
protected SetOriginally written by toi. It was ported to WorldEdit and trimmed down by + * sk89q. Thanks to Raphfrk for optimization of toi's original class.
*/ public class TargetBlock { + private LocalWorld world; private int maxDistance; private double checkDistance, curDistance; @@ -81,8 +80,8 @@ public class TargetBlock { * Set the values, all constructors uses this function * * @param loc location of the view - * @param xRotation - * @param yRotation + * @param xRotation the X rotation + * @param yRotation the Y rotation * @param maxDistance how far it checks for blocks * @param viewHeight where the view is positioned in y-axis * @param checkDistance how often to check for blocks, the smaller the more precise @@ -210,4 +209,5 @@ public class TargetBlock { getAnyTargetBlock(); return WorldVectorFace.getWorldVectorFace(world, getCurrentBlock(), getPreviousBlock()); } + } diff --git a/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java b/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java index c28400d76..2b686e7d5 100644 --- a/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java +++ b/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java @@ -19,22 +19,23 @@ package com.sk89q.worldedit.util; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BlockID; +import javax.annotation.Nullable; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + /** * Tree generator. - * - * @author sk89q */ public class TreeGenerator { + public enum TreeType { TREE("Regular tree", "tree", "regular"), BIG_TREE("Big tree", "big", "bigtree"), @@ -42,22 +43,25 @@ public class TreeGenerator { TALL_REDWOOD("Tall redwood", "tallredwood", "tallsequoia", "tallsequoioideae"), BIRCH("Birch", "birch", "white", "whitebark"), PINE("Pine", "pine") { + @Override public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException { makePineTree(editSession, pos); return true; } }, RANDOM_REDWOOD("Random redwood", "randredwood", "randomredwood", "anyredwood") { + @Override public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException { TreeType[] choices = new TreeType[] { TreeType.REDWOOD, TreeType.TALL_REDWOOD }; - return choices[rand.nextInt(choices.length)].generate(editSession, pos); + return choices[TreeGenerator.RANDOM.nextInt(choices.length)].generate(editSession, pos); } }, JUNGLE("Jungle", "jungle"), SMALL_JUNGLE("Small jungle", "shortjungle", "smalljungle"), SHORT_JUNGLE("Short jungle") { + @Override public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException { return SMALL_JUNGLE.generate(editSession, pos); } @@ -71,12 +75,13 @@ public class TreeGenerator { MEGA_REDWOOD("Mega Redwood", "megaredwood"), TALL_BIRCH("Tall Birch", "tallbirch"), RANDOM("Random", "rand", "random") { + @Override public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException { TreeType[] choices = new TreeType[] { TreeType.TREE, TreeType.BIG_TREE, TreeType.BIRCH, TreeType.REDWOOD, TreeType.TALL_REDWOOD, TreeType.PINE }; - return choices[rand.nextInt(choices.length)].generate(editSession, pos); + return choices[TreeGenerator.RANDOM.nextInt(choices.length)].generate(editSession, pos); } }; @@ -108,7 +113,7 @@ public class TreeGenerator { /** * Get user-friendly tree type name. * - * @return + * @return a name */ public String getName() { return name; @@ -117,22 +122,23 @@ public class TreeGenerator { /** * Return type from name. May return null. * - * @param name - * @return + * @param name name to search + * @return a tree type or null */ + @Nullable public static TreeType lookup(String name) { return lookup.get(name.toLowerCase()); } - }; + } - private static Random rand = new Random(); + private static final Random RANDOM = new Random(); private TreeType type; /** * Construct the tree generator with a tree type. * - * @param type + * @param type the tree type */ @Deprecated public TreeGenerator(TreeType type) { @@ -142,22 +148,21 @@ public class TreeGenerator { /** * Generate a tree. * - * @param editSession - * @param pos - * @return + * @param editSession the edit session + * @param position the position to generate the tree at + * @return true if generation was successful * @throws MaxChangedBlocksException */ - public boolean generate(EditSession editSession, Vector pos) - throws MaxChangedBlocksException { - return type.generate(editSession, pos); + public boolean generate(EditSession editSession, Vector position) throws MaxChangedBlocksException { + return type.generate(editSession, position); } /** * Makes a terrible looking pine tree. * - * @param basePos + * @param basePosition the base position */ - private static void makePineTree(EditSession editSession, Vector basePos) + private static void makePineTree(EditSession editSession, Vector basePosition) throws MaxChangedBlocksException { int trunkHeight = (int) Math.floor(Math.random() * 2) + 3; int height = (int) Math.floor(Math.random() * 5) + 8; @@ -167,58 +172,60 @@ public class TreeGenerator { // Create trunk for (int i = 0; i < trunkHeight; ++i) { - if (!editSession.setBlockIfAir(basePos.add(0, i, 0), logBlock)) { + if (!editSession.setBlockIfAir(basePosition.add(0, i, 0), logBlock)) { return; } } // Move up - basePos = basePos.add(0, trunkHeight, 0); + basePosition = basePosition.add(0, trunkHeight, 0); // Create tree + leaves for (int i = 0; i < height; ++i) { - editSession.setBlockIfAir(basePos.add(0, i, 0), logBlock); + editSession.setBlockIfAir(basePosition.add(0, i, 0), logBlock); // Less leaves at these levels double chance = ((i == 0 || i == height - 1) ? 0.6 : 1); // Inner leaves - editSession.setChanceBlockIfAir(basePos.add(-1, i, 0), leavesBlock, chance); - editSession.setChanceBlockIfAir(basePos.add(1, i, 0), leavesBlock, chance); - editSession.setChanceBlockIfAir(basePos.add(0, i, -1), leavesBlock, chance); - editSession.setChanceBlockIfAir(basePos.add(0, i, 1), leavesBlock, chance); - editSession.setChanceBlockIfAir(basePos.add(1, i, 1), leavesBlock, chance); - editSession.setChanceBlockIfAir(basePos.add(-1, i, 1), leavesBlock, chance); - editSession.setChanceBlockIfAir(basePos.add(1, i, -1), leavesBlock, chance); - editSession.setChanceBlockIfAir(basePos.add(-1, i, -1), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(-1, i, 0), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(1, i, 0), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(0, i, -1), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(0, i, 1), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(1, i, 1), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(-1, i, 1), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(1, i, -1), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(-1, i, -1), leavesBlock, chance); if (!(i == 0 || i == height - 1)) { for (int j = -2; j <= 2; ++j) { - editSession.setChanceBlockIfAir(basePos.add(-2, i, j), leavesBlock, 0.6); + editSession.setChanceBlockIfAir(basePosition.add(-2, i, j), leavesBlock, 0.6); } for (int j = -2; j <= 2; ++j) { - editSession.setChanceBlockIfAir(basePos.add(2, i, j), leavesBlock, 0.6); + editSession.setChanceBlockIfAir(basePosition.add(2, i, j), leavesBlock, 0.6); } for (int j = -2; j <= 2; ++j) { - editSession.setChanceBlockIfAir(basePos.add(j, i, -2), leavesBlock, 0.6); + editSession.setChanceBlockIfAir(basePosition.add(j, i, -2), leavesBlock, 0.6); } for (int j = -2; j <= 2; ++j) { - editSession.setChanceBlockIfAir(basePos.add(j, i, 2), leavesBlock, 0.6); + editSession.setChanceBlockIfAir(basePosition.add(j, i, 2), leavesBlock, 0.6); } } } - editSession.setBlockIfAir(basePos.add(0, height, 0), leavesBlock); + editSession.setBlockIfAir(basePosition.add(0, height, 0), leavesBlock); } /** * Looks up a tree type. May return null if a tree type by that * name is not found. * - * @param type - * @return + * @param type the tree type + * @return a tree type or null */ + @Nullable public static TreeType lookup(String type) { return TreeType.lookup(type); } + } diff --git a/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java b/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java index c800591c5..3110c5bf9 100644 --- a/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java +++ b/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java @@ -27,14 +27,15 @@ import com.sk89q.worldedit.world.snapshot.SnapshotRepository; import java.io.IOException; import java.util.HashSet; +import java.util.logging.Level; import java.util.logging.Logger; /** - * A less simple implementation of {@link LocalConfiguration} using YAML configuration files. - * - * @author sk89q + * A less simple implementation of {@link LocalConfiguration} + * using YAML configuration files. */ public class YAMLConfiguration extends LocalConfiguration { + protected final YAMLProcessor config; protected final Logger logger; @@ -48,8 +49,7 @@ public class YAMLConfiguration extends LocalConfiguration { try { config.load(); } catch (IOException e) { - logger.severe("Error loading WorldEdit configuration: " + e); - e.printStackTrace(); + logger.log(Level.WARNING, "Error loading WorldEdit configuration", e); } profile = config.getBoolean("debug", profile); @@ -112,7 +112,7 @@ public class YAMLConfiguration extends LocalConfiguration { showHelpInfo = config.getBoolean("show-help-on-first-use", true); String snapshotsDir = config.getString("snapshots.directory", ""); - if (snapshotsDir.length() > 0) { + if (!snapshotsDir.isEmpty()) { snapshotRepo = new SnapshotRepository(snapshotsDir); } @@ -123,4 +123,5 @@ public class YAMLConfiguration extends LocalConfiguration { public void unload() { } + } diff --git a/src/main/java/com/sk89q/worldedit/util/collection/DoubleArrayList.java b/src/main/java/com/sk89q/worldedit/util/collection/DoubleArrayList.java index 26f518d4e..f2b0a2539 100644 --- a/src/main/java/com/sk89q/worldedit/util/collection/DoubleArrayList.java +++ b/src/main/java/com/sk89q/worldedit/util/collection/DoubleArrayList.java @@ -29,28 +29,18 @@ import java.util.NoSuchElementException; /** * Double array lists to work like a Map, but not really. * - * @author sk89q - * @param - * @param + *The usefulness of this class is highly questionable.
*/ public class DoubleArrayList implements IterableThe iterator in Java, at least in older Java versions, is very slow, * causing a significant amount of time in operations in WorldEdit * being spent on {@link Iterator#hasNext()}. In contrast, the iterator * implemented by this class is very quick, as long as - * {@link List#get(int)} is fast. + * {@link List#get(int)} is fast.
* * @paramThe implementing class must perform the necessary permission + * checks.
* * @param arguments the arguments * @param locals the locals diff --git a/src/main/java/com/sk89q/worldedit/util/command/Description.java b/src/main/java/com/sk89q/worldedit/util/command/Description.java index 72e9fd5f0..5fe33702c 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/Description.java +++ b/src/main/java/com/sk89q/worldedit/util/command/Description.java @@ -51,7 +51,7 @@ public interface Description { * Get the usage string of this command. * *A usage string may look like
- * [-w <world>] <var1> <var2>
.
When handling this exception, print the error message if it is not null. * Print a one line help instruction unless {@link #isFullHelpSuggested()} - * is true, which, in that case, the full help of the command should be shown. - *
- * If no error message is set and full help is not to be shown, then a generic - * "you used this command incorrectly" message should be shown. + * is true, which, in that case, the full help of the command should be + * shown. + * + *If no error message is set and full help is not to be shown, then a generic + * "you used this command incorrectly" message should be shown.
*/ public class InvalidUsageException extends CommandException { - private static final long serialVersionUID = -3222004168669490390L; private final CommandCallable command; private final boolean fullHelpSuggested; diff --git a/src/main/java/com/sk89q/worldedit/util/command/MissingParameterException.java b/src/main/java/com/sk89q/worldedit/util/command/MissingParameterException.java index 8080929e3..bbdf0e0d5 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/MissingParameterException.java +++ b/src/main/java/com/sk89q/worldedit/util/command/MissingParameterException.java @@ -25,7 +25,5 @@ import com.sk89q.worldedit.util.command.parametric.ParameterException; * Thrown when there is a missing parameter. */ public class MissingParameterException extends ParameterException { - - private static final long serialVersionUID = 2169299987926950535L; } diff --git a/src/main/java/com/sk89q/worldedit/util/command/SimpleDescription.java b/src/main/java/com/sk89q/worldedit/util/command/SimpleDescription.java index efd5aed95..74e386ec8 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/SimpleDescription.java +++ b/src/main/java/com/sk89q/worldedit/util/command/SimpleDescription.java @@ -115,7 +115,7 @@ public class SimpleDescription implements Description { if (!first) { builder.append(" "); } - builder.append(parameter.toString()); + builder.append(parameter); first = false; } diff --git a/src/main/java/com/sk89q/worldedit/util/command/UnconsumedParameterException.java b/src/main/java/com/sk89q/worldedit/util/command/UnconsumedParameterException.java index 360a5408c..0a399f64d 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/UnconsumedParameterException.java +++ b/src/main/java/com/sk89q/worldedit/util/command/UnconsumedParameterException.java @@ -26,8 +26,6 @@ import com.sk89q.worldedit.util.command.parametric.ParameterException; * case of the user providing too many parameters. */ public class UnconsumedParameterException extends ParameterException { - - private static final long serialVersionUID = 4449104854894946023L; private String unconsumed; diff --git a/src/main/java/com/sk89q/worldedit/util/command/binding/Switch.java b/src/main/java/com/sk89q/worldedit/util/command/binding/Switch.java index 34c25cad5..8d0e122ff 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/binding/Switch.java +++ b/src/main/java/com/sk89q/worldedit/util/command/binding/Switch.java @@ -25,7 +25,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Indicates a command flag, such as/command -f
.
+ * Indicates a command flag, such as {@code /command -f}.
*
* If used on a boolean type, then the flag will be a non-value flag. If * used on any other type, then the flag will be a value flag.
diff --git a/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingBehavior.java b/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingBehavior.java index e194bce56..eeef23dbd 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingBehavior.java +++ b/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingBehavior.java @@ -47,6 +47,6 @@ public enum BindingBehavior { * such as from a {@link CommandLocals}. These are "magic" bindings that inject * variables. */ - PROVIDES; + PROVIDES } diff --git a/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingHelper.java b/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingHelper.java index b56c76426..a29d6ddd3 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingHelper.java +++ b/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingHelper.java @@ -64,7 +64,7 @@ public class BindingHelper implements Binding { // Set classifier if (!info.classifier().equals(Annotation.class)) { - classifier = (Class extends Annotation>) info.classifier(); + classifier = info.classifier(); types.add(classifier); } diff --git a/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java b/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java index 8a72f1a33..177e5a899 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java +++ b/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java @@ -89,7 +89,7 @@ public abstract class ExceptionConverterHelper implements ExceptionConverter { final Class extends Throwable> cls; final Method method; - public ExceptionHandler(Class extends Throwable> cls, Method method) { + private ExceptionHandler(Class extends Throwable> cls, Method method) { this.cls = cls; this.method = method; } diff --git a/src/main/java/com/sk89q/worldedit/util/command/parametric/ParameterException.java b/src/main/java/com/sk89q/worldedit/util/command/parametric/ParameterException.java index 8dc924f15..2fe681ba7 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/parametric/ParameterException.java +++ b/src/main/java/com/sk89q/worldedit/util/command/parametric/ParameterException.java @@ -24,8 +24,6 @@ package com.sk89q.worldedit.util.command.parametric; */ public class ParameterException extends Exception { - private static final long serialVersionUID = -8255175019708245673L; - public ParameterException() { super(); } diff --git a/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricBuilder.java b/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricBuilder.java index c7b94ebde..822826fed 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricBuilder.java +++ b/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricBuilder.java @@ -84,9 +84,9 @@ public class ParametricBuilder { * 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 * example, even if there is a binding that handles {@link String} parameters, - * a special@MyArg
annotation can be assigned to a {@link String}
+ * a special {@code @MyArg} annotation can be assigned to a {@link String}
* parameter, which will cause the {@link Builder} to consult the {@link Binding}
- * associated with @MyArg
rather than with the binding for
+ * associated with {@code @MyArg} rather than with the binding for
* the {@link String} type.
*
* @param binding the binding
diff --git a/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricException.java b/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricException.java
index f2c826d73..346816330 100644
--- a/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricException.java
+++ b/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricException.java
@@ -25,8 +25,6 @@ package com.sk89q.worldedit.util.command.parametric;
*/
public class ParametricException extends RuntimeException {
- private static final long serialVersionUID = -5426219576099680971L;
-
public ParametricException() {
super();
}
diff --git a/src/main/java/com/sk89q/worldedit/util/eventbus/AnnotatedSubscriberFinder.java b/src/main/java/com/sk89q/worldedit/util/eventbus/AnnotatedSubscriberFinder.java
index f3b610a9e..03c001138 100644
--- a/src/main/java/com/sk89q/worldedit/util/eventbus/AnnotatedSubscriberFinder.java
+++ b/src/main/java/com/sk89q/worldedit/util/eventbus/AnnotatedSubscriberFinder.java
@@ -27,8 +27,8 @@ import java.lang.reflect.Method;
/**
* A {@link SubscriberFindingStrategy} for collecting all event handler methods
* that are marked with the {@link Subscribe} annotation.
- *
- * Original for Guava, licensed under the Apache License, Version 2.0.
+ *
+ * Original for Guava, licensed under the Apache License, Version 2.0.
*/ class AnnotatedSubscriberFinder implements SubscriberFindingStrategy { diff --git a/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java b/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java index ef2b3691d..0ee7b7d65 100644 --- a/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java +++ b/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java @@ -36,13 +36,14 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Dispatches events to listeners, and provides ways for listeners to register * themselves. - * - * This class is based on Guava's {@link EventBus} but priority is supported + * + *This class is based on Guava's {@link EventBus} but priority is supported * and events are dispatched at the time of call, rather than being queued up. - * This does allow dispatching during an in-progress dispatch. - *
- * This implementation utilizes naive synchronization on all getter and setter - * methods. Dispatch does not occur when a lock has been acquired, however. + * This does allow dispatching during an in-progress dispatch. + * + *This implementation utilizes naive synchronization on all getter and + * setter methods. Dispatch does not occur when a lock has been acquired, + * however.
*/ public class EventBus { diff --git a/src/main/java/com/sk89q/worldedit/util/eventbus/EventHandler.java b/src/main/java/com/sk89q/worldedit/util/eventbus/EventHandler.java index 31c5b3c1e..6488af945 100644 --- a/src/main/java/com/sk89q/worldedit/util/eventbus/EventHandler.java +++ b/src/main/java/com/sk89q/worldedit/util/eventbus/EventHandler.java @@ -26,8 +26,8 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Event handler object for {@link EventBus} that is able to dispatch * an event. - * - * Original for Guava, licensed under the Apache License, Version 2.0. + * + *Original for Guava, licensed under the Apache License, Version 2.0.
*/ public abstract class EventHandler implements ComparableSubclasses should override {@link #dispatch(Object)}.
* * @param event the event * @throws InvocationTargetException thrown if an exception is thrown during dispatch diff --git a/src/main/java/com/sk89q/worldedit/util/eventbus/HierarchyCache.java b/src/main/java/com/sk89q/worldedit/util/eventbus/HierarchyCache.java index 7c0557c0a..31aeb1f53 100644 --- a/src/main/java/com/sk89q/worldedit/util/eventbus/HierarchyCache.java +++ b/src/main/java/com/sk89q/worldedit/util/eventbus/HierarchyCache.java @@ -26,10 +26,10 @@ import com.sk89q.worldedit.internal.annotation.RequiresNewerGuava; import java.util.*; /** - * Holds a cache of class hierarcy. - * - * This exists because Bukkit has an ancient version of Guava and the cache - * library in Guava has since changed. + * Holds a cache of class hierarchy. + * + *This exists because Bukkit has an ancient version of Guava and the cache
+ * library in Guava has since changed.>
*/
@RequiresNewerGuava
class HierarchyCache {
diff --git a/src/main/java/com/sk89q/worldedit/util/eventbus/Subscribe.java b/src/main/java/com/sk89q/worldedit/util/eventbus/Subscribe.java
index fc94f38e3..6616ea65e 100644
--- a/src/main/java/com/sk89q/worldedit/util/eventbus/Subscribe.java
+++ b/src/main/java/com/sk89q/worldedit/util/eventbus/Subscribe.java
@@ -29,7 +29,7 @@ import static java.lang.annotation.RetentionPolicy.*;
* Used to mark methods as event handlers.
*/
@Retention(RUNTIME)
-@Target({METHOD})
+@Target(METHOD)
public @interface Subscribe {
/**
diff --git a/src/main/java/com/sk89q/worldedit/util/formatting/ColorCodeBuilder.java b/src/main/java/com/sk89q/worldedit/util/formatting/ColorCodeBuilder.java
index a0b9a534c..c6bb755bd 100644
--- a/src/main/java/com/sk89q/worldedit/util/formatting/ColorCodeBuilder.java
+++ b/src/main/java/com/sk89q/worldedit/util/formatting/ColorCodeBuilder.java
@@ -61,7 +61,7 @@ public class ColorCodeBuilder {
} else {
StyleSet style = parentStyle.extend(message.getStyle());
builder.append(getAdditive(style, lastStyle));
- builder.append(node.toString());
+ builder.append(node);
lastStyle = style;
}
}
@@ -102,7 +102,7 @@ public class ColorCodeBuilder {
StringBuilder builder = new StringBuilder();
builder.append(getFormattingCode(style));
if (style.getColor() != null) {
- builder.append(style.getColor().toString());
+ builder.append(style.getColor());
}
return builder.toString();
}
@@ -236,7 +236,7 @@ public class ColorCodeBuilder {
}
// Iterate over the wrapped lines, applying the last color from one line to the beginning of the next
- if (lines.get(0).length() == 0 || lines.get(0).charAt(0) != Style.COLOR_CHAR) {
+ if (lines.get(0).isEmpty() || lines.get(0).charAt(0) != Style.COLOR_CHAR) {
lines.set(0, Style.WHITE + lines.get(0));
}
for (int i = 1; i < lines.size(); i++) {
@@ -244,7 +244,7 @@ public class ColorCodeBuilder {
final String subLine = lines.get(i);
char color = pLine.charAt(pLine.lastIndexOf(Style.COLOR_CHAR) + 1);
- if (subLine.length() == 0 || subLine.charAt(0) != Style.COLOR_CHAR) {
+ if (subLine.isEmpty() || subLine.charAt(0) != Style.COLOR_CHAR) {
lines.set(i, Style.getByChar(color) + subLine);
}
}
diff --git a/src/main/java/com/sk89q/worldedit/util/formatting/Style.java b/src/main/java/com/sk89q/worldedit/util/formatting/Style.java
index 3eafd3c8d..c6fd71ddb 100644
--- a/src/main/java/com/sk89q/worldedit/util/formatting/Style.java
+++ b/src/main/java/com/sk89q/worldedit/util/formatting/Style.java
@@ -127,7 +127,7 @@ public enum Style {
* convert color codes from your custom format.
*/
public static final char COLOR_CHAR = '\u00A7';
- private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf(COLOR_CHAR) + "[0-9A-FK-OR]");
+ private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + COLOR_CHAR + "[0-9A-FK-OR]");
private final int intCode;
private final char code;
@@ -254,10 +254,10 @@ public enum Style {
Style color = getByChar(c);
if (color != null) {
- result = color.toString() + result;
+ result = color + result;
// Once we find a color or reset we can stop searching
- if (color.isColor() || color.equals(RESET)) {
+ if (color.isColor() || color == RESET) {
break;
}
}
diff --git a/src/main/java/com/sk89q/worldedit/util/formatting/StyleSet.java b/src/main/java/com/sk89q/worldedit/util/formatting/StyleSet.java
index 35663fa9e..408dc1e43 100644
--- a/src/main/java/com/sk89q/worldedit/util/formatting/StyleSet.java
+++ b/src/main/java/com/sk89q/worldedit/util/formatting/StyleSet.java
@@ -74,7 +74,7 @@ public class StyleSet {
* @return true if bold
*/
public boolean isBold() {
- return getBold() != null && getBold() == true;
+ return getBold() != null && getBold();
}
/**
@@ -101,7 +101,7 @@ public class StyleSet {
* @return true if italicized
*/
public boolean isItalic() {
- return getItalic() != null && getItalic() == true;
+ return getItalic() != null && getItalic();
}
/**
@@ -128,7 +128,7 @@ public class StyleSet {
* @return true if underlined
*/
public boolean isUnderline() {
- return getUnderline() != null && getUnderline() == true;
+ return getUnderline() != null && getUnderline();
}
/**
@@ -155,7 +155,7 @@ public class StyleSet {
* @return true if there is strikethrough applied
*/
public boolean isStrikethrough() {
- return getStrikethrough() != null && getStrikethrough() == true;
+ return getStrikethrough() != null && getStrikethrough();
}
/**
diff --git a/src/main/java/com/sk89q/worldedit/util/formatting/StyledFragment.java b/src/main/java/com/sk89q/worldedit/util/formatting/StyledFragment.java
index 7674d9bf8..eaa4293cc 100644
--- a/src/main/java/com/sk89q/worldedit/util/formatting/StyledFragment.java
+++ b/src/main/java/com/sk89q/worldedit/util/formatting/StyledFragment.java
@@ -57,7 +57,7 @@ public class StyledFragment extends Fragment {
protected Fragment lastText() {
Fragment text;
- if (children.size() > 0) {
+ if (!children.isEmpty()) {
text = children.get(children.size() - 1);
if (text == lastText) {
return text;
diff --git a/src/main/java/com/sk89q/worldedit/util/function/LevenshteinDistance.java b/src/main/java/com/sk89q/worldedit/util/function/LevenshteinDistance.java
index 8767f3a2f..723db8123 100644
--- a/src/main/java/com/sk89q/worldedit/util/function/LevenshteinDistance.java
+++ b/src/main/java/com/sk89q/worldedit/util/function/LevenshteinDistance.java
@@ -114,7 +114,7 @@ public class LevenshteinDistance implements Function {@link #hasNbtData()} must return true if and only if method does not return null. {@link #hasNbtData()} must return true if and only if method does
+ * not return null.null
+ * @throws IllegalArgumentException if either String input {@code null}
*/
public static int distance(String s, String t) {
if (s == null || t == null) {
@@ -150,9 +150,9 @@ public class LevenshteinDistance implements Function
Implementations should override this so that custom liquids + * are supported.
* * @return a mask */ @@ -96,13 +97,13 @@ public interface World extends Extent { * {@code notifyAndLight} parameter indicates whether adjacent blocks * should be notified that changes have been made and lighting operations * should be executed. - * - * If it's not possible to skip lighting, or if it's not possible to + * + *If it's not possible to skip lighting, or if it's not possible to * avoid notifying adjacent blocks, then attempt to meet the - * specification as best as possible. - *
- * On implementations where the world is not simulated, the - * {@code notifyAndLight} parameter has no effect either way. + * specification as best as possible. + * + *On implementations where the world is not simulated, the + * {@code notifyAndLight} parameter has no effect either way.
* * @param position position of the block * @param block block to set @@ -229,12 +230,12 @@ public interface World extends Extent { /** * Fix the given chunks after fast mode was used. - * - * Fast mode makes calls to {@link #setBlock(Vector, BaseBlock, boolean)} + * + *Fast mode makes calls to {@link #setBlock(Vector, BaseBlock, boolean)} * with {@code false} for the {@code notifyAndLight} parameter, which * may causes lighting errors to accumulate. Use of this method, if * it is implemented by the underlying world, corrects those lighting - * errors and may trigger block change notifications. + * errors and may trigger block change notifications.
* * @param chunks a list of chunk coordinates to fix */ diff --git a/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java b/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java index 497935a7f..15a93f575 100644 --- a/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java +++ b/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java @@ -19,7 +19,13 @@ package com.sk89q.worldedit.world.chunk; -import com.sk89q.jnbt.*; +import com.sk89q.jnbt.ByteArrayTag; +import com.sk89q.jnbt.ByteTag; +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.jnbt.IntTag; +import com.sk89q.jnbt.ListTag; +import com.sk89q.jnbt.NBTUtils; +import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; @@ -28,6 +34,7 @@ import com.sk89q.worldedit.world.DataException; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.storage.InvalidFormatException; +import javax.annotation.Nullable; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -93,38 +100,38 @@ public class AnvilChunk implements Chunk { } int sectionsize = 16 * 16 * 16; - for (int i = 0; i < blocks.length; i++) { - if (blocks[i].length != sectionsize) { + for (byte[] block : blocks) { + if (block.length != sectionsize) { throw new InvalidFormatException( "Chunk blocks byte array expected " + "to be " + sectionsize + " bytes; found " - + blocks[i].length); + + block.length); } } - for (int i = 0; i < data.length; i++) { - if (data[i].length != (sectionsize / 2)) { + for (byte[] aData : data) { + if (aData.length != (sectionsize / 2)) { throw new InvalidFormatException("Chunk block data byte array " + "expected to be " + sectionsize + " bytes; found " - + data[i].length); + + aData.length); } } } @Override - public int getBlockID(Vector pos) throws DataException { - int x = pos.getBlockX() - rootX * 16; - int y = pos.getBlockY(); - int z = pos.getBlockZ() - rootZ * 16; + public int getBlockID(Vector position) throws DataException { + int x = position.getBlockX() - rootX * 16; + int y = position.getBlockY(); + int z = position.getBlockZ() - rootZ * 16; int section = y >> 4; if (section < 0 || section >= blocks.length) { - throw new DataException("Chunk does not contain position " + pos); + throw new DataException("Chunk does not contain position " + position); } int yindex = y & 0x0F; if (yindex < 0 || yindex >= 16) { - throw new DataException("Chunk does not contain position " + pos); + throw new DataException("Chunk does not contain position " + position); } int index = x + (z * 16 + (yindex * 16 * 16)); @@ -144,25 +151,25 @@ public class AnvilChunk implements Chunk { return (blocks[section][index] & 0xFF) + addId; } catch (IndexOutOfBoundsException e) { - throw new DataException("Chunk does not contain position " + pos); + throw new DataException("Chunk does not contain position " + position); } } @Override - public int getBlockData(Vector pos) throws DataException { - int x = pos.getBlockX() - rootX * 16; - int y = pos.getBlockY(); - int z = pos.getBlockZ() - rootZ * 16; + public int getBlockData(Vector position) throws DataException { + int x = position.getBlockX() - rootX * 16; + int y = position.getBlockY(); + int z = position.getBlockZ() - rootZ * 16; int section = y >> 4; int yIndex = y & 0x0F; if (section < 0 || section >= blocks.length) { - throw new DataException("Chunk does not contain position " + pos); + throw new DataException("Chunk does not contain position " + position); } if (yIndex < 0 || yIndex >= 16) { - throw new DataException("Chunk does not contain position " + pos); + throw new DataException("Chunk does not contain position " + position); } int index = x + (z * 16 + (yIndex * 16 * 16)); @@ -176,7 +183,7 @@ public class AnvilChunk implements Chunk { return data[section][index] & 0xF; } } catch (IndexOutOfBoundsException e) { - throw new DataException("Chunk does not contain position " + pos); + throw new DataException("Chunk does not contain position " + position); } } @@ -233,26 +240,28 @@ public class AnvilChunk implements Chunk { * return null if there is no tile entity data. Not public yet because * what this function returns isn't ideal for usage. * - * @param pos - * @return - * @throws DataException + * @param position the position + * @return the compound tag for that position, which may be null + * @throws DataException thrown if there is a data error */ - private CompoundTag getBlockTileEntity(Vector pos) throws DataException { + @Nullable + private CompoundTag getBlockTileEntity(Vector position) throws DataException { if (tileEntities == null) { populateTileEntities(); } - Map