Fix Javadocs and code issues.

This commit is contained in:
sk89q
2014-07-29 11:04:04 -07:00
parent 8834af7538
commit 1dc84d2511
230 changed files with 1646 additions and 1882 deletions

View File

@ -20,10 +20,7 @@
package com.sk89q.jnbt;
/**
* The <code>TAG_End</code> tag.
*
* @author Graham Edgecombe
*
* The {@code TAG_End} tag.
*/
public final class EndTag extends Tag {

View File

@ -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;
}
}

View File

@ -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();

View File

@ -23,9 +23,6 @@ import java.nio.charset.Charset;
/**
* A class which holds constant values.
*
* @author Graham Edgecombe
*
*/
public final class NBTConstants {

View File

@ -29,20 +29,13 @@ import java.util.List;
import java.util.Map;
/**
* <p>
* This class reads <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
* streams, and produces an object graph of subclasses of the <code>Tag</code>
* streams, and produces an object graph of subclasses of the {@code Tag}
* object.
* </p>
*
* <p>
* The NBT format was created by Markus Persson, and the specification may be
* <p>The NBT format was created by Markus Persson, and the specification may be
* found at <a href="http://www.minecraft.net/docs/NBT.txt">
* http://www.minecraft.net/docs/NBT.txt</a>.
* </p>
*
* @author Graham Edgecombe
*
* http://www.minecraft.net/docs/NBT.txt</a>.</p>
*/
public final class NBTInputStream implements Closeable {

View File

@ -26,19 +26,12 @@ import java.io.OutputStream;
import java.util.List;
/**
* <p>
* This class writes <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
* <code>Tag</code> objects to an underlying <code>OutputStream</code>.
* </p>
* {@code Tag} objects to an underlying {@code OutputStream}.
*
* <p>
* The NBT format was created by Markus Persson, and the specification may be
* <p>The NBT format was created by Markus Persson, and the specification may be
* found at <a href="http://www.minecraft.net/docs/NBT.txt">
* http://www.minecraft.net/docs/NBT.txt</a>.
* </p>
*
* @author Graham Edgecombe
*
* http://www.minecraft.net/docs/NBT.txt</a>.</p>
*/
public final class NBTOutputStream implements Closeable {
@ -48,7 +41,7 @@ public final class NBTOutputStream implements Closeable {
private final DataOutputStream os;
/**
* Creates a new <code>NBTOutputStream</code>, 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 <code>TAG_Byte</code> tag.
* Writes a {@code TAG_Byte} tag.
*
* @param tag
* The tag.
@ -149,7 +142,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
* Writes a <code>TAG_Byte_Array</code> tag.
* Writes a {@code TAG_Byte_Array} tag.
*
* @param tag
* The tag.
@ -163,7 +156,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
* Writes a <code>TAG_Compound</code> tag.
* Writes a {@code TAG_Compound} tag.
*
* @param tag
* The tag.
@ -178,7 +171,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
* Writes a <code>TAG_List</code> 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 <code>TAG_String</code> tag.
* Writes a {@code TAG_String} tag.
*
* @param tag
* The tag.
@ -212,7 +205,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
* Writes a <code>TAG_Double</code> tag.
* Writes a {@code TAG_Double} tag.
*
* @param tag
* The tag.
@ -224,7 +217,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
* Writes a <code>TAG_Float</code> tag.
* Writes a {@code TAG_Float} tag.
*
* @param tag
* The tag.
@ -236,7 +229,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
* Writes a <code>TAG_Long</code> tag.
* Writes a {@code TAG_Long} tag.
*
* @param tag
* The tag.
@ -248,7 +241,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
* Writes a <code>TAG_Int</code> tag.
* Writes a {@code TAG_Int} tag.
*
* @param tag
* The tag.
@ -260,7 +253,7 @@ public final class NBTOutputStream implements Closeable {
}
/**
* Writes a <code>TAG_Short</code> tag.
* Writes a {@code TAG_Short} tag.
*
* @param tag
* The tag.
@ -272,12 +265,9 @@ public final class NBTOutputStream implements Closeable {
}
/**
* Writes a <code>TAG_Empty</code> 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();
}

View File

@ -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 <T extends Tag> T getChildTag(Map<String,Tag> items, String key,
Class<T> expected) throws InvalidFormatException {
public static <T extends Tag> T getChildTag(Map<String, Tag> items, String key, Class<T> expected) throws InvalidFormatException {
if (!items.containsKey(key)) {
throw new InvalidFormatException("Missing a \"" + key + "\" tag");
}

View File

@ -26,11 +26,10 @@ import java.lang.annotation.RetentionPolicy;
* This annotation indicates a command. Methods should be marked with this
* annotation to tell {@link CommandsManager} that the method is a command.
* Note that the method name can actually be anything.
*
* @author sk89q
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface Command {
/**
* A list of aliases for the command. The first alias is the most
* important -- it is the main name of the command. (The method name
@ -42,7 +41,7 @@ public @interface Command {
/**
* Usage instruction. Example text for usage could be
* <code>[-h harps] [name] [message]</code>.
* {@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;
}

View File

@ -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();
}

View File

@ -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?

View File

@ -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 List<String> commandStack = new ArrayList<String>();
public CommandException() {

View File

@ -24,14 +24,14 @@ import java.lang.annotation.RetentionPolicy;
/**
* Indicates a list of permissions that should be checked.
*
* @author sk89q
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface CommandPermissions {
/**
* A list of permissions. Only one permission has to be met
* for the command to be permitted.
*/
String[] value();
}

View File

@ -21,9 +21,7 @@ package com.sk89q.minecraft.util.commands;
/**
* Thrown when not enough permissions are satisfied.
*
* @author sk89q
*/
public class CommandPermissionsException extends CommandException {
private static final long serialVersionUID = -602374621030168291L;
}

View File

@ -20,7 +20,6 @@
package com.sk89q.minecraft.util.commands;
public class CommandUsageException extends CommandException {
private static final long serialVersionUID = -6761418114414516542L;
protected String usage;

View File

@ -19,6 +19,8 @@
package com.sk89q.minecraft.util.commands;
import com.sk89q.util.StringUtil;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@ -31,16 +33,14 @@ import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.sk89q.util.StringUtil;
/**
* <p>Manager for handling commands. This allows you to easily process commands,
* including nested commands, by correctly annotating methods of a class.</p>
* Manager for handling commands. This allows you to easily process commands,
* including nested commands, by correctly annotating methods of a class.
*
* <p>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
* <code>execute</code> 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.</p>
*
@ -57,13 +57,11 @@ import com.sk89q.util.StringUtil;
* allows for fast command handling. Method invocation still has to be done
* with reflection, but this is quite fast in that of itself.</p>
*
* @author sk89q
* @param <T> command sender class
*/
@SuppressWarnings("ProtectedField")
public abstract class CommandsManager<T> {
/**
* Logger for general errors.
*/
protected static final Logger logger =
Logger.getLogger(CommandsManager.class.getCanonicalName());
@ -105,7 +103,7 @@ public abstract class CommandsManager<T> {
* instances will be created of the command classes and methods will
* not be called statically.
*
* @param cls
* @param cls the class to register
*/
public void register(Class<?> cls) {
registerMethods(cls, null);
@ -119,7 +117,7 @@ public abstract class CommandsManager<T> {
* not be called statically. A List of {@link Command} annotations from
* registered commands is returned.
*
* @param cls
* @param cls the class to register
* @return A List of {@link Command} annotations from registered commands,
* for use in eg. a dynamic command registration system.
*/
@ -131,8 +129,8 @@ public abstract class CommandsManager<T> {
* Register the methods of a class. This will automatically construct
* instances as necessary.
*
* @param cls
* @param parent
* @param cls the class to register
* @param parent the parent method
* @return Commands Registered
*/
public List<Command> registerMethods(Class<?> cls, Method parent) {
@ -156,10 +154,10 @@ public abstract class CommandsManager<T> {
/**
* Register the methods of a class.
*
* @param cls
* @param parent
* @param obj
* @return
* @param cls the class to register
* @param parent the parent method
* @param obj the object whose methods will become commands if they are annotated
* @return a list of commands
*/
private List<Command> registerMethods(Class<?> cls, Method parent, Object obj) {
Map<String, Method> map;
@ -205,14 +203,14 @@ public abstract class CommandsManager<T> {
final String desc = cmd.desc();
final String usage = cmd.usage();
if (usage.length() == 0) {
if (usage.isEmpty()) {
descs.put(commandName, desc);
} else {
descs.put(commandName, usage + " - " + desc);
}
String help = cmd.help();
if (help.length() == 0) {
if (help.isEmpty()) {
help = desc;
}
@ -255,8 +253,8 @@ public abstract class CommandsManager<T> {
* Checks to see whether there is a command named such at the root level.
* This will check aliases as well.
*
* @param command
* @return
* @param command the command
* @return true if the command exists
*/
public boolean hasCommand(String command) {
return commands.get(null).containsKey(command.toLowerCase());
@ -265,12 +263,17 @@ public abstract class CommandsManager<T> {
/**
* Get a list of command descriptions. This is only for root commands.
*
* @return
* @return a map of commands
*/
public Map<String, String> getCommands() {
return descs;
}
/**
* Get the mapping of methods under a parent command.
*
* @return the mapping
*/
public Map<Method, Map<String, Method>> getMethods() {
return commands;
}
@ -278,7 +281,7 @@ public abstract class CommandsManager<T> {
/**
* Get a map from command name to help message. This is only for root commands.
*
* @return
* @return a map of help messages for each command
*/
public Map<String, String> getHelpMessages() {
return helpMessages;
@ -287,10 +290,10 @@ public abstract class CommandsManager<T> {
/**
* Get the usage string for a command.
*
* @param args
* @param level
* @param cmd
* @return
* @param args the arguments
* @param level the depth of the command
* @param cmd the command annotation
* @return the usage string
*/
protected String getUsage(String[] args, int level, Command cmd) {
final StringBuilder command = new StringBuilder();
@ -304,7 +307,7 @@ public abstract class CommandsManager<T> {
command.append(getArguments(cmd));
final String help = cmd.help();
if (help.length() > 0) {
if (!help.isEmpty()) {
command.append("\n\n");
command.append(help);
}
@ -316,9 +319,9 @@ public abstract class CommandsManager<T> {
final String flags = cmd.flags();
final StringBuilder command2 = new StringBuilder();
if (flags.length() > 0) {
if (!flags.isEmpty()) {
String flagString = flags.replaceAll(".:", "");
if (flagString.length() > 0) {
if (!flagString.isEmpty()) {
command2.append("[-");
for (int i = 0; i < flagString.length(); ++i) {
command2.append(flagString.charAt(i));
@ -335,22 +338,20 @@ public abstract class CommandsManager<T> {
/**
* Get the usage string for a nested command.
*
* @param args
* @param level
* @param method
* @param player
* @return
* @throws CommandException
* @param args the arguments
* @param level the depth of the command
* @param method the parent method
* @param player the player
* @return the usage string
* @throws CommandException on some error
*/
protected String getNestedUsage(String[] args, int level,
Method method, T player) throws CommandException {
protected String getNestedUsage(String[] args, int level, Method method, T player) throws CommandException {
StringBuilder command = new StringBuilder();
command.append("/");
for (int i = 0; i <= level; ++i) {
command.append(args[i] + " ");
command.append(args[i]).append(" ");
}
Map<String, Method> map = commands.get(method);
@ -371,7 +372,7 @@ public abstract class CommandsManager<T> {
}
}
if (allowedCommands.size() > 0) {
if (!allowedCommands.isEmpty()) {
command.append(StringUtil.joinString(allowedCommands, "|", 0));
} else {
if (!found) {
@ -412,14 +413,12 @@ public abstract class CommandsManager<T> {
/**
* Attempt to execute a command.
*
* @param args
* @param player
* @param methodArgs
* @throws CommandException
* @param args the arguments
* @param player the player
* @param methodArgs the arguments for the method
* @throws CommandException thrown on command error
*/
public void execute(String[] args, T player,
Object... methodArgs) throws CommandException {
public void execute(String[] args, T player, Object... methodArgs) throws CommandException {
Object[] newMethodArgs = new Object[methodArgs.length + 1];
System.arraycopy(methodArgs, 0, newMethodArgs, 1, methodArgs.length);
executeMethod(null, args, player, newMethodArgs, 0);
@ -428,16 +427,14 @@ public abstract class CommandsManager<T> {
/**
* Attempt to execute a command.
*
* @param parent
* @param args
* @param player
* @param methodArgs
* @param level
* @throws CommandException
* @param parent the parent method
* @param args an array of arguments
* @param player the player
* @param methodArgs the array of method arguments
* @param level the depth of the command
* @throws CommandException thrown on a command error
*/
public void executeMethod(Method parent, String[] args,
T player, Object[] methodArgs, int level) throws CommandException {
public void executeMethod(Method parent, String[] args, T player, Object[] methodArgs, int level) throws CommandException {
String cmdName = args[level];
Map<String, Method> map = commands.get(parent);
@ -527,8 +524,7 @@ public abstract class CommandsManager<T> {
}
}
public void invokeMethod(Method parent, String[] args, T player, Method method,
Object instance, Object[] methodArgs, int level) throws CommandException {
public void invokeMethod(Method parent, String[] args, T player, Method method, Object instance, Object[] methodArgs, int level) throws CommandException {
try {
method.invoke(instance, methodArgs);
} catch (IllegalArgumentException e) {
@ -547,9 +543,9 @@ public abstract class CommandsManager<T> {
/**
* Returns whether a player has access to a command.
*
* @param method
* @param player
* @return
* @param method the method
* @param player the player
* @return true if permission is granted
*/
protected boolean hasPermission(Method method, T player) {
CommandPermissions perms = method.getAnnotation(CommandPermissions.class);
@ -569,11 +565,11 @@ public abstract class CommandsManager<T> {
/**
* Returns whether a player permission..
*
* @param player
* @param perm
* @return
* @param player the player
* @param permission the permission
* @return true if permission is granted
*/
public abstract boolean hasPermission(T player, String perm);
public abstract boolean hasPermission(T player, String permission);
/**
* Get the injector used to create new instances. This can be

View File

@ -24,9 +24,8 @@ import java.lang.annotation.RetentionPolicy;
/**
* This annotation indicates that a command can be used from the console.
*
* @author sk89q
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface Console {
}

View File

@ -27,11 +27,10 @@ import java.lang.annotation.RetentionPolicy;
/**
* Indicates how the affected blocks should be hinted at in the log.
*
* @author sk89q
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface Logging {
public enum LogMode {
/**
* Player position
@ -63,4 +62,5 @@ public @interface Logging {
* Log mode. Can be either POSITION, REGION, ORIENTATION_REGION, PLACEMENT or ALL.
*/
LogMode value();
}

View File

@ -20,7 +20,6 @@
package com.sk89q.minecraft.util.commands;
public class MissingNestedCommandException extends CommandUsageException {
private static final long serialVersionUID = -4382896182979285355L;
public MissingNestedCommandException(String message, String usage) {
super(message, usage);

View File

@ -29,11 +29,10 @@ import java.lang.annotation.RetentionPolicy;
* will never called. Additionally, not all fields of {@link Command} apply
* when it is used in conjunction with this annotation, although both
* are still required.
*
* @author sk89q
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface NestedCommand {
/**
* A list of classes with the child commands.
*/
@ -43,4 +42,5 @@ public @interface NestedCommand {
* If set to true it will execute the body of the tagged method.
*/
boolean executeBody() default false;
}

View File

@ -21,10 +21,12 @@ package com.sk89q.minecraft.util.commands;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class SimpleInjector implements Injector {
private static final Logger logger = Logger.getLogger(SimpleInjector.class.getCanonicalName());
private static final Logger log = Logger.getLogger(SimpleInjector.class.getCanonicalName());
private Object[] args;
private Class<?>[] argClasses;
@ -36,26 +38,23 @@ public class SimpleInjector implements Injector {
}
}
@Override
public Object getInstance(Class<?> clazz) {
try {
Constructor<?> ctr = clazz.getConstructor(argClasses);
ctr.setAccessible(true);
return ctr.newInstance(args);
} catch (NoSuchMethodException e) {
logger.severe("Error initializing commands class " + clazz + ": ");
e.printStackTrace();
log.log(Level.SEVERE, "Error initializing commands class " + clazz, e);
return null;
} catch (InvocationTargetException e) {
logger.severe("Error initializing commands class " + clazz + ": ");
e.printStackTrace();
log.log(Level.SEVERE, "Error initializing commands class " + clazz, e);
return null;
} catch (InstantiationException e) {
logger.severe("Error initializing commands class " + clazz + ": ");
e.printStackTrace();
log.log(Level.SEVERE, "Error initializing commands class " + clazz, e);
return null;
} catch (IllegalAccessException e) {
logger.severe("Error initializing commands class " + clazz + ": ");
e.printStackTrace();
log.log(Level.SEVERE, "Error initializing commands class " + clazz, e);
return null;
}
}

View File

@ -20,6 +20,5 @@
package com.sk89q.minecraft.util.commands;
public class UnhandledCommandException extends CommandException {
private static final long serialVersionUID = 3370887306593968091L;
}

View File

@ -20,9 +20,9 @@
package com.sk89q.minecraft.util.commands;
public class WrappedCommandException extends CommandException {
private static final long serialVersionUID = -4075721444847778918L;
public WrappedCommandException(Throwable t) {
super(t);
}
}

View File

@ -21,9 +21,6 @@ package com.sk89q.util;
import java.lang.reflect.Field;
/**
* @author zml2008
*/
public final class ReflectionUtil {
private ReflectionUtil() {
@ -37,8 +34,8 @@ public final class ReflectionUtil {
Field field = checkClass.getDeclaredField(name);
field.setAccessible(true);
return (T) field.get(from);
} catch (NoSuchFieldException e) {
} catch (IllegalAccessException e) {
} catch (NoSuchFieldException ignored) {
} catch (IllegalAccessException ignored) {
}
} while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null));
return null;

View File

@ -24,8 +24,6 @@ import java.util.Map;
/**
* String utilities.
*
* @author sk89q
*/
public final class StringUtil {
@ -35,9 +33,9 @@ public final class StringUtil {
/**
* Trim a string if it is longer than a certain length.
*
* @param str
* @param len
* @return
* @param str the stirng
* @param len the length to trim to
* @return a new string
*/
public static String trimLength(String str, int len) {
if (str.length() > len) {
@ -50,13 +48,12 @@ public final class StringUtil {
/**
* Join an array of strings into a string.
*
* @param str
* @param delimiter
* @param initialIndex
* @return
* @param str the string array
* @param delimiter the delimiter
* @param initialIndex the initial index to start form
* @return a new string
*/
public static String joinString(String[] str, String delimiter,
int initialIndex) {
public static String joinString(String[] str, String delimiter, int initialIndex) {
if (str.length == 0) {
return "";
}
@ -70,11 +67,11 @@ public final class StringUtil {
/**
* Join an array of strings into a string.
*
* @param str
* @param delimiter
* @param initialIndex
* @param quote
* @return
* @param str the string array
* @param delimiter the delimiter
* @param initialIndex the initial index to start form
* @param quote the character to put around each entry
* @return a new string
*/
public static String joinQuotedString(String[] str, String delimiter,
int initialIndex, String quote) {
@ -94,9 +91,9 @@ public final class StringUtil {
/**
* Join an array of strings into a string.
*
* @param str
* @param delimiter
* @return
* @param str the string array
* @param delimiter the delimiter
* @return a new string
*/
public static String joinString(String[] str, String delimiter) {
return joinString(str, delimiter, 0);
@ -105,19 +102,18 @@ public final class StringUtil {
/**
* Join an array of strings into a string.
*
* @param str
* @param delimiter
* @param initialIndex
* @return
* @param str an array of objects
* @param delimiter the delimiter
* @param initialIndex the initial index to start form
* @return a new string
*/
public static String joinString(Object[] str, String delimiter,
int initialIndex) {
public static String joinString(Object[] str, String delimiter, int initialIndex) {
if (str.length == 0) {
return "";
}
StringBuilder buffer = new StringBuilder(str[initialIndex].toString());
for (int i = initialIndex + 1; i < str.length; ++i) {
buffer.append(delimiter).append(str[i].toString());
buffer.append(delimiter).append(str[i]);
}
return buffer.toString();
}
@ -125,13 +121,12 @@ public final class StringUtil {
/**
* Join an array of strings into a string.
*
* @param str
* @param delimiter
* @param initialIndex
* @return
* @param str a list of integers
* @param delimiter the delimiter
* @param initialIndex the initial index to start form
* @return a new string
*/
public static String joinString(int[] str, String delimiter,
int initialIndex) {
public static String joinString(int[] str, String delimiter, int initialIndex) {
if (str.length == 0) {
return "";
}
@ -144,15 +139,14 @@ public final class StringUtil {
/**
* Join an list of strings into a string.
*
* @param str
* @param delimiter
* @param initialIndex
* @return
*
* @param str a list of strings
* @param delimiter the delimiter
* @param initialIndex the initial index to start form
* @return a new string
*/
public static String joinString(Collection<?> str, String delimiter,
int initialIndex) {
if (str.size() == 0) {
public static String joinString(Collection<?> str, String delimiter,int initialIndex) {
if (str.isEmpty()) {
return "";
}
StringBuilder buffer = new StringBuilder();
@ -163,7 +157,7 @@ public final class StringUtil {
buffer.append(delimiter);
}
buffer.append(o.toString());
buffer.append(o);
}
++i;
}
@ -202,7 +196,7 @@ public final class StringUtil {
* @param s the first String, must not be null
* @param t the second String, must not be null
* @return result distance
* @throws IllegalArgumentException if either String input <code>null</code>
* @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

View File

@ -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 Map<String, Object> root;
private boolean writeDefaults;
@ -106,8 +106,8 @@ public class YAMLNode {
* Prepare a value for serialization, in case it's not a native type
* (and we don't want to serialize objects as YAML objects).
*
* @param value
* @return
* @param value the value to serialize
* @return the new object
*/
private Object prepareSerialization(Object value) {
if (value instanceof Vector) {
@ -126,8 +126,8 @@ public class YAMLNode {
* Set the property at a location. This will override existing
* configuration data to have it conform to key/value mappings.
*
* @param path
* @param value
* @param path the path
* @param value the new value
*/
@SuppressWarnings("unchecked")
public void setProperty(String path, Object value) {
@ -163,10 +163,10 @@ public class YAMLNode {
/**
* Adds a new node to the given path. The returned object is a reference
* to the new node. This method will replace an existing node at
* the same path. See <code>setProperty</code>.
* the same path. See {@code setProperty}.
*
* @param path
* @return
* @param path the path
* @return a node for the path
*/
public YAMLNode addNode(String path) {
Map<String, Object> map = new LinkedHashMap<String, Object>();
@ -557,9 +557,7 @@ public class YAMLNode {
* @param def default value or null for an empty list as default
* @return list of integers
*/
public List<Vector> getVectorList(
String path, List<Vector> def) {
public List<Vector> getVectorList(String path, List<Vector> def) {
List<YAMLNode> raw = getNodeList(path, null);
List<Vector> list = new ArrayList<Vector>();
@ -589,8 +587,7 @@ public class YAMLNode {
* @param def default value or null for an empty list as default
* @return list of integers
*/
public List<Vector2D> getVector2dList(
String path, List<Vector2D> def) {
public List<Vector2D> getVector2dList(String path, List<Vector2D> def) {
List<YAMLNode> raw = getNodeList(path, null);
List<Vector2D> list = new ArrayList<Vector2D>();
@ -620,8 +617,7 @@ public class YAMLNode {
* @param def default value or null for an empty list as default
* @return list of integers
*/
public List<BlockVector2D> getBlockVector2dList(
String path, List<BlockVector2D> def) {
public List<BlockVector2D> getBlockVector2dList(String path, List<BlockVector2D> def) {
List<YAMLNode> raw = getNodeList(path, null);
List<BlockVector2D> list = new ArrayList<BlockVector2D>();
@ -674,9 +670,10 @@ public class YAMLNode {
* path does not lead to a node, null will be returned. A node has
* key/value mappings.
*
* @param path
* @param path the path
* @return node or null
*/
@Nullable
@SuppressWarnings("unchecked")
public YAMLNode getNode(String path) {
Object raw = getProperty(path);
@ -719,9 +716,10 @@ public class YAMLNode {
/**
* Casts a value to an integer. May return null.
*
* @param o
* @return
* @param o the object
* @return an integer or null
*/
@Nullable
private static Integer castInt(Object o) {
if (o == null) {
return null;
@ -734,10 +732,11 @@ public class YAMLNode {
/**
* Casts a value to a double. May return null.
*
* @param o
* @return
*
* @param o the object
* @return a double or null
*/
@Nullable
private static Double castDouble(Object o) {
if (o == null) {
return null;
@ -750,10 +749,11 @@ public class YAMLNode {
/**
* Casts a value to a boolean. May return null.
*
* @param o
* @return
*
* @param o the object
* @return a boolean or null
*/
@Nullable
private static Boolean castBoolean(Object o) {
if (o == null) {
return null;
@ -768,7 +768,7 @@ public class YAMLNode {
* Remove the property at a location. This will override existing
* configuration data to have it conform to key/value mappings.
*
* @param path
* @param path a path
*/
@SuppressWarnings("unchecked")
public void removeProperty(String path) {
@ -800,4 +800,5 @@ public class YAMLNode {
public void setWriteDefaults(boolean writeDefaults) {
this.writeDefaults = writeDefaults;
}
}

View File

@ -32,6 +32,7 @@ import org.yaml.snakeyaml.representer.Representer;
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
/**
* YAML configuration loader. To use this class, construct it with path to
@ -58,13 +59,11 @@ import java.util.*;
* babies: true</pre>
*
* <p>Calling code could access sturmeh's baby eating state by using
* <code>getBoolean("sturmeh.eats.babies", false)</code>. For lists, there are
* methods such as <code>getStringList</code> 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 (Iterator<Map.Entry<String, Object>> i = root.entrySet().iterator(); i.hasNext(); ) {
Map.Entry<String, Object> entry = i.next();
for (Entry<String, Object> entry : root.entrySet()) {
// Output comment, if present
String comment = comments.get(entry.getKey());
if (comment != null) {
@ -204,13 +201,13 @@ public class YAMLProcessor extends YAMLNode {
}
}
return true;
} catch (IOException e) {
} catch (IOException ignored) {
} finally {
try {
if (stream != null) {
stream.close();
}
} catch (IOException e) {}
} catch (IOException ignored) {}
}
return false;
@ -241,7 +238,7 @@ public class YAMLProcessor extends YAMLNode {
* Returns a root-level comment.
*
* @param key the property key
* @return the comment or <code>null</code>
* @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 <code>null</code>, 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<String, Object>(), writeDefaults);
@ -321,12 +319,14 @@ public class YAMLProcessor extends YAMLNode {
}
private static class FancyRepresenter extends Representer {
public FancyRepresenter() {
private FancyRepresenter() {
this.nullRepresenter = new Represent() {
@Override
public Node representData(Object o) {
return representScalar(Tag.NULL, "");
}
};
}
}
}

View File

@ -21,11 +21,8 @@ package com.sk89q.util.yaml;
/**
* YAMLProcessor exception.
*
* @author sk89q
*/
public class YAMLProcessorException extends Exception {
private static final long serialVersionUID = -2442886939908724203L;
public YAMLProcessorException() {
super();
@ -34,4 +31,5 @@ public class YAMLProcessorException extends Exception {
public YAMLProcessorException(String msg) {
super(msg);
}
}

View File

@ -174,7 +174,7 @@ public class CuboidClipboard {
final int shiftX = sizeRotated.getX() < 0 ? -sizeRotated.getBlockX() - 1 : 0;
final int shiftZ = sizeRotated.getZ() < 0 ? -sizeRotated.getBlockZ() - 1 : 0;
final BaseBlock newData[][][] = new BaseBlock
final BaseBlock[][][] newData = new BaseBlock
[Math.abs(sizeRotated.getBlockX())]
[Math.abs(sizeRotated.getBlockY())]
[Math.abs(sizeRotated.getBlockZ())];
@ -476,8 +476,9 @@ public class CuboidClipboard {
* @param position the point, relative to the origin of the copy (0, 0, 0) and not to the actual copy origin
* @return air, if this block was outside the (non-cuboid) selection while copying
* @throws ArrayIndexOutOfBoundsException if the position is outside the bounds of the CuboidClipboard
* @deprecated Use {@link #getBlock(Vector)} instead
* @deprecated use {@link #getBlock(Vector)} instead
*/
@Deprecated
public BaseBlock getPoint(Vector position) throws ArrayIndexOutOfBoundsException {
final BaseBlock block = getBlock(position);
if (block == null) {

View File

@ -80,6 +80,8 @@ import com.sk89q.worldedit.world.biome.BaseBiome;
import javax.annotation.Nullable;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
@ -96,6 +98,8 @@ import static com.sk89q.worldedit.regions.Regions.*;
@SuppressWarnings("FieldCanBeLocal")
public class EditSession implements Extent {
private static final Logger log = Logger.getLogger(EditSession.class.getCanonicalName());
/**
* Used by {@link #setBlock(Vector, BaseBlock, Stage)} to
* determine which {@link Extent}s should be bypassed.
@ -317,8 +321,9 @@ public class EditSession implements Extent {
/**
* Set whether fast mode is enabled.
* </p>
* Fast mode may skip lighting checks or adjacent block notification.
*
* <p>Fast mode may skip lighting checks or adjacent block
* notification.</p>
*
* @param enabled true to enable
*/
@ -330,13 +335,14 @@ public class EditSession implements Extent {
/**
* Return fast mode status.
* </p>
* Fast mode may skip lighting checks or adjacent block notification.
*
* <p>Fast mode may skip lighting checks or adjacent block
* notification.</p>
*
* @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.
* </p>
* This number may not be accurate.
*
* <p>This number may not be accurate.</p>
*
* @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 List<Countable<Integer>> getBlockDistribution(Region region) {
List<Countable<Integer>> distribution = new ArrayList<Countable<Integer>>();
@ -1862,8 +1864,8 @@ public class EditSession implements Extent {
/**
* Get the block distribution (with data values) inside a region.
*
* @param region
* @return
* @param region a region
* @return the results
*/
// TODO reduce code duplication - probably during ops-redux
public List<Countable<BaseBlock>> getBlockDistributionWithData(Region region) {
@ -1942,7 +1944,7 @@ public class EditSession implements Extent {
return new BaseBlock((int) typeVariable.getValue(), (int) dataVariable.getValue());
} catch (Exception e) {
e.printStackTrace();
log.log(Level.WARNING, "Failed to create shape", e);
return null;
}
}
@ -2161,12 +2163,12 @@ public class EditSession implements Extent {
throws MaxChangedBlocksException {
Set<Vector> vset = new HashSet<Vector>();
List<Node> nodes = new ArrayList(nodevectors.size());
List<Node> nodes = new ArrayList<Node>(nodevectors.size());
Interpolation interpol = new KochanekBartelsInterpolation();
for (int loop = 0; loop < nodevectors.size(); loop++) {
Node n = new Node(nodevectors.get(loop));
for (Vector nodevector : nodevectors) {
Node n = new Node(nodevector);
n.setTension(tension);
n.setBias(bias);
n.setContinuity(continuity);
@ -2285,7 +2287,7 @@ public class EditSession implements Extent {
// TODO: Allow biome setting via a script variable (needs BiomeType<->int mapping)
return defaultBiomeType;
} catch (Exception e) {
e.printStackTrace();
log.log(Level.WARNING, "Failed to create shape", e);
return null;
}
}
@ -2303,11 +2305,11 @@ public class EditSession implements Extent {
PlayerDirection.DOWN.vector(),
};
private static final double lengthSq(double x, double y, double z) {
private static double lengthSq(double x, double y, double z) {
return (x * x) + (y * y) + (z * z);
}
private static final double lengthSq(double x, double z) {
private static double lengthSq(double x, double z) {
return (x * x) + (z * z);
}

View File

@ -107,7 +107,7 @@ public class Location {
@Override
public String toString() {
return "World: " + world.getName() + ", Coordinates: " + position.toString()
return "World: " + world.getName() + ", Coordinates: " + position
+ ", Yaw: " + yaw + ", Pitch: " + pitch;
}

View File

@ -39,9 +39,9 @@ public enum PlayerDirection {
UP(new Vector(0, 1, 0), new Vector(0, 0, 1), true),
DOWN(new Vector(0, -1, 0), new Vector(0, 0, 1), true);
private Vector dir;
private Vector leftDir;
private boolean isOrthogonal;
private final Vector dir;
private final Vector leftDir;
private final boolean isOrthogonal;
PlayerDirection(Vector vec, Vector leftDir, boolean isOrthogonal) {
this.dir = vec;

View File

@ -49,9 +49,9 @@ public enum VectorFace {
BELOW_EAST(DOWN, EAST),
SELF(0, 0, 0);
private int modX;
private int modY;
private int modZ;
private final int modX;
private final int modY;
private final int modZ;
private VectorFace(final int modX, final int modY, final int modZ) {
this.modX = modX;

View File

@ -62,6 +62,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkNotNull;
@ -761,7 +762,7 @@ public class WorldEdit {
} catch (ScriptException e) {
player.printError("Failed to execute:");
player.printRaw(e.getMessage());
e.printStackTrace();
logger.log(Level.WARNING, "Failed to execute script", e);
} catch (NumberFormatException e) {
throw e;
} catch (WorldEditException e) {
@ -769,7 +770,7 @@ public class WorldEdit {
} catch (Throwable e) {
player.printError("Failed to execute (see console):");
player.printRaw(e.getClass().getCanonicalName());
e.printStackTrace();
logger.log(Level.WARNING, "Failed to execute script", e);
} finally {
for (EditSession editSession : scriptContext.getEditSessions()) {
editSession.flushQueue();

View File

@ -25,20 +25,19 @@ import com.sk89q.worldedit.world.World;
/**
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
*/
@SuppressWarnings("deprecation")
@Deprecated
public class WorldVector extends Vector {
/**
* Represents the world.
*/
private LocalWorld world;
/**
* Construct the Vector object.
*
* @param world
* @param x
* @param y
* @param z
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public WorldVector(LocalWorld world, double x, double y, double z) {
super(x, y, z);
@ -48,10 +47,10 @@ public class WorldVector extends Vector {
/**
* Construct the Vector object.
*
* @param world
* @param x
* @param y
* @param z
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public WorldVector(LocalWorld world, int x, int y, int z) {
super(x, y, z);
@ -61,10 +60,10 @@ public class WorldVector extends Vector {
/**
* Construct the Vector object.
*
* @param world
* @param x
* @param y
* @param z
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public WorldVector(LocalWorld world, float x, float y, float z) {
super(x, y, z);
@ -74,18 +73,18 @@ public class WorldVector extends Vector {
/**
* Construct the Vector object.
*
* @param world
* @param pt
* @param world a world
* @param other the position to copy
*/
public WorldVector(LocalWorld world, Vector pt) {
super(pt);
public WorldVector(LocalWorld world, Vector other) {
super(other);
this.world = world;
}
/**
* Construct the Vector object.
*
* @param world
* @param world a world
*/
public WorldVector(LocalWorld world) {
super();
@ -104,7 +103,7 @@ public class WorldVector extends Vector {
/**
* Get the world.
*
* @return
* @return the world
*/
public LocalWorld getWorld() {
return world;
@ -112,11 +111,11 @@ public class WorldVector extends Vector {
/**
* Get a block point from a point.
*
* @param world
* @param x
* @param y
* @param z
*
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
* @return point
*/
public static WorldVector toBlockPoint(LocalWorld world, double x, double y,
@ -136,7 +135,7 @@ public class WorldVector extends Vector {
}
/**
* Return this object as a new preferred <code>Location</code>
* Return this object as a new preferred {@code Location}
* object.
*
* @return a new location object

View File

@ -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)) {

View File

@ -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;

View File

@ -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) {

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -173,7 +173,7 @@ public class GeneralCommands {
}
return;
} catch (NumberFormatException e) {
} catch (NumberFormatException ignored) {
}
if (query.length() <= 2) {

View File

@ -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);
}
}

View File

@ -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) {

View File

@ -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 {
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName());
if (snapshots.size() > 0) {
if (!snapshots.isEmpty()) {
int num = args.argsLength() > 0 ? Math.min(40, Math.max(5, args.getInteger(0))) : 5;
@ -269,4 +268,5 @@ public class SnapshotCommands {
}
}
}
}

View File

@ -147,7 +147,7 @@ public class SnapshotUtilCommands {
} finally {
try {
chunkStore.close();
} catch (IOException e) {
} catch (IOException ignored) {
}
}
}

View File

@ -22,7 +22,6 @@ package com.sk89q.worldedit.command;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.minecraft.util.commands.NestedCommand;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.ItemType;

View File

@ -41,7 +41,7 @@ public class ToolUtilCommands {
@Command(
aliases = { "/", "," },
usage = "[on|off]",
desc = "Toggle the super pickaxe pickaxe function",
desc = "Toggle the super pickaxe function",
min = 0,
max = 1
)

View File

@ -72,10 +72,9 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
/**
* Utility commands.
*
* @author sk89q
*/
public class UtilityCommands {
private final WorldEdit we;
public UtilityCommands(WorldEdit we) {
@ -672,4 +671,5 @@ public class UtilityCommands {
actor.printRaw(ColorCodeBuilder.asColorCodes(box));
}
}
}

View File

@ -34,6 +34,8 @@ import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.session.request.Request;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Builds a shape at the place being looked at.
*/
@ -50,9 +52,10 @@ public class BrushTool implements TraceTool {
/**
* Construct the tool.
*
* @param permission
* @param permission the permission to check before use is allowed
*/
public BrushTool(String permission) {
checkNotNull(permission);
this.permission = permission;
}
@ -82,18 +85,18 @@ public class BrushTool implements TraceTool {
/**
* Set the brush.
*
* @param brush
* @param perm
* @param brush tbe brush
* @param permission the permission
*/
public void setBrush(Brush brush, String perm) {
public void setBrush(Brush brush, String permission) {
this.brush = brush;
this.permission = perm;
this.permission = permission;
}
/**
* Get the current brush.
*
* @return
* @return the current brush
*/
public Brush getBrush() {
return brush;
@ -102,7 +105,7 @@ public class BrushTool implements TraceTool {
/**
* Set the material.
*
* @param material
* @param material the material
*/
public void setFill(Pattern material) {
this.material = material;
@ -111,7 +114,7 @@ public class BrushTool implements TraceTool {
/**
* Get the material.
*
* @return
* @return the material
*/
public Pattern getMaterial() {
return material;
@ -120,7 +123,7 @@ public class BrushTool implements TraceTool {
/**
* Get the set brush size.
*
* @return
* @return a radius
*/
public double getSize() {
return size;
@ -129,7 +132,7 @@ public class BrushTool implements TraceTool {
/**
* Set the set brush size.
*
* @param radius
* @param radius a radius
*/
public void setSize(double radius) {
this.size = radius;
@ -138,7 +141,7 @@ public class BrushTool implements TraceTool {
/**
* Get the set brush range.
*
* @return
* @return the range of the brush in blocks
*/
public int getRange() {
return (range < 0) ? MAX_RANGE : Math.min(range, MAX_RANGE);
@ -147,7 +150,7 @@ public class BrushTool implements TraceTool {
/**
* Set the set brush range.
*
* @param range
* @param range the range of the brush in blocks
*/
public void setRange(int range) {
this.range = range;

View File

@ -22,7 +22,6 @@ package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.WorldEditException;
public class InvalidToolBindException extends WorldEditException {
private static final long serialVersionUID = -1865311004052447699L;
private int itemId;
@ -34,4 +33,5 @@ public class InvalidToolBindException extends WorldEditException {
public int getItemId() {
return itemId;
}
}

View File

@ -23,7 +23,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
/**
* Represents a tool. This interface alone defines nothing. A tool also
* has to implement <code>BlockTool</code> or <code>TraceTool</code>.
* has to implement {@code BlockTool} or {@code TraceTool}.
*/
public interface Tool {

View File

@ -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;
}

View File

@ -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())));
}

View File

@ -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();

View File

@ -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);
}
}

View File

@ -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 List<BaseBlock> blockTypes = new ArrayList<BaseBlock>();
for (; y > pos.getBlockY() - size; --y) {
for (; y > position.getBlockY() - size; --y) {
final Vector pt = new Vector(x, y, z);
final BaseBlock block = editSession.getBlock(pt);
if (!block.isAir()) {

View File

@ -34,8 +34,8 @@ public class HollowCylinderBrush implements Brush {
}
@Override
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
editSession.makeCylinder(pos, Patterns.wrap(mat), size, size, height, false);
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
editSession.makeCylinder(position, Patterns.wrap(pattern), size, size, height, false);
}
}

View File

@ -28,7 +28,7 @@ import com.sk89q.worldedit.function.pattern.Patterns;
public class HollowSphereBrush implements Brush {
@Override
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
editSession.makeSphere(pos, Patterns.wrap(mat), size, size, size, false);
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
editSession.makeSphere(position, Patterns.wrap(pattern), size, size, size, false);
}
}

View File

@ -45,10 +45,10 @@ public class SmoothBrush implements Brush {
this.naturalOnly = naturalOnly;
}
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
double rad = size;
WorldVector min = new WorldVector(LocalWorldAdapter.adapt(editSession.getWorld()), pos.subtract(rad, rad, rad));
Vector max = pos.add(rad, rad + 10, rad);
@Override
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
WorldVector min = new WorldVector(LocalWorldAdapter.adapt(editSession.getWorld()), position.subtract(size, size, size));
Vector max = position.add(size, size + 10, size);
Region region = new CuboidRegion(editSession.getWorld(), min, max);
HeightMap heightMap = new HeightMap(editSession, region, naturalOnly);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));

View File

@ -28,7 +28,7 @@ import com.sk89q.worldedit.function.pattern.Patterns;
public class SphereBrush implements Brush {
@Override
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
editSession.makeSphere(pos, Patterns.wrap(mat), size, size, size, true);
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
editSession.makeSphere(position, Patterns.wrap(pattern), size, size, size, true);
}
}

View File

@ -19,8 +19,6 @@
package com.sk89q.worldedit.event;
import com.sk89q.worldedit.util.eventbus.EventBus;
/**
* An abstract base class for all WorldEdit events.
*/

View File

@ -19,9 +19,6 @@
package com.sk89q.worldedit.extension.platform;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandsManager;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.world.World;
import java.util.Collections;

View File

@ -30,9 +30,9 @@ import java.util.Map;
/**
* Represents a platform that WorldEdit has been implemented for.
* </p>
* It is strongly recommended that implementations extend from
* {@link AbstractPlatform}.
*
* <p>It is strongly recommended that implementations extend from
* {@link AbstractPlatform}.</p>
*/
public interface Platform {
@ -58,8 +58,8 @@ public interface Platform {
void reload();
/**
* Schedules the given <code>task</code> to be invoked once every <code>period</code> ticks
* after an initial delay of <code>delay</code> 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.
* </p>
* The given player may have been provided by a different platform.
*
* <p>The given player may have been provided by a different platform.</p>
*
* @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.
* </p>
* The given world may have been provided by a different platform.
*
* <p>The given world may have been provided by a different platform.</p>
*
* @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.
* </p>
* This version should match WorldEdit releases because it may be
* checked to match.
*
* <p>This version should match WorldEdit releases because it may be
* checked to match.</p>
*
* @return the version
*/
@ -121,9 +126,9 @@ public interface Platform {
/**
* Get a friendly name of the platform.
* </p>
* The name can be anything (reasonable). An example name may be
* "Bukkit" or "Forge".
*
* <p>The name can be anything (reasonable). An example name may be
* "Bukkit" or "Forge".</p>
*
* @return the platform name
*/

View File

@ -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

View File

@ -30,8 +30,8 @@ public interface Clipboard extends Extent {
/**
* Get the bounding region of this extent.
* </p>
* Implementations should return a copy of the region.
*
* <p>Implementations should return a copy of the region.</p>
*
* @return the bounding region
*/

View File

@ -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;

View File

@ -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.
*/

View File

@ -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;

View File

@ -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.
* </p>
* 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.
*
* <p>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.</p>
*/
public class BlockMask extends AbstractExtentMask {

View File

@ -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);
}
};
}

View File

@ -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)}.
* </p>
* This method should be used before the search begins, because if
*
* <p>This method should be used before the search begins, because if
* the position <em>does</em> 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.</p>
*
* @param position the position
*/

View File

@ -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:

View File

@ -65,8 +65,6 @@ import java.util.Stack;
*
* <p>Variables are also supported and can be set either by passing values
* to {@link #evaluate(double...)}.</p>
*
* @author TomyLobo
*/
public class Expression {

View File

@ -112,8 +112,7 @@ public final class ParserProcessors {
default:
Map<String, String> m = lBinaryOpMapsLA[i] = new HashMap<String, String>();
for (int j = 0; j < a.length; ++j) {
final Object[] element = a[j];
for (final Object[] element : a) {
m.put((String) element[0], (String) element[1]);
}
}
@ -135,8 +134,7 @@ public final class ParserProcessors {
default:
Map<String, String> m = lBinaryOpMapsRA[i] = new HashMap<String, String>();
for (int j = 0; j < a.length; ++j) {
final Object[] element = a[j];
for (final Object[] element : a) {
m.put((String) element[0], (String) element[1]);
}
}

View File

@ -53,7 +53,7 @@ public class Function extends Node {
return invokeMethod(method, args);
}
protected static final double invokeMethod(Method method, Object[] args) throws EvaluationException {
protected static double invokeMethod(Method method, Object[] args) throws EvaluationException {
try {
return (Double) method.invoke(null, args);
} catch (InvocationTargetException e) {

View File

@ -85,7 +85,7 @@ public class SimpleFor extends Node {
public RValue optimize() throws EvaluationException {
// TODO: unroll small loops into Sequences
return new SimpleFor(getPosition(), (LValue) counter.optimize(), first.optimize(), last.optimize(), body.optimize());
return new SimpleFor(getPosition(), counter.optimize(), first.optimize(), last.optimize(), body.optimize());
}
@Override

View File

@ -181,9 +181,7 @@ public class Switch extends Node implements RValue {
}
if (invokable instanceof Sequence) {
for (RValue subInvokable : ((Sequence) invokable).sequence) {
newSequence.add(subInvokable);
}
Collections.addAll(newSequence, ((Sequence) invokable).sequence);
} else {
newSequence.add(invokable);
}

View File

@ -277,14 +277,14 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
}
@Override
public boolean contains(Vector pt) {
public boolean contains(Vector position) {
if (!isDefined()) {
return false;
}
final int x = pt.getBlockX();
final int y = pt.getBlockY();
final int z = pt.getBlockZ();
final int x = position.getBlockX();
final int y = position.getBlockY();
final int z = position.getBlockZ();
final Vector min = getMinimumPoint();
final Vector max = getMaximumPoint();
@ -296,7 +296,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
if (z < min.getBlockZ()) return false;
if (z > max.getBlockZ()) return false;
return containsRaw(pt);
return containsRaw(position);
}
private boolean containsRaw(Vector pt) {

View File

@ -330,10 +330,10 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
}
@Override
public boolean contains(Vector pt) {
double x = pt.getX();
double y = pt.getY();
double z = pt.getZ();
public boolean contains(Vector position) {
double x = position.getX();
double y = position.getY();
double z = position.getZ();
Vector min = getMinimumPoint();
Vector max = getMaximumPoint();

View File

@ -37,10 +37,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* Represents a cylindrical region.
*
* @author yetanotherx
*/
public class CylinderRegion extends AbstractRegion implements FlatRegion {
private Vector2D center;
private Vector2D radius;
private int minY;
@ -305,13 +304,13 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
* Checks to see if a point is inside this region.
*/
@Override
public boolean contains(Vector pt) {
final int blockY = pt.getBlockY();
public boolean contains(Vector position) {
final int blockY = position.getBlockY();
if (blockY < minY || blockY > maxY) {
return false;
}
return pt.toVector2D().subtract(center).divide(radius).lengthSq() <= 1;
return position.toVector2D().subtract(center).divide(radius).lengthSq() <= 1;
}

View File

@ -206,8 +206,8 @@ public class EllipsoidRegion extends AbstractRegion {
}
@Override
public boolean contains(Vector pt) {
return pt.subtract(center).divide(radius).lengthSq() <= 1;
public boolean contains(Vector position) {
return position.subtract(center).divide(radius).lengthSq() <= 1;
}
/**

View File

@ -83,7 +83,7 @@ public class NullRegion implements Region {
}
@Override
public boolean contains(Vector pt) {
public boolean contains(Vector position) {
return false;
}

View File

@ -19,10 +19,6 @@
package com.sk89q.worldedit.regions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.LocalWorld;
@ -32,12 +28,16 @@ import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator;
import com.sk89q.worldedit.regions.iterator.FlatRegionIterator;
import com.sk89q.worldedit.world.World;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
* Represents a 2D polygonal region.
*
* @author sk89q
*/
public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
private List<BlockVector2D> points;
private Vector2D min;
private Vector2D max;
@ -60,7 +60,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
/**
* Construct the region.
*
* @param world
* @param world the world
*/
public Polygonal2DRegion(World world) {
this(world, Collections.<BlockVector2D>emptyList(), 0, 0);
@ -75,10 +75,10 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
/**
* Construct the region.
*
* @param world
* @param points
* @param minY
* @param maxY
* @param world the world
* @param points list of points
* @param minY minimum Y
* @param maxY maximum Y
*/
public Polygonal2DRegion(World world, List<BlockVector2D> points, int minY, int maxY) {
super(world);
@ -89,6 +89,11 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
recalculate();
}
/**
* Make a copy of another region.
*
* @param region the other region
*/
public Polygonal2DRegion(Polygonal2DRegion region) {
this(region.world, region.points, region.minY, region.maxY);
hasY = region.hasY;
@ -97,7 +102,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
/**
* Get the list of points.
*
* @return
* @return a list of points
*/
public List<BlockVector2D> getPoints() {
return Collections.unmodifiableList(points);
@ -108,7 +113,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
* called after points have been changed.
*/
protected void recalculate() {
if (points.size() == 0) {
if (points.isEmpty()) {
min = new Vector2D(0, 0);
minY = 0;
max = new Vector2D(0, 0);
@ -145,38 +150,34 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
/**
* Add a point to the list.
*
* @param pt
* @param position the position
*/
public void addPoint(Vector2D pt) {
points.add(pt.toBlockVector2D());
public void addPoint(Vector2D position) {
points.add(position.toBlockVector2D());
recalculate();
}
/**
* Add a point to the list.
*
* @param pt
* @param position the position
*/
public void addPoint(BlockVector2D pt) {
points.add(pt);
public void addPoint(BlockVector2D position) {
points.add(position);
recalculate();
}
/**
* Add a point to the list.
*
* @param pt
* @param position the position
*/
public void addPoint(Vector pt) {
points.add(new BlockVector2D(pt.getBlockX(), pt.getBlockZ()));
public void addPoint(Vector position) {
points.add(new BlockVector2D(position.getBlockX(), position.getBlockZ()));
recalculate();
}
/**
* Get the minimum Y.
*
* @return min y
*/
@Override
public int getMinimumY() {
return minY;
}
@ -189,7 +190,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
/**
* Set the minimum Y.
*
* @param y
* @param y the Y
*/
public void setMinimumY(int y) {
hasY = true;
@ -197,11 +198,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
recalculate();
}
/**
* Get the maximum Y.
*
* @return max y
*/
@Override
public int getMaximumY() {
return maxY;
}
@ -209,7 +206,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
/**
* Set the maximum Y.
*
* @param y
* @param y the Y
*/
public void setMaximumY(int y) {
hasY = true;
@ -217,29 +214,17 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
recalculate();
}
/**
* Get the lower point of a region.
*
* @return min. point
*/
@Override
public Vector getMinimumPoint() {
return min.toVector(minY);
}
/**
* Get the upper point of a region.
*
* @return max. point
*/
@Override
public Vector getMaximumPoint() {
return max.toVector(maxY);
}
/**
* Get the number of blocks in the region.
*
* @return number of blocks
*/
@Override
public int getArea() {
double area = 0;
int i, j = points.size() - 1;
@ -254,38 +239,22 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
* (maxY - minY + 1));
}
/**
* Get X-size.
*
* @return width
*/
@Override
public int getWidth() {
return max.getBlockX() - min.getBlockX() + 1;
}
/**
* Get Y-size.
*
* @return height
*/
@Override
public int getHeight() {
return maxY - minY + 1;
}
/**
* Get Z-size.
*
* @return length
*/
@Override
public int getLength() {
return max.getBlockZ() - min.getBlockZ() + 1;
}
/**
* Expand the region.
*
* @param changes
*/
@Override
public void expand(Vector... changes) throws RegionOperationException {
for (Vector change : changes) {
if (change.getBlockX() != 0 || change.getBlockZ() != 0) {
@ -304,11 +273,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
recalculate();
}
/**
* Contract the region.
*
* @param changes
*/
@Override
public void contract(Vector... changes) throws RegionOperationException {
for (Vector change : changes) {
if (change.getBlockX() != 0 || change.getBlockZ() != 0) {
@ -344,24 +309,21 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
recalculate();
}
/**
* Checks to see if a point is inside this region.
*/
public boolean contains(Vector pt) {
return contains(points, minY, maxY, pt);
@Override
public boolean contains(Vector position) {
return contains(points, minY, maxY, position);
}
/**
* Checks to see if a point is inside a region.
*
* @param points
* @param minY
* @param maxY
* @param pt
* @return
* @param points a list of points
* @param minY the min Y
* @param maxY the max Y
* @param pt the position to check
* @return true if the given polygon contains the given point
*/
public static boolean contains(List<BlockVector2D> points, int minY,
int maxY, Vector pt) {
public static boolean contains(List<BlockVector2D> points, int minY, int maxY, Vector pt) {
if (points.size() < 3) {
return false;
}
@ -422,7 +384,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
/**
* Return the number of points.
*
* @return
* @return the number of points
*/
public int size() {
return points.size();
@ -431,7 +393,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
/**
* Expand the height of the polygon to fit the specified Y.
*
* @param y
* @param y the amount to expand
* @return true if the area was expanded
*/
public boolean expandY(int y) {
@ -451,11 +413,6 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
return false;
}
/**
* Get the iterator.
*
* @return iterator of points inside the region
*/
@Override
public Iterator<BlockVector> iterator() {
return new FlatRegion3DIterator(this);
@ -484,13 +441,14 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
Iterator<BlockVector2D> it = pts.iterator();
while (it.hasNext()) {
BlockVector2D current = it.next();
sb.append("(" + current.getBlockX() + ", " + current.getBlockZ() + ")");
sb.append("(").append(current.getBlockX()).append(", ").append(current.getBlockZ()).append(")");
if (it.hasNext()) sb.append(" - ");
}
sb.append(" * (" + minY + " - " + maxY + ")");
sb.append(" * (").append(minY).append(" - ").append(maxY).append(")");
return sb.toString();
}
@Override
public Polygonal2DRegion clone() {
Polygonal2DRegion clone = (Polygonal2DRegion) super.clone();
clone.points = new ArrayList<BlockVector2D>(points);
@ -505,4 +463,5 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
return points;
}
}

View File

@ -26,14 +26,15 @@ import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.world.World;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Set;
/**
*
* @author sk89q
* Represents a physical shape.
*/
public interface Region extends Iterable<BlockVector>, Cloneable {
/**
* Get the lower point of a region.
*
@ -104,7 +105,7 @@ public interface Region extends Iterable<BlockVector>, Cloneable {
/**
* Shift the region.
*
* @param change
* @param change the change
* @throws RegionOperationException
*/
public void shift(Vector change) throws RegionOperationException;
@ -112,47 +113,53 @@ public interface Region extends Iterable<BlockVector>, Cloneable {
/**
* Returns true based on whether the region contains the point.
*
* @param pt
* @return
* @param position the position
* @return true if contained
*/
public boolean contains(Vector pt);
public boolean contains(Vector position);
/**
* Get a list of chunks.
*
* @return
* @return a list of chunk coordinates
*/
public Set<Vector2D> getChunks();
/**
* Return a list of 16*16*16 chunks in a region
*
* @return The chunk cubes this region overlaps with
* @return the chunk cubes this region overlaps with
*/
public Set<Vector> getChunkCubes();
/**
* Get the world the selection is in
* Sets the world that the selection is in.
*
* @return
* @return the world, or null
*/
@Nullable
public World getWorld();
/**
* Sets the world the selection is in
* Sets the world that the selection is in.
*
* @return
* @param world the world, which may be null
*/
public void setWorld(World world);
public void setWorld(@Nullable World world);
/**
* Sets the world the selection is in
* Sets the world that the selection is in.
*
* @return
* @param world the world, which may be null
*/
@Deprecated
public void setWorld(LocalWorld world);
public void setWorld(@Nullable LocalWorld world);
/**
* Make a clone of the region.
*
* @return a cloned version
*/
public Region clone();
/**

View File

@ -25,6 +25,7 @@ import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@ -34,11 +35,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* An intersection of several other regions. Any location that is contained in one
* of the child regions is considered as contained by this region.
* </p>
* {@link #iterator()} returns a special iterator that will iterate through
*
* <p>{@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.</p>
*/
public class RegionIntersection extends AbstractRegion {
@ -71,7 +72,7 @@ public class RegionIntersection extends AbstractRegion {
public RegionIntersection(LocalWorld world, List<Region> regions) {
super(world);
checkNotNull(regions);
checkArgument(regions.size() > 0, "empty region list is not supported");
checkArgument(!regions.isEmpty(), "empty region list is not supported");
for (Region region : regions) {
this.regions.add(region);
}
@ -87,9 +88,7 @@ public class RegionIntersection extends AbstractRegion {
super(world);
checkNotNull(regions);
checkArgument(regions.length > 0, "empty region list is not supported");
for (Region region : regions) {
this.regions.add(region);
}
Collections.addAll(this.regions, regions);
}
@Override
@ -123,11 +122,11 @@ public class RegionIntersection extends AbstractRegion {
}
@Override
public boolean contains(Vector pt) {
checkNotNull(pt);
public boolean contains(Vector position) {
checkNotNull(position);
for (Region region : regions) {
if (region.contains(pt)) {
if (region.contains(position)) {
return true;
}
}

View File

@ -22,9 +22,9 @@ package com.sk89q.worldedit.regions;
import com.sk89q.worldedit.WorldEditException;
public class RegionOperationException extends WorldEditException {
private static final long serialVersionUID = -6180325009115242142L;
public RegionOperationException(String msg) {
super(msg);
}
}

View File

@ -73,10 +73,10 @@ public final class Regions {
/**
* Attempt to get a {@link FlatRegion} from the given region.
* </p>
* If the given region is already a {@link FlatRegion}, then the region
*
* <p>If 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.</p>
*
* @param region the region
* @return a flat region

View File

@ -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

View File

@ -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) {
Map<String, Tag> values = new HashMap<String, Tag>();
for (Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
values.put(entry.getKey(), entry.getValue());
}
values.put("id", new StringTag("id", tileEntityBlock.getNbtId()));
values.put("x", new IntTag("x", x));
values.put("y", new IntTag("y", y));
values.put("z", new IntTag("z", z));
CompoundTag tileEntityTag = new CompoundTag("TileEntity", values);
tileEntities.add(tileEntityTag);
// Get the list of key/values from the block
CompoundTag rawTag = block.getNbtData();
if (rawTag != null) {
Map<String, Tag> values = new HashMap<String, Tag>();
for (Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
values.put(entry.getKey(), entry.getValue());
}
values.put("id", new StringTag("id", block.getNbtId()));
values.put("x", new IntTag("x", x));
values.put("y", new IntTag("y", y));
values.put("z", new IntTag("z", z));
CompoundTag tileEntityTag = new CompoundTag("TileEntity", values);
tileEntities.add(tileEntityTag);
}
}
}

View File

@ -35,10 +35,10 @@ import java.util.Set;
/**
* The context given to scripts.
*
* @author sk89q
*/
@SuppressWarnings("deprecation")
public class CraftScriptContext extends CraftScriptEnvironment {
private List<EditSession> editSessions = new ArrayList<EditSession>();
private String[] args;
@ -53,7 +53,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
* Get an edit session. Every subsequent call returns a new edit session.
* Usually you only need to use one edit session.
*
* @return
* @return an edit session
*/
public EditSession remember() {
EditSession editSession = controller.getEditSessionFactory()
@ -67,7 +67,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
/**
* Get the player.
*
* @return
* @return the calling player
*/
public Player getPlayer() {
return player;
@ -76,7 +76,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
/**
* Get the player's session.
*
* @return
* @return a session
*/
public LocalSession getSession() {
return session;
@ -85,7 +85,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
/**
* Get the configuration for WorldEdit.
*
* @return
* @return the configuration
*/
public LocalConfiguration getConfiguration() {
return config;
@ -94,7 +94,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
/**
* Get a list of edit sessions that have been created.
*
* @return
* @return a list of created {@code EditSession}s
*/
public List<EditSession> getEditSessions() {
return Collections.unmodifiableList(editSessions);
@ -103,34 +103,34 @@ public class CraftScriptContext extends CraftScriptEnvironment {
/**
* Print a regular message to the user.
*
* @param msg
* @param message a message
*/
public void print(String msg) {
player.print(msg);
public void print(String message) {
player.print(message);
}
/**
* Print an error message to the user.
*
* @param msg
* @param message a message
*/
public void error(String msg) {
player.printError(msg);
public void error(String message) {
player.printError(message);
}
/**
* Print an raw message to the user.
*
* @param msg
* @param message a message
*/
public void printRaw(String msg) {
player.printRaw(msg);
public void printRaw(String message) {
player.printRaw(message);
}
/**
* Checks to make sure that there are enough but not too many arguments.
*
* @param min
* @param min a number of arguments
* @param max -1 for no maximum
* @param usage usage string
* @throws InsufficientArgumentsException
@ -145,54 +145,50 @@ public class CraftScriptContext extends CraftScriptEnvironment {
/**
* Get an item ID from an item name or an item ID number.
*
* @param arg
* @param input input to parse
* @param allAllowed true to ignore blacklists
* @return
* @return a block
* @throws UnknownItemException
* @throws DisallowedItemException
*/
public BaseBlock getBlock(String arg, boolean allAllowed)
throws WorldEditException {
return controller.getBlock(player, arg, allAllowed);
public BaseBlock getBlock(String input, boolean allAllowed) throws WorldEditException {
return controller.getBlock(player, input, allAllowed);
}
/**
* Get a block.
*
* @param id
* @return
* @param id the type Id
* @return a block
* @throws UnknownItemException
* @throws DisallowedItemException
*/
public BaseBlock getBlock(String id)
throws WorldEditException {
public BaseBlock getBlock(String id) throws WorldEditException {
return controller.getBlock(player, id, false);
}
/**
* Get a list of blocks as a set. This returns a Pattern.
*
* @param list
* @param list the input
* @return pattern
* @throws UnknownItemException
* @throws DisallowedItemException
*/
public Pattern getBlockPattern(String list)
throws WorldEditException {
public Pattern getBlockPattern(String list) throws WorldEditException {
return controller.getBlockPattern(player, list);
}
/**
* Get a list of blocks as a set.
*
* @param list
* @param allBlocksAllowed
* @param list a list
* @param allBlocksAllowed true if all blocks are allowed
* @return set
* @throws UnknownItemException
* @throws DisallowedItemException
*/
public Set<Integer> getBlockIDs(String list, boolean allBlocksAllowed)
throws WorldEditException {
public Set<Integer> getBlockIDs(String list, boolean allBlocksAllowed) throws WorldEditException {
return controller.getBlockIDs(player, list, allBlocksAllowed);
}
@ -200,13 +196,13 @@ public class CraftScriptContext extends CraftScriptEnvironment {
* Gets the path to a file. 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, a <code>java.io.File</code> object will be returned.
* On success, a {@code java.io.File} object will be returned.
*
* <p>Use this method if you need to read a file from a directory.</p>
*
* @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, a <code>java.io.File</code> object will be
* directory. On success, a {@code java.io.File} object will be
* returned.
*
* <p>Use this method if you need to read a file from a directory.</p>
@ -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, a <code>java.io.File</code> object will be
* directory. On success, a {@code java.io.File} object will be
* returned.
*
* <p>Use this method if you need to read a file from a directory.</p>
@ -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);
}
}

View File

@ -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);
}
}
}

View File

@ -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, Map<String, Object> args)
throws ScriptException, Throwable {
RhinoContextFactory factory = new RhinoContextFactory(timeLimit);
@ -59,7 +62,7 @@ public class RhinoCraftScriptEngine implements CraftScriptEngine {
throw new ScriptException(e.getMessage());
} catch (RhinoException e) {
if (e instanceof WrappedException) {
Throwable cause = ((WrappedException) e).getCause();
Throwable cause = e.getCause();
if (cause instanceof WorldEditException) {
throw cause;
}

View File

@ -47,10 +47,12 @@ public class RhinoScriptEngine extends AbstractScriptEngine {
factory.enterContext();
}
@Override
public Bindings createBindings() {
return new SimpleBindings();
}
@Override
public Object eval(String script, ScriptContext context)
throws ScriptException {
@ -81,6 +83,7 @@ public class RhinoScriptEngine extends AbstractScriptEngine {
}
}
@Override
public Object eval(Reader reader, ScriptContext context)
throws ScriptException {
@ -113,6 +116,7 @@ public class RhinoScriptEngine extends AbstractScriptEngine {
}
}
@Override
public ScriptEngineFactory getFactory() {
if (factory != null) {
return factory;

View File

@ -52,26 +52,32 @@ public class RhinoScriptEngineFactory implements ScriptEngineFactory {
extensions = Collections.unmodifiableList(extensions);
}
@Override
public String getEngineName() {
return "Rhino JavaScript Engine (SK)";
}
@Override
public String getEngineVersion() {
return "unknown";
}
@Override
public List<String> getExtensions() {
return extensions;
}
@Override
public String getLanguageName() {
return "EMCAScript";
}
@Override
public String getLanguageVersion() {
return "1.8";
}
@Override
public String getMethodCallSyntax(String obj, String m, String... args) {
StringBuilder s = new StringBuilder();
s.append(obj);
@ -91,20 +97,24 @@ public class RhinoScriptEngineFactory implements ScriptEngineFactory {
return s.toString();
}
@Override
public List<String> getMimeTypes() {
return mimeTypes;
}
@Override
public List<String> getNames() {
return names;
}
@Override
public String getOutputStatement(String str) {
return "print(" + str.replace("\\", "\\\\")
.replace("\"", "\\\\\"")
.replace(";", "\\\\;") + ")";
}
@Override
public Object getParameter(String key) {
if (key.equals(ScriptEngine.ENGINE)) {
return getEngineName();
@ -123,6 +133,7 @@ public class RhinoScriptEngineFactory implements ScriptEngineFactory {
}
}
@Override
public String getProgram(String... statements) {
StringBuilder s = new StringBuilder();
for (String stmt : statements) {
@ -132,6 +143,7 @@ public class RhinoScriptEngineFactory implements ScriptEngineFactory {
return s.toString();
}
@Override
public ScriptEngine getScriptEngine() {
return new RhinoScriptEngine();
}

View File

@ -49,8 +49,8 @@ public class PasteBuilder {
* Create a new instance.
*
* @param holder the clipboard holder
* @param targetExtent
* @param targetWorldData
* @param targetExtent an extent
* @param targetWorldData world data of the target
*/
PasteBuilder(ClipboardHolder holder, Extent targetExtent, WorldData targetWorldData) {
checkNotNull(holder);

View File

@ -19,7 +19,6 @@
package com.sk89q.worldedit.session;
import com.sk89q.worldedit.util.Identifiable;
import com.sk89q.worldedit.util.auth.Subject;
/**

View File

@ -33,9 +33,9 @@ import java.util.Set;
* A region that mirrors the current selection according to the current
* {@link LocalSession} and {@link LocalWorld} set on the current
* {@link Request}.
* </p>
* If a selection cannot be taken, then the selection will be assumed to be
* that of a {@link NullRegion}.
*
* <p>If a selection cannot be taken, then the selection will be assumed to be
* that of a {@link NullRegion}.</p>
*/
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

View File

@ -19,56 +19,34 @@
package com.sk89q.worldedit.util;
/**
*
* @author sk89q
* @param <T>
*/
public class Countable<T> implements Comparable<Countable<T>> {
/**
* ID.
*/
private T id;
/**
* Amount.
*/
private int amount;
/**
* Construct the object.
*
* @param id
* @param amount
* @param id the ID
* @param amount the count of
*/
public Countable(T id, int amount) {
this.id = id;
this.amount = amount;
}
/**
* @return the id
*/
public T getID() {
return id;
}
/**
* @param id the id to set
*/
public void setID(T id) {
this.id = id;
}
/**
* @return the amount
*/
public int getAmount() {
return amount;
}
/**
* @param amount the amount to set
*/
public void setAmount(int amount) {
this.amount = amount;
}
@ -87,12 +65,7 @@ public class Countable<T> implements Comparable<Countable<T>> {
++this.amount;
}
/**
* Comparison.
*
* @param other
* @return
*/
@Override
public int compareTo(Countable<T> other) {
if (amount > other.amount) {
return 1;

View File

@ -68,7 +68,7 @@ public final class FileDialogUtil {
private Set<String> exts;
private String desc;
public ExtensionFilter(String[] exts) {
private ExtensionFilter(String[] exts) {
this.exts = new HashSet<String>(Arrays.asList(exts));
desc = StringUtil.joinString(exts, ",");

View File

@ -26,13 +26,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* Represents a location in a world with has a direction.
* </p>
* Like {@code Vectors}, {@code Locations} are immutable and mutator methods
* will create a new copy.
* </p>
* At the moment, but this may change in the future, {@link #hashCode()} and
*
* <p>Like {@code Vectors}, {@code Locations} are immutable and mutator methods
* will create a new copy.</p>
*
* <p>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.</p>
*/
public class Location {

View File

@ -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
* <code>java.util.Properties</code>.
*
* @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 Set<Integer> getIntSet(String key, int[] def) {
String val = properties.getProperty(key);
@ -243,10 +242,11 @@ public class PropertiesConfiguration extends LocalConfiguration {
try {
int v = Integer.parseInt(part.trim());
set.add(v);
} catch (NumberFormatException e) {
} catch (NumberFormatException ignored) {
}
}
return set;
}
}
}

Some files were not shown because too many files have changed in this diff Show More