3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-05 11:00:05 +01:00
Dieser Commit ist enthalten in:
TomyLobo 2011-11-23 02:29:48 +01:00
Ursprung 1a57f6e95d
Commit 7e13b60a51
161 geänderte Dateien mit 1433 neuen und 1412 gelöschten Zeilen

Datei anzeigen

@ -38,10 +38,10 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
section.setProperty("permissions.groups.default.permissions", new String[] { section.setProperty("permissions.groups.default.permissions", new String[] {
"worldedit.reload", "worldedit.reload",
"worldedit.selection", "worldedit.selection",
"worlds.creative.worldedit.region"}); "worlds.creative.worldedit.region" });
section.setProperty("permissions.groups.admins.permissions", new String[] {"*"}); section.setProperty("permissions.groups.admins.permissions", new String[] { "*" });
section.setProperty("permissions.users.sk89q.permissions", new String[] {"worldedit"}); section.setProperty("permissions.users.sk89q.permissions", new String[] { "worldedit" });
section.setProperty("permissions.users.sk89q.groups", new String[] {"admins"}); section.setProperty("permissions.users.sk89q.groups", new String[] { "admins" });
return section; return section;
} }

Datei anzeigen

@ -50,18 +50,18 @@ public class DinnerPermsResolver implements PermissionsResolver {
return false; // Permissions are only registered for online players return false; // Permissions are only registered for online players
} }
switch (internalHasPermission(perms, permission)) { switch (internalHasPermission(perms, permission)) {
case -1: case -1:
return false; return false;
case 1: case 1:
return true; return true;
} }
int dotPos = permission.lastIndexOf("."); int dotPos = permission.lastIndexOf(".");
while (dotPos > -1) { while (dotPos > -1) {
switch (internalHasPermission(perms, permission.substring(0, dotPos + 1) + "*")) { switch (internalHasPermission(perms, permission.substring(0, dotPos + 1) + "*")) {
case -1: case -1:
return false; return false;
case 1: case 1:
return true; return true;
} }
dotPos = permission.lastIndexOf(".", dotPos - 1); dotPos = permission.lastIndexOf(".", dotPos - 1);
} }
@ -115,7 +115,7 @@ public class DinnerPermsResolver implements PermissionsResolver {
} }
} }
} }
public String getDetectionMessage() { public String getDetectionMessage() {
return "Using the Bukkit Permissions API."; return "Using the Bukkit Permissions API.";
} }

Datei anzeigen

@ -21,7 +21,10 @@ package com.sk89q.bukkit.migration;
public interface PermissionsProvider { public interface PermissionsProvider {
public boolean hasPermission(String name, String permission); public boolean hasPermission(String name, String permission);
public boolean hasPermission(String worldName, String name, String permission); public boolean hasPermission(String worldName, String name, String permission);
public boolean inGroup(String player, String group); public boolean inGroup(String player, String group);
public String[] getGroups(String player); public String[] getGroups(String player);
} }

Datei anzeigen

@ -64,11 +64,11 @@ public class PermissionsResolverManager implements PermissionsResolver {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[] { protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[] {
PluginPermissionsResolver.class, PluginPermissionsResolver.class,
PermissionsExResolver.class, PermissionsExResolver.class,
NijiPermissionsResolver.class, NijiPermissionsResolver.class,
DinnerPermsResolver.class, DinnerPermsResolver.class,
FlatFilePermissionsResolver.class FlatFilePermissionsResolver.class
}; };
@Deprecated @Deprecated
@ -167,8 +167,8 @@ public class PermissionsResolverManager implements PermissionsResolver {
} }
if (!keys.contains("resolvers")) { if (!keys.contains("resolvers")) {
//List<String> resolverKeys = config.getKeys("resolvers"); //List<String> resolverKeys = config.getKeys("resolvers");
List<String> resolvers = new ArrayList<String>(); List<String> resolvers = new ArrayList<String>();
for (Class<?> clazz : availableResolvers) { for (Class<?> clazz : availableResolvers) {
resolvers.add(clazz.getSimpleName()); resolvers.add(clazz.getSimpleName());
} }

Datei anzeigen

@ -36,29 +36,29 @@ public @interface Command {
* is never used for anything). * is never used for anything).
*/ */
String[] aliases(); String[] aliases();
/** /**
* Usage instruction. Example text for usage could be * Usage instruction. Example text for usage could be
* <code>[-h] [name] [message]</code>. * <code>[-h] [name] [message]</code>.
*/ */
String usage() default ""; String usage() default "";
/** /**
* A short description for the command. * A short description for the command.
*/ */
String desc(); String desc();
/** /**
* The minimum number of arguments. This should be 0 or above. * The minimum number of arguments. This should be 0 or above.
*/ */
int min() default 0; int min() default 0;
/** /**
* The maximum number of arguments. Use -1 for an unlimited number * The maximum number of arguments. Use -1 for an unlimited number
* of arguments. * of arguments.
*/ */
int max() default -1; int max() default -1;
/** /**
* Flags allow special processing for flags such as -h in the command, * Flags allow special processing for flags such as -h in the command,
* allowing users to easily turn on a flag. This is a string with * allowing users to easily turn on a flag. This is a string with
@ -67,5 +67,4 @@ public @interface Command {
* meaning that if it is given it must have a value * meaning that if it is given it must have a value
*/ */
String flags() default ""; String flags() default "";
} }

Datei anzeigen

@ -110,7 +110,7 @@ public class CommandContext {
// Not a flag? // Not a flag?
if (arg.charAt(0) != '-' || arg.length() == 1 || !arg.matches("^-[a-zA-Z]+$")) { if (arg.charAt(0) != '-' || arg.length() == 1 || !arg.matches("^-[a-zA-Z]+$")) {
originalArgIndices.add(argIndexList.get(nextArg-1)); originalArgIndices.add(argIndexList.get(nextArg - 1));
parsedArgs.add(arg); parsedArgs.add(arg);
continue; continue;
} }
@ -134,7 +134,7 @@ public class CommandContext {
} }
if (nextArg >= argList.size()) { if (nextArg >= argList.size()) {
throw new CommandException("No value specified for the '-"+flagName+"' flag."); throw new CommandException("No value specified for the '-" + flagName + "' flag.");
} }
// If it is a value flag, read another argument and add it // If it is a value flag, read another argument and add it

Datei anzeigen

@ -21,14 +21,14 @@ package com.sk89q.minecraft.util.commands;
public class CommandUsageException extends CommandException { public class CommandUsageException extends CommandException {
private static final long serialVersionUID = -6761418114414516542L; private static final long serialVersionUID = -6761418114414516542L;
protected String usage; protected String usage;
public CommandUsageException(String message, String usage) { public CommandUsageException(String message, String usage) {
super(message); super(message);
this.usage = usage; this.usage = usage;
} }
public String getUsage() { public String getUsage() {
return usage; return usage;
} }

Datei anzeigen

@ -56,13 +56,12 @@ import com.sk89q.util.StringUtil;
* @param <T> command sender class * @param <T> command sender class
*/ */
public abstract class CommandsManager<T> { public abstract class CommandsManager<T> {
/** /**
* Logger for general errors. * Logger for general errors.
*/ */
protected static final Logger logger = protected static final Logger logger =
Logger.getLogger(CommandsManager.class.getCanonicalName()); Logger.getLogger(CommandsManager.class.getCanonicalName());
/** /**
* Mapping of commands (including aliases) with a description. Root * Mapping of commands (including aliases) with a description. Root
* commands are stored under a key of null, whereas child commands are * commands are stored under a key of null, whereas child commands are
@ -70,14 +69,13 @@ public abstract class CommandsManager<T> {
* the key of the command name (one for each alias) with the * the key of the command name (one for each alias) with the
* method. * method.
*/ */
protected Map<Method, Map<String, Method>> commands protected Map<Method, Map<String, Method>> commands = new HashMap<Method, Map<String, Method>>();
= new HashMap<Method, Map<String, Method>>();
/** /**
* Used to store the instances associated with a method. * Used to store the instances associated with a method.
*/ */
protected Map<Method, Object> instances = new HashMap<Method, Object>(); protected Map<Method, Object> instances = new HashMap<Method, Object>();
/** /**
* Mapping of commands (not including aliases) with a description. This * Mapping of commands (not including aliases) with a description. This
* is only for top level commands. * is only for top level commands.
@ -88,7 +86,7 @@ public abstract class CommandsManager<T> {
* Stores the injector used to getInstance. * Stores the injector used to getInstance.
*/ */
protected Injector injector; protected Injector injector;
/** /**
* Register an class that contains commands (denoted by {@link Command}. * Register an class that contains commands (denoted by {@link Command}.
* If no dependency injector is specified, then the methods of the * If no dependency injector is specified, then the methods of the
@ -144,7 +142,7 @@ public abstract class CommandsManager<T> {
} }
return null; return null;
} }
/** /**
* Register the methods of a class. * Register the methods of a class.
* *
@ -154,7 +152,7 @@ public abstract class CommandsManager<T> {
private List<Command> registerMethods(Class<?> cls, Method parent, Object obj) { private List<Command> registerMethods(Class<?> cls, Method parent, Object obj) {
Map<String, Method> map; Map<String, Method> map;
List<Command> registered = new ArrayList<Command>(); List<Command> registered = new ArrayList<Command>();
// Make a new hash map to cache the commands for this class // Make a new hash map to cache the commands for this class
// as looking up methods via reflection is fairly slow // as looking up methods via reflection is fairly slow
if (commands.containsKey(parent)) { if (commands.containsKey(parent)) {
@ -163,7 +161,7 @@ public abstract class CommandsManager<T> {
map = new HashMap<String, Method>(); map = new HashMap<String, Method>();
commands.put(parent, map); commands.put(parent, map);
} }
for (Method method : cls.getMethods()) { for (Method method : cls.getMethods()) {
if (!method.isAnnotationPresent(Command.class)) { if (!method.isAnnotationPresent(Command.class)) {
continue; continue;
@ -172,7 +170,7 @@ public abstract class CommandsManager<T> {
boolean isStatic = Modifier.isStatic(method.getModifiers()); boolean isStatic = Modifier.isStatic(method.getModifiers());
Command cmd = method.getAnnotation(Command.class); Command cmd = method.getAnnotation(Command.class);
// Cache the aliases too // Cache the aliases too
for (String alias : cmd.aliases()) { for (String alias : cmd.aliases()) {
map.put(alias, method); map.put(alias, method);
@ -184,10 +182,10 @@ public abstract class CommandsManager<T> {
if (obj == null) { if (obj == null) {
continue; continue;
} }
instances.put(method, obj); instances.put(method, obj);
} }
// Build a list of commands and their usage details, at least for // Build a list of commands and their usage details, at least for
// root level commands // root level commands
if (parent == null) { if (parent == null) {
@ -200,13 +198,13 @@ public abstract class CommandsManager<T> {
// Add the command to the registered command list for return // Add the command to the registered command list for return
registered.add(cmd); registered.add(cmd);
// Look for nested commands -- if there are any, those have // Look for nested commands -- if there are any, those have
// to be cached too so that they can be quickly looked // to be cached too so that they can be quickly looked
// up when processing commands // up when processing commands
if (method.isAnnotationPresent(NestedCommand.class)) { if (method.isAnnotationPresent(NestedCommand.class)) {
NestedCommand nestedCmd = method.getAnnotation(NestedCommand.class); NestedCommand nestedCmd = method.getAnnotation(NestedCommand.class);
for (Class<?> nestedCls : nestedCmd.value()) { for (Class<?> nestedCls : nestedCmd.value()) {
registerMethods(nestedCls, method); registerMethods(nestedCls, method);
} }
@ -214,7 +212,7 @@ public abstract class CommandsManager<T> {
} }
return registered; return registered;
} }
/** /**
* Checks to see whether there is a command named such at the root level. * Checks to see whether there is a command named such at the root level.
* This will check aliases as well. * This will check aliases as well.
@ -225,7 +223,7 @@ public abstract class CommandsManager<T> {
public boolean hasCommand(String command) { public boolean hasCommand(String command) {
return commands.get(null).containsKey(command.toLowerCase()); return commands.get(null).containsKey(command.toLowerCase());
} }
/** /**
* Get a list of command descriptions. This is only for root commands. * Get a list of command descriptions. This is only for root commands.
* *
@ -234,7 +232,7 @@ public abstract class CommandsManager<T> {
public Map<String, String> getCommands() { public Map<String, String> getCommands() {
return descs; return descs;
} }
/** /**
* Get the usage string for a command. * Get the usage string for a command.
* *
@ -245,9 +243,9 @@ public abstract class CommandsManager<T> {
*/ */
protected String getUsage(String[] args, int level, Command cmd) { protected String getUsage(String[] args, int level, Command cmd) {
StringBuilder command = new StringBuilder(); StringBuilder command = new StringBuilder();
command.append("/"); command.append("/");
for (int i = 0; i <= level; ++i) { for (int i = 0; i <= level; ++i) {
command.append(args[i] + " "); command.append(args[i] + " ");
} }
@ -256,7 +254,8 @@ public abstract class CommandsManager<T> {
char[] flags = cmd.flags().toCharArray(); char[] flags = cmd.flags().toCharArray();
for (int i = 0; i < flags.length; ++i) { for (int i = 0; i < flags.length; ++i) {
if (flags.length > i + 1 && flags[i + 1] == ':') { if (flags.length > i + 1 && flags[i + 1] == ':') {
i++; continue; i++;
continue;
} }
flagChars.add(flags[i]); flagChars.add(flags[i]);
} }
@ -269,10 +268,10 @@ public abstract class CommandsManager<T> {
} }
} }
command.append(cmd.usage()); command.append(cmd.usage());
return command.toString(); return command.toString();
} }
/** /**
* Get the usage string for a nested command. * Get the usage string for a nested command.
* *
@ -285,34 +284,33 @@ public abstract class CommandsManager<T> {
*/ */
protected String getNestedUsage(String[] args, int level, protected String getNestedUsage(String[] args, int level,
Method method, T player) throws CommandException { Method method, T player) throws CommandException {
StringBuilder command = new StringBuilder(); StringBuilder command = new StringBuilder();
command.append("/"); command.append("/");
for (int i = 0; i <= level; ++i) { for (int i = 0; i <= level; ++i) {
command.append(args[i] + " "); command.append(args[i] + " ");
} }
Map<String, Method> map = commands.get(method); Map<String, Method> map = commands.get(method);
boolean found = false; boolean found = false;
command.append("<"); command.append("<");
Set<String> allowedCommands = new HashSet<String>(); Set<String> allowedCommands = new HashSet<String>();
for (Map.Entry<String, Method> entry : map.entrySet()) { for (Map.Entry<String, Method> entry : map.entrySet()) {
Method childMethod = entry.getValue(); Method childMethod = entry.getValue();
found = true; found = true;
if (hasPermission(childMethod, player)) { if (hasPermission(childMethod, player)) {
Command childCmd = childMethod.getAnnotation(Command.class); Command childCmd = childMethod.getAnnotation(Command.class);
allowedCommands.add(childCmd.aliases()[0]); allowedCommands.add(childCmd.aliases()[0]);
} }
} }
if (allowedCommands.size() > 0) { if (allowedCommands.size() > 0) {
command.append(StringUtil.joinString(allowedCommands, "|", 0)); command.append(StringUtil.joinString(allowedCommands, "|", 0));
} else { } else {
@ -323,12 +321,12 @@ public abstract class CommandsManager<T> {
throw new CommandPermissionsException(); throw new CommandPermissionsException();
} }
} }
command.append(">"); command.append(">");
return command.toString(); return command.toString();
} }
/** /**
* Attempt to execute a command. This version takes a separate command * Attempt to execute a command. This version takes a separate command
* name (for the root command) and then a list of following arguments. * name (for the root command) and then a list of following arguments.
@ -340,17 +338,17 @@ public abstract class CommandsManager<T> {
* @throws CommandException * @throws CommandException
*/ */
public void execute(String cmd, String[] args, T player, public void execute(String cmd, String[] args, T player,
Object ... methodArgs) throws CommandException { Object... methodArgs) throws CommandException {
String[] newArgs = new String[args.length + 1]; String[] newArgs = new String[args.length + 1];
System.arraycopy(args, 0, newArgs, 1, args.length); System.arraycopy(args, 0, newArgs, 1, args.length);
newArgs[0] = cmd; newArgs[0] = cmd;
Object[] newMethodArgs = new Object[methodArgs.length + 1]; Object[] newMethodArgs = new Object[methodArgs.length + 1];
System.arraycopy(methodArgs, 0, newMethodArgs, 1, methodArgs.length); System.arraycopy(methodArgs, 0, newMethodArgs, 1, methodArgs.length);
executeMethod(null, newArgs, player, newMethodArgs, 0); executeMethod(null, newArgs, player, newMethodArgs, 0);
} }
/** /**
* Attempt to execute a command. * Attempt to execute a command.
* *
@ -360,13 +358,13 @@ public abstract class CommandsManager<T> {
* @throws CommandException * @throws CommandException
*/ */
public void execute(String[] args, T player, public void execute(String[] args, T player,
Object ... methodArgs) throws CommandException { Object... methodArgs) throws CommandException {
Object[] newMethodArgs = new Object[methodArgs.length + 1]; Object[] newMethodArgs = new Object[methodArgs.length + 1];
System.arraycopy(methodArgs, 0, newMethodArgs, 1, methodArgs.length); System.arraycopy(methodArgs, 0, newMethodArgs, 1, methodArgs.length);
executeMethod(null, args, player, newMethodArgs, 0); executeMethod(null, args, player, newMethodArgs, 0);
} }
/** /**
* Attempt to execute a command. * Attempt to execute a command.
* *
@ -379,12 +377,12 @@ public abstract class CommandsManager<T> {
*/ */
public void executeMethod(Method parent, String[] args, public void executeMethod(Method parent, String[] args,
T player, Object[] methodArgs, int level) throws CommandException { T player, Object[] methodArgs, int level) throws CommandException {
String cmdName = args[level]; String cmdName = args[level];
Map<String, Method> map = commands.get(parent); Map<String, Method> map = commands.get(parent);
Method method = map.get(cmdName.toLowerCase()); Method method = map.get(cmdName.toLowerCase());
if (method == null) { if (method == null) {
if (parent == null) { // Root if (parent == null) { // Root
throw new UnhandledCommandException(); throw new UnhandledCommandException();
@ -393,16 +391,16 @@ public abstract class CommandsManager<T> {
getNestedUsage(args, level - 1, parent, player)); getNestedUsage(args, level - 1, parent, player));
} }
} }
if (!hasPermission(method, player)) { if (!hasPermission(method, player)) {
throw new CommandPermissionsException(); throw new CommandPermissionsException();
} }
int argsCount = args.length - 1 - level; int argsCount = args.length - 1 - level;
if (method.isAnnotationPresent(NestedCommand.class)) { if (method.isAnnotationPresent(NestedCommand.class)) {
if (argsCount == 0) { if (argsCount == 0) {
throw new MissingNestedCommandException("Sub-command required.", throw new MissingNestedCommandException("Sub-command required.",
getNestedUsage(args, level, method, player)); getNestedUsage(args, level, method, player));
} else { } else {
executeMethod(method, args, player, methodArgs, level + 1); executeMethod(method, args, player, methodArgs, level + 1);
@ -410,7 +408,7 @@ public abstract class CommandsManager<T> {
} else if (method.isAnnotationPresent(CommandAlias.class)) { } else if (method.isAnnotationPresent(CommandAlias.class)) {
CommandAlias aCmd = method.getAnnotation(CommandAlias.class); CommandAlias aCmd = method.getAnnotation(CommandAlias.class);
executeMethod(parent, aCmd.value(), player, methodArgs, level); executeMethod(parent, aCmd.value(), player, methodArgs, level);
} else { } else {
Command cmd = method.getAnnotation(Command.class); Command cmd = method.getAnnotation(Command.class);
String[] newArgs = new String[args.length - level]; String[] newArgs = new String[args.length - level];
@ -422,23 +420,26 @@ public abstract class CommandsManager<T> {
Set<Character> newFlags = new HashSet<Character>(); Set<Character> newFlags = new HashSet<Character>();
for (int i = 0; i < flags.length; ++i) { for (int i = 0; i < flags.length; ++i) {
if (flags.length > i + 1 && flags[i + 1] == ':') { if (flags.length > i + 1 && flags[i + 1] == ':') {
valueFlags.add(flags[i]); valueFlags.add(flags[i]);
++i; ++i;
} }
newFlags.add(flags[i]); newFlags.add(flags[i]);
} }
CommandContext context = new CommandContext(newArgs, valueFlags); CommandContext context = new CommandContext(newArgs, valueFlags);
if (context.argsLength() < cmd.min()) if (context.argsLength() < cmd.min()) {
throw new CommandUsageException("Too few arguments.", getUsage(args, level, cmd)); throw new CommandUsageException("Too few arguments.", getUsage(args, level, cmd));
}
if (cmd.max() != -1 && context.argsLength() > cmd.max()) if (cmd.max() != -1 && context.argsLength() > cmd.max()) {
throw new CommandUsageException("Too many arguments.", getUsage(args, level, cmd)); throw new CommandUsageException("Too many arguments.", getUsage(args, level, cmd));
}
for (char flag : context.getFlags()) { for (char flag : context.getFlags()) {
if (!newFlags.contains(flag)) if (!newFlags.contains(flag)) {
throw new CommandUsageException("Unknown flag: " + flag, getUsage(args, level, cmd)); throw new CommandUsageException("Unknown flag: " + flag, getUsage(args, level, cmd));
}
} }
methodArgs[0] = context; methodArgs[0] = context;
@ -461,11 +462,11 @@ public abstract class CommandsManager<T> {
if (e.getCause() instanceof CommandException) { if (e.getCause() instanceof CommandException) {
throw (CommandException) e.getCause(); throw (CommandException) e.getCause();
} }
throw new WrappedCommandException(e.getCause()); throw new WrappedCommandException(e.getCause());
} }
} }
/** /**
* Returns whether a player has access to a command. * Returns whether a player has access to a command.
* *
@ -478,16 +479,16 @@ public abstract class CommandsManager<T> {
if (perms == null) { if (perms == null) {
return true; return true;
} }
for (String perm : perms.value()) { for (String perm : perms.value()) {
if (hasPermission(player, perm)) { if (hasPermission(player, perm)) {
return true; return true;
} }
} }
return false; return false;
} }
/** /**
* Returns whether a player permission.. * Returns whether a player permission..
* *

Datei anzeigen

@ -5,6 +5,7 @@ import java.lang.reflect.InvocationTargetException;
public class SimpleInjector<T> implements Injector { public class SimpleInjector<T> implements Injector {
private final T injectionObject; private final T injectionObject;
public SimpleInjector(T injectionObject) { public SimpleInjector(T injectionObject) {
this.injectionObject = injectionObject; this.injectionObject = injectionObject;
} }

Datei anzeigen

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

Datei anzeigen

@ -37,7 +37,7 @@ public class StringUtil {
if (str.length() > len) { if (str.length() > len) {
return str.substring(0, len); return str.substring(0, len);
} }
return str; return str;
} }
@ -156,7 +156,7 @@ public class StringUtil {
if (i > 0) { if (i > 0) {
buffer.append(delimiter); buffer.append(delimiter);
} }
buffer.append(o.toString()); buffer.append(o.toString());
} }
++i; ++i;

Datei anzeigen

@ -5,7 +5,7 @@ import org.yaml.snakeyaml.DumperOptions.FlowStyle;
public enum YAMLFormat { public enum YAMLFormat {
EXTENDED(FlowStyle.BLOCK), EXTENDED(FlowStyle.BLOCK),
COMPACT(FlowStyle.AUTO); COMPACT(FlowStyle.AUTO);
private final FlowStyle style; private final FlowStyle style;
YAMLFormat(FlowStyle style) { YAMLFormat(FlowStyle style) {

Datei anzeigen

@ -36,6 +36,7 @@ import java.util.Map;
public class YAMLNode { public class YAMLNode {
protected Map<String, Object> root; protected Map<String, Object> root;
private boolean writeDefaults; private boolean writeDefaults;
public YAMLNode(Map<String, Object> root, boolean writeDefaults) { public YAMLNode(Map<String, Object> root, boolean writeDefaults) {
this.root = root; this.root = root;
this.writeDefaults = writeDefaults; this.writeDefaults = writeDefaults;
@ -49,14 +50,14 @@ public class YAMLNode {
public Map<String, Object> getMap() { public Map<String, Object> getMap() {
return root; return root;
} }
/** /**
* Clear all nodes. * Clear all nodes.
*/ */
public void clear() { public void clear() {
root.clear(); root.clear();
} }
/** /**
* Gets a property at a location. This will either return an Object * Gets a property at a location. This will either return an Object
* or null, with null meaning that no configuration value exists at * or null, with null meaning that no configuration value exists at
@ -76,31 +77,31 @@ public class YAMLNode {
} }
return val; return val;
} }
String[] parts = path.split("\\."); String[] parts = path.split("\\.");
Map<String, Object> node = root; Map<String, Object> node = root;
for (int i = 0; i < parts.length; i++) { for (int i = 0; i < parts.length; i++) {
Object o = node.get(parts[i]); Object o = node.get(parts[i]);
if (o == null) { if (o == null) {
return null; return null;
} }
if (i == parts.length - 1) { if (i == parts.length - 1) {
return o; return o;
} }
try { try {
node = (Map<String, Object>)o; node = (Map<String, Object>) o;
} catch (ClassCastException e) { } catch (ClassCastException e) {
return null; return null;
} }
} }
return null; return null;
} }
/** /**
* Prepare a value for serialization, in case it's not a native type * Prepare a value for serialization, in case it's not a native type
* (and we don't want to serialize objects as YAML objects). * (and we don't want to serialize objects as YAML objects).
@ -117,10 +118,10 @@ public class YAMLNode {
out.put("z", vec.getZ()); out.put("z", vec.getZ());
return out; return out;
} }
return value; return value;
} }
/** /**
* Set the property at a location. This will override existing * Set the property at a location. This will override existing
* configuration data to have it conform to key/value mappings. * configuration data to have it conform to key/value mappings.
@ -131,34 +132,34 @@ public class YAMLNode {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void setProperty(String path, Object value) { public void setProperty(String path, Object value) {
value = prepareSerialization(value); value = prepareSerialization(value);
if (!path.contains(".")) { if (!path.contains(".")) {
root.put(path, value); root.put(path, value);
return; return;
} }
String[] parts = path.split("\\."); String[] parts = path.split("\\.");
Map<String, Object> node = root; Map<String, Object> node = root;
for (int i = 0; i < parts.length; i++) { for (int i = 0; i < parts.length; i++) {
Object o = node.get(parts[i]); Object o = node.get(parts[i]);
// Found our target! // Found our target!
if (i == parts.length - 1) { if (i == parts.length - 1) {
node.put(parts[i], value); node.put(parts[i], value);
return; return;
} }
if (o == null || !(o instanceof Map)) { if (o == null || !(o instanceof Map)) {
// This will override existing configuration data! // This will override existing configuration data!
o = new HashMap<String, Object>(); o = new HashMap<String, Object>();
node.put(parts[i], o); node.put(parts[i], o);
} }
node = (Map<String, Object>)o; node = (Map<String, Object>) o;
} }
} }
/** /**
* Adds a new node to the given path. The returned object is a reference * 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 * to the new node. This method will replace an existing node at
@ -204,15 +205,15 @@ public class YAMLNode {
if (o == null) { if (o == null) {
return null; return null;
} }
Double x = o.getDouble("x"); Double x = o.getDouble("x");
Double y = o.getDouble("y"); Double y = o.getDouble("y");
Double z = o.getDouble("z"); Double z = o.getDouble("z");
if (x == null || y == null || z == null) { if (x == null || y == null || z == null) {
return null; return null;
} }
return new Vector(x, y, z); return new Vector(x, y, z);
} }
@ -229,14 +230,14 @@ public class YAMLNode {
if (o == null) { if (o == null) {
return null; return null;
} }
Double x = o.getDouble("x"); Double x = o.getDouble("x");
Double z = o.getDouble("z"); Double z = o.getDouble("z");
if (x == null || z == null) { if (x == null || z == null) {
return null; return null;
} }
return new Vector2D(x, z); return new Vector2D(x, z);
} }
@ -387,7 +388,7 @@ public class YAMLNode {
return o; return o;
} }
} }
/** /**
* Get a list of keys at a location. If the map at the particular location * Get a list of keys at a location. If the map at the particular location
* does not exist or it is not a map, null will be returned. * does not exist or it is not a map, null will be returned.
@ -402,7 +403,7 @@ public class YAMLNode {
if (o == null) { if (o == null) {
return null; return null;
} else if (o instanceof Map) { } else if (o instanceof Map) {
return new ArrayList<String>(((Map<String,Object>)o).keySet()); return new ArrayList<String>(((Map<String, Object>) o).keySet());
} else { } else {
return null; return null;
} }
@ -421,12 +422,12 @@ public class YAMLNode {
if (o == null) { if (o == null) {
return null; return null;
} else if (o instanceof List) { } else if (o instanceof List) {
return (List<Object>)o; return (List<Object>) o;
} else { } else {
return null; return null;
} }
} }
/** /**
* Gets a list of strings. Non-valid entries will not be in the list. * Gets a list of strings. Non-valid entries will not be in the list.
* There will be no null slots. If the list is not defined, the * There will be no null slots. If the list is not defined, the
@ -450,13 +451,13 @@ public class YAMLNode {
if (o == null) { if (o == null) {
continue; continue;
} }
list.add(o.toString()); list.add(o.toString());
} }
return list; return list;
} }
/** /**
* Gets a list of integers. Non-valid entries will not be in the list. * Gets a list of integers. Non-valid entries will not be in the list.
* There will be no null slots. If the list is not defined, the * There will be no null slots. If the list is not defined, the
@ -481,10 +482,10 @@ public class YAMLNode {
list.add(i); list.add(i);
} }
} }
return list; return list;
} }
/** /**
* Gets a list of doubles. Non-valid entries will not be in the list. * Gets a list of doubles. Non-valid entries will not be in the list.
* There will be no null slots. If the list is not defined, the * There will be no null slots. If the list is not defined, the
@ -509,10 +510,10 @@ public class YAMLNode {
list.add(i); list.add(i);
} }
} }
return list; return list;
} }
/** /**
* Gets a list of booleans. Non-valid entries will not be in the list. * Gets a list of booleans. Non-valid entries will not be in the list.
* There will be no null slots. If the list is not defined, the * There will be no null slots. If the list is not defined, the
@ -537,10 +538,10 @@ public class YAMLNode {
list.add(tetsu); list.add(tetsu);
} }
} }
return list; return list;
} }
/** /**
* Gets a list of vectors. Non-valid entries will not be in the list. * Gets a list of vectors. Non-valid entries will not be in the list.
* There will be no null slots. If the list is not defined, the * There will be no null slots. If the list is not defined, the
@ -554,25 +555,25 @@ public class YAMLNode {
*/ */
public List<Vector> getVectorList( public List<Vector> getVectorList(
String path, List<Vector> def) { String path, List<Vector> def) {
List<YAMLNode> raw = getNodeList(path, null); List<YAMLNode> raw = getNodeList(path, null);
List<Vector> list = new ArrayList<Vector>(); List<Vector> list = new ArrayList<Vector>();
for (YAMLNode o : raw) { for (YAMLNode o : raw) {
Double x = o.getDouble("x"); Double x = o.getDouble("x");
Double y = o.getDouble("y"); Double y = o.getDouble("y");
Double z = o.getDouble("z"); Double z = o.getDouble("z");
if (x == null || y == null || z == null) { if (x == null || y == null || z == null) {
continue; continue;
} }
list.add(new Vector(x, y, z)); list.add(new Vector(x, y, z));
} }
return list; return list;
} }
/** /**
* Gets a list of 2D vectors. Non-valid entries will not be in the list. * Gets a list of 2D vectors. Non-valid entries will not be in the list.
* There will be no null slots. If the list is not defined, the * There will be no null slots. If the list is not defined, the
@ -586,24 +587,24 @@ public class YAMLNode {
*/ */
public List<Vector2D> getVector2dList( public List<Vector2D> getVector2dList(
String path, List<Vector2D> def) { String path, List<Vector2D> def) {
List<YAMLNode> raw = getNodeList(path, null); List<YAMLNode> raw = getNodeList(path, null);
List<Vector2D> list = new ArrayList<Vector2D>(); List<Vector2D> list = new ArrayList<Vector2D>();
for (YAMLNode o : raw) { for (YAMLNode o : raw) {
Double x = o.getDouble("x"); Double x = o.getDouble("x");
Double z = o.getDouble("z"); Double z = o.getDouble("z");
if (x == null || z == null) { if (x == null || z == null) {
continue; continue;
} }
list.add(new Vector2D(x, z)); list.add(new Vector2D(x, z));
} }
return list; return list;
} }
/** /**
* Gets a list of 2D vectors. Non-valid entries will not be in the list. * Gets a list of 2D vectors. Non-valid entries will not be in the list.
* There will be no null slots. If the list is not defined, the * There will be no null slots. If the list is not defined, the
@ -617,24 +618,24 @@ public class YAMLNode {
*/ */
public List<BlockVector2D> getBlockVector2dList( public List<BlockVector2D> getBlockVector2dList(
String path, List<BlockVector2D> def) { String path, List<BlockVector2D> def) {
List<YAMLNode> raw = getNodeList(path, null); List<YAMLNode> raw = getNodeList(path, null);
List<BlockVector2D> list = new ArrayList<BlockVector2D>(); List<BlockVector2D> list = new ArrayList<BlockVector2D>();
for (YAMLNode o : raw) { for (YAMLNode o : raw) {
Double x = o.getDouble("x"); Double x = o.getDouble("x");
Double z = o.getDouble("z"); Double z = o.getDouble("z");
if (x == null || z == null) { if (x == null || z == null) {
continue; continue;
} }
list.add(new BlockVector2D(x, z)); list.add(new BlockVector2D(x, z));
} }
return list; return list;
} }
/** /**
* Gets a list of nodes. Non-valid entries will not be in the list. * Gets a list of nodes. Non-valid entries will not be in the list.
* There will be no null slots. If the list is not defined, the * There will be no null slots. If the list is not defined, the
@ -656,13 +657,13 @@ public class YAMLNode {
List<YAMLNode> list = new ArrayList<YAMLNode>(); List<YAMLNode> list = new ArrayList<YAMLNode>();
for (Object o : raw) { for (Object o : raw) {
if (o instanceof Map) { if (o instanceof Map) {
list.add(new YAMLNode((Map<String, Object>)o, writeDefaults)); list.add(new YAMLNode((Map<String, Object>) o, writeDefaults));
} }
} }
return list; return list;
} }
/** /**
* Get a configuration node at a path. If the node doesn't exist or the * Get a configuration node at a path. If the node doesn't exist or the
* path does not lead to a node, null will be returned. A node has * path does not lead to a node, null will be returned. A node has
@ -675,12 +676,12 @@ public class YAMLNode {
public YAMLNode getNode(String path) { public YAMLNode getNode(String path) {
Object raw = getProperty(path); Object raw = getProperty(path);
if (raw instanceof Map) { if (raw instanceof Map) {
return new YAMLNode((Map<String, Object>)raw, writeDefaults); return new YAMLNode((Map<String, Object>) raw, writeDefaults);
} }
return null; return null;
} }
/** /**
* Get a list of nodes at a location. If the map at the particular location * Get a list of nodes at a location. If the map at the particular location
* does not exist or it is not a map, null will be returned. * does not exist or it is not a map, null will be returned.
@ -695,21 +696,21 @@ public class YAMLNode {
return null; return null;
} else if (o instanceof Map) { } else if (o instanceof Map) {
Map<String, YAMLNode> nodes = Map<String, YAMLNode> nodes =
new HashMap<String, YAMLNode>(); new HashMap<String, YAMLNode>();
for (Map.Entry<String, Object> entry : ((Map<String, Object>)o).entrySet()) { for (Map.Entry<String, Object> entry : ((Map<String, Object>) o).entrySet()) {
if (entry.getValue() instanceof Map) { if (entry.getValue() instanceof Map) {
nodes.put(entry.getKey(), nodes.put(entry.getKey(),
new YAMLNode((Map<String, Object>) entry.getValue(), writeDefaults)); new YAMLNode((Map<String, Object>) entry.getValue(), writeDefaults));
} }
} }
return nodes; return nodes;
} else { } else {
return null; return null;
} }
} }
/** /**
* Casts a value to an integer. May return null. * Casts a value to an integer. May return null.
* *
@ -720,12 +721,12 @@ public class YAMLNode {
if (o == null) { if (o == null) {
return null; return null;
} else if (o instanceof Number) { } else if (o instanceof Number) {
return ((Number)o).intValue(); return ((Number) o).intValue();
} else { } else {
return null; return null;
} }
} }
/** /**
* Casts a value to a double. May return null. * Casts a value to a double. May return null.
* *
@ -736,12 +737,12 @@ public class YAMLNode {
if (o == null) { if (o == null) {
return null; return null;
} else if (o instanceof Number) { } else if (o instanceof Number) {
return ((Number)o).doubleValue(); return ((Number) o).doubleValue();
} else { } else {
return null; return null;
} }
} }
/** /**
* Casts a value to a boolean. May return null. * Casts a value to a boolean. May return null.
* *
@ -752,12 +753,12 @@ public class YAMLNode {
if (o == null) { if (o == null) {
return null; return null;
} else if (o instanceof Boolean) { } else if (o instanceof Boolean) {
return (Boolean)o; return (Boolean) o;
} else { } else {
return null; return null;
} }
} }
/** /**
* Remove the property at a location. This will override existing * Remove the property at a location. This will override existing
* configuration data to have it conform to key/value mappings. * configuration data to have it conform to key/value mappings.
@ -770,20 +771,20 @@ public class YAMLNode {
root.remove(path); root.remove(path);
return; return;
} }
String[] parts = path.split("\\."); String[] parts = path.split("\\.");
Map<String, Object> node = root; Map<String, Object> node = root;
for (int i = 0; i < parts.length; i++) { for (int i = 0; i < parts.length; i++) {
Object o = node.get(parts[i]); Object o = node.get(parts[i]);
// Found our target! // Found our target!
if (i == parts.length - 1) { if (i == parts.length - 1) {
node.remove(parts[i]); node.remove(parts[i]);
return; return;
} }
node = (Map<String, Object>)o; node = (Map<String, Object>) o;
} }
} }
@ -794,4 +795,4 @@ public class YAMLNode {
public void setWriteDefaults(boolean writeDefaults) { public void setWriteDefaults(boolean writeDefaults) {
this.writeDefaults = writeDefaults; this.writeDefaults = writeDefaults;
} }
} }

Datei anzeigen

@ -66,10 +66,10 @@ public class YAMLProcessor extends YAMLNode {
private Yaml yaml; private Yaml yaml;
private File file; private File file;
private String header = null; private String header = null;
public YAMLProcessor(File file, boolean writeDefaults, YAMLFormat format) { public YAMLProcessor(File file, boolean writeDefaults, YAMLFormat format) {
super(new HashMap<String, Object>(), writeDefaults); super(new HashMap<String, Object>(), writeDefaults);
DumperOptions options = new DumperOptions(); DumperOptions options = new DumperOptions();
options.setIndent(4); options.setIndent(4);
options.setDefaultFlowStyle(format.getStyle()); options.setDefaultFlowStyle(format.getStyle());
@ -77,22 +77,22 @@ public class YAMLProcessor extends YAMLNode {
representer.setDefaultFlowStyle(format.getStyle()); representer.setDefaultFlowStyle(format.getStyle());
yaml = new Yaml(new SafeConstructor(), representer, options); yaml = new Yaml(new SafeConstructor(), representer, options);
this.file = file; this.file = file;
} }
public YAMLProcessor(File file, boolean writeDefaults) { public YAMLProcessor(File file, boolean writeDefaults) {
this(file, writeDefaults, YAMLFormat.COMPACT); this(file, writeDefaults, YAMLFormat.COMPACT);
} }
/** /**
* Loads the configuration file. * Loads the configuration file.
* *
* @throws java.io.IOException * @throws java.io.IOException
*/ */
public void load() throws IOException { public void load() throws IOException {
FileInputStream stream = null; FileInputStream stream = null;
try { try {
stream = new FileInputStream(file); stream = new FileInputStream(file);
read(yaml.load(new UnicodeReader(stream))); read(yaml.load(new UnicodeReader(stream)));
@ -171,7 +171,8 @@ public class YAMLProcessor extends YAMLNode {
} }
yaml.dump(root, writer); yaml.dump(root, writer);
return true; return true;
} catch (IOException e) {} finally { } catch (IOException e) {
} finally {
try { try {
if (stream != null) { if (stream != null) {
stream.close(); stream.close();
@ -181,20 +182,20 @@ public class YAMLProcessor extends YAMLNode {
return false; return false;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void read(Object input) throws YAMLProcessorException { private void read(Object input) throws YAMLProcessorException {
try { try {
if ( null == input ) { if (null == input) {
root = new HashMap<String, Object>(); root = new HashMap<String, Object>();
} else { } else {
root = (Map<String, Object>)input; root = (Map<String, Object>) input;
} }
} catch (ClassCastException e) { } catch (ClassCastException e) {
throw new YAMLProcessorException("Root document must be an key-value structure"); throw new YAMLProcessorException("Root document must be an key-value structure");
} }
} }
/** /**
* This method returns an empty ConfigurationNode for using as a * This method returns an empty ConfigurationNode for using as a
* default in methods that select a node from a node list. * default in methods that select a node from a node list.

Datei anzeigen

@ -26,11 +26,11 @@ package com.sk89q.util.yaml;
*/ */
public class YAMLProcessorException extends Exception { public class YAMLProcessorException extends Exception {
private static final long serialVersionUID = -2442886939908724203L; private static final long serialVersionUID = -2442886939908724203L;
public YAMLProcessorException() { public YAMLProcessorException() {
super(); super();
} }
public YAMLProcessorException(String msg) { public YAMLProcessorException(String msg) {
super(msg); super(msg);
} }

Datei anzeigen

@ -38,9 +38,9 @@ public abstract class ArbitraryShape {
Vector min = extent.getMinimumPoint(); Vector min = extent.getMinimumPoint();
Vector max = extent.getMaximumPoint(); Vector max = extent.getMaximumPoint();
cacheSizeX = (int)(max.getX() - min.getX() + 1 + 2); cacheSizeX = (int) (max.getX() - min.getX() + 1 + 2);
cacheSizeY = (int)(max.getY() - min.getY() + 1 + 2); cacheSizeY = (int) (max.getY() - min.getY() + 1 + 2);
cacheSizeZ = (int)(max.getZ() - min.getZ() + 1 + 2); cacheSizeZ = (int) (max.getZ() - min.getZ() + 1 + 2);
cacheX = min.getBlockX() - 1; cacheX = min.getBlockX() - 1;
cacheY = min.getBlockY() - 1; cacheY = min.getBlockY() - 1;
@ -79,7 +79,7 @@ public abstract class ArbitraryShape {
return null; return null;
} }
short newCacheEntry = (short) (material.getType() | ((material.getData()+1) << 8)); short newCacheEntry = (short) (material.getType() | ((material.getData() + 1) << 8));
if (newCacheEntry == 0) { if (newCacheEntry == 0) {
// type and data 0 // type and data 0
newCacheEntry = -2; newCacheEntry = -2;
@ -102,7 +102,7 @@ public abstract class ArbitraryShape {
private boolean isInsideCached(int x, int y, int z, Pattern pattern) { private boolean isInsideCached(int x, int y, int z, Pattern pattern) {
final int index = (y - cacheY) + (z - cacheZ) * cacheSizeY + (x - cacheX) * cacheSizeY * cacheSizeZ; final int index = (y - cacheY) + (z - cacheZ) * cacheSizeY + (x - cacheX) * cacheSizeY * cacheSizeZ;
switch (cache[index]) { switch (cache[index]) {
case 0: case 0:
// unknown block, meaning they must be outside the extent at this stage, but might still be inside the shape // unknown block, meaning they must be outside the extent at this stage, but might still be inside the shape

Datei anzeigen

@ -80,9 +80,9 @@ public class BlockVector extends Vector {
if (!(obj instanceof Vector)) { if (!(obj instanceof Vector)) {
return false; return false;
} }
Vector other = (Vector)obj; Vector other = (Vector) obj;
return (int)other.getX() == (int)this.x && (int)other.getY() == (int)this.y return (int) other.getX() == (int) this.x && (int) other.getY() == (int) this.y
&& (int)other.getZ() == (int)this.z; && (int) other.getZ() == (int) this.z;
} }
@ -93,8 +93,8 @@ public class BlockVector extends Vector {
*/ */
@Override @Override
public int hashCode() { public int hashCode() {
return (Integer.valueOf((int)x).hashCode() << 19) ^ return (Integer.valueOf((int) x).hashCode() << 19) ^
(Integer.valueOf((int)y).hashCode() << 12) ^ (Integer.valueOf((int) y).hashCode() << 12) ^
Integer.valueOf((int)z).hashCode(); Integer.valueOf((int) z).hashCode();
} }
} }

Datei anzeigen

@ -75,8 +75,8 @@ public class BlockVector2D extends Vector2D {
if (!(obj instanceof Vector2D)) { if (!(obj instanceof Vector2D)) {
return false; return false;
} }
Vector2D other = (Vector2D)obj; Vector2D other = (Vector2D) obj;
return (int)other.x == (int)this.x && (int)other.z == (int)this.z; return (int) other.x == (int) this.x && (int) other.z == (int) this.z;
} }
@ -87,7 +87,7 @@ public class BlockVector2D extends Vector2D {
*/ */
@Override @Override
public int hashCode() { public int hashCode() {
return (Integer.valueOf((int)x).hashCode() >> 13) ^ return (Integer.valueOf((int) x).hashCode() >> 13) ^
Integer.valueOf((int)z).hashCode(); Integer.valueOf((int) z).hashCode();
} }
} }

Datei anzeigen

@ -33,7 +33,7 @@ public class BlockWorldVector extends WorldVector {
public BlockWorldVector(WorldVector pt) { public BlockWorldVector(WorldVector pt) {
super(pt.getWorld(), pt); super(pt.getWorld(), pt);
} }
/** /**
* Construct the Vector object. * Construct the Vector object.
* @param world * @param world
@ -101,7 +101,7 @@ public class BlockWorldVector extends WorldVector {
public BlockWorldVector(LocalWorld world, double x, double y, double z) { public BlockWorldVector(LocalWorld world, double x, double y, double z) {
super(world, x, y, z); super(world, x, y, z);
} }
/** /**
* Checks if another object is equivalent. * Checks if another object is equivalent.
* *
@ -113,9 +113,9 @@ public class BlockWorldVector extends WorldVector {
if (!(obj instanceof WorldVector)) { if (!(obj instanceof WorldVector)) {
return false; return false;
} }
WorldVector other = (WorldVector)obj; WorldVector other = (WorldVector) obj;
return (int)other.getX() == (int)this.x && (int)other.getY() == (int)this.y return (int) other.getX() == (int) this.x && (int) other.getY() == (int) this.y
&& (int)other.getZ() == (int)this.z; && (int) other.getZ() == (int) this.z;
} }
@ -126,8 +126,8 @@ public class BlockWorldVector extends WorldVector {
*/ */
@Override @Override
public int hashCode() { public int hashCode() {
return (Integer.valueOf((int)x).hashCode() << 19) ^ return (Integer.valueOf((int) x).hashCode() << 19) ^
(Integer.valueOf((int)y).hashCode() << 12) ^ (Integer.valueOf((int) y).hashCode() << 12) ^
Integer.valueOf((int)z).hashCode(); Integer.valueOf((int) z).hashCode();
} }
} }

Datei anzeigen

@ -58,4 +58,4 @@ public class BlockWorldVector2D extends WorldVector2D {
&& (int) other.getZ() == (int) this.z; && (int) other.getZ() == (int) this.z;
} }
} }

Datei anzeigen

@ -126,7 +126,7 @@ public class CuboidClipboard {
return; return;
} }
boolean reverse = angle < 0; boolean reverse = angle < 0;
int numRotations = Math.abs((int)Math.floor(angle / 90.0)); int numRotations = Math.abs((int) Math.floor(angle / 90.0));
int width = getWidth(); int width = getWidth();
int length = getLength(); int length = getLength();
@ -260,7 +260,7 @@ public class CuboidClipboard {
for (int y = 0; y < size.getBlockY(); ++y) { for (int y = 0; y < size.getBlockY(); ++y) {
for (int z = 0; z < size.getBlockZ(); ++z) { for (int z = 0; z < size.getBlockZ(); ++z) {
data[x][y][z] = data[x][y][z] =
editSession.getBlock(new Vector(x, y, z).add(getOrigin())); editSession.getBlock(new Vector(x, y, z).add(getOrigin()));
} }
} }
} }
@ -287,16 +287,15 @@ public class CuboidClipboard {
* @param noAir * @param noAir
* @throws MaxChangedBlocksException * @throws MaxChangedBlocksException
*/ */
public void place(EditSession editSession, Vector pos, boolean noAir) public void place(EditSession editSession, Vector pos, boolean noAir) throws MaxChangedBlocksException {
throws MaxChangedBlocksException {
for (int x = 0; x < size.getBlockX(); ++x) { for (int x = 0; x < size.getBlockX(); ++x) {
for (int y = 0; y < size.getBlockY(); ++y) { for (int y = 0; y < size.getBlockY(); ++y) {
for (int z = 0; z < size.getBlockZ(); ++z) { for (int z = 0; z < size.getBlockZ(); ++z) {
if (noAir && data[x][y][z].isAir()) if (noAir && data[x][y][z].isAir()) {
continue; continue;
}
editSession.setBlock(new Vector(x, y, z).add(pos), editSession.setBlock(new Vector(x, y, z).add(pos), data[x][y][z]);
data[x][y][z]);
} }
} }
} }
@ -345,10 +344,10 @@ public class CuboidClipboard {
throw new DataException("Length of region too large for a .schematic"); throw new DataException("Length of region too large for a .schematic");
} }
HashMap<String,Tag> schematic = new HashMap<String,Tag>(); HashMap<String, Tag> schematic = new HashMap<String, Tag>();
schematic.put("Width", new ShortTag("Width", (short)width)); schematic.put("Width", new ShortTag("Width", (short) width));
schematic.put("Length", new ShortTag("Length", (short)length)); schematic.put("Length", new ShortTag("Length", (short) length));
schematic.put("Height", new ShortTag("Height", (short)height)); schematic.put("Height", new ShortTag("Height", (short) height));
schematic.put("Materials", new StringTag("Materials", "Alpha")); schematic.put("Materials", new StringTag("Materials", "Alpha"));
schematic.put("WEOriginX", new IntTag("WEOriginX", getOrigin().getBlockX())); schematic.put("WEOriginX", new IntTag("WEOriginX", getOrigin().getBlockX()));
schematic.put("WEOriginY", new IntTag("WEOriginY", getOrigin().getBlockY())); schematic.put("WEOriginY", new IntTag("WEOriginY", getOrigin().getBlockY()));
@ -366,16 +365,16 @@ public class CuboidClipboard {
for (int y = 0; y < height; ++y) { for (int y = 0; y < height; ++y) {
for (int z = 0; z < length; ++z) { for (int z = 0; z < length; ++z) {
int index = y * width * length + z * width + x; int index = y * width * length + z * width + x;
blocks[index] = (byte)data[x][y][z].getType(); blocks[index] = (byte) data[x][y][z].getType();
blockData[index] = (byte)data[x][y][z].getData(); blockData[index] = (byte) data[x][y][z].getData();
// Store TileEntity data // Store TileEntity data
if (data[x][y][z] instanceof TileEntityBlock) { if (data[x][y][z] instanceof TileEntityBlock) {
TileEntityBlock tileEntityBlock = TileEntityBlock tileEntityBlock =
(TileEntityBlock)data[x][y][z]; (TileEntityBlock) data[x][y][z];
// Get the list of key/values from the block // Get the list of key/values from the block
Map<String,Tag> values = tileEntityBlock.toTileEntityNBT(); Map<String, Tag> values = tileEntityBlock.toTileEntityNBT();
if (values != null) { if (values != null) {
values.put("id", new StringTag("id", values.put("id", new StringTag("id",
tileEntityBlock.getTileEntityID())); tileEntityBlock.getTileEntityID()));
@ -421,78 +420,78 @@ public class CuboidClipboard {
Vector offset = new Vector(); Vector offset = new Vector();
// Schematic tag // Schematic tag
CompoundTag schematicTag = (CompoundTag)nbtStream.readTag(); CompoundTag schematicTag = (CompoundTag) nbtStream.readTag();
if (!schematicTag.getName().equals("Schematic")) { if (!schematicTag.getName().equals("Schematic")) {
throw new DataException("Tag \"Schematic\" does not exist or is not first"); throw new DataException("Tag \"Schematic\" does not exist or is not first");
} }
// Check // Check
Map<String,Tag> schematic = schematicTag.getValue(); Map<String, Tag> schematic = schematicTag.getValue();
if (!schematic.containsKey("Blocks")) { if (!schematic.containsKey("Blocks")) {
throw new DataException("Schematic file is missing a \"Blocks\" tag"); throw new DataException("Schematic file is missing a \"Blocks\" tag");
} }
// Get information // Get information
short width = (Short)getChildTag(schematic, "Width", ShortTag.class).getValue(); short width = (Short) getChildTag(schematic, "Width", ShortTag.class).getValue();
short length = (Short)getChildTag(schematic, "Length", ShortTag.class).getValue(); short length = (Short) getChildTag(schematic, "Length", ShortTag.class).getValue();
short height = (Short)getChildTag(schematic, "Height", ShortTag.class).getValue(); short height = (Short) getChildTag(schematic, "Height", ShortTag.class).getValue();
try { try {
int originX = (Integer)getChildTag(schematic, "WEOriginX", IntTag.class).getValue(); int originX = (Integer) getChildTag(schematic, "WEOriginX", IntTag.class).getValue();
int originY = (Integer)getChildTag(schematic, "WEOriginY", IntTag.class).getValue(); int originY = (Integer) getChildTag(schematic, "WEOriginY", IntTag.class).getValue();
int originZ = (Integer)getChildTag(schematic, "WEOriginZ", IntTag.class).getValue(); int originZ = (Integer) getChildTag(schematic, "WEOriginZ", IntTag.class).getValue();
origin = new Vector(originX, originY, originZ); origin = new Vector(originX, originY, originZ);
} catch (DataException e) { } catch (DataException e) {
// No origin data // No origin data
} }
try { try {
int offsetX = (Integer)getChildTag(schematic, "WEOffsetX", IntTag.class).getValue(); int offsetX = (Integer) getChildTag(schematic, "WEOffsetX", IntTag.class).getValue();
int offsetY = (Integer)getChildTag(schematic, "WEOffsetY", IntTag.class).getValue(); int offsetY = (Integer) getChildTag(schematic, "WEOffsetY", IntTag.class).getValue();
int offsetZ = (Integer)getChildTag(schematic, "WEOffsetZ", IntTag.class).getValue(); int offsetZ = (Integer) getChildTag(schematic, "WEOffsetZ", IntTag.class).getValue();
offset = new Vector(offsetX, offsetY, offsetZ); offset = new Vector(offsetX, offsetY, offsetZ);
} catch (DataException e) { } catch (DataException e) {
// No offset data // No offset data
} }
// Check type of Schematic // Check type of Schematic
String materials = (String)getChildTag(schematic, "Materials", StringTag.class).getValue(); String materials = (String) getChildTag(schematic, "Materials", StringTag.class).getValue();
if (!materials.equals("Alpha")) { if (!materials.equals("Alpha")) {
throw new DataException("Schematic file is not an Alpha schematic"); throw new DataException("Schematic file is not an Alpha schematic");
} }
// Get blocks // Get blocks
byte[] blocks = (byte[])getChildTag(schematic, "Blocks", ByteArrayTag.class).getValue(); byte[] blocks = (byte[]) getChildTag(schematic, "Blocks", ByteArrayTag.class).getValue();
byte[] blockData = (byte[])getChildTag(schematic, "Data", ByteArrayTag.class).getValue(); byte[] blockData = (byte[]) getChildTag(schematic, "Data", ByteArrayTag.class).getValue();
// Need to pull out tile entities // Need to pull out tile entities
List<Tag> tileEntities = (List<Tag>)((ListTag)getChildTag(schematic, "TileEntities", ListTag.class)) List<Tag> tileEntities = (List<Tag>) ((ListTag) getChildTag(schematic, "TileEntities", ListTag.class))
.getValue(); .getValue();
Map<BlockVector,Map<String,Tag>> tileEntitiesMap = Map<BlockVector, Map<String, Tag>> tileEntitiesMap =
new HashMap<BlockVector,Map<String,Tag>>(); new HashMap<BlockVector, Map<String, Tag>>();
for (Tag tag : tileEntities) { for (Tag tag : tileEntities) {
if (!(tag instanceof CompoundTag)) continue; if (!(tag instanceof CompoundTag)) continue;
CompoundTag t = (CompoundTag)tag; CompoundTag t = (CompoundTag) tag;
int x = 0; int x = 0;
int y = 0; int y = 0;
int z = 0; int z = 0;
Map<String,Tag> values = new HashMap<String,Tag>(); Map<String, Tag> values = new HashMap<String, Tag>();
for (Map.Entry<String,Tag> entry : t.getValue().entrySet()) { for (Map.Entry<String, Tag> entry : t.getValue().entrySet()) {
if (entry.getKey().equals("x")) { if (entry.getKey().equals("x")) {
if (entry.getValue() instanceof IntTag) { if (entry.getValue() instanceof IntTag) {
x = ((IntTag)entry.getValue()).getValue(); x = ((IntTag) entry.getValue()).getValue();
} }
} else if (entry.getKey().equals("y")) { } else if (entry.getKey().equals("y")) {
if (entry.getValue() instanceof IntTag) { if (entry.getValue() instanceof IntTag) {
y = ((IntTag)entry.getValue()).getValue(); y = ((IntTag) entry.getValue()).getValue();
} }
} else if (entry.getKey().equals("z")) { } else if (entry.getKey().equals("z")) {
if (entry.getValue() instanceof IntTag) { if (entry.getValue() instanceof IntTag) {
z = ((IntTag)entry.getValue()).getValue(); z = ((IntTag) entry.getValue()).getValue();
} }
} }
@ -549,7 +548,7 @@ public class CuboidClipboard {
if (block instanceof TileEntityBlock if (block instanceof TileEntityBlock
&& tileEntitiesMap.containsKey(pt)) { && tileEntitiesMap.containsKey(pt)) {
((TileEntityBlock)block).fromTileEntityNBT( ((TileEntityBlock) block).fromTileEntityNBT(
tileEntitiesMap.get(pt)); tileEntitiesMap.get(pt));
} }
@ -570,7 +569,7 @@ public class CuboidClipboard {
* @return child tag * @return child tag
* @throws DataException * @throws DataException
*/ */
private static Tag getChildTag(Map<String,Tag> items, String key, private static Tag getChildTag(Map<String, Tag> items, String key,
Class<? extends Tag> expected) throws DataException { Class<? extends Tag> expected) throws DataException {
if (!items.containsKey(key)) { if (!items.containsKey(key)) {

Datei anzeigen

@ -33,7 +33,7 @@ import java.util.NoSuchElementException;
* @param <A> * @param <A>
* @param <B> * @param <B>
*/ */
public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> { public class DoubleArrayList<A, B> implements Iterable<Map.Entry<A, B>> {
/** /**
* First list. * First list.
*/ */
@ -88,13 +88,13 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
* *
* @return * @return
*/ */
public Iterator<Map.Entry<A,B>> iterator() { public Iterator<Map.Entry<A, B>> iterator() {
if (isReversed) { if (isReversed) {
return new ReverseEntryIterator<Map.Entry<A,B>>( return new ReverseEntryIterator<Map.Entry<A, B>>(
listA.listIterator(listA.size()), listA.listIterator(listA.size()),
listB.listIterator(listB.size())); listB.listIterator(listB.size()));
} else { } else {
return new ForwardEntryIterator<Map.Entry<A,B>>( return new ForwardEntryIterator<Map.Entry<A, B>>(
listA.iterator(), listA.iterator(),
listB.iterator()); listB.iterator());
} }
@ -105,8 +105,8 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
* *
* @param <T> * @param <T>
*/ */
public class ForwardEntryIterator<T extends Map.Entry<A,B>> public class ForwardEntryIterator<T extends Map.Entry<A, B>>
implements Iterator<Map.Entry<A,B>> { implements Iterator<Map.Entry<A, B>> {
private Iterator<A> keyIterator; private Iterator<A> keyIterator;
private Iterator<B> valueIterator; private Iterator<B> valueIterator;
@ -120,8 +120,8 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
return keyIterator.hasNext(); return keyIterator.hasNext();
} }
public Map.Entry<A,B> next() throws NoSuchElementException { public Map.Entry<A, B> next() throws NoSuchElementException {
return new Entry<A,B>(keyIterator.next(), valueIterator.next()); return new Entry<A, B>(keyIterator.next(), valueIterator.next());
} }
public void remove() { public void remove() {
@ -134,8 +134,8 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
* *
* @param <T> * @param <T>
*/ */
public class ReverseEntryIterator<T extends Map.Entry<A,B>> public class ReverseEntryIterator<T extends Map.Entry<A, B>>
implements Iterator<Map.Entry<A,B>> { implements Iterator<Map.Entry<A, B>> {
private ListIterator<A> keyIterator; private ListIterator<A> keyIterator;
private ListIterator<B> valueIterator; private ListIterator<B> valueIterator;
@ -149,8 +149,8 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
return keyIterator.hasPrevious(); return keyIterator.hasPrevious();
} }
public Map.Entry<A,B> next() throws NoSuchElementException { public Map.Entry<A, B> next() throws NoSuchElementException {
return new Entry<A,B>(keyIterator.previous(), valueIterator.previous()); return new Entry<A, B>(keyIterator.previous(), valueIterator.previous());
} }
public void remove() { public void remove() {
@ -164,7 +164,7 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
* @param <C> * @param <C>
* @param <D> * @param <D>
*/ */
public class Entry<C,D> implements Map.Entry<A,B> { public class Entry<C, D> implements Map.Entry<A, B> {
private A key; private A key;
private B value; private B value;

Datei anzeigen

@ -66,31 +66,31 @@ public class EditSession {
* Stores the original blocks before modification. * Stores the original blocks before modification.
*/ */
private DoubleArrayList<BlockVector, BaseBlock> original = private DoubleArrayList<BlockVector, BaseBlock> original =
new DoubleArrayList<BlockVector, BaseBlock>(true); new DoubleArrayList<BlockVector, BaseBlock>(true);
/** /**
* Stores the current blocks. * Stores the current blocks.
*/ */
private DoubleArrayList<BlockVector, BaseBlock> current = private DoubleArrayList<BlockVector, BaseBlock> current =
new DoubleArrayList<BlockVector, BaseBlock>(false); new DoubleArrayList<BlockVector, BaseBlock>(false);
/** /**
* Blocks that should be placed before last. * Blocks that should be placed before last.
*/ */
private DoubleArrayList<BlockVector, BaseBlock> queueAfter = private DoubleArrayList<BlockVector, BaseBlock> queueAfter =
new DoubleArrayList<BlockVector, BaseBlock>(false); new DoubleArrayList<BlockVector, BaseBlock>(false);
/** /**
* Blocks that should be placed last. * Blocks that should be placed last.
*/ */
private DoubleArrayList<BlockVector, BaseBlock> queueLast = private DoubleArrayList<BlockVector, BaseBlock> queueLast =
new DoubleArrayList<BlockVector, BaseBlock>(false); new DoubleArrayList<BlockVector, BaseBlock>(false);
/** /**
* Blocks that should be placed after all other blocks. * Blocks that should be placed after all other blocks.
*/ */
private DoubleArrayList<BlockVector, BaseBlock> queueFinal = private DoubleArrayList<BlockVector, BaseBlock> queueFinal =
new DoubleArrayList<BlockVector, BaseBlock>(false); new DoubleArrayList<BlockVector, BaseBlock>(false);
/** /**
* The maximum number of blocks to change at a time. If this number is * The maximum number of blocks to change at a time. If this number is
@ -327,20 +327,17 @@ public class EditSession {
if (BlockType.shouldPlaceLast(block.getType())) { if (BlockType.shouldPlaceLast(block.getType())) {
// Place torches, etc. last // Place torches, etc. last
queueLast.put(pt.toBlockVector(), block); queueLast.put(pt.toBlockVector(), block);
return !(getBlockType(pt) == block.getType() return !(getBlockType(pt) == block.getType() && getBlockData(pt) == block.getData());
&& getBlockData(pt) == block.getData());
} else if (BlockType.shouldPlaceFinal(block.getType())) { } else if (BlockType.shouldPlaceFinal(block.getType())) {
// Place signs, reed, etc even later // Place signs, reed, etc even later
queueFinal.put(pt.toBlockVector(), block); queueFinal.put(pt.toBlockVector(), block);
return !(getBlockType(pt) == block.getType() return !(getBlockType(pt) == block.getType() && getBlockData(pt) == block.getData());
&& getBlockData(pt) == block.getData());
} else if (BlockType.shouldPlaceLast(getBlockType(pt))) { } else if (BlockType.shouldPlaceLast(getBlockType(pt))) {
// Destroy torches, etc. first // Destroy torches, etc. first
rawSetBlock(pt, new BaseBlock(BlockID.AIR)); rawSetBlock(pt, new BaseBlock(BlockID.AIR));
} else { } else {
queueAfter.put(pt.toBlockVector(), block); queueAfter.put(pt.toBlockVector(), block);
return !(getBlockType(pt) == block.getType() return !(getBlockType(pt) == block.getType() && getBlockData(pt) == block.getData());
&& getBlockData(pt) == block.getData());
} }
} }
@ -403,6 +400,7 @@ public class EditSession {
return world.getBlockData(pt); return world.getBlockData(pt);
} }
/** /**
* Gets the block type at a position x, y, z. * Gets the block type at a position x, y, z.
* *
@ -765,7 +763,7 @@ public class EditSession {
continue; continue;
} }
final Deque<BlockVector> walked = new LinkedList<BlockVector>(); final Deque<BlockVector> walked = new LinkedList<BlockVector>();
while (true) { while (true) {
walked.addFirst(current); walked.addFirst(current);
@ -1962,7 +1960,7 @@ public class EditSession {
visited.add(cur); visited.add(cur);
if (setBlock(cur, stationaryBlock)){ if (setBlock(cur, stationaryBlock)) {
++affected; ++affected;
} }
@ -2033,13 +2031,11 @@ public class EditSession {
final int ceilRadiusZ = (int) Math.ceil(radiusZ); final int ceilRadiusZ = (int) Math.ceil(radiusZ);
double nextXn = 0; double nextXn = 0;
forX: forX: for (int x = 0; x <= ceilRadiusX; ++x) {
for (int x = 0; x <= ceilRadiusX; ++x) {
final double xn = nextXn; final double xn = nextXn;
nextXn = (x + 1) * invRadiusX; nextXn = (x + 1) * invRadiusX;
double nextZn = 0; double nextZn = 0;
forZ: forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
for (int z = 0; z <= ceilRadiusZ; ++z) {
final double zn = nextZn; final double zn = nextZn;
nextZn = (z + 1) * invRadiusZ; nextZn = (z + 1) * invRadiusZ;
@ -2119,18 +2115,15 @@ public class EditSession {
final int ceilRadiusZ = (int) Math.ceil(radiusZ); final int ceilRadiusZ = (int) Math.ceil(radiusZ);
double nextXn = 0; double nextXn = 0;
forX: forX: for (int x = 0; x <= ceilRadiusX; ++x) {
for (int x = 0; x <= ceilRadiusX; ++x) {
final double xn = nextXn; final double xn = nextXn;
nextXn = (x + 1) * invRadiusX; nextXn = (x + 1) * invRadiusX;
double nextYn = 0; double nextYn = 0;
forY: forY: for (int y = 0; y <= ceilRadiusY; ++y) {
for (int y = 0; y <= ceilRadiusY; ++y) {
final double yn = nextYn; final double yn = nextYn;
nextYn = (y + 1) * invRadiusY; nextYn = (y + 1) * invRadiusY;
double nextZn = 0; double nextZn = 0;
forZ: forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
for (int z = 0; z <= ceilRadiusZ; ++z) {
final double zn = nextZn; final double zn = nextZn;
nextZn = (z + 1) * invRadiusZ; nextZn = (z + 1) * invRadiusZ;
@ -2244,7 +2237,7 @@ public class EditSession {
public int thaw(Vector pos, double radius) public int thaw(Vector pos, double radius)
throws MaxChangedBlocksException { throws MaxChangedBlocksException {
int affected = 0; int affected = 0;
double radiusSq = radius*radius; double radiusSq = radius * radius;
int ox = pos.getBlockX(); int ox = pos.getBlockX();
int oy = pos.getBlockY(); int oy = pos.getBlockY();
@ -2303,7 +2296,7 @@ public class EditSession {
public int simulateSnow(Vector pos, double radius) public int simulateSnow(Vector pos, double radius)
throws MaxChangedBlocksException { throws MaxChangedBlocksException {
int affected = 0; int affected = 0;
double radiusSq = radius*radius; double radiusSq = radius * radius;
int ox = pos.getBlockX(); int ox = pos.getBlockX();
int oy = pos.getBlockY(); int oy = pos.getBlockY();
@ -2368,7 +2361,7 @@ public class EditSession {
public int green(Vector pos, double radius) public int green(Vector pos, double radius)
throws MaxChangedBlocksException { throws MaxChangedBlocksException {
int affected = 0; int affected = 0;
double radiusSq = radius*radius; double radiusSq = radius * radius;
int ox = pos.getBlockX(); int ox = pos.getBlockX();
int oy = pos.getBlockY(); int oy = pos.getBlockY();
@ -2655,7 +2648,7 @@ public class EditSession {
return null; return null;
} }
return new BaseBlock((int)typeVariable.getValue(), (int)dataVariable.getValue()); return new BaseBlock((int) typeVariable.getValue(), (int) dataVariable.getValue());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;

Datei anzeigen

@ -30,4 +30,4 @@ public enum EntityType {
MINECARTS, MINECARTS,
TNT, TNT,
XP_ORBS XP_ORBS
} }

Datei anzeigen

@ -21,11 +21,11 @@ package com.sk89q.worldedit;
public class FileSelectionAbortedException extends FilenameException { public class FileSelectionAbortedException extends FilenameException {
private static final long serialVersionUID = 7377072269988014886L; private static final long serialVersionUID = 7377072269988014886L;
public FileSelectionAbortedException() { public FileSelectionAbortedException() {
super(""); super("");
} }
public FileSelectionAbortedException(String msg) { public FileSelectionAbortedException(String msg) {
super("", msg); super("", msg);
} }

Datei anzeigen

@ -21,19 +21,19 @@ package com.sk89q.worldedit;
public class FilenameException extends WorldEditException { public class FilenameException extends WorldEditException {
private static final long serialVersionUID = 6072601657326106265L; private static final long serialVersionUID = 6072601657326106265L;
private String filename; private String filename;
public FilenameException(String filename) { public FilenameException(String filename) {
super(); super();
this.filename = filename; this.filename = filename;
} }
public FilenameException(String filename, String msg) { public FilenameException(String filename, String msg) {
super(msg); super(msg);
this.filename = filename; this.filename = filename;
} }
public String getFilename() { public String getFilename() {
return filename; return filename;
} }

Datei anzeigen

@ -21,11 +21,11 @@ package com.sk89q.worldedit;
public class FilenameResolutionException extends FilenameException { public class FilenameResolutionException extends FilenameException {
private static final long serialVersionUID = 4673670296313383121L; private static final long serialVersionUID = 4673670296313383121L;
public FilenameResolutionException(String filename) { public FilenameResolutionException(String filename) {
super(filename); super(filename);
} }
public FilenameResolutionException(String filename, String msg) { public FilenameResolutionException(String filename, String msg) {
super(filename, msg); super(filename, msg);
} }

Datei anzeigen

@ -1,4 +1,3 @@
package com.sk89q.worldedit;
// $Id$ // $Id$
/* /*
* WorldEditLibrary * WorldEditLibrary
@ -18,6 +17,8 @@ package com.sk89q.worldedit;
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldedit;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.filtering.HeightMapFilter; import com.sk89q.worldedit.filtering.HeightMapFilter;

Datei anzeigen

@ -21,11 +21,11 @@ package com.sk89q.worldedit;
public class InvalidFilenameException extends FilenameException { public class InvalidFilenameException extends FilenameException {
private static final long serialVersionUID = 7377072269988014886L; private static final long serialVersionUID = 7377072269988014886L;
public InvalidFilenameException(String filename) { public InvalidFilenameException(String filename) {
super(filename); super(filename);
} }
public InvalidFilenameException(String filename, String msg) { public InvalidFilenameException(String filename, String msg) {
super(filename, msg); super(filename, msg);
} }

Datei anzeigen

@ -21,9 +21,9 @@ package com.sk89q.worldedit;
public class InvalidToolBindException extends WorldEditException { public class InvalidToolBindException extends WorldEditException {
private static final long serialVersionUID = -1865311004052447699L; private static final long serialVersionUID = -1865311004052447699L;
private int itemId; private int itemId;
public InvalidToolBindException(int itemId, String msg) { public InvalidToolBindException(int itemId, String msg) {
super(msg); super(msg);
this.itemId = itemId; this.itemId = itemId;

Datei anzeigen

@ -26,7 +26,6 @@ import java.io.File;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
/** /**
* Represents WorldEdit's configuration. * Represents WorldEdit's configuration.
* *
@ -102,12 +101,12 @@ public abstract class LocalConfiguration {
public String saveDir = "schematics"; public String saveDir = "schematics";
public String scriptsDir = "craftscripts"; public String scriptsDir = "craftscripts";
public boolean showFirstUseVersion = true; public boolean showFirstUseVersion = true;
/** /**
* Loads the configuration. * Loads the configuration.
*/ */
public abstract void load(); public abstract void load();
/** /**
* Get the working directory to work from. * Get the working directory to work from.
* *

Datei anzeigen

@ -322,6 +322,7 @@ public abstract class LocalPlayer {
TargetBlock tb = new TargetBlock(this, range, 0.2); TargetBlock tb = new TargetBlock(this, range, 0.2);
return (useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace()); return (useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace());
} }
/** /**
* Get the point of the block being looked at. May return null. * Get the point of the block being looked at. May return null.
* *
@ -556,7 +557,7 @@ public abstract class LocalPlayer {
* @param pos * @param pos
*/ */
public void setPosition(Vector pos) { public void setPosition(Vector pos) {
setPosition(pos, (float)getPitch(), (float)getYaw()); setPosition(pos, (float) getPitch(), (float) getYaw());
} }
/** /**
@ -637,7 +638,7 @@ public abstract class LocalPlayer {
if (!(other instanceof LocalPlayer)) { if (!(other instanceof LocalPlayer)) {
return false; return false;
} }
LocalPlayer other2 = (LocalPlayer)other; LocalPlayer other2 = (LocalPlayer) other;
return other2.getName().equals(getName()); return other2.getName().equals(getName());
} }
@ -652,8 +653,8 @@ public abstract class LocalPlayer {
} }
public void checkPermission(String permission) throws WorldEditPermissionException { public void checkPermission(String permission) throws WorldEditPermissionException {
if (!hasPermission(permission)) { if (!hasPermission(permission)) {
throw new WorldEditPermissionException(); throw new WorldEditPermissionException();
} }
} }
} }

Datei anzeigen

@ -75,7 +75,6 @@ public class LocalSession {
private boolean fastMode = false; private boolean fastMode = false;
private Mask mask; private Mask mask;
private TimeZone timezone = TimeZone.getDefault(); private TimeZone timezone = TimeZone.getDefault();
//private Boolean jumptoBlock = true;
/** /**
* Construct the object. * Construct the object.
@ -165,7 +164,7 @@ public class LocalSession {
if (historyPointer < history.size()) { if (historyPointer < history.size()) {
EditSession editSession = history.get(historyPointer); EditSession editSession = history.get(historyPointer);
EditSession newEditSession = EditSession newEditSession =
new EditSession(editSession.getWorld(), -1, newBlockBag); new EditSession(editSession.getWorld(), -1, newBlockBag);
newEditSession.enableQueue(); newEditSession.enableQueue();
newEditSession.setFastMode(fastMode); newEditSession.setFastMode(fastMode);
editSession.redo(newEditSession); editSession.redo(newEditSession);
@ -465,7 +464,7 @@ public class LocalSession {
setTool(item, tool); setTool(item, tool);
} }
return (BrushTool)tool; return (BrushTool) tool;
} }
/** /**

Datei anzeigen

@ -35,7 +35,7 @@ public abstract class LocalWorld {
* Random generator. * Random generator.
*/ */
protected Random random = new Random(); protected Random random = new Random();
/** /**
* Get the name of the world. * Get the name of the world.
* *
@ -129,7 +129,7 @@ public abstract class LocalWorld {
* @return * @return
*/ */
public abstract int getBlockLightLevel(Vector pt); public abstract int getBlockLightLevel(Vector pt);
/** /**
* Regenerate an area. * Regenerate an area.
* *
@ -248,10 +248,16 @@ public abstract class LocalWorld {
*/ */
public void simulateBlockMine(Vector pt) { public void simulateBlockMine(Vector pt) {
BaseItemStack stack = BlockType.getBlockDrop(getBlockType(pt), (short) getBlockData(pt)); BaseItemStack stack = BlockType.getBlockDrop(getBlockType(pt), (short) getBlockData(pt));
if (stack != null) dropItem(pt, if (stack == null) {
stack.getAmount() > 1 ? new BaseItemStack(stack.getType(), return;
1, stack.getDamage()) : stack, stack.getAmount()); }
final int amount = stack.getAmount();
if (amount > 1) {
dropItem(pt, new BaseItemStack(stack.getType(), 1, stack.getDamage()), amount);
} else {
dropItem(pt, stack, amount);
}
} }
/** /**
@ -282,7 +288,7 @@ public abstract class LocalWorld {
* @return * @return
*/ */
public abstract int removeEntities(EntityType type, Vector origin, int radius); public abstract int removeEntities(EntityType type, Vector origin, int radius);
/** /**
* Returns whether a block has a valid ID. * Returns whether a block has a valid ID.
* *
@ -298,7 +304,8 @@ public abstract class LocalWorld {
* *
* @param pt Position to check * @param pt Position to check
*/ */
public void checkLoadedChunk(Vector pt) {} public void checkLoadedChunk(Vector pt) {
}
/** /**
* Compare if the other world is equal. * Compare if the other world is equal.
@ -331,7 +338,9 @@ public abstract class LocalWorld {
* *
* @param chunks the chunks to fix * @param chunks the chunks to fix
*/ */
public void fixAfterFastMode(Iterable<BlockVector2D> chunks) {} public void fixAfterFastMode(Iterable<BlockVector2D> chunks) {
}
public void fixLighting(Iterable<BlockVector2D> chunks) {} public void fixLighting(Iterable<BlockVector2D> chunks) {
}
} }

Datei anzeigen

@ -33,27 +33,27 @@ public enum PlayerDirection {
NORTH_WEST((new Vector(-1, 0, 1)).normalize(), (new Vector(1, 0, 1)).normalize(), false), NORTH_WEST((new Vector(-1, 0, 1)).normalize(), (new Vector(1, 0, 1)).normalize(), false),
UP(new Vector(0, 1, 0), new Vector(0, 0, 1), true), UP(new Vector(0, 1, 0), new Vector(0, 0, 1), true),
DOWN(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 dir;
private Vector leftDir; private Vector leftDir;
private boolean isOrthogonal; private boolean isOrthogonal;
PlayerDirection(Vector vec, Vector leftDir, boolean isOrthogonal) { PlayerDirection(Vector vec, Vector leftDir, boolean isOrthogonal) {
this.dir = vec; this.dir = vec;
this.leftDir = leftDir; this.leftDir = leftDir;
this.isOrthogonal = isOrthogonal; this.isOrthogonal = isOrthogonal;
} }
public Vector vector() { public Vector vector() {
return dir; return dir;
} }
@Deprecated @Deprecated
public Vector leftVector() { public Vector leftVector() {
return leftDir; return leftDir;
} }
public boolean isOrthogonal() { public boolean isOrthogonal() {
return isOrthogonal; return isOrthogonal;
} }
} }

Datei anzeigen

@ -25,7 +25,7 @@ package com.sk89q.worldedit;
* @author sk89q * @author sk89q
*/ */
public interface SessionCheck { public interface SessionCheck {
/** /**
* Checks if a player is online. * Checks if a player is online.
* *
@ -33,5 +33,5 @@ public interface SessionCheck {
* @return * @return
*/ */
public boolean isOnlinePlayer(String name); public boolean isOnlinePlayer(String name);
} }

Datei anzeigen

@ -47,9 +47,9 @@ public class Vector {
* @param z * @param z
*/ */
public Vector(int x, int y, int z) { public Vector(int x, int y, int z) {
this.x = (double)x; this.x = (double) x;
this.y = (double)y; this.y = (double) y;
this.z = (double)z; this.z = (double) z;
} }
/** /**
@ -60,9 +60,9 @@ public class Vector {
* @param z * @param z
*/ */
public Vector(float x, float y, float z) { public Vector(float x, float y, float z) {
this.x = (double)x; this.x = (double) x;
this.y = (double)y; this.y = (double) y;
this.z = (double)z; this.z = (double) z;
} }
/** /**
@ -96,7 +96,7 @@ public class Vector {
* @return the x * @return the x
*/ */
public int getBlockX() { public int getBlockX() {
return (int)Math.round(x); return (int) Math.round(x);
} }
/** /**
@ -130,7 +130,7 @@ public class Vector {
* @return the y * @return the y
*/ */
public int getBlockY() { public int getBlockY() {
return (int)Math.round(y); return (int) Math.round(y);
} }
/** /**
@ -164,7 +164,7 @@ public class Vector {
* @return the z * @return the z
*/ */
public int getBlockZ() { public int getBlockZ() {
return (int)Math.round(z); return (int) Math.round(z);
} }
/** /**
@ -227,7 +227,7 @@ public class Vector {
* @param others * @param others
* @return New point * @return New point
*/ */
public Vector add(Vector ... others) { public Vector add(Vector... others) {
double newX = x, newY = y, newZ = z; double newX = x, newY = y, newZ = z;
for (int i = 0; i < others.length; ++i) { for (int i = 0; i < others.length; ++i) {
@ -278,7 +278,7 @@ public class Vector {
* @param others * @param others
* @return New point * @return New point
*/ */
public Vector subtract(Vector ... others) { public Vector subtract(Vector... others) {
double newX = x, newY = y, newZ = z; double newX = x, newY = y, newZ = z;
for (int i = 0; i < others.length; ++i) { for (int i = 0; i < others.length; ++i) {
@ -329,7 +329,7 @@ public class Vector {
* @param others * @param others
* @return New point * @return New point
*/ */
public Vector multiply(Vector ... others) { public Vector multiply(Vector... others) {
double newX = x, newY = y, newZ = z; double newX = x, newY = y, newZ = z;
for (int i = 0; i < others.length; ++i) { for (int i = 0; i < others.length; ++i) {
@ -546,9 +546,9 @@ public class Vector {
* @return point * @return point
*/ */
public static Vector toBlockPoint(double x, double y, double z) { public static Vector toBlockPoint(double x, double y, double z) {
return new Vector((int)Math.floor(x), return new Vector((int) Math.floor(x),
(int)Math.floor(y), (int) Math.floor(y),
(int)Math.floor(z)); (int) Math.floor(z));
} }
/** /**
@ -557,9 +557,9 @@ public class Vector {
* @return point * @return point
*/ */
public BlockVector toBlockPoint() { public BlockVector toBlockPoint() {
return new BlockVector((int)Math.floor(x), return new BlockVector((int) Math.floor(x),
(int)Math.floor(y), (int) Math.floor(y),
(int)Math.floor(z)); (int) Math.floor(z));
} }
/** /**

Datei anzeigen

@ -44,8 +44,8 @@ public class Vector2D {
* @param z * @param z
*/ */
public Vector2D(int x, int z) { public Vector2D(int x, int z) {
this.x = (double)x; this.x = (double) x;
this.z = (double)z; this.z = (double) z;
} }
/** /**
@ -55,8 +55,8 @@ public class Vector2D {
* @param z * @param z
*/ */
public Vector2D(float x, float z) { public Vector2D(float x, float z) {
this.x = (double)x; this.x = (double) x;
this.z = (double)z; this.z = (double) z;
} }
/** /**

Datei anzeigen

@ -53,27 +53,27 @@ public class WorldEdit {
* Logger for debugging. * Logger for debugging.
*/ */
public static final Logger logger = Logger.getLogger("Minecraft.WorldEdit"); public static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
/** /**
* Holds WorldEdit's version. * Holds WorldEdit's version.
*/ */
private static String version; private static String version;
/** /**
* Interface to the server. * Interface to the server.
*/ */
private ServerInterface server; private ServerInterface server;
/** /**
* Configuration. This is a subclass. * Configuration. This is a subclass.
*/ */
private LocalConfiguration config; private LocalConfiguration config;
/** /**
* List of commands. * List of commands.
*/ */
private CommandsManager<LocalPlayer> commands; private CommandsManager<LocalPlayer> commands;
/** /**
* Stores a list of WorldEdit sessions, keyed by players' names. Sessions * Stores a list of WorldEdit sessions, keyed by players' names. Sessions
* persist only for the user's session. On disconnect, the session will be * persist only for the user's session. On disconnect, the session will be
@ -81,15 +81,15 @@ public class WorldEdit {
* without any WorldEdit abilities or never use WorldEdit in a session will * without any WorldEdit abilities or never use WorldEdit in a session will
* not have a session object generated for them. * not have a session object generated for them.
*/ */
private HashMap<String,LocalSession> sessions = new HashMap<String,LocalSession>(); private HashMap<String, LocalSession> sessions = new HashMap<String, LocalSession>();
/** /**
* Initialize statically. * Initialize statically.
*/ */
static { static {
getVersion(); getVersion();
} }
/** /**
* Construct an instance of the plugin * Construct an instance of the plugin
* *
@ -99,13 +99,13 @@ public class WorldEdit {
public WorldEdit(ServerInterface server, final LocalConfiguration config) { public WorldEdit(ServerInterface server, final LocalConfiguration config) {
this.server = server; this.server = server;
this.config = config; this.config = config;
commands = new CommandsManager<LocalPlayer>() { commands = new CommandsManager<LocalPlayer>() {
@Override @Override
public boolean hasPermission(LocalPlayer player, String perm) { public boolean hasPermission(LocalPlayer player, String perm) {
return player.hasPermission(perm); return player.hasPermission(perm);
} }
@Override @Override
public void invokeMethod(Method parent, String[] args, public void invokeMethod(Method parent, String[] args,
LocalPlayer player, Method method, Object instance, LocalPlayer player, Method method, Object instance,
@ -135,20 +135,20 @@ public class WorldEdit {
/* FALL-THROUGH */ /* FALL-THROUGH */
case POSITION: case POSITION:
msg += " - Position: "+position; msg += " - Position: " + position;
break; break;
case ALL: case ALL:
msg += " - Position: "+position; msg += " - Position: " + position;
/* FALL-THROUGH */ /* FALL-THROUGH */
case ORIENTATION_REGION: case ORIENTATION_REGION:
msg += " - Orientation: "+player.getCardinalDirection().name(); msg += " - Orientation: " + player.getCardinalDirection().name();
/* FALL-THROUGH */ /* FALL-THROUGH */
case REGION: case REGION:
try { try {
msg += " - Region: "+session.getSelection(player.getWorld()); msg += " - Region: " + session.getSelection(player.getWorld());
} catch (IncompleteRegionException e) { } catch (IncompleteRegionException e) {
break; break;
} }
@ -194,20 +194,20 @@ public class WorldEdit {
*/ */
public LocalSession getSession(LocalPlayer player) { public LocalSession getSession(LocalPlayer player) {
LocalSession session; LocalSession session;
synchronized (sessions) { synchronized (sessions) {
if (sessions.containsKey(player.getName())) { if (sessions.containsKey(player.getName())) {
return sessions.get(player.getName()); return sessions.get(player.getName());
} }
session = new LocalSession(config); session = new LocalSession(config);
// Set the limit on the number of blocks that an operation can // Set the limit on the number of blocks that an operation can
// change at once, or don't if the player has an override or there // change at once, or don't if the player has an override or there
// is no limit. There is also a default limit // is no limit. There is also a default limit
if (!player.hasPermission("worldedit.limit.unrestricted") if (!player.hasPermission("worldedit.limit.unrestricted")
&& config.maxChangeLimit > -1) { && config.maxChangeLimit > -1) {
// If the default limit is infinite but there is a maximum // If the default limit is infinite but there is a maximum
// limit, make sure to not have it be overridden // limit, make sure to not have it be overridden
if (config.defaultChangeLimit < 0) { if (config.defaultChangeLimit < 0) {
@ -222,17 +222,17 @@ public class WorldEdit {
// No change limit or override // No change limit or override
session.setBlockChangeLimit(config.defaultChangeLimit); session.setBlockChangeLimit(config.defaultChangeLimit);
} }
// Have the session use inventory if it's enabled and the player // Have the session use inventory if it's enabled and the player
// doesn't have an override // doesn't have an override
session.setUseInventory(config.useInventory session.setUseInventory(config.useInventory
&& (!config.useInventoryOverride && (!config.useInventoryOverride
|| !player.hasPermission("worldedit.inventory.unrestricted"))); || !player.hasPermission("worldedit.inventory.unrestricted")));
// Remember the session // Remember the session
sessions.put(player.getName(), session); sessions.put(player.getName(), session);
} }
return session; return session;
} }
@ -274,7 +274,7 @@ public class WorldEdit {
String[] typeAndData = blockAndExtraData[0].split(":", 2); String[] typeAndData = blockAndExtraData[0].split(":", 2);
String testID = typeAndData[0]; String testID = typeAndData[0];
int blockId = -1; int blockId = -1;
int data = -1; int data = -1;
// Attempt to parse the item ID or otherwise resolve an item/block // Attempt to parse the item ID or otherwise resolve an item/block
@ -295,7 +295,7 @@ public class WorldEdit {
if (blockId == -1 && blockType == null) { if (blockId == -1 && blockType == null) {
// Maybe it's a cloth // Maybe it's a cloth
ClothColor col = ClothColor.lookup(testID); ClothColor col = ClothColor.lookup(testID);
if (col != null) { if (col != null) {
blockType = BlockType.CLOTH; blockType = BlockType.CLOTH;
data = col.getID(); data = col.getID();
@ -303,16 +303,16 @@ public class WorldEdit {
throw new UnknownItemException(arg); throw new UnknownItemException(arg);
} }
} }
// Read block ID // Read block ID
if (blockId == -1) { if (blockId == -1) {
blockId = blockType.getID(); blockId = blockType.getID();
} }
if (!player.getWorld().isValidBlockType(blockId)) { if (!player.getWorld().isValidBlockType(blockId)) {
throw new UnknownItemException(arg); throw new UnknownItemException(arg);
} }
if (data == -1) { // Block data not yet detected if (data == -1) { // Block data not yet detected
// Parse the block data (optional) // Parse the block data (optional)
try { try {
@ -324,7 +324,7 @@ public class WorldEdit {
switch (blockType) { switch (blockType) {
case CLOTH: case CLOTH:
ClothColor col = ClothColor.lookup(typeAndData[1]); ClothColor col = ClothColor.lookup(typeAndData[1]);
if (col != null) { if (col != null) {
data = col.getID(); data = col.getID();
} else { } else {
@ -335,7 +335,7 @@ public class WorldEdit {
case STEP: case STEP:
case DOUBLE_STEP: case DOUBLE_STEP:
BlockType dataType = BlockType.lookup(typeAndData[1]); BlockType dataType = BlockType.lookup(typeAndData[1]);
if (dataType != null) { if (dataType != null) {
switch (dataType) { switch (dataType) {
case STONE: case STONE:
@ -374,25 +374,24 @@ public class WorldEdit {
} }
// Check if the item is allowed // Check if the item is allowed
if (allAllowed || player.hasPermission("worldedit.anyblock") if (allAllowed || player.hasPermission("worldedit.anyblock") || !config.disallowedBlocks.contains(blockId)) {
|| !config.disallowedBlocks.contains(blockId)) { switch (blockType) {
case SIGN_POST:
// Allow special sign text syntax case WALL_SIGN:
if (blockType == BlockType.SIGN_POST // Allow special sign text syntax
|| blockType == BlockType.WALL_SIGN) {
String[] text = new String[4]; String[] text = new String[4];
text[0] = blockAndExtraData.length > 1 ? blockAndExtraData[1] : ""; text[0] = blockAndExtraData.length > 1 ? blockAndExtraData[1] : "";
text[1] = blockAndExtraData.length > 2 ? blockAndExtraData[2] : ""; text[1] = blockAndExtraData.length > 2 ? blockAndExtraData[2] : "";
text[2] = blockAndExtraData.length > 3 ? blockAndExtraData[3] : ""; text[2] = blockAndExtraData.length > 3 ? blockAndExtraData[3] : "";
text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : ""; text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : "";
return new SignBlock(blockType.getID(), data, text); return new SignBlock(blockType.getID(), data, text);
// Allow setting mob spawn type case MOB_SPAWNER:
} else if (blockType == BlockType.MOB_SPAWNER) { // Allow setting mob spawn type
if (blockAndExtraData.length > 1) { if (blockAndExtraData.length > 1) {
String mobName = blockAndExtraData[1]; String mobName = blockAndExtraData[1];
for (MobType mobType : MobType.values()){ for (MobType mobType : MobType.values()) {
if (mobType.getName().toLowerCase().equals(mobName.toLowerCase())){ if (mobType.getName().toLowerCase().equals(mobName.toLowerCase())) {
mobName = mobType.getName(); mobName = mobType.getName();
break; break;
} }
@ -404,9 +403,9 @@ public class WorldEdit {
} else { } else {
return new MobSpawnerBlock(data, MobType.PIG.getName()); return new MobSpawnerBlock(data, MobType.PIG.getName());
} }
// Allow setting note case NOTE_BLOCK:
} else if (blockType == BlockType.NOTE_BLOCK) { // Allow setting note
if (blockAndExtraData.length > 1) { if (blockAndExtraData.length > 1) {
byte note = Byte.parseByte(blockAndExtraData[1]); byte note = Byte.parseByte(blockAndExtraData[1]);
if (note < 0 || note > 24) { if (note < 0 || note > 24) {
@ -415,11 +414,12 @@ public class WorldEdit {
return new NoteBlock(data, note); return new NoteBlock(data, note);
} }
} else { } else {
return new NoteBlock(data, (byte)0); return new NoteBlock(data, (byte) 0);
} }
}
return new BaseBlock(blockId, data); default:
return new BaseBlock(blockId, data);
}
} }
throw new DisallowedItemException(arg); throw new DisallowedItemException(arg);
@ -439,7 +439,7 @@ public class WorldEdit {
return getBlock(player, id, false); return getBlock(player, id, false);
} }
public Set<BaseBlock> getBlocks (LocalPlayer player, String list, boolean allAllowed, boolean allowNoData) public Set<BaseBlock> getBlocks(LocalPlayer player, String list, boolean allAllowed, boolean allowNoData)
throws DisallowedItemException, UnknownItemException { throws DisallowedItemException, UnknownItemException {
String[] items = list.split(","); String[] items = list.split(",");
Set<BaseBlock> blocks = new HashSet<BaseBlock>(); Set<BaseBlock> blocks = new HashSet<BaseBlock>();
@ -473,20 +473,20 @@ public class WorldEdit {
throws UnknownItemException, DisallowedItemException { throws UnknownItemException, DisallowedItemException {
String[] items = patternString.split(","); String[] items = patternString.split(",");
// Handle special block pattern types // Handle special block pattern types
if (patternString.charAt(0) == '#') { if (patternString.charAt(0) == '#') {
if (patternString.equals("#clipboard") || patternString.equals("#copy")) { if (patternString.equals("#clipboard") || patternString.equals("#copy")) {
LocalSession session = getSession(player); LocalSession session = getSession(player);
CuboidClipboard clipboard; CuboidClipboard clipboard;
try { try {
clipboard = session.getClipboard(); clipboard = session.getClipboard();
} catch (EmptyClipboardException e) { } catch (EmptyClipboardException e) {
player.printError("Copy a selection first with //copy."); player.printError("Copy a selection first with //copy.");
throw new UnknownItemException("#clipboard"); throw new UnknownItemException("#clipboard");
} }
return new ClipboardPattern(clipboard); return new ClipboardPattern(clipboard);
} else { } else {
throw new UnknownItemException(patternString); throw new UnknownItemException(patternString);
@ -502,9 +502,9 @@ public class WorldEdit {
for (String s : items) { for (String s : items) {
BaseBlock block; BaseBlock block;
double chance; double chance;
// Parse special percentage syntax // Parse special percentage syntax
if (s.matches("[0-9]+(?:\\.(?:[0-9]+)?)?%.*")) { if (s.matches("[0-9]+(?:\\.(?:[0-9]+)?)?%.*")) {
String[] p = s.split("%"); String[] p = s.split("%");
@ -514,22 +514,22 @@ public class WorldEdit {
chance = 1; chance = 1;
block = getBlock(player, s); block = getBlock(player, s);
} }
blockChances.add(new BlockChance(block, chance)); blockChances.add(new BlockChance(block, chance));
} }
return new RandomFillPattern(blockChances); return new RandomFillPattern(blockChances);
} }
/** /**
* Get a block mask. Block masks are used to determine which * Get a block mask. Block masks are used to determine which
* blocks to include when replacing. * blocks to include when replacing.
* *
* @param player * @param player
* @param session * @param session
* @param maskString * @param maskString
* @return * @return
* @throws WorldEditException * @throws WorldEditException
*/ */
public Mask getBlockMask(LocalPlayer player, LocalSession session, public Mask getBlockMask(LocalPlayer player, LocalSession session,
String maskString) throws WorldEditException { String maskString) throws WorldEditException {
@ -622,7 +622,7 @@ public class WorldEdit {
public Set<Integer> getBlockIDs(LocalPlayer player, public Set<Integer> getBlockIDs(LocalPlayer player,
String list, boolean allBlocksAllowed) String list, boolean allBlocksAllowed)
throws UnknownItemException, DisallowedItemException { throws UnknownItemException, DisallowedItemException {
String[] items = list.split(","); String[] items = list.split(",");
Set<Integer> blocks = new HashSet<Integer>(); Set<Integer> blocks = new HashSet<Integer>();
for (String s : items) { for (String s : items) {
@ -630,7 +630,7 @@ public class WorldEdit {
} }
return blocks; return blocks;
} }
/** /**
* Gets the path to a file. This method will check to see if the filename * 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 * has valid characters and has an extension. It also prevents directory
@ -650,7 +650,7 @@ public class WorldEdit {
throws FilenameException { throws FilenameException {
return getSafeFile(player, dir, filename, defaultExt, extensions, true); return getSafeFile(player, dir, filename, defaultExt, extensions, true);
} }
/** /**
* Gets the path to a file. This method will check to see if the filename * 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 * has valid characters and has an extension. It also prevents directory
@ -670,7 +670,7 @@ public class WorldEdit {
throws FilenameException { throws FilenameException {
return getSafeFile(player, dir, filename, defaultExt, extensions, false); return getSafeFile(player, dir, filename, defaultExt, extensions, false);
} }
/** /**
* Get a safe path to a file. * Get a safe path to a file.
* *
@ -687,14 +687,14 @@ public class WorldEdit {
String defaultExt, String[] extensions, boolean isSave) String defaultExt, String[] extensions, boolean isSave)
throws FilenameException { throws FilenameException {
File f; File f;
if (filename.equals("#")) { if (filename.equals("#")) {
if (isSave) { if (isSave) {
f = player.openFileSaveDialog(extensions); f = player.openFileSaveDialog(extensions);
} else { } else {
f = player.openFileOpenDialog(extensions); f = player.openFileOpenDialog(extensions);
} }
if (f == null) { if (f == null) {
throw new FileSelectionAbortedException("No file selected"); throw new FileSelectionAbortedException("No file selected");
} }
@ -702,11 +702,11 @@ public class WorldEdit {
if (defaultExt != null && filename.lastIndexOf('.') == -1) { if (defaultExt != null && filename.lastIndexOf('.') == -1) {
filename += "." + defaultExt; filename += "." + defaultExt;
} }
if (!filename.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+\\.[A-Za-z0-9]+$")) { if (!filename.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+\\.[A-Za-z0-9]+$")) {
throw new InvalidFilenameException(filename, "Invalid characters or extension missing"); throw new InvalidFilenameException(filename, "Invalid characters or extension missing");
} }
f = new File(dir, filename); f = new File(dir, filename);
} }
@ -718,7 +718,7 @@ public class WorldEdit {
throw new FilenameResolutionException(filename, throw new FilenameResolutionException(filename,
"Path is outside allowable root"); "Path is outside allowable root");
} }
return f; return f;
} catch (IOException e) { } catch (IOException e) {
throw new FilenameResolutionException(filename, throw new FilenameResolutionException(filename,
@ -737,7 +737,7 @@ public class WorldEdit {
throw new MaxRadiusException(); throw new MaxRadiusException();
} }
} }
/** /**
* Get a file relative to the defined working directory. If the specified * Get a file relative to the defined working directory. If the specified
* path is absolute, then the working directory is not used. * path is absolute, then the working directory is not used.
@ -793,7 +793,7 @@ public class WorldEdit {
default: default:
throw new UnknownDirectionException(dir.name()); throw new UnknownDirectionException(dir.name());
} }
} }
private PlayerDirection getPlayerDirection(LocalPlayer player, String dirStr) throws UnknownDirectionException { private PlayerDirection getPlayerDirection(LocalPlayer player, String dirStr) throws UnknownDirectionException {
final PlayerDirection dir; final PlayerDirection dir;
@ -859,7 +859,7 @@ public class WorldEdit {
} }
return dir; return dir;
} }
/** /**
* Get diagonal direction vector for a player's direction. May return * Get diagonal direction vector for a player's direction. May return
* null if a direction could not be found. * null if a direction could not be found.
@ -870,7 +870,7 @@ public class WorldEdit {
* @throws UnknownDirectionException * @throws UnknownDirectionException
*/ */
public Vector getDiagonalDirection(LocalPlayer player, String dirStr) public Vector getDiagonalDirection(LocalPlayer player, String dirStr)
throws UnknownDirectionException { throws UnknownDirectionException {
return getPlayerDirection(player, dirStr.toLowerCase()).vector(); return getPlayerDirection(player, dirStr.toLowerCase()).vector();
} }
@ -924,7 +924,7 @@ public class WorldEdit {
sessions.clear(); sessions.clear();
} }
} }
/** /**
* Flush a block bag's changes to a player. * Flush a block bag's changes to a player.
* *
@ -933,35 +933,35 @@ public class WorldEdit {
*/ */
public void flushBlockBag(LocalPlayer player, public void flushBlockBag(LocalPlayer player,
EditSession editSession) { EditSession editSession) {
BlockBag blockBag = editSession.getBlockBag(); BlockBag blockBag = editSession.getBlockBag();
if (blockBag != null) { if (blockBag != null) {
blockBag.flushChanges(); blockBag.flushChanges();
} }
Set<Integer> missingBlocks = editSession.popMissingBlocks(); Set<Integer> missingBlocks = editSession.popMissingBlocks();
if (missingBlocks.size() > 0) { if (missingBlocks.size() > 0) {
StringBuilder str = new StringBuilder(); StringBuilder str = new StringBuilder();
str.append("Missing these blocks: "); str.append("Missing these blocks: ");
int size = missingBlocks.size(); int size = missingBlocks.size();
int i = 0; int i = 0;
for (Integer id : missingBlocks) { for (Integer id : missingBlocks) {
BlockType type = BlockType.fromID(id); BlockType type = BlockType.fromID(id);
str.append(type != null str.append(type != null
? type.getName() + " (" + id + ")" ? type.getName() + " (" + id + ")"
: id.toString()); : id.toString());
++i; ++i;
if (i != size) { if (i != size) {
str.append(", "); str.append(", ");
} }
} }
player.printError(str.toString()); player.printError(str.toString());
} }
} }
@ -972,7 +972,7 @@ public class WorldEdit {
public Map<String, String> getCommands() { public Map<String, String> getCommands() {
return commands.getCommands(); return commands.getCommands();
} }
/** /**
* *
* @param player * @param player
@ -981,7 +981,7 @@ public class WorldEdit {
public void handleDisconnect(LocalPlayer player) { public void handleDisconnect(LocalPlayer player) {
forgetPlayer(player); forgetPlayer(player);
} }
/** /**
* *
* @param player * @param player
@ -994,7 +994,7 @@ public class WorldEdit {
} }
} }
} }
/** /**
* Forget a player. * Forget a player.
* *
@ -1003,14 +1003,14 @@ public class WorldEdit {
public void forgetPlayer(LocalPlayer player) { public void forgetPlayer(LocalPlayer player) {
removeSession(player); removeSession(player);
} }
/* /*
* Flush expired sessions. * Flush expired sessions.
*/ */
public void flushExpiredSessions(SessionCheck checker) { public void flushExpiredSessions(SessionCheck checker) {
synchronized (sessions) { synchronized (sessions) {
Iterator<Map.Entry<String, LocalSession>> it = sessions.entrySet().iterator(); Iterator<Map.Entry<String, LocalSession>> it = sessions.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry<String, LocalSession> entry = it.next(); Map.Entry<String, LocalSession> entry = it.next();
if (entry.getValue().hasExpired() if (entry.getValue().hasExpired()
@ -1127,7 +1127,7 @@ public class WorldEdit {
Tool tool = session.getTool(player.getItemInHand()); Tool tool = session.getTool(player.getItemInHand());
if (tool != null && tool instanceof BlockTool) { if (tool != null && tool instanceof BlockTool) {
if (tool.canUse(player)) { if (tool.canUse(player)) {
((BlockTool)tool).actPrimary(server, config, player, session, clicked); ((BlockTool) tool).actPrimary(server, config, player, session, clicked);
return true; return true;
} }
} }
@ -1172,7 +1172,7 @@ public class WorldEdit {
Tool tool = session.getTool(player.getItemInHand()); Tool tool = session.getTool(player.getItemInHand());
if (tool != null && tool instanceof DoubleActionBlockTool) { if (tool != null && tool instanceof DoubleActionBlockTool) {
if (tool.canUse(player)) { if (tool.canUse(player)) {
((DoubleActionBlockTool)tool).actSecondary(server, config, player, session, clicked); ((DoubleActionBlockTool) tool).actSecondary(server, config, player, session, clicked);
return true; return true;
} }
} }
@ -1191,7 +1191,7 @@ public class WorldEdit {
public boolean handleCommand(LocalPlayer player, String[] split) { public boolean handleCommand(LocalPlayer player, String[] split) {
try { try {
split[0] = split[0].substring(1); split[0] = split[0].substring(1);
// Quick script shortcut // Quick script shortcut
if (split[0].matches("^[^/].*\\.js$")) { if (split[0].matches("^[^/].*\\.js$")) {
String[] newSplit = new String[split.length + 1]; String[] newSplit = new String[split.length + 1];
@ -1200,9 +1200,9 @@ public class WorldEdit {
newSplit[1] = newSplit[1]; newSplit[1] = newSplit[1];
split = newSplit; split = newSplit;
} }
String searchCmd = split[0].toLowerCase(); String searchCmd = split[0].toLowerCase();
// Try to detect the command // Try to detect the command
if (commands.hasCommand(searchCmd)) { if (commands.hasCommand(searchCmd)) {
} else if (config.noDoubleSlash && commands.hasCommand("/" + searchCmd)) { } else if (config.noDoubleSlash && commands.hasCommand("/" + searchCmd)) {
@ -1211,12 +1211,12 @@ public class WorldEdit {
&& commands.hasCommand(searchCmd.substring(1))) { && commands.hasCommand(searchCmd.substring(1))) {
split[0] = split[0].substring(1); split[0] = split[0].substring(1);
} }
// No command found! // No command found!
if (!commands.hasCommand(split[0])) { if (!commands.hasCommand(split[0])) {
return false; return false;
} }
LocalSession session = getSession(player); LocalSession session = getSession(player);
EditSession editSession = session.createEditSession(player); EditSession editSession = session.createEditSession(player);
editSession.enableQueue(); editSession.enableQueue();
@ -1254,14 +1254,14 @@ public class WorldEdit {
player.printDebug((time / 1000.0) + "s elapsed."); player.printDebug((time / 1000.0) + "s elapsed.");
} }
} }
flushBlockBag(player, editSession); flushBlockBag(player, editSession);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
final Matcher matcher = numberFormatExceptionPattern.matcher(e.getMessage()); final Matcher matcher = numberFormatExceptionPattern.matcher(e.getMessage());
if (matcher.matches()) { if (matcher.matches()) {
player.printError("Number expected; string \""+matcher.group(1)+"\" given."); player.printError("Number expected; string \"" + matcher.group(1) + "\" given.");
} else { } else {
player.printError("Number expected; string given."); player.printError("Number expected; string given.");
} }
@ -1305,7 +1305,7 @@ public class WorldEdit {
return true; return true;
} }
/** /**
* Executes a WorldEdit script. * Executes a WorldEdit script.
* *
@ -1316,24 +1316,24 @@ public class WorldEdit {
*/ */
public void runScript(LocalPlayer player, File f, String[] args) public void runScript(LocalPlayer player, File f, String[] args)
throws WorldEditException { throws WorldEditException {
String filename = f.getPath(); String filename = f.getPath();
int index = filename.lastIndexOf("."); int index = filename.lastIndexOf(".");
String ext = filename.substring(index + 1, filename.length()); String ext = filename.substring(index + 1, filename.length());
if (!ext.equalsIgnoreCase("js")) { if (!ext.equalsIgnoreCase("js")) {
player.printError("Only .js scripts are currently supported"); player.printError("Only .js scripts are currently supported");
return; return;
} }
String script; String script;
try { try {
InputStream file; InputStream file;
if (!f.exists()) { if (!f.exists()) {
file = WorldEdit.class.getResourceAsStream( file = WorldEdit.class.getResourceAsStream(
"craftscripts/" + filename); "craftscripts/" + filename);
if (file == null) { if (file == null) {
player.printError("Script does not exist: " + filename); player.printError("Script does not exist: " + filename);
return; return;
@ -1341,7 +1341,7 @@ public class WorldEdit {
} else { } else {
file = new FileInputStream(f); file = new FileInputStream(f);
} }
DataInputStream in = new DataInputStream(file); DataInputStream in = new DataInputStream(file);
byte[] data = new byte[in.available()]; byte[] data = new byte[in.available()];
in.readFully(data); in.readFully(data);
@ -1351,11 +1351,11 @@ public class WorldEdit {
player.printError("Script read error: " + e.getMessage()); player.printError("Script read error: " + e.getMessage());
return; return;
} }
LocalSession session = getSession(player); LocalSession session = getSession(player);
CraftScriptContext scriptContext = CraftScriptContext scriptContext =
new CraftScriptContext(this, server, config, session, player, args); new CraftScriptContext(this, server, config, session, player, args);
CraftScriptEngine engine = null; CraftScriptEngine engine = null;
try { try {
@ -1365,18 +1365,18 @@ public class WorldEdit {
player.printError("Please see http://wiki.sk89q.com/wiki/WorldEdit/Installation"); player.printError("Please see http://wiki.sk89q.com/wiki/WorldEdit/Installation");
return; return;
} }
engine.setTimeLimit(config.scriptTimeout); engine.setTimeLimit(config.scriptTimeout);
Map<String, Object> vars = new HashMap<String, Object>(); Map<String, Object> vars = new HashMap<String, Object>();
vars.put("argv", args); vars.put("argv", args);
vars.put("context", scriptContext); vars.put("context", scriptContext);
vars.put("player", player); vars.put("player", player);
try { try {
engine.evaluate(script, filename, vars); engine.evaluate(script, filename, vars);
} catch (ScriptException e) { } catch (ScriptException e) {
player.printError("Failed to execute:");; player.printError("Failed to execute:");
player.printRaw(e.getMessage()); player.printRaw(e.getMessage());
e.printStackTrace(); e.printStackTrace();
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
@ -1394,7 +1394,7 @@ public class WorldEdit {
} }
} }
} }
/** /**
* Get Worldedit's configuration. * Get Worldedit's configuration.
* *
@ -1403,7 +1403,7 @@ public class WorldEdit {
public LocalConfiguration getConfiguration() { public LocalConfiguration getConfiguration() {
return config; return config;
} }
/** /**
* Get the server interface. * Get the server interface.
* *
@ -1422,18 +1422,18 @@ public class WorldEdit {
if (version != null) { if (version != null) {
return version; return version;
} }
Package p = WorldEdit.class.getPackage(); Package p = WorldEdit.class.getPackage();
if (p == null) { if (p == null) {
p = Package.getPackage("com.sk89q.worldedit"); p = Package.getPackage("com.sk89q.worldedit");
} }
if (p == null) { if (p == null) {
version = "(unknown)"; version = "(unknown)";
} else { } else {
version = p.getImplementationVersion(); version = p.getImplementationVersion();
if (version == null) { if (version == null) {
version = "(unknown)"; version = "(unknown)";
} }

Datei anzeigen

@ -28,7 +28,7 @@ public class WorldVector extends Vector {
/** /**
* Represents the world. * Represents the world.
*/ */
private LocalWorld world; private LocalWorld world;
/** /**
* Construct the Vector object. * Construct the Vector object.
@ -89,7 +89,7 @@ public class WorldVector extends Vector {
super(); super();
this.world = world; this.world = world;
} }
/** /**
* Get the world. * Get the world.
* *
@ -110,9 +110,9 @@ public class WorldVector extends Vector {
*/ */
public static WorldVector toBlockPoint(LocalWorld world, double x, double y, public static WorldVector toBlockPoint(LocalWorld world, double x, double y,
double z) { double z) {
return new WorldVector(world, (int)Math.floor(x), return new WorldVector(world, (int) Math.floor(x),
(int)Math.floor(y), (int) Math.floor(y),
(int)Math.floor(z)); (int) Math.floor(z));
} }
/** /**

Datei anzeigen

@ -80,7 +80,7 @@ public class WorldVector2D extends Vector2D {
@Override @Override
public int hashCode() { public int hashCode() {
return (world.hashCode() >> 7) ^ return (world.hashCode() >> 7) ^
((int)(Double.doubleToLongBits(x)^(Double.doubleToLongBits(x)>>>32)) >> 13) ^ ((int) (Double.doubleToLongBits(x) ^ (Double.doubleToLongBits(x) >>> 32)) >> 13) ^
(int)(Double.doubleToLongBits(z)^(Double.doubleToLongBits(z)>>>32)); (int) (Double.doubleToLongBits(z) ^ (Double.doubleToLongBits(z) >>> 32));
} }
} }

Datei anzeigen

@ -40,7 +40,7 @@ public abstract class BlockBag {
public void storeDroppedBlock(int id) throws BlockBagException { public void storeDroppedBlock(int id) throws BlockBagException {
storeDroppedBlock(id, 0); storeDroppedBlock(id, 0);
} }
/** /**
* Stores a block as if it was mined. * Stores a block as if it was mined.
* *
@ -55,7 +55,7 @@ public abstract class BlockBag {
storeItem(dropped); storeItem(dropped);
} }
/** /**
* Sets a block as if it was placed by hand. * Sets a block as if it was placed by hand.
* *
@ -149,7 +149,7 @@ public abstract class BlockBag {
public void storeBlock(int id) throws BlockBagException { public void storeBlock(int id) throws BlockBagException {
storeItem(new BaseItem(id)); storeItem(new BaseItem(id));
} }
/** /**
* Store a block. * Store a block.
* *
@ -161,7 +161,7 @@ public abstract class BlockBag {
public void storeItem(BaseItem item) throws BlockBagException { public void storeItem(BaseItem item) throws BlockBagException {
storeBlock(item.getType()); storeBlock(item.getType());
} }
/** /**
* Checks to see if a block exists without removing it. * Checks to see if a block exists without removing it.
* *
@ -177,7 +177,7 @@ public abstract class BlockBag {
return false; return false;
} }
} }
/** /**
* Flush any changes. This is called at the end. * Flush any changes. This is called at the end.
*/ */
@ -189,6 +189,7 @@ public abstract class BlockBag {
* @param pos * @param pos
*/ */
public abstract void addSourcePosition(Vector pos); public abstract void addSourcePosition(Vector pos);
/** /**
* Adds a position to be used a source. * Adds a position to be used a source.
* *

Datei anzeigen

@ -25,7 +25,7 @@ package com.sk89q.worldedit.bags;
*/ */
public class OutOfSpaceException extends BlockBagException { public class OutOfSpaceException extends BlockBagException {
private static final long serialVersionUID = -2962840237632916821L; private static final long serialVersionUID = -2962840237632916821L;
/** /**
* Stores the block ID. * Stores the block ID.
*/ */

Datei anzeigen

@ -19,7 +19,6 @@
package com.sk89q.worldedit.bags; package com.sk89q.worldedit.bags;
/** /**
* *
* @author sk89q * @author sk89q

Datei anzeigen

@ -74,7 +74,7 @@ public class BaseBlock {
* @return the data * @return the data
*/ */
public int getData() { public int getData() {
return (int)data; return (int) data;
} }
/** /**
@ -130,6 +130,7 @@ public class BaseBlock {
data = (byte) BlockData.flip(type, data); data = (byte) BlockData.flip(type, data);
return this; return this;
} }
/** /**
* Flip this block. * Flip this block.
* @param direction * @param direction

Datei anzeigen

@ -61,7 +61,7 @@ public class BaseItemStack extends BaseItem {
super(id, damage); super(id, damage);
this.amount = amount; this.amount = amount;
} }
/** /**
* @return the amount * @return the amount
*/ */

Datei anzeigen

@ -721,7 +721,7 @@ public final class BlockData {
case ClothColor.ID.MAGENTA: return ClothColor.ID.PINK; case ClothColor.ID.MAGENTA: return ClothColor.ID.PINK;
case ClothColor.ID.PINK: return ClothColor.ID.WHITE; case ClothColor.ID.PINK: return ClothColor.ID.WHITE;
} }
return ClothColor.ID.WHITE; return ClothColor.ID.WHITE;
} }
@ -750,7 +750,7 @@ public final class BlockData {
case ClothColor.ID.PINK: return ClothColor.ID.MAGENTA; case ClothColor.ID.PINK: return ClothColor.ID.MAGENTA;
case ClothColor.ID.WHITE: return ClothColor.ID.PINK; case ClothColor.ID.WHITE: return ClothColor.ID.PINK;
} }
return ClothColor.ID.WHITE; return ClothColor.ID.WHITE;
} }
} }

Datei anzeigen

@ -146,7 +146,7 @@ public enum BlockType {
FENCE_GATE(BlockID.FENCE_GATE, "Fence gate", "fencegate", "gate"), FENCE_GATE(BlockID.FENCE_GATE, "Fence gate", "fencegate", "gate"),
BRICK_STAIRS(BlockID.BRICK_STAIRS, "Brick stairs", "brickstairs", "bricksteps"), BRICK_STAIRS(BlockID.BRICK_STAIRS, "Brick stairs", "brickstairs", "bricksteps"),
STONE_BRICK_STAIRS(BlockID.STONE_BRICK_STAIRS, "Stone brick stairs", "stonebrickstairs", "smoothstonebrickstairs"), STONE_BRICK_STAIRS(BlockID.STONE_BRICK_STAIRS, "Stone brick stairs", "stonebrickstairs", "smoothstonebrickstairs"),
MYCELIUM(BlockID.MYCELIUM, "Mycelium", "fungus" ,"mycel"), MYCELIUM(BlockID.MYCELIUM, "Mycelium", "fungus", "mycel"),
LILY_PAD(BlockID.LILY_PAD, "Lily pad", "lilypad", "waterlily"), LILY_PAD(BlockID.LILY_PAD, "Lily pad", "lilypad", "waterlily"),
NETHER_BRICK(BlockID.NETHER_BRICK, "Nether brick", "netherbrick"), NETHER_BRICK(BlockID.NETHER_BRICK, "Nether brick", "netherbrick"),
NETHER_BRICK_FENCE(BlockID.NETHER_BRICK_FENCE, "Nether brick fence", "netherbrickfence", "netherfence"), NETHER_BRICK_FENCE(BlockID.NETHER_BRICK_FENCE, "Nether brick fence", "netherbrickfence", "netherfence"),
@ -162,18 +162,18 @@ public enum BlockType {
/** /**
* Stores a map of the IDs for fast access. * Stores a map of the IDs for fast access.
*/ */
private static final Map<Integer,BlockType> ids = new HashMap<Integer,BlockType>(); private static final Map<Integer, BlockType> ids = new HashMap<Integer, BlockType>();
/** /**
* Stores a map of the names for fast access. * Stores a map of the names for fast access.
*/ */
private static final Map<String,BlockType> lookup = new HashMap<String,BlockType>(); private static final Map<String, BlockType> lookup = new HashMap<String, BlockType>();
private final int id; private final int id;
private final String name; private final String name;
private final String[] lookupKeys; private final String[] lookupKeys;
static { static {
for(BlockType type : EnumSet.allOf(BlockType.class)) { for (BlockType type : EnumSet.allOf(BlockType.class)) {
ids.put(type.id, type); ids.put(type.id, type);
for (String key : type.lookupKeys) { for (String key : type.lookupKeys) {
lookup.put(key, type); lookup.put(key, type);
@ -200,7 +200,7 @@ public enum BlockType {
* @param id * @param id
* @param name * @param name
*/ */
BlockType(int id, String name, String ... lookupKeys) { BlockType(int id, String name, String... lookupKeys) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.lookupKeys = lookupKeys; this.lookupKeys = lookupKeys;
@ -947,7 +947,7 @@ public enum BlockType {
addIdentity(BlockID.STONE_PRESSURE_PLATE); // rule 1 addIdentity(BlockID.STONE_PRESSURE_PLATE); // rule 1
addIdentities(BlockID.IRON_DOOR, 8); // rule 2 addIdentities(BlockID.IRON_DOOR, 8); // rule 2
addIdentity(BlockID.WOODEN_PRESSURE_PLATE); // rule 1 addIdentity(BlockID.WOODEN_PRESSURE_PLATE); // rule 1
addIdentity(BlockID.REDSTONE_ORE); // rule 4 addIdentity(BlockID.REDSTONE_ORE); // rule 4
nonDataBlockBagItems.put(BlockID.GLOWING_REDSTONE_ORE, new BaseItem(BlockID.REDSTONE_ORE)); // rule 4 nonDataBlockBagItems.put(BlockID.GLOWING_REDSTONE_ORE, new BaseItem(BlockID.REDSTONE_ORE)); // rule 4
nonDataBlockBagItems.put(BlockID.REDSTONE_TORCH_OFF, new BaseItem(BlockID.REDSTONE_TORCH_ON)); // rule 3 nonDataBlockBagItems.put(BlockID.REDSTONE_TORCH_OFF, new BaseItem(BlockID.REDSTONE_TORCH_ON)); // rule 3
addIdentity(BlockID.REDSTONE_TORCH_ON); // rule 1 addIdentity(BlockID.REDSTONE_TORCH_ON); // rule 1
@ -1029,7 +1029,7 @@ public enum BlockType {
private static void addIdentity(int type) { private static void addIdentity(int type) {
nonDataBlockBagItems.put(type, new BaseItem(type)); nonDataBlockBagItems.put(type, new BaseItem(type));
} }
private static void addIdentities(int type, int maxData) { private static void addIdentities(int type, int maxData) {
for (int data = 0; data < maxData; ++data) { for (int data = 0; data < maxData; ++data) {
dataBlockBagItems.put(typeDataKey(type, data), new BaseItem(type, (short) data)); dataBlockBagItems.put(typeDataKey(type, data), new BaseItem(type, (short) data));

Datei anzeigen

@ -97,22 +97,22 @@ public class ChestBlock extends BaseBlock implements TileEntityBlock, ContainerB
* @return map of values * @return map of values
* @throws DataException * @throws DataException
*/ */
public Map<String,Tag> toTileEntityNBT() public Map<String, Tag> toTileEntityNBT()
throws DataException { throws DataException {
List<Tag> itemsList = new ArrayList<Tag>(); List<Tag> itemsList = new ArrayList<Tag>();
for (int i = 0; i < items.length; ++i) { for (int i = 0; i < items.length; ++i) {
BaseItemStack item = items[i]; BaseItemStack item = items[i];
if (item != null) { if (item != null) {
Map<String,Tag> data = new HashMap<String,Tag>(); Map<String, Tag> data = new HashMap<String, Tag>();
CompoundTag itemTag = new CompoundTag("Items", data); CompoundTag itemTag = new CompoundTag("Items", data);
data.put("id", new ShortTag("id", (short)item.getType())); data.put("id", new ShortTag("id", (short) item.getType()));
data.put("Damage", new ShortTag("Damage", item.getDamage())); data.put("Damage", new ShortTag("Damage", item.getDamage()));
data.put("Count", new ByteTag("Count", (byte)item.getAmount())); data.put("Count", new ByteTag("Count", (byte) item.getAmount()));
data.put("Slot", new ByteTag("Slot", (byte)i)); data.put("Slot", new ByteTag("Slot", (byte) i));
itemsList.add(itemTag); itemsList.add(itemTag);
} }
} }
Map<String,Tag> values = new HashMap<String,Tag>(); Map<String, Tag> values = new HashMap<String, Tag>();
values.put("Items", new ListTag("Items", CompoundTag.class, itemsList)); values.put("Items", new ListTag("Items", CompoundTag.class, itemsList));
return values; return values;
} }
@ -123,19 +123,18 @@ public class ChestBlock extends BaseBlock implements TileEntityBlock, ContainerB
* @param values * @param values
* @throws DataException * @throws DataException
*/ */
public void fromTileEntityNBT(Map<String,Tag> values) public void fromTileEntityNBT(Map<String, Tag> values)
throws DataException { throws DataException {
if (values == null) { if (values == null) {
return; return;
} }
Tag t = values.get("id"); Tag t = values.get("id");
if (!(t instanceof StringTag) || !((StringTag)t).getValue().equals("Chest")) { if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Chest")) {
throw new DataException("'Chest' tile entity expected"); throw new DataException("'Chest' tile entity expected");
} }
ListTag items = (ListTag)Chunk.getChildTag(values, "Items", ListTag.class); ListTag items = (ListTag) Chunk.getChildTag(values, "Items", ListTag.class);
BaseItemStack[] newItems = new BaseItemStack[27]; BaseItemStack[] newItems = new BaseItemStack[27];
for (Tag tag : items.getValue()) { for (Tag tag : items.getValue()) {
@ -143,16 +142,16 @@ public class ChestBlock extends BaseBlock implements TileEntityBlock, ContainerB
throw new DataException("CompoundTag expected as child tag of Chest's Items"); throw new DataException("CompoundTag expected as child tag of Chest's Items");
} }
CompoundTag item = (CompoundTag)tag; CompoundTag item = (CompoundTag) tag;
Map<String,Tag> itemValues = item.getValue(); Map<String, Tag> itemValues = item.getValue();
short id = (Short)((ShortTag)Chunk.getChildTag(itemValues, "id", ShortTag.class)) short id = (Short) ((ShortTag) Chunk.getChildTag(itemValues, "id", ShortTag.class))
.getValue(); .getValue();
short damage = (Short)((ShortTag)Chunk.getChildTag(itemValues, "Damage", ShortTag.class)) short damage = (Short) ((ShortTag) Chunk.getChildTag(itemValues, "Damage", ShortTag.class))
.getValue(); .getValue();
byte count = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Count", ByteTag.class)) byte count = (Byte) ((ByteTag) Chunk.getChildTag(itemValues, "Count", ByteTag.class))
.getValue(); .getValue();
byte slot = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Slot", ByteTag.class)) byte slot = (Byte) ((ByteTag) Chunk.getChildTag(itemValues, "Slot", ByteTag.class))
.getValue(); .getValue();
if (slot >= 0 && slot <= 26) { if (slot >= 0 && slot <= 26) {

Datei anzeigen

@ -35,14 +35,14 @@ public enum ClothColor {
LIGHT_BLUE(ID.LIGHT_BLUE, "Light blue", "lightblue"), LIGHT_BLUE(ID.LIGHT_BLUE, "Light blue", "lightblue"),
YELLOW(ID.YELLOW, "Yellow", "yellow"), YELLOW(ID.YELLOW, "Yellow", "yellow"),
LIGHT_GREEN(ID.LIGHT_GREEN, "Light green", "lightgreen"), LIGHT_GREEN(ID.LIGHT_GREEN, "Light green", "lightgreen"),
PINK(ID.PINK, "Pink", new String[] {"pink", "lightred"}), PINK(ID.PINK, "Pink", new String[] { "pink", "lightred" }),
GRAY(ID.GRAY, "Gray", new String[] {"grey", "gray"}), GRAY(ID.GRAY, "Gray", new String[] { "grey", "gray" }),
LIGHT_GRAY(ID.LIGHT_GRAY, "Light gray", new String[] {"lightgrey", "lightgray"}), LIGHT_GRAY(ID.LIGHT_GRAY, "Light gray", new String[] { "lightgrey", "lightgray" }),
CYAN(ID.CYAN, "Cyan", new String[] {"cyan", "turquoise"}), CYAN(ID.CYAN, "Cyan", new String[] { "cyan", "turquoise" }),
PURPLE(ID.PURPLE, "Purple", new String[] {"purple", "violet"}), PURPLE(ID.PURPLE, "Purple", new String[] { "purple", "violet" }),
BLUE(ID.BLUE, "Blue", "blue"), BLUE(ID.BLUE, "Blue", "blue"),
BROWN(ID.BROWN, "Brown", new String[] {"brown", "cocoa", "coffee"}), BROWN(ID.BROWN, "Brown", new String[] { "brown", "cocoa", "coffee" }),
DARK_GREEN(ID.DARK_GREEN, "Dark green", new String[] {"green", "darkgreen", "cactusgreen", "cactigreen"}), DARK_GREEN(ID.DARK_GREEN, "Dark green", new String[] { "green", "darkgreen", "cactusgreen", "cactigreen" }),
RED(ID.RED, "Red", "red"), RED(ID.RED, "Red", "red"),
BLACK(ID.BLACK, "Black", "black"); BLACK(ID.BLACK, "Black", "black");
@ -68,11 +68,11 @@ public enum ClothColor {
/** /**
* Stores a map of the IDs for fast access. * Stores a map of the IDs for fast access.
*/ */
private static final Map<Integer,ClothColor> ids = new HashMap<Integer,ClothColor>(); private static final Map<Integer, ClothColor> ids = new HashMap<Integer, ClothColor>();
/** /**
* Stores a map of the names for fast access. * Stores a map of the names for fast access.
*/ */
private static final Map<String,ClothColor> lookup = new HashMap<String,ClothColor>(); private static final Map<String, ClothColor> lookup = new HashMap<String, ClothColor>();
private final int id; private final int id;
private final String name; private final String name;
@ -97,7 +97,7 @@ public enum ClothColor {
ClothColor(int id, String name, String lookupKey) { ClothColor(int id, String name, String lookupKey) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.lookupKeys = new String[]{lookupKey}; this.lookupKeys = new String[] { lookupKey };
} }
/** /**
@ -149,4 +149,4 @@ public enum ClothColor {
public String getName() { public String getName() {
return name; return name;
} }
} }

Datei anzeigen

@ -97,22 +97,22 @@ public class DispenserBlock extends BaseBlock implements TileEntityBlock, Contai
* @return map of values * @return map of values
* @throws DataException * @throws DataException
*/ */
public Map<String,Tag> toTileEntityNBT() public Map<String, Tag> toTileEntityNBT()
throws DataException { throws DataException {
List<Tag> itemsList = new ArrayList<Tag>(); List<Tag> itemsList = new ArrayList<Tag>();
for (int i = 0; i < items.length; ++i) { for (int i = 0; i < items.length; ++i) {
BaseItemStack item = items[i]; BaseItemStack item = items[i];
if (item != null) { if (item != null) {
Map<String,Tag> data = new HashMap<String,Tag>(); Map<String, Tag> data = new HashMap<String, Tag>();
CompoundTag itemTag = new CompoundTag("Items", data); CompoundTag itemTag = new CompoundTag("Items", data);
data.put("id", new ShortTag("id", (short)item.getType())); data.put("id", new ShortTag("id", (short) item.getType()));
data.put("Damage", new ShortTag("Damage", item.getDamage())); data.put("Damage", new ShortTag("Damage", item.getDamage()));
data.put("Count", new ByteTag("Count", (byte)item.getAmount())); data.put("Count", new ByteTag("Count", (byte) item.getAmount()));
data.put("Slot", new ByteTag("Slot", (byte)i)); data.put("Slot", new ByteTag("Slot", (byte) i));
itemsList.add(itemTag); itemsList.add(itemTag);
} }
} }
Map<String,Tag> values = new HashMap<String,Tag>(); Map<String, Tag> values = new HashMap<String, Tag>();
values.put("Items", new ListTag("Items", CompoundTag.class, itemsList)); values.put("Items", new ListTag("Items", CompoundTag.class, itemsList));
return values; return values;
} }
@ -123,19 +123,18 @@ public class DispenserBlock extends BaseBlock implements TileEntityBlock, Contai
* @param values * @param values
* @throws DataException * @throws DataException
*/ */
public void fromTileEntityNBT(Map<String,Tag> values) public void fromTileEntityNBT(Map<String, Tag> values)
throws DataException { throws DataException {
if (values == null) { if (values == null) {
return; return;
} }
Tag t = values.get("id"); Tag t = values.get("id");
if (!(t instanceof StringTag) || !((StringTag)t).getValue().equals("Trap")) { if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Trap")) {
throw new DataException("'Trap' tile entity expected"); throw new DataException("'Trap' tile entity expected");
} }
ListTag items = (ListTag)Chunk.getChildTag(values, "Items", ListTag.class); ListTag items = (ListTag) Chunk.getChildTag(values, "Items", ListTag.class);
BaseItemStack[] newItems = new BaseItemStack[27]; BaseItemStack[] newItems = new BaseItemStack[27];
for (Tag tag : items.getValue()) { for (Tag tag : items.getValue()) {
@ -143,16 +142,16 @@ public class DispenserBlock extends BaseBlock implements TileEntityBlock, Contai
throw new DataException("CompoundTag expected as child tag of Trap Items"); throw new DataException("CompoundTag expected as child tag of Trap Items");
} }
CompoundTag item = (CompoundTag)tag; CompoundTag item = (CompoundTag) tag;
Map<String,Tag> itemValues = item.getValue(); Map<String, Tag> itemValues = item.getValue();
short id = (Short)((ShortTag)Chunk.getChildTag(itemValues, "id", ShortTag.class)) short id = (Short) ((ShortTag) Chunk.getChildTag(itemValues, "id", ShortTag.class))
.getValue(); .getValue();
short damage = (Short)((ShortTag)Chunk.getChildTag(itemValues, "Damage", ShortTag.class)) short damage = (Short) ((ShortTag) Chunk.getChildTag(itemValues, "Damage", ShortTag.class))
.getValue(); .getValue();
byte count = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Count", ByteTag.class)) byte count = (Byte) ((ByteTag) Chunk.getChildTag(itemValues, "Count", ByteTag.class))
.getValue(); .getValue();
byte slot = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Slot", ByteTag.class)) byte slot = (Byte) ((ByteTag) Chunk.getChildTag(itemValues, "Slot", ByteTag.class))
.getValue(); .getValue();
if (slot >= 0 && slot <= 8) { if (slot >= 0 && slot <= 8) {

Datei anzeigen

@ -36,7 +36,7 @@ public class FurnaceBlock extends BaseBlock implements TileEntityBlock, Containe
* Store the list of items. * Store the list of items.
*/ */
private BaseItemStack[] items; private BaseItemStack[] items;
/** /**
* Fuel time. * Fuel time.
*/ */
@ -95,7 +95,7 @@ public class FurnaceBlock extends BaseBlock implements TileEntityBlock, Containe
public void setItems(BaseItemStack[] items) { public void setItems(BaseItemStack[] items) {
this.items = items; this.items = items;
} }
/** /**
* @return the burnTime * @return the burnTime
*/ */
@ -139,22 +139,22 @@ public class FurnaceBlock extends BaseBlock implements TileEntityBlock, Containe
* @return map of values * @return map of values
* @throws DataException * @throws DataException
*/ */
public Map<String,Tag> toTileEntityNBT() public Map<String, Tag> toTileEntityNBT()
throws DataException { throws DataException {
List<Tag> itemsList = new ArrayList<Tag>(); List<Tag> itemsList = new ArrayList<Tag>();
for (int i = 0; i < items.length; ++i) { for (int i = 0; i < items.length; ++i) {
BaseItemStack item = items[i]; BaseItemStack item = items[i];
if (item != null) { if (item != null) {
Map<String,Tag> data = new HashMap<String,Tag>(); Map<String, Tag> data = new HashMap<String, Tag>();
CompoundTag itemTag = new CompoundTag("Items", data); CompoundTag itemTag = new CompoundTag("Items", data);
data.put("id", new ShortTag("id", (short)item.getType())); data.put("id", new ShortTag("id", (short) item.getType()));
data.put("Damage", new ShortTag("Damage", item.getDamage())); data.put("Damage", new ShortTag("Damage", item.getDamage()));
data.put("Count", new ByteTag("Count", (byte)item.getAmount())); data.put("Count", new ByteTag("Count", (byte) item.getAmount()));
data.put("Slot", new ByteTag("Slot", (byte)i)); data.put("Slot", new ByteTag("Slot", (byte) i));
itemsList.add(itemTag); itemsList.add(itemTag);
} }
} }
Map<String,Tag> values = new HashMap<String,Tag>(); Map<String, Tag> values = new HashMap<String, Tag>();
values.put("Items", new ListTag("Items", CompoundTag.class, itemsList)); values.put("Items", new ListTag("Items", CompoundTag.class, itemsList));
values.put("BurnTime", new ShortTag("BurnTime", burnTime)); values.put("BurnTime", new ShortTag("BurnTime", burnTime));
values.put("CookTime", new ShortTag("CookTime", cookTime)); values.put("CookTime", new ShortTag("CookTime", cookTime));
@ -167,18 +167,18 @@ public class FurnaceBlock extends BaseBlock implements TileEntityBlock, Containe
* @param values * @param values
* @throws DataException * @throws DataException
*/ */
public void fromTileEntityNBT(Map<String,Tag> values) public void fromTileEntityNBT(Map<String, Tag> values)
throws DataException { throws DataException {
if (values == null) { if (values == null) {
return; return;
} }
Tag t = values.get("id"); Tag t = values.get("id");
if (!(t instanceof StringTag) || !((StringTag)t).getValue().equals("Furnace")) { if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Furnace")) {
throw new DataException("'Furnace' tile entity expected"); throw new DataException("'Furnace' tile entity expected");
} }
ListTag items = (ListTag)Chunk.getChildTag(values, "Items", ListTag.class); ListTag items = (ListTag) Chunk.getChildTag(values, "Items", ListTag.class);
BaseItemStack[] newItems = new BaseItemStack[27]; BaseItemStack[] newItems = new BaseItemStack[27];
for (Tag tag : items.getValue()) { for (Tag tag : items.getValue()) {
@ -186,16 +186,16 @@ public class FurnaceBlock extends BaseBlock implements TileEntityBlock, Containe
throw new DataException("CompoundTag expected as child tag of Trap Items"); throw new DataException("CompoundTag expected as child tag of Trap Items");
} }
CompoundTag item = (CompoundTag)tag; CompoundTag item = (CompoundTag) tag;
Map<String,Tag> itemValues = item.getValue(); Map<String, Tag> itemValues = item.getValue();
short id = (Short)((ShortTag)Chunk.getChildTag(itemValues, "id", ShortTag.class)) short id = (Short) ((ShortTag) Chunk.getChildTag(itemValues, "id", ShortTag.class))
.getValue(); .getValue();
short damage = (Short)((ShortTag)Chunk.getChildTag(itemValues, "Damage", ShortTag.class)) short damage = (Short) ((ShortTag) Chunk.getChildTag(itemValues, "Damage", ShortTag.class))
.getValue(); .getValue();
byte count = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Count", ByteTag.class)) byte count = (Byte) ((ByteTag) Chunk.getChildTag(itemValues, "Count", ByteTag.class))
.getValue(); .getValue();
byte slot = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Slot", ByteTag.class)) byte slot = (Byte) ((ByteTag) Chunk.getChildTag(itemValues, "Slot", ByteTag.class))
.getValue(); .getValue();
if (slot >= 0 && slot <= 26) { if (slot >= 0 && slot <= 26) {
@ -207,12 +207,12 @@ public class FurnaceBlock extends BaseBlock implements TileEntityBlock, Containe
t = values.get("BurnTime"); t = values.get("BurnTime");
if (t instanceof ShortTag) { if (t instanceof ShortTag) {
burnTime = ((ShortTag)t).getValue(); burnTime = ((ShortTag) t).getValue();
} }
t = values.get("CookTime"); t = values.get("CookTime");
if (t instanceof ShortTag) { if (t instanceof ShortTag) {
cookTime = ((ShortTag)t).getValue(); cookTime = ((ShortTag) t).getValue();
} }
} }
} }

Datei anzeigen

@ -163,6 +163,6 @@ public final class ItemID {
public static final int DISC_MELLOHI = 2262; public static final int DISC_MELLOHI = 2262;
public static final int DISC_STAL = 2263; public static final int DISC_STAL = 2263;
public static final int DISC_STRAD = 2264; public static final int DISC_STRAD = 2264;
public static final int DISC_WARD = 2265; public static final int DISC_WARD = 2265;
public static final int DISC_11 = 2266; public static final int DISC_11 = 2266;
} }

Datei anzeigen

@ -146,7 +146,7 @@ public enum ItemType {
FENCE_GATE(BlockID.FENCE_GATE, "Fence gate", "fencegate", "gate"), FENCE_GATE(BlockID.FENCE_GATE, "Fence gate", "fencegate", "gate"),
BRICK_STAIRS(BlockID.BRICK_STAIRS, "Brick stairs", "brickstairs", "bricksteps"), BRICK_STAIRS(BlockID.BRICK_STAIRS, "Brick stairs", "brickstairs", "bricksteps"),
STONE_BRICK_STAIRS(BlockID.STONE_BRICK_STAIRS, "Stone brick stairs", "stonebrickstairs", "smoothstonebrickstairs"), STONE_BRICK_STAIRS(BlockID.STONE_BRICK_STAIRS, "Stone brick stairs", "stonebrickstairs", "smoothstonebrickstairs"),
MYCELIUM(BlockID.MYCELIUM, "Mycelium", "fungus" ,"mycel"), MYCELIUM(BlockID.MYCELIUM, "Mycelium", "fungus", "mycel"),
LILY_PAD(BlockID.LILY_PAD, "Lily pad", "lilypad", "waterlily"), LILY_PAD(BlockID.LILY_PAD, "Lily pad", "lilypad", "waterlily"),
NETHER_BRICK(BlockID.NETHER_BRICK, "Nether brick", "netherbrick"), NETHER_BRICK(BlockID.NETHER_BRICK, "Nether brick", "netherbrick"),
NETHER_BRICK_FENCE(BlockID.NETHER_BRICK_FENCE, "Nether brick fence", "netherbrickfence", "netherfence"), NETHER_BRICK_FENCE(BlockID.NETHER_BRICK_FENCE, "Nether brick fence", "netherbrickfence", "netherfence"),
@ -306,11 +306,11 @@ public enum ItemType {
/** /**
* Stores a map of the IDs for fast access. * Stores a map of the IDs for fast access.
*/ */
private static final Map<Integer,ItemType> ids = new HashMap<Integer,ItemType>(); private static final Map<Integer, ItemType> ids = new HashMap<Integer, ItemType>();
/** /**
* Stores a map of the names for fast access. * Stores a map of the names for fast access.
*/ */
private static final Map<String,ItemType> lookup = new LinkedHashMap<String,ItemType>(); private static final Map<String, ItemType> lookup = new LinkedHashMap<String, ItemType>();
private final int id; private final int id;
private final String name; private final String name;
@ -335,7 +335,7 @@ public enum ItemType {
ItemType(int id, String name, String lookupKey) { ItemType(int id, String name, String lookupKey) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.lookupKeys = new String[] {lookupKey}; this.lookupKeys = new String[] { lookupKey };
} }
/** /**
@ -344,7 +344,7 @@ public enum ItemType {
* @param id * @param id
* @param name * @param name
*/ */
ItemType(int id, String name, String ... lookupKeys) { ItemType(int id, String name, String... lookupKeys) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.lookupKeys = lookupKeys; this.lookupKeys = lookupKeys;
@ -412,32 +412,32 @@ public enum ItemType {
*/ */
public static ItemType lookup(String name, boolean fuzzy) { public static ItemType lookup(String name, boolean fuzzy) {
String testName = name.replace(" ", "").toLowerCase(); String testName = name.replace(" ", "").toLowerCase();
ItemType type = lookup.get(testName); ItemType type = lookup.get(testName);
if (type != null) { if (type != null) {
return type; return type;
} }
if (!fuzzy) { if (!fuzzy) {
return null; return null;
} }
int minDist = -1; int minDist = -1;
for (Entry<String, ItemType> entry : lookup.entrySet()) { for (Entry<String, ItemType> entry : lookup.entrySet()) {
if (entry.getKey().charAt(0) != testName.charAt(0)) { if (entry.getKey().charAt(0) != testName.charAt(0)) {
continue; continue;
} }
int dist = StringUtil.getLevenshteinDistance(entry.getKey(), testName); int dist = StringUtil.getLevenshteinDistance(entry.getKey(), testName);
if ((dist < minDist || minDist == -1) && dist < 2) { if ((dist < minDist || minDist == -1) && dist < 2) {
minDist = dist; minDist = dist;
type = entry.getValue(); type = entry.getValue();
} }
} }
return type; return type;
} }

Datei anzeigen

@ -126,9 +126,9 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock {
* @return map of values * @return map of values
* @throws DataException * @throws DataException
*/ */
public Map<String,Tag> toTileEntityNBT() public Map<String, Tag> toTileEntityNBT()
throws DataException { throws DataException {
Map<String,Tag> values = new HashMap<String,Tag>(); Map<String, Tag> values = new HashMap<String, Tag>();
values.put("EntityId", new StringTag("EntityId", mobType)); values.put("EntityId", new StringTag("EntityId", mobType));
values.put("Delay", new ShortTag("Delay", delay)); values.put("Delay", new ShortTag("Delay", delay));
return values; return values;
@ -140,19 +140,19 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock {
* @param values * @param values
* @throws DataException * @throws DataException
*/ */
public void fromTileEntityNBT(Map<String,Tag> values) public void fromTileEntityNBT(Map<String, Tag> values)
throws DataException { throws DataException {
if (values == null) { if (values == null) {
return; return;
} }
Tag t = values.get("id"); Tag t = values.get("id");
if (!(t instanceof StringTag) || !((StringTag)t).getValue().equals("MobSpawner")) { if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("MobSpawner")) {
throw new DataException("'MobSpawner' tile entity expected"); throw new DataException("'MobSpawner' tile entity expected");
} }
StringTag mobTypeTag = (StringTag)Chunk.getChildTag(values, "EntityId", StringTag.class); StringTag mobTypeTag = (StringTag) Chunk.getChildTag(values, "EntityId", StringTag.class);
ShortTag delayTag = (ShortTag)Chunk.getChildTag(values, "Delay", ShortTag.class); ShortTag delayTag = (ShortTag) Chunk.getChildTag(values, "Delay", ShortTag.class);
this.mobType = mobTypeTag.getValue(); this.mobType = mobTypeTag.getValue();
this.delay = delayTag.getValue(); this.delay = delayTag.getValue();

Datei anzeigen

@ -85,16 +85,16 @@ public class NoteBlock extends BaseBlock implements TileEntityBlock {
public String getTileEntityID() { public String getTileEntityID() {
return "Music"; return "Music";
} }
/** /**
* Store additional tile entity data. Returns true if the data is used. * Store additional tile entity data. Returns true if the data is used.
* *
* @return map of values * @return map of values
* @throws DataException * @throws DataException
*/ */
public Map<String,Tag> toTileEntityNBT() public Map<String, Tag> toTileEntityNBT()
throws DataException { throws DataException {
Map<String,Tag> values = new HashMap<String,Tag>(); Map<String, Tag> values = new HashMap<String, Tag>();
values.put("note", new ByteTag("note", note)); values.put("note", new ByteTag("note", note));
return values; return values;
} }
@ -105,22 +105,22 @@ public class NoteBlock extends BaseBlock implements TileEntityBlock {
* @param values * @param values
* @throws DataException * @throws DataException
*/ */
public void fromTileEntityNBT(Map<String,Tag> values) public void fromTileEntityNBT(Map<String, Tag> values)
throws DataException { throws DataException {
if (values == null) { if (values == null) {
return; return;
} }
Tag t; Tag t;
t = values.get("id"); t = values.get("id");
if (!(t instanceof StringTag) || !((StringTag)t).getValue().equals("Music")) { if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Music")) {
throw new DataException("'Music' tile entity expected"); throw new DataException("'Music' tile entity expected");
} }
t = values.get("note"); t = values.get("note");
if (t instanceof ByteTag) { if (t instanceof ByteTag) {
note = ((ByteTag)t).getValue(); note = ((ByteTag) t).getValue();
} }
} }
} }

Datei anzeigen

@ -42,7 +42,7 @@ public class SignBlock extends BaseBlock implements TileEntityBlock {
*/ */
public SignBlock(int type, int data) { public SignBlock(int type, int data) {
super(type, data); super(type, data);
this.text = new String[]{ "", "", "", "" }; this.text = new String[] { "", "", "", "" };
} }
/** /**
@ -86,9 +86,9 @@ public class SignBlock extends BaseBlock implements TileEntityBlock {
* @return map of values * @return map of values
* @throws DataException * @throws DataException
*/ */
public Map<String,Tag> toTileEntityNBT() public Map<String, Tag> toTileEntityNBT()
throws DataException { throws DataException {
Map<String,Tag> values = new HashMap<String,Tag>(); Map<String, Tag> values = new HashMap<String, Tag>();
values.put("Text1", new StringTag("Text1", text[0])); values.put("Text1", new StringTag("Text1", text[0]));
values.put("Text2", new StringTag("Text2", text[1])); values.put("Text2", new StringTag("Text2", text[1]));
values.put("Text3", new StringTag("Text3", text[2])); values.put("Text3", new StringTag("Text3", text[2]));
@ -102,39 +102,39 @@ public class SignBlock extends BaseBlock implements TileEntityBlock {
* @param values * @param values
* @throws DataException * @throws DataException
*/ */
public void fromTileEntityNBT(Map<String,Tag> values) public void fromTileEntityNBT(Map<String, Tag> values)
throws DataException { throws DataException {
if (values == null) { if (values == null) {
return; return;
} }
Tag t; Tag t;
text = new String[]{ "", "", "", "" }; text = new String[] { "", "", "", "" };
t = values.get("id"); t = values.get("id");
if (!(t instanceof StringTag) || !((StringTag)t).getValue().equals("Sign")) { if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Sign")) {
throw new DataException("'Sign' tile entity expected"); throw new DataException("'Sign' tile entity expected");
} }
t = values.get("Text1"); t = values.get("Text1");
if (t instanceof StringTag) { if (t instanceof StringTag) {
text[0] = ((StringTag)t).getValue(); text[0] = ((StringTag) t).getValue();
} }
t = values.get("Text2"); t = values.get("Text2");
if (t instanceof StringTag) { if (t instanceof StringTag) {
text[1] = ((StringTag)t).getValue(); text[1] = ((StringTag) t).getValue();
} }
t = values.get("Text3"); t = values.get("Text3");
if (t instanceof StringTag) { if (t instanceof StringTag) {
text[2] = ((StringTag)t).getValue(); text[2] = ((StringTag) t).getValue();
} }
t = values.get("Text4"); t = values.get("Text4");
if (t instanceof StringTag) { if (t instanceof StringTag) {
text[3] = ((StringTag)t).getValue(); text[3] = ((StringTag) t).getValue();
} }
} }
} }

Datei anzeigen

@ -35,20 +35,22 @@ public interface TileEntityBlock {
* @return title entity ID * @return title entity ID
*/ */
public String getTileEntityID(); public String getTileEntityID();
/** /**
* Store additional tile entity data. * Store additional tile entity data.
* *
* @return map of values * @return map of values
* @throws DataException * @throws DataException
*/ */
public Map<String,Tag> toTileEntityNBT() public Map<String, Tag> toTileEntityNBT()
throws DataException; throws DataException;
/** /**
* Get additional information from the title entity data. * Get additional information from the title entity data.
* *
* @param values * @param values
* @throws DataException * @throws DataException
*/ */
public void fromTileEntityNBT(Map<String,Tag> values) public void fromTileEntityNBT(Map<String, Tag> values)
throws DataException; throws DataException;
} }

Datei anzeigen

@ -36,9 +36,9 @@ public class BukkitConfiguration extends LocalConfiguration {
private YAMLProcessor config; private YAMLProcessor config;
private Logger logger; private Logger logger;
private FileHandler logFileHandler; private FileHandler logFileHandler;
public boolean noOpPermissions = false; public boolean noOpPermissions = false;
public BukkitConfiguration(YAMLProcessor config, Logger logger) { public BukkitConfiguration(YAMLProcessor config, Logger logger) {
this.config = config; this.config = config;
this.logger = logger; this.logger = logger;
@ -53,7 +53,7 @@ public class BukkitConfiguration extends LocalConfiguration {
e.printStackTrace(); e.printStackTrace();
} }
showFirstUseVersion = false; showFirstUseVersion = false;
profile = config.getBoolean("debug", profile); profile = config.getBoolean("debug", profile);
wandItem = config.getInt("wand-item", wandItem); wandItem = config.getInt("wand-item", wandItem);
defaultChangeLimit = Math.max(-1, config.getInt( defaultChangeLimit = Math.max(-1, config.getInt(
@ -74,7 +74,7 @@ public class BukkitConfiguration extends LocalConfiguration {
useInventoryOverride = config.getBoolean("use-inventory.allow-override", useInventoryOverride = config.getBoolean("use-inventory.allow-override",
useInventoryOverride); useInventoryOverride);
maxBrushRadius = config.getInt("limits.max-brush-radius", maxBrushRadius); maxBrushRadius = config.getInt("limits.max-brush-radius", maxBrushRadius);
navigationWand = config.getInt("navigation-wand.item", navigationWand); navigationWand = config.getInt("navigation-wand.item", navigationWand);
navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance); navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance);
@ -82,18 +82,18 @@ public class BukkitConfiguration extends LocalConfiguration {
scriptsDir = config.getString("scripting.dir", scriptsDir); scriptsDir = config.getString("scripting.dir", scriptsDir);
saveDir = config.getString("saving.dir", saveDir); saveDir = config.getString("saving.dir", saveDir);
disallowedBlocks = new HashSet<Integer>(config.getIntList("limits.disallowed-blocks", null)); disallowedBlocks = new HashSet<Integer>(config.getIntList("limits.disallowed-blocks", null));
allowedDataCycleBlocks = new HashSet<Integer>(config.getIntList("limits.allowed-data-cycle-blocks", null)); allowedDataCycleBlocks = new HashSet<Integer>(config.getIntList("limits.allowed-data-cycle-blocks", null));
noOpPermissions = config.getBoolean("no-op-permissions", false); noOpPermissions = config.getBoolean("no-op-permissions", false);
LocalSession.MAX_HISTORY_SIZE = Math.max(0, config.getInt("history.size", 15)); LocalSession.MAX_HISTORY_SIZE = Math.max(0, config.getInt("history.size", 15));
LocalSession.EXPIRATION_GRACE = config.getInt("history.expiration", 10) * 60 * 1000; LocalSession.EXPIRATION_GRACE = config.getInt("history.expiration", 10) * 60 * 1000;
String snapshotsDir = config.getString("snapshots.directory", ""); String snapshotsDir = config.getString("snapshots.directory", "");
if (!snapshotsDir.isEmpty()){ if (!snapshotsDir.isEmpty()) {
snapshotRepo = new SnapshotRepository(snapshotsDir); snapshotRepo = new SnapshotRepository(snapshotsDir);
} }
@ -116,11 +116,10 @@ public class BukkitConfiguration extends LocalConfiguration {
} }
} }
} }
public void unload() { public void unload() {
if (logFileHandler != null) { if (logFileHandler != null) {
logFileHandler.close(); logFileHandler.close();
} }
} }
} }

Datei anzeigen

@ -30,7 +30,7 @@ import com.sk89q.worldedit.cui.CUIEvent;
public class BukkitPlayer extends LocalPlayer { public class BukkitPlayer extends LocalPlayer {
private Player player; private Player player;
private WorldEditPlugin plugin; private WorldEditPlugin plugin;
public BukkitPlayer(WorldEditPlugin plugin, ServerInterface server, Player player) { public BukkitPlayer(WorldEditPlugin plugin, ServerInterface server, Player player) {
super(server); super(server);
this.plugin = plugin; this.plugin = plugin;
@ -117,11 +117,11 @@ public class BukkitPlayer extends LocalPlayer {
public LocalWorld getWorld() { public LocalWorld getWorld() {
return new BukkitWorld(player.getWorld()); return new BukkitWorld(player.getWorld());
} }
@Override @Override
public void dispatchCUIEvent(CUIEvent event) { public void dispatchCUIEvent(CUIEvent event) {
String[] params = event.getParameters(); String[] params = event.getParameters();
if (params.length > 0) { if (params.length > 0) {
player.sendRawMessage("\u00A75\u00A76\u00A74\u00A75" + event.getTypeId() player.sendRawMessage("\u00A75\u00A76\u00A74\u00A75" + event.getTypeId()
+ "|" + StringUtil.joinString(params, "|")); + "|" + StringUtil.joinString(params, "|"));
@ -129,7 +129,7 @@ public class BukkitPlayer extends LocalPlayer {
player.sendRawMessage("\u00A75\u00A76\u00A74\u00A75" + event.getTypeId()); player.sendRawMessage("\u00A75\u00A76\u00A74\u00A75" + event.getTypeId());
} }
} }
@Override @Override
public void dispatchCUIHandshake() { public void dispatchCUIHandshake() {
player.sendRawMessage("\u00A75\u00A76\u00A74\u00A75"); player.sendRawMessage("\u00A75\u00A76\u00A74\u00A75");

Datei anzeigen

@ -37,7 +37,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
* The player's inventory; * The player's inventory;
*/ */
private ItemStack[] items; private ItemStack[] items;
/** /**
* Construct the object. * Construct the object.
* *
@ -46,7 +46,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
public BukkitPlayerBlockBag(Player player) { public BukkitPlayerBlockBag(Player player) {
this.player = player; this.player = player;
} }
/** /**
* Loads inventory on first use. * Loads inventory on first use.
*/ */
@ -55,7 +55,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
items = player.getInventory().getContents(); items = player.getInventory().getContents();
} }
} }
/** /**
* Get the player. * Get the player.
* *
@ -64,7 +64,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
public Player getPlayer() { public Player getPlayer() {
return player; return player;
} }
/** /**
* Get a block. * Get a block.
* *
@ -113,7 +113,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
bukkitItem.setAmount(currentAmount - 1); bukkitItem.setAmount(currentAmount - 1);
found = true; found = true;
} else { } else {
items[slot] = null; items[slot] = null;
found = true; found = true;
} }
@ -196,7 +196,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
throw new OutOfSpaceException(id); throw new OutOfSpaceException(id);
} }
/** /**
* Flush any changes. This is called at the end. * Flush any changes. This is called at the end.
*/ */
@ -216,7 +216,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
@Override @Override
public void addSourcePosition(Vector pos) { public void addSourcePosition(Vector pos) {
} }
/** /**
* Adds a position to be used a source. * Adds a position to be used a source.
* *

Datei anzeigen

@ -26,7 +26,7 @@ import com.sk89q.worldedit.ServerInterface;
public class BukkitServerInterface extends ServerInterface { public class BukkitServerInterface extends ServerInterface {
public Server server; public Server server;
public WorldEditPlugin plugin; public WorldEditPlugin plugin;
public BukkitServerInterface(WorldEditPlugin plugin, Server server) { public BukkitServerInterface(WorldEditPlugin plugin, Server server) {
this.plugin = plugin; this.plugin = plugin;
this.server = server; this.server = server;

Datei anzeigen

@ -30,10 +30,10 @@ import com.sk89q.worldedit.*;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
public class BukkitUtil { public class BukkitUtil {
private BukkitUtil() { private BukkitUtil() {
} }
private static final Map<World,LocalWorld> wlw = new HashMap<World,LocalWorld>(); private static final Map<World, LocalWorld> wlw = new HashMap<World, LocalWorld>();
public static LocalWorld getLocalWorld(World w) { public static LocalWorld getLocalWorld(World w) {
LocalWorld lw = wlw.get(w); LocalWorld lw = wlw.get(w);
@ -43,27 +43,27 @@ public class BukkitUtil {
} }
return lw; return lw;
} }
public static BlockVector toVector(Block block) { public static BlockVector toVector(Block block) {
return new BlockVector(block.getX(), block.getY(), block.getZ()); return new BlockVector(block.getX(), block.getY(), block.getZ());
} }
public static BlockVector toVector(BlockFace face) { public static BlockVector toVector(BlockFace face) {
return new BlockVector(face.getModX(), face.getModY(), face.getModZ()); return new BlockVector(face.getModX(), face.getModY(), face.getModZ());
} }
public static BlockWorldVector toWorldVector(Block block) { public static BlockWorldVector toWorldVector(Block block) {
return new BlockWorldVector(getLocalWorld(block.getWorld()), block.getX(), block.getY(), block.getZ()); return new BlockWorldVector(getLocalWorld(block.getWorld()), block.getX(), block.getY(), block.getZ());
} }
public static Vector toVector(Location loc) { public static Vector toVector(Location loc) {
return new Vector(loc.getX(), loc.getY(), loc.getZ()); return new Vector(loc.getX(), loc.getY(), loc.getZ());
} }
public static Vector toVector(org.bukkit.util.Vector vector) { public static Vector toVector(org.bukkit.util.Vector vector) {
return new Vector(vector.getX(), vector.getY(), vector.getZ()); return new Vector(vector.getX(), vector.getY(), vector.getZ());
} }
public static Location toLocation(WorldVector pt) { public static Location toLocation(WorldVector pt) {
return new Location(toWorld(pt), pt.getX(), pt.getY(), pt.getZ()); return new Location(toWorld(pt), pt.getX(), pt.getY(), pt.getZ());
} }
@ -71,18 +71,18 @@ public class BukkitUtil {
public static Location toLocation(World world, Vector pt) { public static Location toLocation(World world, Vector pt) {
return new Location(world, pt.getX(), pt.getY(), pt.getZ()); return new Location(world, pt.getX(), pt.getY(), pt.getZ());
} }
public static Location center(Location loc) { public static Location center(Location loc) {
return new Location( return new Location(
loc.getWorld(), loc.getWorld(),
loc.getBlockX()+0.5, loc.getBlockX() + 0.5,
loc.getBlockY()+0.5, loc.getBlockY() + 0.5,
loc.getBlockZ()+0.5, loc.getBlockZ() + 0.5,
loc.getPitch(), loc.getPitch(),
loc.getYaw() loc.getYaw()
); );
} }
public static Player matchSinglePlayer(Server server, String name) { public static Player matchSinglePlayer(Server server, String name) {
List<Player> players = server.matchPlayer(name); List<Player> players = server.matchPlayer(name);
if (players.size() == 0) { if (players.size() == 0) {
@ -96,18 +96,19 @@ public class BukkitUtil {
} }
public static World toWorld(WorldVector pt) { public static World toWorld(WorldVector pt) {
return ((BukkitWorld)pt.getWorld()).getWorld(); return ((BukkitWorld) pt.getWorld()).getWorld();
} }
/** /**
* Bukkit's Location class has serious problems with floating point * Bukkit's Location class has serious problems with floating point
* precision. * precision.
*/ */
public static boolean equals(Location a, Location b) { public static boolean equals(Location a, Location b) {
if (Math.abs(a.getX()-b.getX()) > EQUALS_PRECISION) return false; if (Math.abs(a.getX() - b.getX()) > EQUALS_PRECISION) return false;
if (Math.abs(a.getY()-b.getY()) > EQUALS_PRECISION) return false; if (Math.abs(a.getY() - b.getY()) > EQUALS_PRECISION) return false;
if (Math.abs(a.getZ()-b.getZ()) > EQUALS_PRECISION) return false; if (Math.abs(a.getZ() - b.getZ()) > EQUALS_PRECISION) return false;
return true; return true;
} }
public static final double EQUALS_PRECISION = 0.0001; public static final double EQUALS_PRECISION = 0.0001;
} }

Datei anzeigen

@ -61,7 +61,7 @@ import com.sk89q.worldedit.regions.Region;
public class BukkitWorld extends LocalWorld { public class BukkitWorld extends LocalWorld {
private World world; private World world;
/** /**
* Construct the object. * Construct the object.
* @param world * @param world
@ -69,7 +69,7 @@ public class BukkitWorld extends LocalWorld {
public BukkitWorld(World world) { public BukkitWorld(World world) {
this.world = world; this.world = world;
} }
/** /**
* Get the world handle. * Get the world handle.
* *
@ -78,7 +78,7 @@ public class BukkitWorld extends LocalWorld {
public World getWorld() { public World getWorld() {
return world; return world;
} }
/** /**
* Get the name of the world * Get the name of the world
* *
@ -130,10 +130,10 @@ public class BukkitWorld extends LocalWorld {
* @return * @return
*/ */
@Override @Override
public boolean setTypeIdAndData(Vector pt, int type, int data){ public boolean setTypeIdAndData(Vector pt, int type, int data) {
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setTypeIdAndData(type, (byte) data, true); return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setTypeIdAndData(type, (byte) data, true);
} }
/** /**
* set block type & data * set block type & data
* @param pt * @param pt
@ -142,7 +142,7 @@ public class BukkitWorld extends LocalWorld {
* @return * @return
*/ */
@Override @Override
public boolean setTypeIdAndDataFast(Vector pt, int type, int data){ public boolean setTypeIdAndDataFast(Vector pt, int type, int data) {
final Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); final Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (fastLightingAvailable) { if (fastLightingAvailable) {
type = type & 255; type = type & 255;
@ -175,7 +175,7 @@ public class BukkitWorld extends LocalWorld {
*/ */
@Override @Override
public void setBlockData(Vector pt, int data) { public void setBlockData(Vector pt, int data) {
world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setData((byte)data); world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setData((byte) data);
} }
/** /**
@ -186,7 +186,7 @@ public class BukkitWorld extends LocalWorld {
*/ */
@Override @Override
public void setBlockDataFast(Vector pt, int data) { public void setBlockDataFast(Vector pt, int data) {
world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setData((byte)data, false); world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setData((byte) data, false);
} }
/** /**
@ -221,10 +221,10 @@ public class BukkitWorld extends LocalWorld {
@Override @Override
public boolean regenerate(Region region, EditSession editSession) { public boolean regenerate(Region region, EditSession editSession) {
BaseBlock[] history = new BaseBlock[16 * 16 * 128]; BaseBlock[] history = new BaseBlock[16 * 16 * 128];
for (Vector2D chunk : region.getChunks()) { for (Vector2D chunk : region.getChunks()) {
Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16); Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
// First save all the blocks inside // First save all the blocks inside
for (int x = 0; x < 16; ++x) { for (int x = 0; x < 16; ++x) {
for (int y = 0; y < 128; ++y) { for (int y = 0; y < 128; ++y) {
@ -235,20 +235,20 @@ public class BukkitWorld extends LocalWorld {
} }
} }
} }
try { try {
world.regenerateChunk(chunk.getBlockX(), chunk.getBlockZ()); world.regenerateChunk(chunk.getBlockX(), chunk.getBlockZ());
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
} }
// Then restore // Then restore
for (int x = 0; x < 16; ++x) { for (int x = 0; x < 16; ++x) {
for (int y = 0; y < 128; ++y) { for (int y = 0; y < 128; ++y) {
for (int z = 0; z < 16; ++z) { for (int z = 0; z < 16; ++z) {
Vector pt = min.add(x, y, z); Vector pt = min.add(x, y, z);
int index = y * 16 * 16 + z * 16 + x; int index = y * 16 * 16 + z * 16 + x;
// We have to restore the block if it was outside // We have to restore the block if it was outside
if (!region.contains(pt)) { if (!region.contains(pt)) {
editSession.smartSetBlock(pt, history[index]); editSession.smartSetBlock(pt, history[index]);
@ -260,7 +260,7 @@ public class BukkitWorld extends LocalWorld {
} }
} }
} }
return true; return true;
} }
@ -273,51 +273,55 @@ public class BukkitWorld extends LocalWorld {
*/ */
@Override @Override
public boolean copyToWorld(Vector pt, BaseBlock block) { public boolean copyToWorld(Vector pt, BaseBlock block) {
// Signs
if (block instanceof SignBlock) { if (block instanceof SignBlock) {
setSignText(pt, ((SignBlock)block).getText()); // Signs
setSignText(pt, ((SignBlock) block).getText());
return true; return true;
}
// Furnaces
} else if (block instanceof FurnaceBlock) { if (block instanceof FurnaceBlock) {
// Furnaces
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
if (!(state instanceof Furnace)) return false; if (!(state instanceof Furnace)) return false;
Furnace bukkit = (Furnace)state; Furnace bukkit = (Furnace) state;
FurnaceBlock we = (FurnaceBlock)block; FurnaceBlock we = (FurnaceBlock) block;
bukkit.setBurnTime(we.getBurnTime()); bukkit.setBurnTime(we.getBurnTime());
bukkit.setCookTime(we.getCookTime()); bukkit.setCookTime(we.getCookTime());
return setContainerBlockContents(pt, ((ContainerBlock)block).getItems()); return setContainerBlockContents(pt, ((ContainerBlock) block).getItems());
}
// Chests/dispenser
} else if (block instanceof ContainerBlock) { if (block instanceof ContainerBlock) {
return setContainerBlockContents(pt, ((ContainerBlock)block).getItems()); // Chests/dispenser
return setContainerBlockContents(pt, ((ContainerBlock) block).getItems());
// Mob spawners }
} else if (block instanceof MobSpawnerBlock) {
if (block instanceof MobSpawnerBlock) {
// Mob spawners
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
if (!(state instanceof CreatureSpawner)) return false; if (!(state instanceof CreatureSpawner)) return false;
CreatureSpawner bukkit = (CreatureSpawner)state; CreatureSpawner bukkit = (CreatureSpawner) state;
MobSpawnerBlock we = (MobSpawnerBlock)block; MobSpawnerBlock we = (MobSpawnerBlock) block;
bukkit.setCreatureTypeId(we.getMobType()); bukkit.setCreatureTypeId(we.getMobType());
bukkit.setDelay(we.getDelay()); bukkit.setDelay(we.getDelay());
return true; return true;
}
// Note block
} else if (block instanceof NoteBlock) { if (block instanceof NoteBlock) {
// Note block
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
if (!(state instanceof org.bukkit.block.NoteBlock)) return false; if (!(state instanceof org.bukkit.block.NoteBlock)) return false;
org.bukkit.block.NoteBlock bukkit = (org.bukkit.block.NoteBlock)state; org.bukkit.block.NoteBlock bukkit = (org.bukkit.block.NoteBlock) state;
NoteBlock we = (NoteBlock)block; NoteBlock we = (NoteBlock) block;
bukkit.setRawNote(we.getNote()); bukkit.setRawNote(we.getNote());
return true; return true;
} }
return false; return false;
} }
@ -330,13 +334,14 @@ public class BukkitWorld extends LocalWorld {
*/ */
@Override @Override
public boolean copyFromWorld(Vector pt, BaseBlock block) { public boolean copyFromWorld(Vector pt, BaseBlock block) {
// Signs
if (block instanceof SignBlock) { if (block instanceof SignBlock) {
// Signs
((SignBlock) block).setText(getSignText(pt)); ((SignBlock) block).setText(getSignText(pt));
return true; return true;
}
// Furnaces
} else if (block instanceof FurnaceBlock) { if (block instanceof FurnaceBlock) {
// Furnaces
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
@ -347,14 +352,16 @@ public class BukkitWorld extends LocalWorld {
we.setCookTime(bukkit.getCookTime()); we.setCookTime(bukkit.getCookTime());
((ContainerBlock) block).setItems(getContainerBlockContents(pt)); ((ContainerBlock) block).setItems(getContainerBlockContents(pt));
return true; return true;
}
// Chests/dispenser if (block instanceof ContainerBlock) {
} else if (block instanceof ContainerBlock) { // Chests/dispenser
((ContainerBlock) block).setItems(getContainerBlockContents(pt)); ((ContainerBlock) block).setItems(getContainerBlockContents(pt));
return true; return true;
}
// Mob spawners
} else if (block instanceof MobSpawnerBlock) { if (block instanceof MobSpawnerBlock) {
// Mob spawners
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
@ -364,18 +371,19 @@ public class BukkitWorld extends LocalWorld {
we.setMobType(bukkit.getCreatureTypeId()); we.setMobType(bukkit.getCreatureTypeId());
we.setDelay((short) bukkit.getDelay()); we.setDelay((short) bukkit.getDelay());
return true; return true;
}
// Note block
} else if (block instanceof NoteBlock) { if (block instanceof NoteBlock) {
// Note block
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
if (!(state instanceof org.bukkit.block.NoteBlock)) return false; if (!(state instanceof org.bukkit.block.NoteBlock)) return false;
org.bukkit.block.NoteBlock bukkit = (org.bukkit.block.NoteBlock)state; org.bukkit.block.NoteBlock bukkit = (org.bukkit.block.NoteBlock) state;
NoteBlock we = (NoteBlock) block; NoteBlock we = (NoteBlock) block;
we.setNote(bukkit.getRawNote()); we.setNote(bukkit.getRawNote());
} }
return false; return false;
} }
@ -395,7 +403,7 @@ public class BukkitWorld extends LocalWorld {
return false; return false;
} }
org.bukkit.block.ContainerBlock chest = (org.bukkit.block.ContainerBlock)state; org.bukkit.block.ContainerBlock chest = (org.bukkit.block.ContainerBlock) state;
Inventory inven = chest.getInventory(); Inventory inven = chest.getInventory();
inven.clear(); inven.clear();
return true; return true;
@ -472,7 +480,7 @@ public class BukkitWorld extends LocalWorld {
ItemStack bukkitItem = new ItemStack(item.getType(), item.getAmount(), ItemStack bukkitItem = new ItemStack(item.getType(), item.getAmount(),
(byte) item.getDamage()); (byte) item.getDamage());
world.dropItemNaturally(toLocation(pt), bukkitItem); world.dropItemNaturally(toLocation(pt), bukkitItem);
} }
/** /**
@ -499,7 +507,7 @@ public class BukkitWorld extends LocalWorld {
public int killMobs(Vector origin, int radius, boolean killPets) { public int killMobs(Vector origin, int radius, boolean killPets) {
int num = 0; int num = 0;
double radiusSq = Math.pow(radius, 2); double radiusSq = Math.pow(radius, 2);
for (LivingEntity ent : world.getLivingEntities()) { for (LivingEntity ent : world.getLivingEntities()) {
if (!killPets && ent instanceof Tameable && ((Tameable) ent).isTamed()) { if (!killPets && ent instanceof Tameable && ((Tameable) ent).isTamed()) {
continue; // tamed wolf continue; // tamed wolf
@ -512,10 +520,10 @@ public class BukkitWorld extends LocalWorld {
} }
} }
} }
return num; return num;
} }
/** /**
* Remove entities in an area. * Remove entities in an area.
* *
@ -527,54 +535,68 @@ public class BukkitWorld extends LocalWorld {
public int removeEntities(EntityType type, Vector origin, int radius) { public int removeEntities(EntityType type, Vector origin, int radius) {
int num = 0; int num = 0;
double radiusSq = Math.pow(radius, 2); double radiusSq = Math.pow(radius, 2);
for (Entity ent : world.getEntities()) { for (Entity ent : world.getEntities()) {
if (radius != -1 if (radius != -1
&& origin.distanceSq(BukkitUtil.toVector(ent.getLocation())) > radiusSq) { && origin.distanceSq(BukkitUtil.toVector(ent.getLocation())) > radiusSq) {
continue; continue;
} }
if (type == EntityType.ARROWS) { switch (type) {
case ARROWS:
if (ent instanceof Arrow) { if (ent instanceof Arrow) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.BOATS) { break;
case BOATS:
if (ent instanceof Boat) { if (ent instanceof Boat) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.ITEMS) { break;
case ITEMS:
if (ent instanceof Item) { if (ent instanceof Item) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.MINECARTS) { break;
case MINECARTS:
if (ent instanceof Minecart) { if (ent instanceof Minecart) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.PAINTINGS) { break;
case PAINTINGS:
if (ent instanceof Painting) { if (ent instanceof Painting) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.TNT) { break;
case TNT:
if (ent instanceof TNTPrimed) { if (ent instanceof TNTPrimed) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.XP_ORBS) { break;
case XP_ORBS:
if (ent instanceof ExperienceOrb) { if (ent instanceof ExperienceOrb) {
ent.remove(); ent.remove();
++num; ++num;
} }
break;
} }
} }
return num; return num;
} }
private Location toLocation(Vector pt) { private Location toLocation(Vector pt) {
return new Location(world, pt.getX(), pt.getY(), pt.getZ()); return new Location(world, pt.getX(), pt.getY(), pt.getZ());
} }
@ -639,22 +661,22 @@ public class BukkitWorld extends LocalWorld {
if (!(state instanceof org.bukkit.block.ContainerBlock)) { if (!(state instanceof org.bukkit.block.ContainerBlock)) {
return new BaseItemStack[0]; return new BaseItemStack[0];
} }
org.bukkit.block.ContainerBlock container = (org.bukkit.block.ContainerBlock) state; org.bukkit.block.ContainerBlock container = (org.bukkit.block.ContainerBlock) state;
Inventory inven = container.getInventory(); Inventory inven = container.getInventory();
int size = inven.getSize(); int size = inven.getSize();
BaseItemStack[] contents = new BaseItemStack[size]; BaseItemStack[] contents = new BaseItemStack[size];
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
ItemStack bukkitStack = inven.getItem(i); ItemStack bukkitStack = inven.getItem(i);
if (bukkitStack.getTypeId() > 0) { if (bukkitStack.getTypeId() > 0) {
contents[i] = new BaseItemStack( contents[i] = new BaseItemStack(
bukkitStack.getTypeId(), bukkitStack.getTypeId(),
bukkitStack.getAmount(), bukkitStack.getAmount(),
bukkitStack.getDurability()); bukkitStack.getDurability());
} }
} }
return contents; return contents;
} }
@ -674,11 +696,11 @@ public class BukkitWorld extends LocalWorld {
if (!(state instanceof org.bukkit.block.ContainerBlock)) { if (!(state instanceof org.bukkit.block.ContainerBlock)) {
return false; return false;
} }
org.bukkit.block.ContainerBlock chest = (org.bukkit.block.ContainerBlock)state; org.bukkit.block.ContainerBlock chest = (org.bukkit.block.ContainerBlock) state;
Inventory inven = chest.getInventory(); Inventory inven = chest.getInventory();
int size = inven.getSize(); int size = inven.getSize();
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
if (i >= contents.length) { if (i >= contents.length) {
break; break;
@ -686,16 +708,16 @@ public class BukkitWorld extends LocalWorld {
if (contents[i] != null) { if (contents[i] != null) {
inven.setItem(i, new ItemStack(contents[i].getType(), inven.setItem(i, new ItemStack(contents[i].getType(),
contents[i].getAmount(), contents[i].getAmount(),
(byte) contents[i].getDamage())); (byte) contents[i].getDamage()));
} else { } else {
inven.setItem(i, null); inven.setItem(i, null);
} }
} }
return true; return true;
} }
/** /**
* Returns whether a block has a valid ID. * Returns whether a block has a valid ID.
* *
@ -719,7 +741,7 @@ public class BukkitWorld extends LocalWorld {
if (!(other instanceof BukkitWorld)) { if (!(other instanceof BukkitWorld)) {
return false; return false;
} }
return ((BukkitWorld) other).world.equals(world); return ((BukkitWorld) other).world.equals(world);
} }
@ -761,7 +783,7 @@ public class BukkitWorld extends LocalWorld {
final Object notchChunk = World_getChunkFromChunkCoords.invoke(notchWorld, chunkX, chunkZ); final Object notchChunk = World_getChunkFromChunkCoords.invoke(notchWorld, chunkX, chunkZ);
// Fix skylight // Fix skylight
final byte[] blocks = (byte[])Chunk_blocks.get(notchChunk); final byte[] blocks = (byte[]) Chunk_blocks.get(notchChunk);
final int length = blocks.length; final int length = blocks.length;
Chunk_skylightMap.set(notchChunk, NibbleArray_ctor.newInstance(length, 7)); Chunk_skylightMap.set(notchChunk, NibbleArray_ctor.newInstance(length, 7));
@ -781,7 +803,7 @@ public class BukkitWorld extends LocalWorld {
for (int y = 0; y < chunkSizeY; ++y) { for (int y = 0; y < chunkSizeY; ++y) {
final int index = y + z * chunkSizeY + x * chunkSizeY * chunkSizeZ; final int index = y + z * chunkSizeY + x * chunkSizeY * chunkSizeZ;
byte blockID = blocks[index]; byte blockID = blocks[index];
if (!BlockType.emitsLight(blockID)) { if (!BlockType.emitsLight(blockID)) {
if (xBorder || zBorder && BlockType.isTranslucent(blockID)) { if (xBorder || zBorder && BlockType.isTranslucent(blockID)) {
lightEmitters.add(chunk.getBlock(x, y, z).getState()); lightEmitters.add(chunk.getBlock(x, y, z).getState());
if (blockID == 20) { if (blockID == 20) {
@ -789,7 +811,7 @@ public class BukkitWorld extends LocalWorld {
} else { } else {
blocks[index] = 20; blocks[index] = 20;
} }
} }
continue; continue;
} }

Datei anzeigen

@ -44,7 +44,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
return false; return false;
} }
} }
public boolean setRawTypeIdAndData(int x, int y, int z, int typeId, int data) { public boolean setRawTypeIdAndData(int x, int y, int z, int typeId, int data) {
try { try {
return editSession.setBlock(new Vector(x, y, z), new BaseBlock(typeId, data)); return editSession.setBlock(new Vector(x, y, z), new BaseBlock(typeId, data));

Datei anzeigen

@ -30,10 +30,10 @@ import com.sk89q.worldedit.WorldEdit;
* @author sk89q * @author sk89q
*/ */
public class SessionTimer implements Runnable { public class SessionTimer implements Runnable {
private WorldEdit worldEdit; private WorldEdit worldEdit;
private SessionCheck checker; private SessionCheck checker;
public SessionTimer(WorldEdit worldEdit, final Server server) { public SessionTimer(WorldEdit worldEdit, final Server server) {
this.worldEdit = worldEdit; this.worldEdit = worldEdit;
this.checker = new SessionCheck() { this.checker = new SessionCheck() {

Datei anzeigen

@ -22,13 +22,13 @@ package com.sk89q.worldedit.bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
public class WorldEditAPI { public class WorldEditAPI {
private WorldEditPlugin plugin; private WorldEditPlugin plugin;
public WorldEditAPI(WorldEditPlugin plugin) { public WorldEditAPI(WorldEditPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
/** /**
* Get the session for a player. * Get the session for a player.
* *

Datei anzeigen

@ -32,7 +32,7 @@ public class WorldEditCriticalPlayerListener extends PlayerListener {
* Plugin. * Plugin.
*/ */
private WorldEditPlugin plugin; private WorldEditPlugin plugin;
/** /**
* Construct the object; * Construct the object;
* *

Datei anzeigen

@ -88,7 +88,7 @@ public class WorldEditPlayerListener extends PlayerListener {
} }
private boolean ignoreLeftClickAir = false; private boolean ignoreLeftClickAir = false;
/** /**
* Called when a player interacts * Called when a player interacts
* *
@ -115,9 +115,11 @@ public class WorldEditPlayerListener extends PlayerListener {
} }
if (!ignoreLeftClickAir) { if (!ignoreLeftClickAir) {
final int taskId = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { public void run() { final int taskId = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
ignoreLeftClickAir = false; public void run() {
}}, 2); ignoreLeftClickAir = false;
}
}, 2);
if (taskId != -1) { if (taskId != -1) {
ignoreLeftClickAir = true; ignoreLeftClickAir = true;

Datei anzeigen

@ -53,7 +53,7 @@ public class WorldEditPlugin extends JavaPlugin {
* WorldEdit messages get sent here. * WorldEdit messages get sent here.
*/ */
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit"); private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
/** /**
* The server interface that all server-related API goes through. * The server interface that all server-related API goes through.
*/ */
@ -66,7 +66,7 @@ public class WorldEditPlugin extends JavaPlugin {
* Deprecated API. * Deprecated API.
*/ */
private WorldEditAPI api; private WorldEditAPI api;
/** /**
* Holds the configuration for WorldEdit. * Holds the configuration for WorldEdit.
*/ */
@ -93,15 +93,15 @@ public class WorldEditPlugin extends JavaPlugin {
// Create the default configuration file // Create the default configuration file
createDefaultConfiguration("config.yml"); createDefaultConfiguration("config.yml");
// Set up configuration and such, including the permissions // Set up configuration and such, including the permissions
// resolver // resolver
config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config.yml"), true), logger); config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config.yml"), true), logger);
perms = new PermissionsResolverManager(this, "WorldEdit", logger); perms = new PermissionsResolverManager(this, "WorldEdit", logger);
// Load the configuration // Load the configuration
loadConfiguration(); loadConfiguration();
// Setup interfaces // Setup interfaces
server = new BukkitServerInterface(this, getServer()); server = new BukkitServerInterface(this, getServer());
controller = new WorldEdit(server, config); controller = new WorldEdit(server, config);
@ -109,8 +109,8 @@ public class WorldEditPlugin extends JavaPlugin {
// Now we can register events! // Now we can register events!
registerEvents(); registerEvents();
getServer().getScheduler().scheduleAsyncRepeatingTask(this, getServer().getScheduler().scheduleAsyncRepeatingTask(this,
new SessionTimer(controller, getServer()), 120, 120); new SessionTimer(controller, getServer()), 120, 120);
} }
@ -128,7 +128,7 @@ public class WorldEditPlugin extends JavaPlugin {
config.unload(); config.unload();
this.getServer().getScheduler().cancelTasks(this); this.getServer().getScheduler().cancelTasks(this);
} }
/** /**
* Loads and reloads all configuration. * Loads and reloads all configuration.
*/ */
@ -200,20 +200,22 @@ public class WorldEditPlugin extends JavaPlugin {
while ((length = input.read(buf)) > 0) { while ((length = input.read(buf)) > 0) {
output.write(buf, 0, length); output.write(buf, 0, length);
} }
logger.info(getDescription().getName() logger.info(getDescription().getName()
+ ": Default configuration file written: " + name); + ": Default configuration file written: " + name);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
try { try {
if (input != null) if (input != null) {
input.close(); input.close();
}
} catch (IOException e) {} } catch (IOException e) {}
try { try {
if (output != null) if (output != null) {
output.close(); output.close();
}
} catch (IOException e) {} } catch (IOException e) {}
} }
} }
@ -231,20 +233,20 @@ public class WorldEditPlugin extends JavaPlugin {
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
return true; return true;
} }
Player player = (Player)sender; Player player = (Player) sender;
// Add the command to the array because the underlying command handling // Add the command to the array because the underlying command handling
// code of WorldEdit expects it // code of WorldEdit expects it
String[] split = new String[args.length + 1]; String[] split = new String[args.length + 1];
System.arraycopy(args, 0, split, 1, args.length); System.arraycopy(args, 0, split, 1, args.length);
split[0] = "/" + cmd.getName(); split[0] = "/" + cmd.getName();
controller.handleCommand(wrapPlayer(player), split); controller.handleCommand(wrapPlayer(player), split);
return true; return true;
} }
/** /**
* Gets the session for the player. * Gets the session for the player.
* *
@ -254,7 +256,7 @@ public class WorldEditPlugin extends JavaPlugin {
public LocalSession getSession(Player player) { public LocalSession getSession(Player player) {
return controller.getSession(wrapPlayer(player)); return controller.getSession(wrapPlayer(player));
} }
/** /**
* Gets the session for the player. * Gets the session for the player.
* *
@ -265,15 +267,14 @@ public class WorldEditPlugin extends JavaPlugin {
LocalPlayer wePlayer = wrapPlayer(player); LocalPlayer wePlayer = wrapPlayer(player);
LocalSession session = controller.getSession(wePlayer); LocalSession session = controller.getSession(wePlayer);
BlockBag blockBag = session.getBlockBag(wePlayer); BlockBag blockBag = session.getBlockBag(wePlayer);
EditSession editSession = EditSession editSession =
new EditSession(wePlayer.getWorld(), new EditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag);
session.getBlockChangeLimit(), blockBag);
editSession.enableQueue(); editSession.enableQueue();
return editSession; return editSession;
} }
/** /**
* Remember an edit session. * Remember an edit session.
* *
@ -283,13 +284,13 @@ public class WorldEditPlugin extends JavaPlugin {
public void remember(Player player, EditSession editSession) { public void remember(Player player, EditSession editSession) {
LocalPlayer wePlayer = wrapPlayer(player); LocalPlayer wePlayer = wrapPlayer(player);
LocalSession session = controller.getSession(wePlayer); LocalSession session = controller.getSession(wePlayer);
session.remember(editSession); session.remember(editSession);
editSession.flushQueue(); editSession.flushQueue();
controller.flushBlockBag(wePlayer, editSession); controller.flushBlockBag(wePlayer, editSession);
} }
/** /**
* Wrap an operation into an EditSession. * Wrap an operation into an EditSession.
* *
@ -301,7 +302,7 @@ public class WorldEditPlugin extends JavaPlugin {
throws Throwable { throws Throwable {
LocalPlayer wePlayer = wrapPlayer(player); LocalPlayer wePlayer = wrapPlayer(player);
LocalSession session = controller.getSession(wePlayer); LocalSession session = controller.getSession(wePlayer);
EditSession editSession = createEditSession(player); EditSession editSession = createEditSession(player);
try { try {
op.run(session, wePlayer, editSession); op.run(session, wePlayer, editSession);
@ -309,7 +310,7 @@ public class WorldEditPlugin extends JavaPlugin {
remember(player, editSession); remember(player, editSession);
} }
} }
/** /**
* Get the API. * Get the API.
* *
@ -319,7 +320,7 @@ public class WorldEditPlugin extends JavaPlugin {
public WorldEditAPI getAPI() { public WorldEditAPI getAPI() {
return api; return api;
} }
/** /**
* Returns the configuration used by WorldEdit. * Returns the configuration used by WorldEdit.
* *
@ -328,7 +329,7 @@ public class WorldEditPlugin extends JavaPlugin {
public BukkitConfiguration getLocalConfiguration() { public BukkitConfiguration getLocalConfiguration() {
return config; return config;
} }
/** /**
* Get the permissions resolver in use. * Get the permissions resolver in use.
* *
@ -337,7 +338,7 @@ public class WorldEditPlugin extends JavaPlugin {
public PermissionsResolverManager getPermissionsResolver() { public PermissionsResolverManager getPermissionsResolver() {
return perms; return perms;
} }
/** /**
* Used to wrap a Bukkit Player as a LocalPlayer. * Used to wrap a Bukkit Player as a LocalPlayer.
* *
@ -347,7 +348,7 @@ public class WorldEditPlugin extends JavaPlugin {
public BukkitPlayer wrapPlayer(Player player) { public BukkitPlayer wrapPlayer(Player player) {
return new BukkitPlayer(this, this.server, player); return new BukkitPlayer(this, this.server, player);
} }
/** /**
* Get the server interface. * Get the server interface.
* *
@ -356,7 +357,7 @@ public class WorldEditPlugin extends JavaPlugin {
public ServerInterface getServerInterface() { public ServerInterface getServerInterface() {
return server; return server;
} }
/** /**
* Get WorldEdit. * Get WorldEdit.
* *
@ -365,7 +366,7 @@ public class WorldEditPlugin extends JavaPlugin {
public WorldEdit getWorldEdit() { public WorldEdit getWorldEdit() {
return controller; return controller;
} }
/** /**
* Gets the region selection for the player. * Gets the region selection for the player.
* *
@ -379,18 +380,18 @@ public class WorldEditPlugin extends JavaPlugin {
if (!player.isOnline()) { if (!player.isOnline()) {
throw new IllegalArgumentException("Offline player not allowed"); throw new IllegalArgumentException("Offline player not allowed");
} }
LocalSession session = controller.getSession(wrapPlayer(player)); LocalSession session = controller.getSession(wrapPlayer(player));
RegionSelector selector = session.getRegionSelector(); RegionSelector selector = session.getRegionSelector();
try { try {
Region region = selector.getRegion(); Region region = selector.getRegion();
World world = ((BukkitWorld) session.getSelectionWorld()).getWorld(); World world = ((BukkitWorld) session.getSelectionWorld()).getWorld();
if (region instanceof CuboidRegion) { if (region instanceof CuboidRegion) {
return new CuboidSelection(world, selector, (CuboidRegion)region); return new CuboidSelection(world, selector, (CuboidRegion) region);
} else if (region instanceof Polygonal2DRegion) { } else if (region instanceof Polygonal2DRegion) {
return new Polygonal2DSelection(world, selector, (Polygonal2DRegion)region); return new Polygonal2DSelection(world, selector, (Polygonal2DRegion) region);
} else { } else {
return null; return null;
} }
@ -398,7 +399,7 @@ public class WorldEditPlugin extends JavaPlugin {
return null; return null;
} }
} }
/** /**
* Sets the region selection for a player. * Sets the region selection for a player.
* *
@ -415,8 +416,8 @@ public class WorldEditPlugin extends JavaPlugin {
if (selection == null) { if (selection == null) {
throw new IllegalArgumentException("Null selection not allowed"); throw new IllegalArgumentException("Null selection not allowed");
} }
LocalSession session = controller.getSession(wrapPlayer(player)); LocalSession session = controller.getSession(wrapPlayer(player));
RegionSelector sel = selection.getRegionSelector(); RegionSelector sel = selection.getRegionSelector();
session.setRegionSelector(new BukkitWorld(player.getWorld()), sel); session.setRegionSelector(new BukkitWorld(player.getWorld()), sel);
session.dispatchCUISelection(wrapPlayer(player)); session.dispatchCUISelection(wrapPlayer(player));

Datei anzeigen

@ -29,26 +29,26 @@ import com.sk89q.worldedit.regions.*;
public class CuboidSelection extends RegionSelection { public class CuboidSelection extends RegionSelection {
protected CuboidRegion cuboid; protected CuboidRegion cuboid;
public CuboidSelection(World world, Location pt1, Location pt2) { public CuboidSelection(World world, Location pt1, Location pt2) {
this(world, BukkitUtil.toVector(pt1), BukkitUtil.toVector(pt2)); this(world, BukkitUtil.toVector(pt1), BukkitUtil.toVector(pt2));
} }
public CuboidSelection(World world, Vector pt1, Vector pt2) { public CuboidSelection(World world, Vector pt1, Vector pt2) {
super(world); super(world);
if (pt1 == null) { if (pt1 == null) {
throw new IllegalArgumentException("Null point 1 not permitted"); throw new IllegalArgumentException("Null point 1 not permitted");
} }
if (pt2 == null) { if (pt2 == null) {
throw new IllegalArgumentException("Null point 2 not permitted"); throw new IllegalArgumentException("Null point 2 not permitted");
} }
CuboidRegionSelector sel = new CuboidRegionSelector(); CuboidRegionSelector sel = new CuboidRegionSelector();
sel.selectPrimary(pt1); sel.selectPrimary(pt1);
sel.selectSecondary(pt2); sel.selectSecondary(pt2);
try { try {
cuboid = sel.getRegion(); cuboid = sel.getRegion();
} catch (IncompleteRegionException e) { } catch (IncompleteRegionException e) {
@ -58,7 +58,7 @@ public class CuboidSelection extends RegionSelection {
setRegionSelector(sel); setRegionSelector(sel);
setRegion(cuboid); setRegion(cuboid);
} }
public CuboidSelection(World world, RegionSelector sel, CuboidRegion region) { public CuboidSelection(World world, RegionSelector sel, CuboidRegion region) {
super(world, sel, region); super(world, sel, region);
this.cuboid = region; this.cuboid = region;

Datei anzeigen

@ -28,13 +28,13 @@ import com.sk89q.worldedit.regions.*;
public class Polygonal2DSelection extends RegionSelection { public class Polygonal2DSelection extends RegionSelection {
protected Polygonal2DRegion poly2d; protected Polygonal2DRegion poly2d;
public Polygonal2DSelection(World world, RegionSelector sel, Polygonal2DRegion region) { public Polygonal2DSelection(World world, RegionSelector sel, Polygonal2DRegion region) {
super(world, sel, region); super(world, sel, region);
this.poly2d = region; this.poly2d = region;
} }
public Polygonal2DSelection(World world, List<BlockVector2D> points, int minY, int maxY) { public Polygonal2DSelection(World world, List<BlockVector2D> points, int minY, int maxY) {
super(world); super(world);
minY = Math.min(Math.max(0, minY), 127); minY = Math.min(Math.max(0, minY), 127);
@ -48,7 +48,7 @@ public class Polygonal2DSelection extends RegionSelection {
setRegionSelector(sel); setRegionSelector(sel);
setRegion(poly2d); setRegion(poly2d);
} }
public List<BlockVector2D> getNativePoints() { public List<BlockVector2D> getNativePoints() {
return Collections.unmodifiableList(poly2d.getPoints()); return Collections.unmodifiableList(poly2d.getPoints());
} }

Datei anzeigen

@ -32,29 +32,29 @@ public abstract class RegionSelection implements Selection {
private World world; private World world;
private RegionSelector selector; private RegionSelector selector;
private Region region; private Region region;
public RegionSelection(World world) { public RegionSelection(World world) {
this.world = world; this.world = world;
} }
public RegionSelection(World world, RegionSelector selector, Region region) { public RegionSelection(World world, RegionSelector selector, Region region) {
this.world = world; this.world = world;
this.region = region; this.region = region;
this.selector = selector; this.selector = selector;
} }
protected Region getRegion() { protected Region getRegion() {
return region; return region;
} }
protected void setRegion(Region region) { protected void setRegion(Region region) {
this.region = region; this.region = region;
} }
public RegionSelector getRegionSelector() { public RegionSelector getRegionSelector() {
return selector; return selector;
} }
protected void setRegionSelector(RegionSelector selector) { protected void setRegionSelector(RegionSelector selector) {
this.selector = selector; this.selector = selector;
} }
@ -99,7 +99,7 @@ public abstract class RegionSelection implements Selection {
if (!pt.getWorld().equals(world)) { if (!pt.getWorld().equals(world)) {
return false; return false;
} }
return region.contains(toVector(pt)); return region.contains(toVector(pt));
} }

Datei anzeigen

@ -31,70 +31,70 @@ public interface Selection {
* @return min. point * @return min. point
*/ */
public Location getMinimumPoint(); public Location getMinimumPoint();
/** /**
* Get the lower point of a region. * Get the lower point of a region.
* *
* @return min. point * @return min. point
*/ */
public Vector getNativeMinimumPoint(); public Vector getNativeMinimumPoint();
/** /**
* Get the upper point of a region. * Get the upper point of a region.
* *
* @return max. point * @return max. point
*/ */
public Location getMaximumPoint(); public Location getMaximumPoint();
/** /**
* Get the upper point of a region. * Get the upper point of a region.
* *
* @return max. point * @return max. point
*/ */
public Vector getNativeMaximumPoint(); public Vector getNativeMaximumPoint();
/** /**
* Get the region selector. This is for internal use. * Get the region selector. This is for internal use.
* *
* @return * @return
*/ */
public RegionSelector getRegionSelector(); public RegionSelector getRegionSelector();
/** /**
* Get the world. * Get the world.
* *
* @return * @return
*/ */
public World getWorld(); public World getWorld();
/** /**
* Get the number of blocks in the region. * Get the number of blocks in the region.
* *
* @return number of blocks * @return number of blocks
*/ */
public int getArea(); public int getArea();
/** /**
* Get X-size. * Get X-size.
* *
* @return width * @return width
*/ */
public int getWidth(); public int getWidth();
/** /**
* Get Y-size. * Get Y-size.
* *
* @return height * @return height
*/ */
public int getHeight(); public int getHeight();
/** /**
* Get Z-size. * Get Z-size.
* *
* @return length * @return length
*/ */
public int getLength(); public int getLength();
/** /**
* Returns true based on whether the region contains the point, * Returns true based on whether the region contains the point,
* *

Datei anzeigen

@ -75,7 +75,7 @@ public class BrushCommands {
Pattern fill = we.getBlockPattern(player, args.getString(0)); Pattern fill = we.getBlockPattern(player, args.getString(0));
tool.setFill(fill); tool.setFill(fill);
tool.setSize(radius); tool.setSize(radius);
if (args.hasFlag('h')) { if (args.hasFlag('h')) {
tool.setBrush(new HollowSphereBrush(), "worldedit.brush.sphere"); tool.setBrush(new HollowSphereBrush(), "worldedit.brush.sphere");
} else { } else {
@ -119,13 +119,13 @@ public class BrushCommands {
Pattern fill = we.getBlockPattern(player, args.getString(0)); Pattern fill = we.getBlockPattern(player, args.getString(0));
tool.setFill(fill); tool.setFill(fill);
tool.setSize(radius); tool.setSize(radius);
if (args.hasFlag('h')) { if (args.hasFlag('h')) {
tool.setBrush(new HollowCylinderBrush(height), "worldedit.brush.cylinder"); tool.setBrush(new HollowCylinderBrush(height), "worldedit.brush.cylinder");
} else { } else {
tool.setBrush(new CylinderBrush(height), "worldedit.brush.cylinder"); tool.setBrush(new CylinderBrush(height), "worldedit.brush.cylinder");
} }
player.print(String.format("Cylinder brush shape equipped (%.0f by %d).", player.print(String.format("Cylinder brush shape equipped (%.0f by %d).",
radius, height)); radius, height));
} }
@ -144,14 +144,14 @@ public class BrushCommands {
throws WorldEditException { throws WorldEditException {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
CuboidClipboard clipboard = session.getClipboard(); CuboidClipboard clipboard = session.getClipboard();
if (clipboard == null) { if (clipboard == null) {
player.printError("Copy something first."); player.printError("Copy something first.");
return; return;
} }
Vector size = clipboard.getSize(); Vector size = clipboard.getSize();
if (size.getBlockX() > config.maxBrushRadius if (size.getBlockX() > config.maxBrushRadius
@ -164,7 +164,7 @@ public class BrushCommands {
BrushTool tool = session.getBrushTool(player.getItemInHand()); BrushTool tool = session.getBrushTool(player.getItemInHand());
tool.setBrush(new ClipboardBrush(clipboard, args.hasFlag('a')), "worldedit.brush.clipboard"); tool.setBrush(new ClipboardBrush(clipboard, args.hasFlag('a')), "worldedit.brush.clipboard");
player.print("Clipboard brush shape equipped."); player.print("Clipboard brush shape equipped.");
} }
@ -199,7 +199,7 @@ public class BrushCommands {
player.print(String.format("Smooth brush equipped (%.0f x %dx, using " + (args.hasFlag('n') ? "natural blocks only" : "any block") + ").", player.print(String.format("Smooth brush equipped (%.0f x %dx, using " + (args.hasFlag('n') ? "natural blocks only" : "any block") + ").",
radius, iterations)); radius, iterations));
} }
@Command( @Command(
aliases = { "ex", "extinguish" }, aliases = { "ex", "extinguish" },
usage = "[radius]", usage = "[radius]",

Datei anzeigen

@ -97,7 +97,7 @@ public class ChunkCommands {
player.print("Note that this command does not yet support the mcregion format."); player.print("Note that this command does not yet support the mcregion format.");
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks(); Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
FileOutputStream out = null; FileOutputStream out = null;
@ -129,7 +129,9 @@ public class ChunkCommands {
player.printError("Error occurred: " + e.getMessage()); player.printError("Error occurred: " + e.getMessage());
} finally { } finally {
if (out != null) { if (out != null) {
try { out.close(); } catch (IOException ie) {} try {
out.close();
} catch (IOException ie) { }
} }
} }
} else if (config.shellSaveType.equalsIgnoreCase("bash")) { } else if (config.shellSaveType.equalsIgnoreCase("bash")) {

Datei anzeigen

@ -82,7 +82,7 @@ public class ClipboardCommands {
if (args.argsLength() > 0) { if (args.argsLength() > 0) {
block = we.getBlock(player, args.getString(0)); block = we.getBlock(player, args.getString(0));
} }
Region region = session.getSelection(player.getWorld()); Region region = session.getSelection(player.getWorld());
Vector min = region.getMinimumPoint(); Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint(); Vector max = region.getMaximumPoint();
@ -97,7 +97,7 @@ public class ClipboardCommands {
editSession.setBlocks(session.getSelection(player.getWorld()), block); editSession.setBlocks(session.getSelection(player.getWorld()), block);
player.print("Block(s) cut."); player.print("Block(s) cut.");
} }
@Command( @Command(
aliases = { "/paste" }, aliases = { "/paste" },
usage = "", usage = "",
@ -114,7 +114,7 @@ public class ClipboardCommands {
boolean atOrigin = args.hasFlag('o'); boolean atOrigin = args.hasFlag('o');
boolean pasteNoAir = args.hasFlag('a'); boolean pasteNoAir = args.hasFlag('a');
if (atOrigin) { if (atOrigin) {
Vector pos = session.getClipboard().getOrigin(); Vector pos = session.getClipboard().getOrigin();
session.getClipboard().place(editSession, pos, pasteNoAir); session.getClipboard().place(editSession, pos, pasteNoAir);
@ -141,7 +141,7 @@ public class ClipboardCommands {
throws WorldEditException { throws WorldEditException {
int angle = args.getInteger(0); int angle = args.getInteger(0);
if (angle % 90 == 0) { if (angle % 90 == 0) {
CuboidClipboard clipboard = session.getClipboard(); CuboidClipboard clipboard = session.getClipboard();
clipboard.rotate2D(angle); clipboard.rotate2D(angle);
@ -171,7 +171,7 @@ public class ClipboardCommands {
clipboard.flip(dir, args.hasFlag('p')); clipboard.flip(dir, args.hasFlag('p'));
player.print("Clipboard flipped."); player.print("Clipboard flipped.");
} }
@Command( @Command(
aliases = { "/load" }, aliases = { "/load" },
usage = "<filename>", usage = "<filename>",
@ -189,7 +189,7 @@ public class ClipboardCommands {
String filename = args.getString(0); String filename = args.getString(0);
File dir = we.getWorkingDirectoryFile(config.saveDir); File dir = we.getWorkingDirectoryFile(config.saveDir);
File f = we.getSafeOpenFile(player, dir, filename, "schematic", File f = we.getSafeOpenFile(player, dir, filename, "schematic",
new String[] {"schematic"}); new String[] { "schematic" });
try { try {
String filePath = f.getCanonicalPath(); String filePath = f.getCanonicalPath();
@ -208,7 +208,7 @@ public class ClipboardCommands {
player.printError("Schematic could not read or it does not exist: " + e.getMessage()); player.printError("Schematic could not read or it does not exist: " + e.getMessage());
} }
} }
@Command( @Command(
aliases = { "/save" }, aliases = { "/save" },
usage = "<filename>", usage = "<filename>",
@ -227,7 +227,7 @@ public class ClipboardCommands {
File dir = we.getWorkingDirectoryFile(config.saveDir); File dir = we.getWorkingDirectoryFile(config.saveDir);
File f = we.getSafeSaveFile(player, dir, filename, "schematic", File f = we.getSafeSaveFile(player, dir, filename, "schematic",
new String[] {"schematic"}); new String[] { "schematic" });
if (!dir.exists()) { if (!dir.exists()) {
if (!dir.mkdir()) { if (!dir.mkdir()) {
@ -252,7 +252,7 @@ public class ClipboardCommands {
player.printError("Schematic could not written: " + e.getMessage()); player.printError("Schematic could not written: " + e.getMessage());
} }
} }
@Command( @Command(
aliases = { "clearclipboard" }, aliases = { "clearclipboard" },
usage = "", usage = "",

Datei anzeigen

@ -56,7 +56,7 @@ public class GeneralCommands {
return; return;
} }
} }
session.setBlockChangeLimit(limit); session.setBlockChangeLimit(limit);
player.print("Block change limit set to " + limit + "."); player.print("Block change limit set to " + limit + ".");
} }
@ -147,27 +147,27 @@ public class GeneralCommands {
String query = args.getString(0).trim().toLowerCase(); String query = args.getString(0).trim().toLowerCase();
boolean blocksOnly = args.hasFlag('b'); boolean blocksOnly = args.hasFlag('b');
boolean itemsOnly = args.hasFlag('i'); boolean itemsOnly = args.hasFlag('i');
try { try {
int id = Integer.parseInt(query); int id = Integer.parseInt(query);
ItemType type = ItemType.fromID(id); ItemType type = ItemType.fromID(id);
if (type != null) { if (type != null) {
player.print("#" + type.getID() + " (" + type.getName() + ")"); player.print("#" + type.getID() + " (" + type.getName() + ")");
} else { } else {
player.printError("No item found by ID " + id); player.printError("No item found by ID " + id);
} }
return; return;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
if (query.length() <= 2) { if (query.length() <= 2) {
player.printError("Enter a longer search string (len > 2)."); player.printError("Enter a longer search string (len > 2).");
return; return;
} }
if (!blocksOnly && !itemsOnly) { if (!blocksOnly && !itemsOnly) {
player.print("Searching for: " + query); player.print("Searching for: " + query);
} else if (blocksOnly && itemsOnly) { } else if (blocksOnly && itemsOnly) {
@ -178,23 +178,23 @@ public class GeneralCommands {
} else { } else {
player.print("Searching for items: " + query); player.print("Searching for items: " + query);
} }
int found = 0; int found = 0;
for (ItemType type : ItemType.values()) { for (ItemType type : ItemType.values()) {
if (found >= 15) { if (found >= 15) {
player.print("Too many results!"); player.print("Too many results!");
break; break;
} }
if (blocksOnly && type.getID() > 255) { if (blocksOnly && type.getID() > 255) {
continue; continue;
} }
if (itemsOnly && type.getID() <= 255) { if (itemsOnly && type.getID() <= 255) {
continue; continue;
} }
for (String alias : type.getAliases()) { for (String alias : type.getAliases()) {
if (alias.contains(query)) { if (alias.contains(query)) {
player.print("#" + type.getID() + " (" + type.getName() + ")"); player.print("#" + type.getID() + " (" + type.getName() + ")");
@ -203,7 +203,7 @@ public class GeneralCommands {
} }
} }
} }
if (found == 0) { if (found == 0) {
player.printError("No items found."); player.printError("No items found.");
} }

Datei anzeigen

@ -229,12 +229,12 @@ public class GenerationCommands {
player.printError("Tree type '" + args.getString(1) + "' is unknown."); player.printError("Tree type '" + args.getString(1) + "' is unknown.");
return; return;
} }
int affected = editSession.makeForest(player.getPosition(), int affected = editSession.makeForest(player.getPosition(),
size, density, new TreeGenerator(type)); size, density, new TreeGenerator(type));
player.print(affected + " trees created."); player.print(affected + " trees created.");
} }
@Command( @Command(
aliases = { "pumpkins" }, aliases = { "pumpkins" },
usage = "[size]", usage = "[size]",
@ -253,7 +253,7 @@ public class GenerationCommands {
int affected = editSession.makePumpkinPatches(player.getPosition(), size); int affected = editSession.makePumpkinPatches(player.getPosition(), size);
player.print(affected + " pumpkin patches created."); player.print(affected + " pumpkin patches created.");
} }
@Command( @Command(
aliases = { "/pyramid" }, aliases = { "/pyramid" },
usage = "<block> <size>", usage = "<block> <size>",
@ -270,13 +270,13 @@ public class GenerationCommands {
Pattern block = we.getBlockPattern(player, args.getString(0)); Pattern block = we.getBlockPattern(player, args.getString(0));
int size = Math.max(1, args.getInteger(1)); int size = Math.max(1, args.getInteger(1));
Vector pos = session.getPlacementPosition(player); Vector pos = session.getPlacementPosition(player);
int affected = editSession.makePyramid(pos, block, size, true); int affected = editSession.makePyramid(pos, block, size, true);
player.findFreePosition(); player.findFreePosition();
player.print(affected + " block(s) have been created."); player.print(affected + " block(s) have been created.");
} }
@Command( @Command(
aliases = { "/hpyramid" }, aliases = { "/hpyramid" },
usage = "<block> <size>", usage = "<block> <size>",
@ -293,9 +293,9 @@ public class GenerationCommands {
Pattern block = we.getBlockPattern(player, args.getString(0)); Pattern block = we.getBlockPattern(player, args.getString(0));
int size = Math.max(1, args.getInteger(1)); int size = Math.max(1, args.getInteger(1));
Vector pos = session.getPlacementPosition(player); Vector pos = session.getPlacementPosition(player);
int affected = editSession.makePyramid(pos, block, size, false); int affected = editSession.makePyramid(pos, block, size, false);
player.findFreePosition(); player.findFreePosition();
player.print(affected + " block(s) have been created."); player.print(affected + " block(s) have been created.");
} }

Datei anzeigen

@ -50,7 +50,7 @@ public class HistoryCommands {
} else { } else {
player.checkPermission("worldedit.history.undo.other"); player.checkPermission("worldedit.history.undo.other");
LocalSession sess = we.getSession(args.getString(1)); LocalSession sess = we.getSession(args.getString(1));
if (sess == null){ if (sess == null) {
player.printError("Unable to find session for " + args.getString(1)); player.printError("Unable to find session for " + args.getString(1));
break; break;
} }
@ -65,7 +65,7 @@ public class HistoryCommands {
} }
} }
} }
@Command( @Command(
aliases = { "/redo", "redo" }, aliases = { "/redo", "redo" },
usage = "[times] [player]", usage = "[times] [player]",
@ -79,7 +79,7 @@ public class HistoryCommands {
throws WorldEditException { throws WorldEditException {
int times = Math.max(1, args.getInteger(0, 1)); int times = Math.max(1, args.getInteger(0, 1));
for (int i = 0; i < times; ++i) { for (int i = 0; i < times; ++i) {
EditSession redone; EditSession redone;
if (args.argsLength() < 2) { if (args.argsLength() < 2) {
@ -87,7 +87,7 @@ public class HistoryCommands {
} else { } else {
player.checkPermission("worldedit.history.redo.other"); player.checkPermission("worldedit.history.redo.other");
LocalSession sess = we.getSession(args.getString(1)); LocalSession sess = we.getSession(args.getString(1));
if (sess == null){ if (sess == null) {
player.printError("Unable to find session for " + args.getString(1)); player.printError("Unable to find session for " + args.getString(1));
break; break;
} }

Datei anzeigen

@ -74,7 +74,6 @@ public class NavigationCommands {
} else { } else {
player.print((ascentLevels != 1) ? "Ascended " + Integer.toString(ascentLevels) + " levels." : "Ascended a level."); player.print((ascentLevels != 1) ? "Ascended " + Integer.toString(ascentLevels) + " levels." : "Ascended a level.");
} }
} }
@Command( @Command(
@ -103,7 +102,6 @@ public class NavigationCommands {
} else { } else {
player.print((descentLevels != 1) ? "Descended " + Integer.toString(descentLevels) + " levels." : "Descended a level."); player.print((descentLevels != 1) ? "Descended " + Integer.toString(descentLevels) + " levels." : "Descended a level.");
} }
} }
@Command( @Command(
@ -128,7 +126,7 @@ public class NavigationCommands {
player.printError("No free spot above you found."); player.printError("No free spot above you found.");
} }
} }
@Command( @Command(
aliases = { "thru" }, aliases = { "thru" },
usage = "", usage = "",

Datei anzeigen

@ -19,7 +19,6 @@
package com.sk89q.worldedit.commands; package com.sk89q.worldedit.commands;
import java.util.Set; import java.util.Set;
import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandContext;
@ -57,16 +56,16 @@ public class RegionCommands {
throws WorldEditException { throws WorldEditException {
Pattern pattern = we.getBlockPattern(player, args.getString(0)); Pattern pattern = we.getBlockPattern(player, args.getString(0));
int affected; int affected;
if (pattern instanceof SingleBlockPattern) { if (pattern instanceof SingleBlockPattern) {
affected = editSession.setBlocks(session.getSelection(player.getWorld()), affected = editSession.setBlocks(session.getSelection(player.getWorld()),
((SingleBlockPattern) pattern).getBlock()); ((SingleBlockPattern) pattern).getBlock());
} else { } else {
affected = editSession.setBlocks(session.getSelection(player.getWorld()), pattern); affected = editSession.setBlocks(session.getSelection(player.getWorld()), pattern);
} }
player.print(affected + " block(s) have been changed."); player.print(affected + " block(s) have been changed.");
} }
@ -101,10 +100,10 @@ public class RegionCommands {
} else { } else {
affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from, to); affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from, to);
} }
player.print(affected + " block(s) have been replaced."); player.print(affected + " block(s) have been replaced.");
} }
@Command( @Command(
aliases = { "/overlay" }, aliases = { "/overlay" },
usage = "<block>", usage = "<block>",
@ -169,7 +168,7 @@ public class RegionCommands {
} else { } else {
affected = editSession.makeCuboidWalls(session.getSelection(player.getWorld()), pattern); affected = editSession.makeCuboidWalls(session.getSelection(player.getWorld()), pattern);
} }
player.print(affected + " block(s) have been changed."); player.print(affected + " block(s) have been changed.");
} }
@ -220,7 +219,7 @@ public class RegionCommands {
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0)); HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
int affected = heightMap.applyFilter(filter, iterations); int affected = heightMap.applyFilter(filter, iterations);
player.print("Terrain's height map smoothed. " + affected + " block(s) changed."); player.print("Terrain's height map smoothed. " + affected + " block(s) changed.");
} }
@Command( @Command(
@ -267,7 +266,6 @@ public class RegionCommands {
player.print(affected + " blocks moved."); player.print(affected + " blocks moved.");
} }
@Command( @Command(
aliases = { "/stack" }, aliases = { "/stack" },

Datei anzeigen

@ -48,7 +48,7 @@ public class ScriptingCommands {
String[] scriptArgs = args.getSlice(1); String[] scriptArgs = args.getSlice(1);
String name = args.getString(0); String name = args.getString(0);
if (!player.hasPermission("worldedit.scripting.execute." + name)) { if (!player.hasPermission("worldedit.scripting.execute." + name)) {
player.printError("You don't have permission to use that script."); player.printError("You don't have permission to use that script.");
return; return;
@ -58,8 +58,8 @@ public class ScriptingCommands {
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir); File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
File f = we.getSafeOpenFile(player, dir, name, "js", File f = we.getSafeOpenFile(player, dir, name, "js",
new String[] {"js"}); new String[] { "js" });
we.runScript(player, f, scriptArgs); we.runScript(player, f, scriptArgs);
} }
@ -77,12 +77,12 @@ public class ScriptingCommands {
throws WorldEditException { throws WorldEditException {
String lastScript = session.getLastScript(); String lastScript = session.getLastScript();
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) { if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {
player.printError("You don't have permission to use that script."); player.printError("You don't have permission to use that script.");
return; return;
} }
if (lastScript == null) { if (lastScript == null) {
player.printError("Use /cs with a script name first."); player.printError("Use /cs with a script name first.");
return; return;
@ -92,8 +92,8 @@ public class ScriptingCommands {
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir); File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
File f = we.getSafeOpenFile(player, dir, lastScript, "js", File f = we.getSafeOpenFile(player, dir, lastScript, "js",
new String[] {"js"}); new String[] { "js" });
we.runScript(player, f, scriptArgs); we.runScript(player, f, scriptArgs);
} }
} }

Datei anzeigen

@ -87,11 +87,11 @@ public class SelectionCommands {
throws WorldEditException { throws WorldEditException {
Vector pos; Vector pos;
if(args.argsLength() == 1) { if (args.argsLength() == 1) {
if(args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) { if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
String[] coords = args.getString(0).split(","); String[] coords = args.getString(0).split(",");
pos = new Vector(Integer.parseInt(coords[0]), pos = new Vector(Integer.parseInt(coords[0]),
Integer.parseInt(coords[1]), Integer.parseInt(coords[1]),
Integer.parseInt(coords[2])); Integer.parseInt(coords[2]));
} else { } else {
player.printError("Invalid coordinates " + args.getString(0)); player.printError("Invalid coordinates " + args.getString(0));
@ -106,7 +106,6 @@ public class SelectionCommands {
return; return;
} }
session.getRegionSelector(player.getWorld()) session.getRegionSelector(player.getWorld())
.explainSecondarySelection(player, session, pos); .explainSecondarySelection(player, session, pos);
} }
@ -124,7 +123,7 @@ public class SelectionCommands {
throws WorldEditException { throws WorldEditException {
Vector pos = player.getBlockTrace(300); Vector pos = player.getBlockTrace(300);
if (pos != null) { if (pos != null) {
if (!session.getRegionSelector(player.getWorld()) if (!session.getRegionSelector(player.getWorld())
.selectPrimary(pos)) { .selectPrimary(pos)) {
@ -152,7 +151,7 @@ public class SelectionCommands {
throws WorldEditException { throws WorldEditException {
Vector pos = player.getBlockTrace(300); Vector pos = player.getBlockTrace(300);
if (pos != null) { if (pos != null) {
if (!session.getRegionSelector(player.getWorld()) if (!session.getRegionSelector(player.getWorld())
.selectSecondary(pos)) { .selectSecondary(pos)) {
@ -208,11 +207,11 @@ public class SelectionCommands {
selector.selectPrimary(min); selector.selectPrimary(min);
selector.selectSecondary(max); selector.selectSecondary(max);
session.setRegionSelector(player.getWorld(), selector); session.setRegionSelector(player.getWorld(), selector);
session.dispatchCUISelection(player); session.dispatchCUISelection(player);
} }
@Command( @Command(
aliases = { "/wand" }, aliases = { "/wand" },
usage = "", usage = "",
@ -228,7 +227,7 @@ public class SelectionCommands {
player.giveItem(we.getConfiguration().wandItem, 1); player.giveItem(we.getConfiguration().wandItem, 1);
player.print("Left click: select pos #1; Right click: select pos #2"); player.print("Left click: select pos #1; Right click: select pos #2");
} }
@Command( @Command(
aliases = { "toggleeditwand" }, aliases = { "toggleeditwand" },
usage = "", usage = "",
@ -242,7 +241,7 @@ public class SelectionCommands {
throws WorldEditException { throws WorldEditException {
session.setToolControl(!session.isToolControlEnabled()); session.setToolControl(!session.isToolControlEnabled());
if (session.isToolControlEnabled()) { if (session.isToolControlEnabled()) {
player.print("Edit wand enabled."); player.print("Edit wand enabled.");
} else { } else {
@ -281,13 +280,13 @@ public class SelectionCommands {
} catch (RegionOperationException e) { } catch (RegionOperationException e) {
player.printError(e.getMessage()); player.printError(e.getMessage());
} }
return; return;
} }
int change = args.getInteger(0); int change = args.getInteger(0);
int reverseChange = 0; int reverseChange = 0;
switch (args.argsLength()) { switch (args.argsLength()) {
case 2: case 2:
// Either a reverse amount or a direction // Either a reverse amount or a direction
@ -300,7 +299,7 @@ public class SelectionCommands {
} }
break; break;
case 3: case 3:
// Both reverse amount and direction // Both reverse amount and direction
reverseChange = args.getInteger(1) * -1; reverseChange = args.getInteger(1) * -1;
dir = we.getDirection(player, dir = we.getDirection(player,
@ -313,16 +312,16 @@ public class SelectionCommands {
Region region = session.getSelection(player.getWorld()); Region region = session.getSelection(player.getWorld());
int oldSize = region.getArea(); int oldSize = region.getArea();
region.expand(dir.multiply(change)); region.expand(dir.multiply(change));
if (reverseChange != 0) { if (reverseChange != 0) {
region.expand(dir.multiply(reverseChange)); region.expand(dir.multiply(reverseChange));
} }
session.getRegionSelector().learnChanges(); session.getRegionSelector().learnChanges();
int newSize = region.getArea(); int newSize = region.getArea();
session.getRegionSelector().explainRegionAdjust(player, session); session.getRegionSelector().explainRegionAdjust(player, session);
player.print("Region expanded " + (newSize - oldSize) + " blocks."); player.print("Region expanded " + (newSize - oldSize) + " blocks.");
} }
@ -353,7 +352,7 @@ public class SelectionCommands {
} }
break; break;
case 3: case 3:
// Both reverse amount and direction // Both reverse amount and direction
reverseChange = args.getInteger(1) * -1; reverseChange = args.getInteger(1) * -1;
dir = we.getDirection(player, args.getString(2).toLowerCase()); dir = we.getDirection(player, args.getString(2).toLowerCase());
@ -371,9 +370,9 @@ public class SelectionCommands {
} }
session.getRegionSelector().learnChanges(); session.getRegionSelector().learnChanges();
int newSize = region.getArea(); int newSize = region.getArea();
session.getRegionSelector().explainRegionAdjust(player, session); session.getRegionSelector().explainRegionAdjust(player, session);
player.print("Region contracted " + (oldSize - newSize) + " blocks."); player.print("Region contracted " + (oldSize - newSize) + " blocks.");
} catch (RegionOperationException e) { } catch (RegionOperationException e) {
player.printError(e.getMessage()); player.printError(e.getMessage());
@ -392,7 +391,7 @@ public class SelectionCommands {
LocalSession session, LocalPlayer player, EditSession editSession) LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException { throws WorldEditException {
Vector dir; Vector dir;
int change = args.getInteger(0); int change = args.getInteger(0);
if (args.argsLength() == 2) { if (args.argsLength() == 2) {
dir = we.getDirection(player, args.getString(1).toLowerCase()); dir = we.getDirection(player, args.getString(1).toLowerCase());
@ -405,9 +404,9 @@ public class SelectionCommands {
region.expand(dir.multiply(change)); region.expand(dir.multiply(change));
region.contract(dir.multiply(change)); region.contract(dir.multiply(change));
session.getRegionSelector().learnChanges(); session.getRegionSelector().learnChanges();
session.getRegionSelector().explainRegionAdjust(player, session); session.getRegionSelector().explainRegionAdjust(player, session);
player.print("Region shifted."); player.print("Region shifted.");
} catch (RegionOperationException e) { } catch (RegionOperationException e) {
player.printError(e.getMessage()); player.printError(e.getMessage());
@ -429,13 +428,13 @@ public class SelectionCommands {
int change = args.getInteger(0); int change = args.getInteger(0);
Region region = session.getSelection(player.getWorld()); Region region = session.getSelection(player.getWorld());
try { try {
if (!args.hasFlag('h')) { if (!args.hasFlag('h')) {
region.expand((new Vector(0, 1, 0)).multiply(change)); region.expand((new Vector(0, 1, 0)).multiply(change));
region.expand((new Vector(0, -1, 0)).multiply(change)); region.expand((new Vector(0, -1, 0)).multiply(change));
} }
if (!args.hasFlag('v')) { if (!args.hasFlag('v')) {
region.expand((new Vector(1, 0, 0)).multiply(change)); region.expand((new Vector(1, 0, 0)).multiply(change));
region.expand((new Vector(-1, 0, 0)).multiply(change)); region.expand((new Vector(-1, 0, 0)).multiply(change));
@ -444,9 +443,9 @@ public class SelectionCommands {
} }
session.getRegionSelector().learnChanges(); session.getRegionSelector().learnChanges();
session.getRegionSelector().explainRegionAdjust(player, session); session.getRegionSelector().explainRegionAdjust(player, session);
player.print("Region outset."); player.print("Region outset.");
} catch (RegionOperationException e) { } catch (RegionOperationException e) {
player.printError(e.getMessage()); player.printError(e.getMessage());
@ -468,12 +467,12 @@ public class SelectionCommands {
int change = args.getInteger(0); int change = args.getInteger(0);
Region region = session.getSelection(player.getWorld()); Region region = session.getSelection(player.getWorld());
if (!args.hasFlag('h')) { if (!args.hasFlag('h')) {
region.contract((new Vector(0, 1, 0)).multiply(change)); region.contract((new Vector(0, 1, 0)).multiply(change));
region.contract((new Vector(0, -1, 0)).multiply(change)); region.contract((new Vector(0, -1, 0)).multiply(change));
} }
if (!args.hasFlag('v')) { if (!args.hasFlag('v')) {
region.contract((new Vector(1, 0, 0)).multiply(change)); region.contract((new Vector(1, 0, 0)).multiply(change));
region.contract((new Vector(-1, 0, 0)).multiply(change)); region.contract((new Vector(-1, 0, 0)).multiply(change));
@ -482,9 +481,9 @@ public class SelectionCommands {
} }
session.getRegionSelector().learnChanges(); session.getRegionSelector().learnChanges();
session.getRegionSelector().explainRegionAdjust(player, session); session.getRegionSelector().explainRegionAdjust(player, session);
player.print("Region inset."); player.print("Region inset.");
} }
@ -506,11 +505,11 @@ public class SelectionCommands {
.add(1, 1, 1); .add(1, 1, 1);
player.print("Type: " + session.getRegionSelector().getTypeName()); player.print("Type: " + session.getRegionSelector().getTypeName());
for (String line : session.getRegionSelector().getInformationLines()) { for (String line : session.getRegionSelector().getInformationLines()) {
player.print(line); player.print(line);
} }
player.print("Size: " + size); player.print("Size: " + size);
player.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint())); player.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint()));
player.print("# of blocks: " + region.getArea()); player.print("# of blocks: " + region.getArea());
@ -548,28 +547,28 @@ public class SelectionCommands {
throws WorldEditException { throws WorldEditException {
List<Countable<Integer>> distribution = List<Countable<Integer>> distribution =
editSession.getBlockDistribution(session.getSelection(player.getWorld())); editSession.getBlockDistribution(session.getSelection(player.getWorld()));
Logger logger = Logger.getLogger("Minecraft.WorldEdit"); Logger logger = Logger.getLogger("Minecraft.WorldEdit");
if (distribution.size() > 0) { // *Should* always be true if (distribution.size() > 0) { // *Should* always be true
int size = session.getSelection(player.getWorld()).getArea(); int size = session.getSelection(player.getWorld()).getArea();
player.print("# total blocks: " + size); player.print("# total blocks: " + size);
if (args.hasFlag('c')) { if (args.hasFlag('c')) {
logger.info("Block distribution (req. by " + player.getName() + "):"); logger.info("Block distribution (req. by " + player.getName() + "):");
logger.info("# total blocks: " + size); logger.info("# total blocks: " + size);
} }
for (Countable<Integer> c : distribution) { for (Countable<Integer> c : distribution) {
BlockType block = BlockType.fromID(c.getID()); BlockType block = BlockType.fromID(c.getID());
String str = String.format("%-7s (%.3f%%) %s #%d", String str = String.format("%-7s (%.3f%%) %s #%d",
String.valueOf(c.getAmount()), String.valueOf(c.getAmount()),
c.getAmount() / (double)size * 100, c.getAmount() / (double) size * 100,
block == null ? "Unknown" : block.getName(), c.getID()); block == null ? "Unknown" : block.getName(), c.getID());
player.print(str); player.print(str);
if (args.hasFlag('c')) { if (args.hasFlag('c')) {
logger.info(str); logger.info(str);
} }

Datei anzeigen

@ -65,9 +65,9 @@ public class SnapshotCommands {
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName()); List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName());
if (snapshots.size() > 0) { if (snapshots.size() > 0) {
int num = args.argsLength() > 0 ? Math.min(40, Math.max(5, args.getInteger(0))) : 5; int num = args.argsLength() > 0 ? Math.min(40, Math.max(5, args.getInteger(0))) : 5;
player.print("Snapshots for world: '" + player.getWorld().getName() + "'"); player.print("Snapshots for world: '" + player.getWorld().getName() + "'");
for (byte i = 0; i < Math.min(num, snapshots.size()); i++) { for (byte i = 0; i < Math.min(num, snapshots.size()); i++) {
player.print((i + 1) + ". " + snapshots.get(i).getName()); player.print((i + 1) + ". " + snapshots.get(i).getName());

Datei anzeigen

@ -32,7 +32,7 @@ import com.sk89q.worldedit.tools.AreaPickaxe;
import com.sk89q.worldedit.tools.RecursivePickaxe; import com.sk89q.worldedit.tools.RecursivePickaxe;
import com.sk89q.worldedit.tools.SinglePickaxe; import com.sk89q.worldedit.tools.SinglePickaxe;
public class SuperPickaxeCommands { public class SuperPickaxeCommands {
@Command( @Command(
aliases = { "single" }, aliases = { "single" },
usage = "", usage = "",
@ -49,7 +49,7 @@ public class SuperPickaxeCommands {
session.enableSuperPickAxe(); session.enableSuperPickAxe();
player.print("Mode changed. Left click with a pickaxe. // to disable."); player.print("Mode changed. Left click with a pickaxe. // to disable.");
} }
@Command( @Command(
aliases = { "area" }, aliases = { "area" },
usage = "<radius>", usage = "<radius>",
@ -64,17 +64,17 @@ public class SuperPickaxeCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
int range = args.getInteger(0); int range = args.getInteger(0);
if (range > config.maxSuperPickaxeSize) { if (range > config.maxSuperPickaxeSize) {
player.printError("Maximum range: " + config.maxSuperPickaxeSize); player.printError("Maximum range: " + config.maxSuperPickaxeSize);
return; return;
} }
session.setSuperPickaxe(new AreaPickaxe(range)); session.setSuperPickaxe(new AreaPickaxe(range));
session.enableSuperPickAxe(); session.enableSuperPickAxe();
player.print("Mode changed. Left click with a pickaxe. // to disable."); player.print("Mode changed. Left click with a pickaxe. // to disable.");
} }
@Command( @Command(
aliases = { "recur", "recursive" }, aliases = { "recur", "recursive" },
usage = "<radius>", usage = "<radius>",
@ -89,12 +89,12 @@ public class SuperPickaxeCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
double range = args.getDouble(0); double range = args.getDouble(0);
if (range > config.maxSuperPickaxeSize) { if (range > config.maxSuperPickaxeSize) {
player.printError("Maximum range: " + config.maxSuperPickaxeSize); player.printError("Maximum range: " + config.maxSuperPickaxeSize);
return; return;
} }
session.setSuperPickaxe(new RecursivePickaxe(range)); session.setSuperPickaxe(new RecursivePickaxe(range));
session.enableSuperPickAxe(); session.enableSuperPickAxe();
player.print("Mode changed. Left click with a pickaxe. // to disable."); player.print("Mode changed. Left click with a pickaxe. // to disable.");

Datei anzeigen

@ -138,7 +138,7 @@ public class ToolCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
int range = args.getInteger(1); int range = args.getInteger(1);
if (range > config.maxSuperPickaxeSize) { if (range > config.maxSuperPickaxeSize) {
player.printError("Maximum range: " + config.maxSuperPickaxeSize); player.printError("Maximum range: " + config.maxSuperPickaxeSize);
return; return;
@ -159,7 +159,7 @@ public class ToolCommands {
LocalSession session, LocalPlayer player, EditSession editSession) LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException { throws WorldEditException {
} }
@Command( @Command(
aliases = { "deltree" }, aliases = { "deltree" },
usage = "", usage = "",

Datei anzeigen

@ -151,14 +151,14 @@ public class ToolUtilCommands {
throws WorldEditException { throws WorldEditException {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
int radius = args.getInteger(0); int radius = args.getInteger(0);
if (radius > config.maxBrushRadius) { if (radius > config.maxBrushRadius) {
player.printError("Maximum allowed brush radius: " player.printError("Maximum allowed brush radius: "
+ config.maxBrushRadius); + config.maxBrushRadius);
return; return;
} }
session.getBrushTool(player.getItemInHand()).setSize(radius); session.getBrushTool(player.getItemInHand()).setSize(radius);
player.print("Brush size set."); player.print("Brush size set.");
} }

Datei anzeigen

@ -19,7 +19,6 @@
package com.sk89q.worldedit.commands; package com.sk89q.worldedit.commands;
import java.util.Set; import java.util.Set;
import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandContext;
@ -97,7 +96,7 @@ public class UtilityCommands {
} }
player.print(affected + " block(s) have been created."); player.print(affected + " block(s) have been created.");
} }
@Command( @Command(
aliases = { "/drain" }, aliases = { "/drain" },
usage = "<radius>", usage = "<radius>",
@ -260,7 +259,7 @@ public class UtilityCommands {
} }
player.print(affected + " block(s) have been replaced."); player.print(affected + " block(s) have been replaced.");
} }
@Command( @Command(
aliases = { "/snow", "snow" }, aliases = { "/snow", "snow" },
usage = "[radius]", usage = "[radius]",
@ -332,7 +331,7 @@ public class UtilityCommands {
throws WorldEditException { throws WorldEditException {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
int defaultRadius = config.maxRadius != -1 ? Math.min(40, config.maxRadius) : 40; int defaultRadius = config.maxRadius != -1 ? Math.min(40, config.maxRadius) : 40;
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0))
: defaultRadius; : defaultRadius;
@ -378,12 +377,12 @@ public class UtilityCommands {
String typeStr = args.getString(0); String typeStr = args.getString(0);
int radius = args.getInteger(1); int radius = args.getInteger(1);
if (radius < -1) { if (radius < -1) {
player.printError("Use -1 to remove all entities in loaded chunks"); player.printError("Use -1 to remove all entities in loaded chunks");
return; return;
} }
EntityType type = null; EntityType type = null;
if (typeStr.matches("arrows?")) { if (typeStr.matches("arrows?")) {

Datei anzeigen

@ -34,7 +34,7 @@ import com.sk89q.worldedit.WorldEditException;
public class WorldEditCommands { public class WorldEditCommands {
private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
@Command( @Command(
aliases = { "version", "ver" }, aliases = { "version", "ver" },
usage = "", usage = "",

Datei anzeigen

@ -21,5 +21,6 @@ package com.sk89q.worldedit.cui;
public interface CUIEvent { public interface CUIEvent {
public String getTypeId(); public String getTypeId();
public String[] getParameters(); public String[] getParameters();
} }

Datei anzeigen

@ -23,7 +23,7 @@ public class SelectionMinMaxEvent implements CUIEvent {
protected int min; protected int min;
protected int max; protected int max;
public SelectionMinMaxEvent(int min, int max) { public SelectionMinMaxEvent(int min, int max) {
this.min = min; this.min = min;
this.max = max; this.max = max;

Datei anzeigen

@ -26,7 +26,7 @@ public class SelectionPointEvent implements CUIEvent {
protected int id; protected int id;
protected Vector pos; protected Vector pos;
protected int area; protected int area;
public SelectionPointEvent(int id, Vector pos, int area) { public SelectionPointEvent(int id, Vector pos, int area) {
this.id = id; this.id = id;
this.pos = pos; this.pos = pos;

Datei anzeigen

@ -20,9 +20,9 @@
package com.sk89q.worldedit.cui; package com.sk89q.worldedit.cui;
public class SelectionShapeEvent implements CUIEvent { public class SelectionShapeEvent implements CUIEvent {
protected String shapeName; protected String shapeName;
public SelectionShapeEvent(String shapeName) { public SelectionShapeEvent(String shapeName) {
this.shapeName = shapeName; this.shapeName = shapeName;
} }

Datei anzeigen

@ -17,7 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldedit.data; package com.sk89q.worldedit.data;
import java.util.List; import java.util.List;
@ -38,7 +37,7 @@ public class Chunk {
private byte[] data; private byte[] data;
private int rootX; private int rootX;
private int rootZ; private int rootZ;
private Map<BlockVector,Map<String,Tag>> tileEntities; private Map<BlockVector, Map<String, Tag>> tileEntities;
/** /**
* Construct the chunk with a compound tag. * Construct the chunk with a compound tag.
@ -49,13 +48,13 @@ public class Chunk {
public Chunk(CompoundTag tag) throws DataException { public Chunk(CompoundTag tag) throws DataException {
rootTag = tag; rootTag = tag;
blocks = ((ByteArrayTag)getChildTag( blocks = ((ByteArrayTag) getChildTag(
rootTag.getValue(), "Blocks", ByteArrayTag.class)).getValue(); rootTag.getValue(), "Blocks", ByteArrayTag.class)).getValue();
data = ((ByteArrayTag)getChildTag( data = ((ByteArrayTag) getChildTag(
rootTag.getValue(), "Data", ByteArrayTag.class)).getValue(); rootTag.getValue(), "Data", ByteArrayTag.class)).getValue();
rootX = ((IntTag)getChildTag( rootX = ((IntTag) getChildTag(
rootTag.getValue(), "xPos", IntTag.class)).getValue(); rootTag.getValue(), "xPos", IntTag.class)).getValue();
rootZ = ((IntTag)getChildTag( rootZ = ((IntTag) getChildTag(
rootTag.getValue(), "zPos", IntTag.class)).getValue(); rootTag.getValue(), "zPos", IntTag.class)).getValue();
if (blocks.length != 32768) { if (blocks.length != 32768) {
@ -121,37 +120,37 @@ public class Chunk {
* @throws DataException * @throws DataException
*/ */
private void populateTileEntities() throws DataException { private void populateTileEntities() throws DataException {
List<Tag> tags = (List<Tag>)((ListTag)getChildTag( List<Tag> tags = (List<Tag>) ((ListTag) getChildTag(
rootTag.getValue(), "TileEntities", ListTag.class)) rootTag.getValue(), "TileEntities", ListTag.class))
.getValue(); .getValue();
tileEntities = new HashMap<BlockVector,Map<String,Tag>>(); tileEntities = new HashMap<BlockVector, Map<String, Tag>>();
for (Tag tag : tags) { for (Tag tag : tags) {
if (!(tag instanceof CompoundTag)) { if (!(tag instanceof CompoundTag)) {
throw new InvalidFormatException("CompoundTag expected in TileEntities"); throw new InvalidFormatException("CompoundTag expected in TileEntities");
} }
CompoundTag t = (CompoundTag)tag; CompoundTag t = (CompoundTag) tag;
int x = 0; int x = 0;
int y = 0; int y = 0;
int z = 0; int z = 0;
Map<String,Tag> values = new HashMap<String,Tag>(); Map<String, Tag> values = new HashMap<String, Tag>();
for (Map.Entry<String,Tag> entry : t.getValue().entrySet()) { for (Map.Entry<String, Tag> entry : t.getValue().entrySet()) {
if (entry.getKey().equals("x")) { if (entry.getKey().equals("x")) {
if (entry.getValue() instanceof IntTag) { if (entry.getValue() instanceof IntTag) {
x = ((IntTag)entry.getValue()).getValue(); x = ((IntTag) entry.getValue()).getValue();
} }
} else if (entry.getKey().equals("y")) { } else if (entry.getKey().equals("y")) {
if (entry.getValue() instanceof IntTag) { if (entry.getValue() instanceof IntTag) {
y = ((IntTag)entry.getValue()).getValue(); y = ((IntTag) entry.getValue()).getValue();
} }
} else if (entry.getKey().equals("z")) { } else if (entry.getKey().equals("z")) {
if (entry.getValue() instanceof IntTag) { if (entry.getValue() instanceof IntTag) {
z = ((IntTag)entry.getValue()).getValue(); z = ((IntTag) entry.getValue()).getValue();
} }
} }
@ -172,9 +171,10 @@ public class Chunk {
* @return * @return
* @throws DataException * @throws DataException
*/ */
private Map<String,Tag> getBlockTileEntity(Vector pos) throws DataException { private Map<String, Tag> getBlockTileEntity(Vector pos) throws DataException {
if (tileEntities == null) if (tileEntities == null) {
populateTileEntities(); populateTileEntities();
}
return tileEntities.get(new BlockVector(pos)); return tileEntities.get(new BlockVector(pos));
} }
@ -208,8 +208,8 @@ public class Chunk {
} }
if (block instanceof TileEntityBlock) { if (block instanceof TileEntityBlock) {
Map<String,Tag> tileEntity = getBlockTileEntity(pos); Map<String, Tag> tileEntity = getBlockTileEntity(pos);
((TileEntityBlock)block).fromTileEntityNBT(tileEntity); ((TileEntityBlock) block).fromTileEntityNBT(tileEntity);
} }
return block; return block;
@ -224,7 +224,7 @@ public class Chunk {
* @return child tag * @return child tag
* @throws InvalidFormatException * @throws InvalidFormatException
*/ */
public static Tag getChildTag(Map<String,Tag> items, String key, public static Tag getChildTag(Map<String, Tag> items, String key,
Class<? extends Tag> expected) Class<? extends Tag> expected)
throws InvalidFormatException { throws InvalidFormatException {
if (!items.containsKey(key)) { if (!items.containsKey(key)) {
@ -232,8 +232,7 @@ public class Chunk {
} }
Tag tag = items.get(key); Tag tag = items.get(key);
if (!expected.isInstance(tag)) { if (!expected.isInstance(tag)) {
throw new InvalidFormatException( throw new InvalidFormatException(key + " tag is not of tag type " + expected.getName());
key + " tag is not of tag type " + expected.getName());
} }
return tag; return tag;
} }

Datei anzeigen

@ -36,8 +36,8 @@ public abstract class ChunkStore {
* @return * @return
*/ */
public static BlockVector2D toChunk(Vector pos) { public static BlockVector2D toChunk(Vector pos) {
int chunkX = (int)Math.floor(pos.getBlockX() / 16.0); int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
int chunkZ = (int)Math.floor(pos.getBlockZ() / 16.0); int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
return new BlockVector2D(chunkX, chunkZ); return new BlockVector2D(chunkX, chunkZ);
} }

Datei anzeigen

@ -49,7 +49,7 @@ public class FileMcRegionChunkStore extends McRegionChunkStore {
if (!file.exists()) { if (!file.exists()) {
file = new File(path, "DIM-1" + File.separator + fileName); file = new File(path, "DIM-1" + File.separator + fileName);
} }
try { try {
return new FileInputStream(file); return new FileInputStream(file);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {

Datei anzeigen

@ -23,10 +23,10 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
public class ForwardSeekableInputStream extends InputStream { public class ForwardSeekableInputStream extends InputStream {
protected InputStream parent; protected InputStream parent;
protected long position = 0; protected long position = 0;
public ForwardSeekableInputStream(InputStream parent) { public ForwardSeekableInputStream(InputStream parent) {
this.parent = parent; this.parent = parent;
} }
@ -83,18 +83,18 @@ public class ForwardSeekableInputStream extends InputStream {
position += skipped; position += skipped;
return skipped; return skipped;
} }
public void seek(long n) throws IOException { public void seek(long n) throws IOException {
long diff = n - position; long diff = n - position;
if (diff < 0) { if (diff < 0) {
throw new IOException("Can't seek backwards"); throw new IOException("Can't seek backwards");
} }
if (diff == 0) { if (diff == 0) {
return; return;
} }
if (skip(diff) < diff) { if (skip(diff) < diff) {
throw new IOException("Failed to seek " + diff + " bytes"); throw new IOException("Failed to seek " + diff + " bytes");
} }

Datei anzeigen

@ -96,14 +96,14 @@ public abstract class LegacyChunkStore extends ChunkStore {
+ tag.getClass().getName()); + tag.getClass().getName());
} }
Map<String,Tag> children = (Map<String,Tag>)((CompoundTag)tag).getValue(); Map<String, Tag> children = (Map<String, Tag>) ((CompoundTag) tag).getValue();
CompoundTag rootTag = null; CompoundTag rootTag = null;
// Find Level tag // Find Level tag
for (Map.Entry<String,Tag> entry : children.entrySet()) { for (Map.Entry<String, Tag> entry : children.entrySet()) {
if (entry.getKey().equals("Level")) { if (entry.getKey().equals("Level")) {
if (entry.getValue() instanceof CompoundTag) { if (entry.getValue() instanceof CompoundTag) {
rootTag = (CompoundTag)entry.getValue(); rootTag = (CompoundTag) entry.getValue();
break; break;
} else { } else {
throw new ChunkStoreException("CompoundTag expected for 'Level'; got " throw new ChunkStoreException("CompoundTag expected for 'Level'; got "
@ -130,7 +130,7 @@ public abstract class LegacyChunkStore extends ChunkStore {
* @return * @return
*/ */
private static int divisorMod(int a, int n) { private static int divisorMod(int a, int n) {
return (int)(a - n * Math.floor(Math.floor(a) / (double)n)); return (int) (a - n * Math.floor(Math.floor(a) / (double) n));
} }
/** /**

Datei anzeigen

@ -30,7 +30,7 @@ import com.sk89q.worldedit.Vector2D;
public abstract class McRegionChunkStore extends ChunkStore { public abstract class McRegionChunkStore extends ChunkStore {
protected String curFilename = null; protected String curFilename = null;
protected McRegionReader cachedReader = null; protected McRegionReader cachedReader = null;
/** /**
* Get the filename of a region file. * Get the filename of a region file.
* *
@ -40,12 +40,12 @@ public abstract class McRegionChunkStore extends ChunkStore {
public static String getFilename(Vector2D pos) { public static String getFilename(Vector2D pos) {
int x = pos.getBlockX(); int x = pos.getBlockX();
int z = pos.getBlockZ(); int z = pos.getBlockZ();
String filename = "r." + (x >> 5) + "." + (z >> 5) + ".mcr"; String filename = "r." + (x >> 5) + "." + (z >> 5) + ".mcr";
return filename; return filename;
} }
protected McRegionReader getReader(Vector2D pos, String worldname) throws DataException, IOException { protected McRegionReader getReader(Vector2D pos, String worldname) throws DataException, IOException {
String filename = getFilename(pos); String filename = getFilename(pos);
if (curFilename != null) { if (curFilename != null) {
@ -67,7 +67,7 @@ public abstract class McRegionChunkStore extends ChunkStore {
@Override @Override
public CompoundTag getChunkTag(Vector2D pos, String worldname) throws DataException, public CompoundTag getChunkTag(Vector2D pos, String worldname) throws DataException,
IOException { IOException {
McRegionReader reader = getReader(pos, worldname); McRegionReader reader = getReader(pos, worldname);
InputStream stream = reader.getChunkInputStream(pos); InputStream stream = reader.getChunkInputStream(pos);
NBTInputStream nbt = new NBTInputStream(stream); NBTInputStream nbt = new NBTInputStream(stream);
@ -80,14 +80,14 @@ public abstract class McRegionChunkStore extends ChunkStore {
+ tag.getClass().getName()); + tag.getClass().getName());
} }
Map<String,Tag> children = (Map<String,Tag>)((CompoundTag)tag).getValue(); Map<String, Tag> children = (Map<String, Tag>) ((CompoundTag) tag).getValue();
CompoundTag rootTag = null; CompoundTag rootTag = null;
// Find Level tag // Find Level tag
for (Map.Entry<String,Tag> entry : children.entrySet()) { for (Map.Entry<String, Tag> entry : children.entrySet()) {
if (entry.getKey().equals("Level")) { if (entry.getKey().equals("Level")) {
if (entry.getValue() instanceof CompoundTag) { if (entry.getValue() instanceof CompoundTag) {
rootTag = (CompoundTag)entry.getValue(); rootTag = (CompoundTag) entry.getValue();
break; break;
} else { } else {
throw new ChunkStoreException("CompoundTag expected for 'Level'; got " throw new ChunkStoreException("CompoundTag expected for 'Level'; got "
@ -115,7 +115,6 @@ public abstract class McRegionChunkStore extends ChunkStore {
*/ */
protected abstract InputStream getInputStream(String name, String worldname) protected abstract InputStream getInputStream(String name, String worldname)
throws IOException, DataException; throws IOException, DataException;
/** /**
* Close resources. * Close resources.

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen