geforkt von Mirrors/FastAsyncWorldEdit
Cleanup
Dieser Commit ist enthalten in:
Ursprung
1a57f6e95d
Commit
7e13b60a51
@ -38,10 +38,10 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
section.setProperty("permissions.groups.default.permissions", new String[] {
|
||||
"worldedit.reload",
|
||||
"worldedit.selection",
|
||||
"worlds.creative.worldedit.region"});
|
||||
section.setProperty("permissions.groups.admins.permissions", new String[] {"*"});
|
||||
section.setProperty("permissions.users.sk89q.permissions", new String[] {"worldedit"});
|
||||
section.setProperty("permissions.users.sk89q.groups", new String[] {"admins"});
|
||||
"worlds.creative.worldedit.region" });
|
||||
section.setProperty("permissions.groups.admins.permissions", new String[] { "*" });
|
||||
section.setProperty("permissions.users.sk89q.permissions", new String[] { "worldedit" });
|
||||
section.setProperty("permissions.users.sk89q.groups", new String[] { "admins" });
|
||||
return section;
|
||||
}
|
||||
|
||||
|
@ -50,18 +50,18 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
||||
return false; // Permissions are only registered for online players
|
||||
}
|
||||
switch (internalHasPermission(perms, permission)) {
|
||||
case -1:
|
||||
return false;
|
||||
case 1:
|
||||
return true;
|
||||
case -1:
|
||||
return false;
|
||||
case 1:
|
||||
return true;
|
||||
}
|
||||
int dotPos = permission.lastIndexOf(".");
|
||||
while (dotPos > -1) {
|
||||
switch (internalHasPermission(perms, permission.substring(0, dotPos + 1) + "*")) {
|
||||
case -1:
|
||||
return false;
|
||||
case 1:
|
||||
return true;
|
||||
case -1:
|
||||
return false;
|
||||
case 1:
|
||||
return true;
|
||||
}
|
||||
dotPos = permission.lastIndexOf(".", dotPos - 1);
|
||||
}
|
||||
@ -115,7 +115,7 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getDetectionMessage() {
|
||||
return "Using the Bukkit Permissions API.";
|
||||
}
|
||||
|
@ -21,7 +21,10 @@ package com.sk89q.bukkit.migration;
|
||||
|
||||
public interface PermissionsProvider {
|
||||
public boolean hasPermission(String name, String permission);
|
||||
|
||||
public boolean hasPermission(String worldName, String name, String permission);
|
||||
|
||||
public boolean inGroup(String player, String group);
|
||||
|
||||
public String[] getGroups(String player);
|
||||
}
|
||||
|
@ -64,11 +64,11 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[] {
|
||||
PluginPermissionsResolver.class,
|
||||
PermissionsExResolver.class,
|
||||
NijiPermissionsResolver.class,
|
||||
DinnerPermsResolver.class,
|
||||
FlatFilePermissionsResolver.class
|
||||
PluginPermissionsResolver.class,
|
||||
PermissionsExResolver.class,
|
||||
NijiPermissionsResolver.class,
|
||||
DinnerPermsResolver.class,
|
||||
FlatFilePermissionsResolver.class
|
||||
};
|
||||
|
||||
@Deprecated
|
||||
@ -167,8 +167,8 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
}
|
||||
|
||||
if (!keys.contains("resolvers")) {
|
||||
//List<String> resolverKeys = config.getKeys("resolvers");
|
||||
List<String> resolvers = new ArrayList<String>();
|
||||
//List<String> resolverKeys = config.getKeys("resolvers");
|
||||
List<String> resolvers = new ArrayList<String>();
|
||||
for (Class<?> clazz : availableResolvers) {
|
||||
resolvers.add(clazz.getSimpleName());
|
||||
}
|
||||
|
@ -36,29 +36,29 @@ public @interface Command {
|
||||
* is never used for anything).
|
||||
*/
|
||||
String[] aliases();
|
||||
|
||||
|
||||
/**
|
||||
* Usage instruction. Example text for usage could be
|
||||
* <code>[-h] [name] [message]</code>.
|
||||
*/
|
||||
String usage() default "";
|
||||
|
||||
|
||||
/**
|
||||
* A short description for the command.
|
||||
*/
|
||||
String desc();
|
||||
|
||||
|
||||
/**
|
||||
* The minimum number of arguments. This should be 0 or above.
|
||||
*/
|
||||
int min() default 0;
|
||||
|
||||
|
||||
/**
|
||||
* The maximum number of arguments. Use -1 for an unlimited number
|
||||
* of arguments.
|
||||
*/
|
||||
int max() default -1;
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -67,5 +67,4 @@ public @interface Command {
|
||||
* meaning that if it is given it must have a value
|
||||
*/
|
||||
String flags() default "";
|
||||
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public class CommandContext {
|
||||
|
||||
// Not a flag?
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
@ -134,7 +134,7 @@ public class CommandContext {
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -21,14 +21,14 @@ package com.sk89q.minecraft.util.commands;
|
||||
|
||||
public class CommandUsageException extends CommandException {
|
||||
private static final long serialVersionUID = -6761418114414516542L;
|
||||
|
||||
|
||||
protected String usage;
|
||||
|
||||
|
||||
public CommandUsageException(String message, String usage) {
|
||||
super(message);
|
||||
this.usage = usage;
|
||||
}
|
||||
|
||||
|
||||
public String getUsage() {
|
||||
return usage;
|
||||
}
|
||||
|
@ -56,13 +56,12 @@ import com.sk89q.util.StringUtil;
|
||||
* @param <T> command sender class
|
||||
*/
|
||||
public abstract class CommandsManager<T> {
|
||||
|
||||
/**
|
||||
* Logger for general errors.
|
||||
*/
|
||||
protected static final Logger logger =
|
||||
Logger.getLogger(CommandsManager.class.getCanonicalName());
|
||||
|
||||
|
||||
/**
|
||||
* Mapping of commands (including aliases) with a description. Root
|
||||
* 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
|
||||
* method.
|
||||
*/
|
||||
protected Map<Method, Map<String, Method>> commands
|
||||
= new HashMap<Method, Map<String, Method>>();
|
||||
protected Map<Method, Map<String, Method>> commands = new HashMap<Method, Map<String, Method>>();
|
||||
|
||||
/**
|
||||
* Used to store the instances associated with a method.
|
||||
*/
|
||||
protected Map<Method, Object> instances = new HashMap<Method, Object>();
|
||||
|
||||
|
||||
/**
|
||||
* Mapping of commands (not including aliases) with a description. This
|
||||
* is only for top level commands.
|
||||
@ -88,7 +86,7 @@ public abstract class CommandsManager<T> {
|
||||
* Stores the injector used to getInstance.
|
||||
*/
|
||||
protected Injector injector;
|
||||
|
||||
|
||||
/**
|
||||
* Register an class that contains commands (denoted by {@link Command}.
|
||||
* If no dependency injector is specified, then the methods of the
|
||||
@ -144,7 +142,7 @@ public abstract class CommandsManager<T> {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
Map<String, Method> map;
|
||||
List<Command> registered = new ArrayList<Command>();
|
||||
|
||||
|
||||
// Make a new hash map to cache the commands for this class
|
||||
// as looking up methods via reflection is fairly slow
|
||||
if (commands.containsKey(parent)) {
|
||||
@ -163,7 +161,7 @@ public abstract class CommandsManager<T> {
|
||||
map = new HashMap<String, Method>();
|
||||
commands.put(parent, map);
|
||||
}
|
||||
|
||||
|
||||
for (Method method : cls.getMethods()) {
|
||||
if (!method.isAnnotationPresent(Command.class)) {
|
||||
continue;
|
||||
@ -172,7 +170,7 @@ public abstract class CommandsManager<T> {
|
||||
boolean isStatic = Modifier.isStatic(method.getModifiers());
|
||||
|
||||
Command cmd = method.getAnnotation(Command.class);
|
||||
|
||||
|
||||
// Cache the aliases too
|
||||
for (String alias : cmd.aliases()) {
|
||||
map.put(alias, method);
|
||||
@ -184,10 +182,10 @@ public abstract class CommandsManager<T> {
|
||||
if (obj == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
instances.put(method, obj);
|
||||
}
|
||||
|
||||
|
||||
// Build a list of commands and their usage details, at least for
|
||||
// root level commands
|
||||
if (parent == null) {
|
||||
@ -200,13 +198,13 @@ public abstract class CommandsManager<T> {
|
||||
|
||||
// Add the command to the registered command list for return
|
||||
registered.add(cmd);
|
||||
|
||||
|
||||
// Look for nested commands -- if there are any, those have
|
||||
// to be cached too so that they can be quickly looked
|
||||
// up when processing commands
|
||||
if (method.isAnnotationPresent(NestedCommand.class)) {
|
||||
NestedCommand nestedCmd = method.getAnnotation(NestedCommand.class);
|
||||
|
||||
|
||||
for (Class<?> nestedCls : nestedCmd.value()) {
|
||||
registerMethods(nestedCls, method);
|
||||
}
|
||||
@ -214,7 +212,7 @@ public abstract class CommandsManager<T> {
|
||||
}
|
||||
return registered;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks to see whether there is a command named such at the root level.
|
||||
* This will check aliases as well.
|
||||
@ -225,7 +223,7 @@ public abstract class CommandsManager<T> {
|
||||
public boolean hasCommand(String command) {
|
||||
return commands.get(null).containsKey(command.toLowerCase());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
return descs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
StringBuilder command = new StringBuilder();
|
||||
|
||||
|
||||
command.append("/");
|
||||
|
||||
|
||||
for (int i = 0; i <= level; ++i) {
|
||||
command.append(args[i] + " ");
|
||||
}
|
||||
@ -256,7 +254,8 @@ public abstract class CommandsManager<T> {
|
||||
char[] flags = cmd.flags().toCharArray();
|
||||
for (int i = 0; i < flags.length; ++i) {
|
||||
if (flags.length > i + 1 && flags[i + 1] == ':') {
|
||||
i++; continue;
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
flagChars.add(flags[i]);
|
||||
}
|
||||
@ -269,10 +268,10 @@ public abstract class CommandsManager<T> {
|
||||
}
|
||||
}
|
||||
command.append(cmd.usage());
|
||||
|
||||
|
||||
return command.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the usage string for a nested command.
|
||||
*
|
||||
@ -285,34 +284,33 @@ public abstract class CommandsManager<T> {
|
||||
*/
|
||||
protected String getNestedUsage(String[] args, int level,
|
||||
Method method, T player) throws CommandException {
|
||||
|
||||
|
||||
StringBuilder command = new StringBuilder();
|
||||
|
||||
|
||||
command.append("/");
|
||||
|
||||
|
||||
for (int i = 0; i <= level; ++i) {
|
||||
command.append(args[i] + " ");
|
||||
}
|
||||
|
||||
|
||||
Map<String, Method> map = commands.get(method);
|
||||
boolean found = false;
|
||||
|
||||
|
||||
command.append("<");
|
||||
|
||||
|
||||
Set<String> allowedCommands = new HashSet<String>();
|
||||
|
||||
|
||||
for (Map.Entry<String, Method> entry : map.entrySet()) {
|
||||
Method childMethod = entry.getValue();
|
||||
found = true;
|
||||
|
||||
|
||||
if (hasPermission(childMethod, player)) {
|
||||
Command childCmd = childMethod.getAnnotation(Command.class);
|
||||
|
||||
|
||||
allowedCommands.add(childCmd.aliases()[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (allowedCommands.size() > 0) {
|
||||
command.append(StringUtil.joinString(allowedCommands, "|", 0));
|
||||
} else {
|
||||
@ -323,12 +321,12 @@ public abstract class CommandsManager<T> {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
command.append(">");
|
||||
|
||||
|
||||
return command.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attempt to execute a command. This version takes a separate command
|
||||
* name (for the root command) and then a list of following arguments.
|
||||
@ -340,17 +338,17 @@ public abstract class CommandsManager<T> {
|
||||
* @throws CommandException
|
||||
*/
|
||||
public void execute(String cmd, String[] args, T player,
|
||||
Object ... methodArgs) throws CommandException {
|
||||
|
||||
Object... methodArgs) throws CommandException {
|
||||
|
||||
String[] newArgs = new String[args.length + 1];
|
||||
System.arraycopy(args, 0, newArgs, 1, args.length);
|
||||
newArgs[0] = cmd;
|
||||
Object[] newMethodArgs = new Object[methodArgs.length + 1];
|
||||
System.arraycopy(methodArgs, 0, newMethodArgs, 1, methodArgs.length);
|
||||
|
||||
|
||||
executeMethod(null, newArgs, player, newMethodArgs, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attempt to execute a command.
|
||||
*
|
||||
@ -360,13 +358,13 @@ public abstract class CommandsManager<T> {
|
||||
* @throws CommandException
|
||||
*/
|
||||
public void execute(String[] args, T player,
|
||||
Object ... methodArgs) throws CommandException {
|
||||
|
||||
Object... methodArgs) throws CommandException {
|
||||
|
||||
Object[] newMethodArgs = new Object[methodArgs.length + 1];
|
||||
System.arraycopy(methodArgs, 0, newMethodArgs, 1, methodArgs.length);
|
||||
executeMethod(null, args, player, newMethodArgs, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attempt to execute a command.
|
||||
*
|
||||
@ -379,12 +377,12 @@ public abstract class CommandsManager<T> {
|
||||
*/
|
||||
public void executeMethod(Method parent, String[] args,
|
||||
T player, Object[] methodArgs, int level) throws CommandException {
|
||||
|
||||
|
||||
String cmdName = args[level];
|
||||
|
||||
|
||||
Map<String, Method> map = commands.get(parent);
|
||||
Method method = map.get(cmdName.toLowerCase());
|
||||
|
||||
|
||||
if (method == null) {
|
||||
if (parent == null) { // Root
|
||||
throw new UnhandledCommandException();
|
||||
@ -393,16 +391,16 @@ public abstract class CommandsManager<T> {
|
||||
getNestedUsage(args, level - 1, parent, player));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!hasPermission(method, player)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
|
||||
int argsCount = args.length - 1 - level;
|
||||
|
||||
if (method.isAnnotationPresent(NestedCommand.class)) {
|
||||
if (argsCount == 0) {
|
||||
throw new MissingNestedCommandException("Sub-command required.",
|
||||
throw new MissingNestedCommandException("Sub-command required.",
|
||||
getNestedUsage(args, level, method, player));
|
||||
} else {
|
||||
executeMethod(method, args, player, methodArgs, level + 1);
|
||||
@ -410,7 +408,7 @@ public abstract class CommandsManager<T> {
|
||||
} else if (method.isAnnotationPresent(CommandAlias.class)) {
|
||||
CommandAlias aCmd = method.getAnnotation(CommandAlias.class);
|
||||
executeMethod(parent, aCmd.value(), player, methodArgs, level);
|
||||
} else {
|
||||
} else {
|
||||
Command cmd = method.getAnnotation(Command.class);
|
||||
|
||||
String[] newArgs = new String[args.length - level];
|
||||
@ -422,23 +420,26 @@ public abstract class CommandsManager<T> {
|
||||
Set<Character> newFlags = new HashSet<Character>();
|
||||
for (int i = 0; i < flags.length; ++i) {
|
||||
if (flags.length > i + 1 && flags[i + 1] == ':') {
|
||||
valueFlags.add(flags[i]);
|
||||
++i;
|
||||
valueFlags.add(flags[i]);
|
||||
++i;
|
||||
}
|
||||
newFlags.add(flags[i]);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
for (char flag : context.getFlags()) {
|
||||
if (!newFlags.contains(flag))
|
||||
if (!newFlags.contains(flag)) {
|
||||
throw new CommandUsageException("Unknown flag: " + flag, getUsage(args, level, cmd));
|
||||
}
|
||||
}
|
||||
|
||||
methodArgs[0] = context;
|
||||
@ -461,11 +462,11 @@ public abstract class CommandsManager<T> {
|
||||
if (e.getCause() instanceof CommandException) {
|
||||
throw (CommandException) e.getCause();
|
||||
}
|
||||
|
||||
|
||||
throw new WrappedCommandException(e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether a player has access to a command.
|
||||
*
|
||||
@ -478,16 +479,16 @@ public abstract class CommandsManager<T> {
|
||||
if (perms == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
for (String perm : perms.value()) {
|
||||
if (hasPermission(player, perm)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether a player permission..
|
||||
*
|
||||
|
@ -5,6 +5,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class SimpleInjector<T> implements Injector {
|
||||
private final T injectionObject;
|
||||
|
||||
public SimpleInjector(T injectionObject) {
|
||||
this.injectionObject = injectionObject;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package com.sk89q.minecraft.util.commands;
|
||||
|
||||
public class WrappedCommandException extends CommandException {
|
||||
private static final long serialVersionUID = -4075721444847778918L;
|
||||
|
||||
|
||||
public WrappedCommandException(Throwable t) {
|
||||
super(t);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class StringUtil {
|
||||
if (str.length() > len) {
|
||||
return str.substring(0, len);
|
||||
}
|
||||
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ public class StringUtil {
|
||||
if (i > 0) {
|
||||
buffer.append(delimiter);
|
||||
}
|
||||
|
||||
|
||||
buffer.append(o.toString());
|
||||
}
|
||||
++i;
|
||||
|
@ -5,7 +5,7 @@ import org.yaml.snakeyaml.DumperOptions.FlowStyle;
|
||||
public enum YAMLFormat {
|
||||
EXTENDED(FlowStyle.BLOCK),
|
||||
COMPACT(FlowStyle.AUTO);
|
||||
|
||||
|
||||
private final FlowStyle style;
|
||||
|
||||
YAMLFormat(FlowStyle style) {
|
||||
|
@ -36,6 +36,7 @@ import java.util.Map;
|
||||
public class YAMLNode {
|
||||
protected Map<String, Object> root;
|
||||
private boolean writeDefaults;
|
||||
|
||||
public YAMLNode(Map<String, Object> root, boolean writeDefaults) {
|
||||
this.root = root;
|
||||
this.writeDefaults = writeDefaults;
|
||||
@ -49,14 +50,14 @@ public class YAMLNode {
|
||||
public Map<String, Object> getMap() {
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear all nodes.
|
||||
*/
|
||||
public void clear() {
|
||||
root.clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a property at a location. This will either return an Object
|
||||
* or null, with null meaning that no configuration value exists at
|
||||
@ -76,31 +77,31 @@ public class YAMLNode {
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
String[] parts = path.split("\\.");
|
||||
Map<String, Object> node = root;
|
||||
|
||||
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
Object o = node.get(parts[i]);
|
||||
|
||||
|
||||
if (o == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (i == parts.length - 1) {
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
node = (Map<String, Object>)o;
|
||||
node = (Map<String, Object>) o;
|
||||
} catch (ClassCastException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare a value for serialization, in case it's not a native type
|
||||
* (and we don't want to serialize objects as YAML objects).
|
||||
@ -117,10 +118,10 @@ public class YAMLNode {
|
||||
out.put("z", vec.getZ());
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the property at a location. This will override existing
|
||||
* configuration data to have it conform to key/value mappings.
|
||||
@ -131,34 +132,34 @@ public class YAMLNode {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setProperty(String path, Object value) {
|
||||
value = prepareSerialization(value);
|
||||
|
||||
|
||||
if (!path.contains(".")) {
|
||||
root.put(path, value);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String[] parts = path.split("\\.");
|
||||
Map<String, Object> node = root;
|
||||
|
||||
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
Object o = node.get(parts[i]);
|
||||
|
||||
|
||||
// Found our target!
|
||||
if (i == parts.length - 1) {
|
||||
node.put(parts[i], value);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (o == null || !(o instanceof Map)) {
|
||||
// This will override existing configuration data!
|
||||
o = new HashMap<String, Object>();
|
||||
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
|
||||
* to the new node. This method will replace an existing node at
|
||||
@ -204,15 +205,15 @@ public class YAMLNode {
|
||||
if (o == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Double x = o.getDouble("x");
|
||||
Double y = o.getDouble("y");
|
||||
Double z = o.getDouble("z");
|
||||
|
||||
|
||||
if (x == null || y == null || z == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return new Vector(x, y, z);
|
||||
}
|
||||
|
||||
@ -229,14 +230,14 @@ public class YAMLNode {
|
||||
if (o == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Double x = o.getDouble("x");
|
||||
Double z = o.getDouble("z");
|
||||
|
||||
|
||||
if (x == null || z == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return new Vector2D(x, z);
|
||||
}
|
||||
|
||||
@ -387,7 +388,7 @@ public class YAMLNode {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@ -402,7 +403,7 @@ public class YAMLNode {
|
||||
if (o == null) {
|
||||
return null;
|
||||
} else if (o instanceof Map) {
|
||||
return new ArrayList<String>(((Map<String,Object>)o).keySet());
|
||||
return new ArrayList<String>(((Map<String, Object>) o).keySet());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -421,12 +422,12 @@ public class YAMLNode {
|
||||
if (o == null) {
|
||||
return null;
|
||||
} else if (o instanceof List) {
|
||||
return (List<Object>)o;
|
||||
return (List<Object>) o;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -450,13 +451,13 @@ public class YAMLNode {
|
||||
if (o == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
list.add(o.toString());
|
||||
}
|
||||
|
||||
|
||||
return 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
|
||||
@ -481,10 +482,10 @@ public class YAMLNode {
|
||||
list.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 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
|
||||
@ -509,10 +510,10 @@ public class YAMLNode {
|
||||
list.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 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
|
||||
@ -537,10 +538,10 @@ public class YAMLNode {
|
||||
list.add(tetsu);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 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
|
||||
@ -554,25 +555,25 @@ public class YAMLNode {
|
||||
*/
|
||||
public List<Vector> getVectorList(
|
||||
String path, List<Vector> def) {
|
||||
|
||||
|
||||
List<YAMLNode> raw = getNodeList(path, null);
|
||||
List<Vector> list = new ArrayList<Vector>();
|
||||
|
||||
|
||||
for (YAMLNode o : raw) {
|
||||
Double x = o.getDouble("x");
|
||||
Double y = o.getDouble("y");
|
||||
Double z = o.getDouble("z");
|
||||
|
||||
|
||||
if (x == null || y == null || z == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
list.add(new Vector(x, y, z));
|
||||
}
|
||||
|
||||
|
||||
return 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
|
||||
@ -586,24 +587,24 @@ public class YAMLNode {
|
||||
*/
|
||||
public List<Vector2D> getVector2dList(
|
||||
String path, List<Vector2D> def) {
|
||||
|
||||
|
||||
List<YAMLNode> raw = getNodeList(path, null);
|
||||
List<Vector2D> list = new ArrayList<Vector2D>();
|
||||
|
||||
|
||||
for (YAMLNode o : raw) {
|
||||
Double x = o.getDouble("x");
|
||||
Double z = o.getDouble("z");
|
||||
|
||||
|
||||
if (x == null || z == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
list.add(new Vector2D(x, z));
|
||||
}
|
||||
|
||||
|
||||
return 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
|
||||
@ -617,24 +618,24 @@ public class YAMLNode {
|
||||
*/
|
||||
public List<BlockVector2D> getBlockVector2dList(
|
||||
String path, List<BlockVector2D> def) {
|
||||
|
||||
|
||||
List<YAMLNode> raw = getNodeList(path, null);
|
||||
List<BlockVector2D> list = new ArrayList<BlockVector2D>();
|
||||
|
||||
|
||||
for (YAMLNode o : raw) {
|
||||
Double x = o.getDouble("x");
|
||||
Double z = o.getDouble("z");
|
||||
|
||||
|
||||
if (x == null || z == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
list.add(new BlockVector2D(x, z));
|
||||
}
|
||||
|
||||
|
||||
return 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
|
||||
@ -656,13 +657,13 @@ public class YAMLNode {
|
||||
List<YAMLNode> list = new ArrayList<YAMLNode>();
|
||||
for (Object o : raw) {
|
||||
if (o instanceof Map) {
|
||||
list.add(new YAMLNode((Map<String, Object>)o, writeDefaults));
|
||||
list.add(new YAMLNode((Map<String, Object>) o, writeDefaults));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -675,12 +676,12 @@ public class YAMLNode {
|
||||
public YAMLNode getNode(String path) {
|
||||
Object raw = getProperty(path);
|
||||
if (raw instanceof Map) {
|
||||
return new YAMLNode((Map<String, Object>)raw, writeDefaults);
|
||||
return new YAMLNode((Map<String, Object>) raw, writeDefaults);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@ -695,21 +696,21 @@ public class YAMLNode {
|
||||
return null;
|
||||
} else if (o instanceof Map) {
|
||||
Map<String, YAMLNode> nodes =
|
||||
new HashMap<String, YAMLNode>();
|
||||
|
||||
for (Map.Entry<String, Object> entry : ((Map<String, Object>)o).entrySet()) {
|
||||
new HashMap<String, YAMLNode>();
|
||||
|
||||
for (Map.Entry<String, Object> entry : ((Map<String, Object>) o).entrySet()) {
|
||||
if (entry.getValue() instanceof Map) {
|
||||
nodes.put(entry.getKey(),
|
||||
new YAMLNode((Map<String, Object>) entry.getValue(), writeDefaults));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nodes;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Casts a value to an integer. May return null.
|
||||
*
|
||||
@ -720,12 +721,12 @@ public class YAMLNode {
|
||||
if (o == null) {
|
||||
return null;
|
||||
} else if (o instanceof Number) {
|
||||
return ((Number)o).intValue();
|
||||
return ((Number) o).intValue();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Casts a value to a double. May return null.
|
||||
*
|
||||
@ -736,12 +737,12 @@ public class YAMLNode {
|
||||
if (o == null) {
|
||||
return null;
|
||||
} else if (o instanceof Number) {
|
||||
return ((Number)o).doubleValue();
|
||||
return ((Number) o).doubleValue();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Casts a value to a boolean. May return null.
|
||||
*
|
||||
@ -752,12 +753,12 @@ public class YAMLNode {
|
||||
if (o == null) {
|
||||
return null;
|
||||
} else if (o instanceof Boolean) {
|
||||
return (Boolean)o;
|
||||
return (Boolean) o;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the property at a location. This will override existing
|
||||
* configuration data to have it conform to key/value mappings.
|
||||
@ -770,20 +771,20 @@ public class YAMLNode {
|
||||
root.remove(path);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String[] parts = path.split("\\.");
|
||||
Map<String, Object> node = root;
|
||||
|
||||
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
Object o = node.get(parts[i]);
|
||||
|
||||
|
||||
// Found our target!
|
||||
if (i == parts.length - 1) {
|
||||
node.remove(parts[i]);
|
||||
return;
|
||||
}
|
||||
|
||||
node = (Map<String, Object>)o;
|
||||
|
||||
node = (Map<String, Object>) o;
|
||||
}
|
||||
}
|
||||
|
||||
@ -794,4 +795,4 @@ public class YAMLNode {
|
||||
public void setWriteDefaults(boolean writeDefaults) {
|
||||
this.writeDefaults = writeDefaults;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,10 +66,10 @@ public class YAMLProcessor extends YAMLNode {
|
||||
private Yaml yaml;
|
||||
private File file;
|
||||
private String header = null;
|
||||
|
||||
|
||||
public YAMLProcessor(File file, boolean writeDefaults, YAMLFormat format) {
|
||||
super(new HashMap<String, Object>(), writeDefaults);
|
||||
|
||||
|
||||
DumperOptions options = new DumperOptions();
|
||||
options.setIndent(4);
|
||||
options.setDefaultFlowStyle(format.getStyle());
|
||||
@ -77,22 +77,22 @@ public class YAMLProcessor extends YAMLNode {
|
||||
representer.setDefaultFlowStyle(format.getStyle());
|
||||
|
||||
yaml = new Yaml(new SafeConstructor(), representer, options);
|
||||
|
||||
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public YAMLProcessor(File file, boolean writeDefaults) {
|
||||
this(file, writeDefaults, YAMLFormat.COMPACT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads the configuration file.
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void load() throws IOException {
|
||||
public void load() throws IOException {
|
||||
FileInputStream stream = null;
|
||||
|
||||
|
||||
try {
|
||||
stream = new FileInputStream(file);
|
||||
read(yaml.load(new UnicodeReader(stream)));
|
||||
@ -171,7 +171,8 @@ public class YAMLProcessor extends YAMLNode {
|
||||
}
|
||||
yaml.dump(root, writer);
|
||||
return true;
|
||||
} catch (IOException e) {} finally {
|
||||
} catch (IOException e) {
|
||||
} finally {
|
||||
try {
|
||||
if (stream != null) {
|
||||
stream.close();
|
||||
@ -181,20 +182,20 @@ public class YAMLProcessor extends YAMLNode {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void read(Object input) throws YAMLProcessorException {
|
||||
try {
|
||||
if ( null == input ) {
|
||||
if (null == input) {
|
||||
root = new HashMap<String, Object>();
|
||||
} else {
|
||||
root = (Map<String, Object>)input;
|
||||
root = (Map<String, Object>) input;
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
throw new YAMLProcessorException("Root document must be an key-value structure");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method returns an empty ConfigurationNode for using as a
|
||||
* default in methods that select a node from a node list.
|
||||
|
@ -26,11 +26,11 @@ package com.sk89q.util.yaml;
|
||||
*/
|
||||
public class YAMLProcessorException extends Exception {
|
||||
private static final long serialVersionUID = -2442886939908724203L;
|
||||
|
||||
|
||||
public YAMLProcessorException() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
public YAMLProcessorException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
@ -38,9 +38,9 @@ public abstract class ArbitraryShape {
|
||||
Vector min = extent.getMinimumPoint();
|
||||
Vector max = extent.getMaximumPoint();
|
||||
|
||||
cacheSizeX = (int)(max.getX() - min.getX() + 1 + 2);
|
||||
cacheSizeY = (int)(max.getY() - min.getY() + 1 + 2);
|
||||
cacheSizeZ = (int)(max.getZ() - min.getZ() + 1 + 2);
|
||||
cacheSizeX = (int) (max.getX() - min.getX() + 1 + 2);
|
||||
cacheSizeY = (int) (max.getY() - min.getY() + 1 + 2);
|
||||
cacheSizeZ = (int) (max.getZ() - min.getZ() + 1 + 2);
|
||||
|
||||
cacheX = min.getBlockX() - 1;
|
||||
cacheY = min.getBlockY() - 1;
|
||||
@ -79,7 +79,7 @@ public abstract class ArbitraryShape {
|
||||
return null;
|
||||
}
|
||||
|
||||
short newCacheEntry = (short) (material.getType() | ((material.getData()+1) << 8));
|
||||
short newCacheEntry = (short) (material.getType() | ((material.getData() + 1) << 8));
|
||||
if (newCacheEntry == 0) {
|
||||
// type and data 0
|
||||
newCacheEntry = -2;
|
||||
@ -102,7 +102,7 @@ public abstract class ArbitraryShape {
|
||||
|
||||
private boolean isInsideCached(int x, int y, int z, Pattern pattern) {
|
||||
final int index = (y - cacheY) + (z - cacheZ) * cacheSizeY + (x - cacheX) * cacheSizeY * cacheSizeZ;
|
||||
|
||||
|
||||
switch (cache[index]) {
|
||||
case 0:
|
||||
// unknown block, meaning they must be outside the extent at this stage, but might still be inside the shape
|
||||
|
@ -80,9 +80,9 @@ public class BlockVector extends Vector {
|
||||
if (!(obj instanceof Vector)) {
|
||||
return false;
|
||||
}
|
||||
Vector other = (Vector)obj;
|
||||
return (int)other.getX() == (int)this.x && (int)other.getY() == (int)this.y
|
||||
&& (int)other.getZ() == (int)this.z;
|
||||
Vector other = (Vector) obj;
|
||||
return (int) other.getX() == (int) this.x && (int) other.getY() == (int) this.y
|
||||
&& (int) other.getZ() == (int) this.z;
|
||||
|
||||
}
|
||||
|
||||
@ -93,8 +93,8 @@ public class BlockVector extends Vector {
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (Integer.valueOf((int)x).hashCode() << 19) ^
|
||||
(Integer.valueOf((int)y).hashCode() << 12) ^
|
||||
Integer.valueOf((int)z).hashCode();
|
||||
return (Integer.valueOf((int) x).hashCode() << 19) ^
|
||||
(Integer.valueOf((int) y).hashCode() << 12) ^
|
||||
Integer.valueOf((int) z).hashCode();
|
||||
}
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ public class BlockVector2D extends Vector2D {
|
||||
if (!(obj instanceof Vector2D)) {
|
||||
return false;
|
||||
}
|
||||
Vector2D other = (Vector2D)obj;
|
||||
return (int)other.x == (int)this.x && (int)other.z == (int)this.z;
|
||||
Vector2D other = (Vector2D) obj;
|
||||
return (int) other.x == (int) this.x && (int) other.z == (int) this.z;
|
||||
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ public class BlockVector2D extends Vector2D {
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (Integer.valueOf((int)x).hashCode() >> 13) ^
|
||||
Integer.valueOf((int)z).hashCode();
|
||||
return (Integer.valueOf((int) x).hashCode() >> 13) ^
|
||||
Integer.valueOf((int) z).hashCode();
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class BlockWorldVector extends WorldVector {
|
||||
public BlockWorldVector(WorldVector pt) {
|
||||
super(pt.getWorld(), pt);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct the Vector object.
|
||||
* @param world
|
||||
@ -101,7 +101,7 @@ public class BlockWorldVector extends WorldVector {
|
||||
public BlockWorldVector(LocalWorld world, double x, double y, double z) {
|
||||
super(world, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if another object is equivalent.
|
||||
*
|
||||
@ -113,9 +113,9 @@ public class BlockWorldVector extends WorldVector {
|
||||
if (!(obj instanceof WorldVector)) {
|
||||
return false;
|
||||
}
|
||||
WorldVector other = (WorldVector)obj;
|
||||
return (int)other.getX() == (int)this.x && (int)other.getY() == (int)this.y
|
||||
&& (int)other.getZ() == (int)this.z;
|
||||
WorldVector other = (WorldVector) obj;
|
||||
return (int) other.getX() == (int) this.x && (int) other.getY() == (int) this.y
|
||||
&& (int) other.getZ() == (int) this.z;
|
||||
|
||||
}
|
||||
|
||||
@ -126,8 +126,8 @@ public class BlockWorldVector extends WorldVector {
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (Integer.valueOf((int)x).hashCode() << 19) ^
|
||||
(Integer.valueOf((int)y).hashCode() << 12) ^
|
||||
Integer.valueOf((int)z).hashCode();
|
||||
return (Integer.valueOf((int) x).hashCode() << 19) ^
|
||||
(Integer.valueOf((int) y).hashCode() << 12) ^
|
||||
Integer.valueOf((int) z).hashCode();
|
||||
}
|
||||
}
|
||||
|
@ -58,4 +58,4 @@ public class BlockWorldVector2D extends WorldVector2D {
|
||||
&& (int) other.getZ() == (int) this.z;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ public class CuboidClipboard {
|
||||
return;
|
||||
}
|
||||
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 length = getLength();
|
||||
@ -260,7 +260,7 @@ public class CuboidClipboard {
|
||||
for (int y = 0; y < size.getBlockY(); ++y) {
|
||||
for (int z = 0; z < size.getBlockZ(); ++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
|
||||
* @throws MaxChangedBlocksException
|
||||
*/
|
||||
public void place(EditSession editSession, Vector pos, boolean noAir)
|
||||
throws MaxChangedBlocksException {
|
||||
public void place(EditSession editSession, Vector pos, boolean noAir) throws MaxChangedBlocksException {
|
||||
for (int x = 0; x < size.getBlockX(); ++x) {
|
||||
for (int y = 0; y < size.getBlockY(); ++y) {
|
||||
for (int z = 0; z < size.getBlockZ(); ++z) {
|
||||
if (noAir && data[x][y][z].isAir())
|
||||
if (noAir && data[x][y][z].isAir()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
editSession.setBlock(new Vector(x, y, z).add(pos),
|
||||
data[x][y][z]);
|
||||
editSession.setBlock(new Vector(x, y, z).add(pos), data[x][y][z]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -345,10 +344,10 @@ public class CuboidClipboard {
|
||||
throw new DataException("Length of region too large for a .schematic");
|
||||
}
|
||||
|
||||
HashMap<String,Tag> schematic = new HashMap<String,Tag>();
|
||||
schematic.put("Width", new ShortTag("Width", (short)width));
|
||||
schematic.put("Length", new ShortTag("Length", (short)length));
|
||||
schematic.put("Height", new ShortTag("Height", (short)height));
|
||||
HashMap<String, Tag> schematic = new HashMap<String, Tag>();
|
||||
schematic.put("Width", new ShortTag("Width", (short) width));
|
||||
schematic.put("Length", new ShortTag("Length", (short) length));
|
||||
schematic.put("Height", new ShortTag("Height", (short) height));
|
||||
schematic.put("Materials", new StringTag("Materials", "Alpha"));
|
||||
schematic.put("WEOriginX", new IntTag("WEOriginX", getOrigin().getBlockX()));
|
||||
schematic.put("WEOriginY", new IntTag("WEOriginY", getOrigin().getBlockY()));
|
||||
@ -366,16 +365,16 @@ public class CuboidClipboard {
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int z = 0; z < length; ++z) {
|
||||
int index = y * width * length + z * width + x;
|
||||
blocks[index] = (byte)data[x][y][z].getType();
|
||||
blockData[index] = (byte)data[x][y][z].getData();
|
||||
blocks[index] = (byte) data[x][y][z].getType();
|
||||
blockData[index] = (byte) data[x][y][z].getData();
|
||||
|
||||
// Store TileEntity data
|
||||
if (data[x][y][z] instanceof TileEntityBlock) {
|
||||
TileEntityBlock tileEntityBlock =
|
||||
(TileEntityBlock)data[x][y][z];
|
||||
(TileEntityBlock) data[x][y][z];
|
||||
|
||||
// Get the list of key/values from the block
|
||||
Map<String,Tag> values = tileEntityBlock.toTileEntityNBT();
|
||||
Map<String, Tag> values = tileEntityBlock.toTileEntityNBT();
|
||||
if (values != null) {
|
||||
values.put("id", new StringTag("id",
|
||||
tileEntityBlock.getTileEntityID()));
|
||||
@ -421,78 +420,78 @@ public class CuboidClipboard {
|
||||
Vector offset = new Vector();
|
||||
|
||||
// Schematic tag
|
||||
CompoundTag schematicTag = (CompoundTag)nbtStream.readTag();
|
||||
CompoundTag schematicTag = (CompoundTag) nbtStream.readTag();
|
||||
if (!schematicTag.getName().equals("Schematic")) {
|
||||
throw new DataException("Tag \"Schematic\" does not exist or is not first");
|
||||
}
|
||||
|
||||
// Check
|
||||
Map<String,Tag> schematic = schematicTag.getValue();
|
||||
Map<String, Tag> schematic = schematicTag.getValue();
|
||||
if (!schematic.containsKey("Blocks")) {
|
||||
throw new DataException("Schematic file is missing a \"Blocks\" tag");
|
||||
}
|
||||
|
||||
// Get information
|
||||
short width = (Short)getChildTag(schematic, "Width", ShortTag.class).getValue();
|
||||
short length = (Short)getChildTag(schematic, "Length", ShortTag.class).getValue();
|
||||
short height = (Short)getChildTag(schematic, "Height", ShortTag.class).getValue();
|
||||
short width = (Short) getChildTag(schematic, "Width", ShortTag.class).getValue();
|
||||
short length = (Short) getChildTag(schematic, "Length", ShortTag.class).getValue();
|
||||
short height = (Short) getChildTag(schematic, "Height", ShortTag.class).getValue();
|
||||
|
||||
try {
|
||||
int originX = (Integer)getChildTag(schematic, "WEOriginX", IntTag.class).getValue();
|
||||
int originY = (Integer)getChildTag(schematic, "WEOriginY", IntTag.class).getValue();
|
||||
int originZ = (Integer)getChildTag(schematic, "WEOriginZ", IntTag.class).getValue();
|
||||
int originX = (Integer) getChildTag(schematic, "WEOriginX", IntTag.class).getValue();
|
||||
int originY = (Integer) getChildTag(schematic, "WEOriginY", IntTag.class).getValue();
|
||||
int originZ = (Integer) getChildTag(schematic, "WEOriginZ", IntTag.class).getValue();
|
||||
origin = new Vector(originX, originY, originZ);
|
||||
} catch (DataException e) {
|
||||
// No origin data
|
||||
}
|
||||
|
||||
try {
|
||||
int offsetX = (Integer)getChildTag(schematic, "WEOffsetX", IntTag.class).getValue();
|
||||
int offsetY = (Integer)getChildTag(schematic, "WEOffsetY", IntTag.class).getValue();
|
||||
int offsetZ = (Integer)getChildTag(schematic, "WEOffsetZ", IntTag.class).getValue();
|
||||
int offsetX = (Integer) getChildTag(schematic, "WEOffsetX", IntTag.class).getValue();
|
||||
int offsetY = (Integer) getChildTag(schematic, "WEOffsetY", IntTag.class).getValue();
|
||||
int offsetZ = (Integer) getChildTag(schematic, "WEOffsetZ", IntTag.class).getValue();
|
||||
offset = new Vector(offsetX, offsetY, offsetZ);
|
||||
} catch (DataException e) {
|
||||
// No offset data
|
||||
}
|
||||
|
||||
// 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")) {
|
||||
throw new DataException("Schematic file is not an Alpha schematic");
|
||||
}
|
||||
|
||||
// Get blocks
|
||||
byte[] blocks = (byte[])getChildTag(schematic, "Blocks", ByteArrayTag.class).getValue();
|
||||
byte[] blockData = (byte[])getChildTag(schematic, "Data", ByteArrayTag.class).getValue();
|
||||
byte[] blocks = (byte[]) getChildTag(schematic, "Blocks", ByteArrayTag.class).getValue();
|
||||
byte[] blockData = (byte[]) getChildTag(schematic, "Data", ByteArrayTag.class).getValue();
|
||||
|
||||
// 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();
|
||||
Map<BlockVector,Map<String,Tag>> tileEntitiesMap =
|
||||
new HashMap<BlockVector,Map<String,Tag>>();
|
||||
Map<BlockVector, Map<String, Tag>> tileEntitiesMap =
|
||||
new HashMap<BlockVector, Map<String, Tag>>();
|
||||
|
||||
for (Tag tag : tileEntities) {
|
||||
if (!(tag instanceof CompoundTag)) continue;
|
||||
CompoundTag t = (CompoundTag)tag;
|
||||
CompoundTag t = (CompoundTag) tag;
|
||||
|
||||
int x = 0;
|
||||
int y = 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.getValue() instanceof IntTag) {
|
||||
x = ((IntTag)entry.getValue()).getValue();
|
||||
x = ((IntTag) entry.getValue()).getValue();
|
||||
}
|
||||
} else if (entry.getKey().equals("y")) {
|
||||
if (entry.getValue() instanceof IntTag) {
|
||||
y = ((IntTag)entry.getValue()).getValue();
|
||||
y = ((IntTag) entry.getValue()).getValue();
|
||||
}
|
||||
} else if (entry.getKey().equals("z")) {
|
||||
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
|
||||
&& tileEntitiesMap.containsKey(pt)) {
|
||||
((TileEntityBlock)block).fromTileEntityNBT(
|
||||
((TileEntityBlock) block).fromTileEntityNBT(
|
||||
tileEntitiesMap.get(pt));
|
||||
}
|
||||
|
||||
@ -570,7 +569,7 @@ public class CuboidClipboard {
|
||||
* @return child tag
|
||||
* @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 {
|
||||
|
||||
if (!items.containsKey(key)) {
|
||||
|
@ -33,7 +33,7 @@ import java.util.NoSuchElementException;
|
||||
* @param <A>
|
||||
* @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.
|
||||
*/
|
||||
@ -88,13 +88,13 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Iterator<Map.Entry<A,B>> iterator() {
|
||||
public Iterator<Map.Entry<A, B>> iterator() {
|
||||
if (isReversed) {
|
||||
return new ReverseEntryIterator<Map.Entry<A,B>>(
|
||||
return new ReverseEntryIterator<Map.Entry<A, B>>(
|
||||
listA.listIterator(listA.size()),
|
||||
listB.listIterator(listB.size()));
|
||||
} else {
|
||||
return new ForwardEntryIterator<Map.Entry<A,B>>(
|
||||
return new ForwardEntryIterator<Map.Entry<A, B>>(
|
||||
listA.iterator(),
|
||||
listB.iterator());
|
||||
}
|
||||
@ -105,8 +105,8 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public class ForwardEntryIterator<T extends Map.Entry<A,B>>
|
||||
implements Iterator<Map.Entry<A,B>> {
|
||||
public class ForwardEntryIterator<T extends Map.Entry<A, B>>
|
||||
implements Iterator<Map.Entry<A, B>> {
|
||||
|
||||
private Iterator<A> keyIterator;
|
||||
private Iterator<B> valueIterator;
|
||||
@ -120,8 +120,8 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
|
||||
return keyIterator.hasNext();
|
||||
}
|
||||
|
||||
public Map.Entry<A,B> next() throws NoSuchElementException {
|
||||
return new Entry<A,B>(keyIterator.next(), valueIterator.next());
|
||||
public Map.Entry<A, B> next() throws NoSuchElementException {
|
||||
return new Entry<A, B>(keyIterator.next(), valueIterator.next());
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
@ -134,8 +134,8 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public class ReverseEntryIterator<T extends Map.Entry<A,B>>
|
||||
implements Iterator<Map.Entry<A,B>> {
|
||||
public class ReverseEntryIterator<T extends Map.Entry<A, B>>
|
||||
implements Iterator<Map.Entry<A, B>> {
|
||||
|
||||
private ListIterator<A> keyIterator;
|
||||
private ListIterator<B> valueIterator;
|
||||
@ -149,8 +149,8 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
|
||||
return keyIterator.hasPrevious();
|
||||
}
|
||||
|
||||
public Map.Entry<A,B> next() throws NoSuchElementException {
|
||||
return new Entry<A,B>(keyIterator.previous(), valueIterator.previous());
|
||||
public Map.Entry<A, B> next() throws NoSuchElementException {
|
||||
return new Entry<A, B>(keyIterator.previous(), valueIterator.previous());
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
@ -164,7 +164,7 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
|
||||
* @param <C>
|
||||
* @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 B value;
|
||||
|
||||
|
@ -66,31 +66,31 @@ public class EditSession {
|
||||
* Stores the original blocks before modification.
|
||||
*/
|
||||
private DoubleArrayList<BlockVector, BaseBlock> original =
|
||||
new DoubleArrayList<BlockVector, BaseBlock>(true);
|
||||
new DoubleArrayList<BlockVector, BaseBlock>(true);
|
||||
|
||||
/**
|
||||
* Stores the current blocks.
|
||||
*/
|
||||
private DoubleArrayList<BlockVector, BaseBlock> current =
|
||||
new DoubleArrayList<BlockVector, BaseBlock>(false);
|
||||
new DoubleArrayList<BlockVector, BaseBlock>(false);
|
||||
|
||||
/**
|
||||
* Blocks that should be placed before last.
|
||||
*/
|
||||
private DoubleArrayList<BlockVector, BaseBlock> queueAfter =
|
||||
new DoubleArrayList<BlockVector, BaseBlock>(false);
|
||||
new DoubleArrayList<BlockVector, BaseBlock>(false);
|
||||
|
||||
/**
|
||||
* Blocks that should be placed last.
|
||||
*/
|
||||
private DoubleArrayList<BlockVector, BaseBlock> queueLast =
|
||||
new DoubleArrayList<BlockVector, BaseBlock>(false);
|
||||
new DoubleArrayList<BlockVector, BaseBlock>(false);
|
||||
|
||||
/**
|
||||
* Blocks that should be placed after all other blocks.
|
||||
*/
|
||||
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
|
||||
@ -327,20 +327,17 @@ public class EditSession {
|
||||
if (BlockType.shouldPlaceLast(block.getType())) {
|
||||
// Place torches, etc. last
|
||||
queueLast.put(pt.toBlockVector(), block);
|
||||
return !(getBlockType(pt) == block.getType()
|
||||
&& getBlockData(pt) == block.getData());
|
||||
return !(getBlockType(pt) == block.getType() && getBlockData(pt) == block.getData());
|
||||
} else if (BlockType.shouldPlaceFinal(block.getType())) {
|
||||
// Place signs, reed, etc even later
|
||||
queueFinal.put(pt.toBlockVector(), block);
|
||||
return !(getBlockType(pt) == block.getType()
|
||||
&& getBlockData(pt) == block.getData());
|
||||
return !(getBlockType(pt) == block.getType() && getBlockData(pt) == block.getData());
|
||||
} else if (BlockType.shouldPlaceLast(getBlockType(pt))) {
|
||||
// Destroy torches, etc. first
|
||||
rawSetBlock(pt, new BaseBlock(BlockID.AIR));
|
||||
} else {
|
||||
queueAfter.put(pt.toBlockVector(), block);
|
||||
return !(getBlockType(pt) == block.getType()
|
||||
&& getBlockData(pt) == block.getData());
|
||||
return !(getBlockType(pt) == block.getType() && getBlockData(pt) == block.getData());
|
||||
}
|
||||
}
|
||||
|
||||
@ -403,6 +400,7 @@ public class EditSession {
|
||||
|
||||
return world.getBlockData(pt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the block type at a position x, y, z.
|
||||
*
|
||||
@ -765,7 +763,7 @@ public class EditSession {
|
||||
continue;
|
||||
}
|
||||
|
||||
final Deque<BlockVector> walked = new LinkedList<BlockVector>();
|
||||
final Deque<BlockVector> walked = new LinkedList<BlockVector>();
|
||||
|
||||
while (true) {
|
||||
walked.addFirst(current);
|
||||
@ -1962,7 +1960,7 @@ public class EditSession {
|
||||
|
||||
visited.add(cur);
|
||||
|
||||
if (setBlock(cur, stationaryBlock)){
|
||||
if (setBlock(cur, stationaryBlock)) {
|
||||
++affected;
|
||||
}
|
||||
|
||||
@ -2033,13 +2031,11 @@ public class EditSession {
|
||||
final int ceilRadiusZ = (int) Math.ceil(radiusZ);
|
||||
|
||||
double nextXn = 0;
|
||||
forX:
|
||||
for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
forX: for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
final double xn = nextXn;
|
||||
nextXn = (x + 1) * invRadiusX;
|
||||
double nextZn = 0;
|
||||
forZ:
|
||||
for (int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
final double zn = nextZn;
|
||||
nextZn = (z + 1) * invRadiusZ;
|
||||
|
||||
@ -2119,18 +2115,15 @@ public class EditSession {
|
||||
final int ceilRadiusZ = (int) Math.ceil(radiusZ);
|
||||
|
||||
double nextXn = 0;
|
||||
forX:
|
||||
for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
forX: for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
final double xn = nextXn;
|
||||
nextXn = (x + 1) * invRadiusX;
|
||||
double nextYn = 0;
|
||||
forY:
|
||||
for (int y = 0; y <= ceilRadiusY; ++y) {
|
||||
forY: for (int y = 0; y <= ceilRadiusY; ++y) {
|
||||
final double yn = nextYn;
|
||||
nextYn = (y + 1) * invRadiusY;
|
||||
double nextZn = 0;
|
||||
forZ:
|
||||
for (int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
final double zn = nextZn;
|
||||
nextZn = (z + 1) * invRadiusZ;
|
||||
|
||||
@ -2244,7 +2237,7 @@ public class EditSession {
|
||||
public int thaw(Vector pos, double radius)
|
||||
throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
double radiusSq = radius*radius;
|
||||
double radiusSq = radius * radius;
|
||||
|
||||
int ox = pos.getBlockX();
|
||||
int oy = pos.getBlockY();
|
||||
@ -2303,7 +2296,7 @@ public class EditSession {
|
||||
public int simulateSnow(Vector pos, double radius)
|
||||
throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
double radiusSq = radius*radius;
|
||||
double radiusSq = radius * radius;
|
||||
|
||||
int ox = pos.getBlockX();
|
||||
int oy = pos.getBlockY();
|
||||
@ -2368,7 +2361,7 @@ public class EditSession {
|
||||
public int green(Vector pos, double radius)
|
||||
throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
double radiusSq = radius*radius;
|
||||
double radiusSq = radius * radius;
|
||||
|
||||
int ox = pos.getBlockX();
|
||||
int oy = pos.getBlockY();
|
||||
@ -2655,7 +2648,7 @@ public class EditSession {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new BaseBlock((int)typeVariable.getValue(), (int)dataVariable.getValue());
|
||||
return new BaseBlock((int) typeVariable.getValue(), (int) dataVariable.getValue());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
@ -30,4 +30,4 @@ public enum EntityType {
|
||||
MINECARTS,
|
||||
TNT,
|
||||
XP_ORBS
|
||||
}
|
||||
}
|
||||
|
@ -21,11 +21,11 @@ package com.sk89q.worldedit;
|
||||
|
||||
public class FileSelectionAbortedException extends FilenameException {
|
||||
private static final long serialVersionUID = 7377072269988014886L;
|
||||
|
||||
|
||||
public FileSelectionAbortedException() {
|
||||
super("");
|
||||
}
|
||||
|
||||
|
||||
public FileSelectionAbortedException(String msg) {
|
||||
super("", msg);
|
||||
}
|
||||
|
@ -21,19 +21,19 @@ package com.sk89q.worldedit;
|
||||
|
||||
public class FilenameException extends WorldEditException {
|
||||
private static final long serialVersionUID = 6072601657326106265L;
|
||||
|
||||
|
||||
private String filename;
|
||||
|
||||
|
||||
public FilenameException(String filename) {
|
||||
super();
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
|
||||
public FilenameException(String filename, String msg) {
|
||||
super(msg);
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
@ -21,11 +21,11 @@ package com.sk89q.worldedit;
|
||||
|
||||
public class FilenameResolutionException extends FilenameException {
|
||||
private static final long serialVersionUID = 4673670296313383121L;
|
||||
|
||||
|
||||
public FilenameResolutionException(String filename) {
|
||||
super(filename);
|
||||
}
|
||||
|
||||
|
||||
public FilenameResolutionException(String filename, String msg) {
|
||||
super(filename, msg);
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
package com.sk89q.worldedit;
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEditLibrary
|
||||
@ -18,6 +17,8 @@ package com.sk89q.worldedit;
|
||||
* 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.BlockID;
|
||||
import com.sk89q.worldedit.filtering.HeightMapFilter;
|
||||
|
@ -21,11 +21,11 @@ package com.sk89q.worldedit;
|
||||
|
||||
public class InvalidFilenameException extends FilenameException {
|
||||
private static final long serialVersionUID = 7377072269988014886L;
|
||||
|
||||
|
||||
public InvalidFilenameException(String filename) {
|
||||
super(filename);
|
||||
}
|
||||
|
||||
|
||||
public InvalidFilenameException(String filename, String msg) {
|
||||
super(filename, msg);
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ package com.sk89q.worldedit;
|
||||
|
||||
public class InvalidToolBindException extends WorldEditException {
|
||||
private static final long serialVersionUID = -1865311004052447699L;
|
||||
|
||||
|
||||
private int itemId;
|
||||
|
||||
|
||||
public InvalidToolBindException(int itemId, String msg) {
|
||||
super(msg);
|
||||
this.itemId = itemId;
|
||||
|
@ -26,7 +26,6 @@ import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* Represents WorldEdit's configuration.
|
||||
*
|
||||
@ -102,12 +101,12 @@ public abstract class LocalConfiguration {
|
||||
public String saveDir = "schematics";
|
||||
public String scriptsDir = "craftscripts";
|
||||
public boolean showFirstUseVersion = true;
|
||||
|
||||
|
||||
/**
|
||||
* Loads the configuration.
|
||||
*/
|
||||
public abstract void load();
|
||||
|
||||
|
||||
/**
|
||||
* Get the working directory to work from.
|
||||
*
|
||||
|
@ -322,6 +322,7 @@ public abstract class LocalPlayer {
|
||||
TargetBlock tb = new TargetBlock(this, range, 0.2);
|
||||
return (useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the point of the block being looked at. May return null.
|
||||
*
|
||||
@ -556,7 +557,7 @@ public abstract class LocalPlayer {
|
||||
* @param 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)) {
|
||||
return false;
|
||||
}
|
||||
LocalPlayer other2 = (LocalPlayer)other;
|
||||
LocalPlayer other2 = (LocalPlayer) other;
|
||||
return other2.getName().equals(getName());
|
||||
}
|
||||
|
||||
@ -652,8 +653,8 @@ public abstract class LocalPlayer {
|
||||
}
|
||||
|
||||
public void checkPermission(String permission) throws WorldEditPermissionException {
|
||||
if (!hasPermission(permission)) {
|
||||
throw new WorldEditPermissionException();
|
||||
}
|
||||
if (!hasPermission(permission)) {
|
||||
throw new WorldEditPermissionException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,6 @@ public class LocalSession {
|
||||
private boolean fastMode = false;
|
||||
private Mask mask;
|
||||
private TimeZone timezone = TimeZone.getDefault();
|
||||
//private Boolean jumptoBlock = true;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
@ -165,7 +164,7 @@ public class LocalSession {
|
||||
if (historyPointer < history.size()) {
|
||||
EditSession editSession = history.get(historyPointer);
|
||||
EditSession newEditSession =
|
||||
new EditSession(editSession.getWorld(), -1, newBlockBag);
|
||||
new EditSession(editSession.getWorld(), -1, newBlockBag);
|
||||
newEditSession.enableQueue();
|
||||
newEditSession.setFastMode(fastMode);
|
||||
editSession.redo(newEditSession);
|
||||
@ -465,7 +464,7 @@ public class LocalSession {
|
||||
setTool(item, tool);
|
||||
}
|
||||
|
||||
return (BrushTool)tool;
|
||||
return (BrushTool) tool;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ public abstract class LocalWorld {
|
||||
* Random generator.
|
||||
*/
|
||||
protected Random random = new Random();
|
||||
|
||||
|
||||
/**
|
||||
* Get the name of the world.
|
||||
*
|
||||
@ -129,7 +129,7 @@ public abstract class LocalWorld {
|
||||
* @return
|
||||
*/
|
||||
public abstract int getBlockLightLevel(Vector pt);
|
||||
|
||||
|
||||
/**
|
||||
* Regenerate an area.
|
||||
*
|
||||
@ -248,10 +248,16 @@ public abstract class LocalWorld {
|
||||
*/
|
||||
public void simulateBlockMine(Vector pt) {
|
||||
BaseItemStack stack = BlockType.getBlockDrop(getBlockType(pt), (short) getBlockData(pt));
|
||||
if (stack != null) dropItem(pt,
|
||||
stack.getAmount() > 1 ? new BaseItemStack(stack.getType(),
|
||||
1, stack.getDamage()) : stack, stack.getAmount());
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
public abstract int removeEntities(EntityType type, Vector origin, int radius);
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether a block has a valid ID.
|
||||
*
|
||||
@ -298,7 +304,8 @@ public abstract class LocalWorld {
|
||||
*
|
||||
* @param pt Position to check
|
||||
*/
|
||||
public void checkLoadedChunk(Vector pt) {}
|
||||
public void checkLoadedChunk(Vector pt) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare if the other world is equal.
|
||||
@ -331,7 +338,9 @@ public abstract class LocalWorld {
|
||||
*
|
||||
* @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) {
|
||||
}
|
||||
}
|
||||
|
@ -33,27 +33,27 @@ public enum PlayerDirection {
|
||||
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),
|
||||
DOWN(new Vector(0, -1, 0), new Vector(0, 0, 1), true);
|
||||
|
||||
|
||||
private Vector dir;
|
||||
private Vector leftDir;
|
||||
private boolean isOrthogonal;
|
||||
|
||||
|
||||
PlayerDirection(Vector vec, Vector leftDir, boolean isOrthogonal) {
|
||||
this.dir = vec;
|
||||
this.leftDir = leftDir;
|
||||
this.isOrthogonal = isOrthogonal;
|
||||
}
|
||||
|
||||
|
||||
public Vector vector() {
|
||||
return dir;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public Vector leftVector() {
|
||||
return leftDir;
|
||||
}
|
||||
|
||||
|
||||
public boolean isOrthogonal() {
|
||||
return isOrthogonal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ package com.sk89q.worldedit;
|
||||
* @author sk89q
|
||||
*/
|
||||
public interface SessionCheck {
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a player is online.
|
||||
*
|
||||
@ -33,5 +33,5 @@ public interface SessionCheck {
|
||||
* @return
|
||||
*/
|
||||
public boolean isOnlinePlayer(String name);
|
||||
|
||||
|
||||
}
|
||||
|
@ -47,9 +47,9 @@ public class Vector {
|
||||
* @param z
|
||||
*/
|
||||
public Vector(int x, int y, int z) {
|
||||
this.x = (double)x;
|
||||
this.y = (double)y;
|
||||
this.z = (double)z;
|
||||
this.x = (double) x;
|
||||
this.y = (double) y;
|
||||
this.z = (double) z;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,9 +60,9 @@ public class Vector {
|
||||
* @param z
|
||||
*/
|
||||
public Vector(float x, float y, float z) {
|
||||
this.x = (double)x;
|
||||
this.y = (double)y;
|
||||
this.z = (double)z;
|
||||
this.x = (double) x;
|
||||
this.y = (double) y;
|
||||
this.z = (double) z;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,7 +96,7 @@ public class Vector {
|
||||
* @return the x
|
||||
*/
|
||||
public int getBlockX() {
|
||||
return (int)Math.round(x);
|
||||
return (int) Math.round(x);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,7 +130,7 @@ public class Vector {
|
||||
* @return the y
|
||||
*/
|
||||
public int getBlockY() {
|
||||
return (int)Math.round(y);
|
||||
return (int) Math.round(y);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,7 +164,7 @@ public class Vector {
|
||||
* @return the z
|
||||
*/
|
||||
public int getBlockZ() {
|
||||
return (int)Math.round(z);
|
||||
return (int) Math.round(z);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,7 +227,7 @@ public class Vector {
|
||||
* @param others
|
||||
* @return New point
|
||||
*/
|
||||
public Vector add(Vector ... others) {
|
||||
public Vector add(Vector... others) {
|
||||
double newX = x, newY = y, newZ = z;
|
||||
|
||||
for (int i = 0; i < others.length; ++i) {
|
||||
@ -278,7 +278,7 @@ public class Vector {
|
||||
* @param others
|
||||
* @return New point
|
||||
*/
|
||||
public Vector subtract(Vector ... others) {
|
||||
public Vector subtract(Vector... others) {
|
||||
double newX = x, newY = y, newZ = z;
|
||||
|
||||
for (int i = 0; i < others.length; ++i) {
|
||||
@ -329,7 +329,7 @@ public class Vector {
|
||||
* @param others
|
||||
* @return New point
|
||||
*/
|
||||
public Vector multiply(Vector ... others) {
|
||||
public Vector multiply(Vector... others) {
|
||||
double newX = x, newY = y, newZ = z;
|
||||
|
||||
for (int i = 0; i < others.length; ++i) {
|
||||
@ -546,9 +546,9 @@ public class Vector {
|
||||
* @return point
|
||||
*/
|
||||
public static Vector toBlockPoint(double x, double y, double z) {
|
||||
return new Vector((int)Math.floor(x),
|
||||
(int)Math.floor(y),
|
||||
(int)Math.floor(z));
|
||||
return new Vector((int) Math.floor(x),
|
||||
(int) Math.floor(y),
|
||||
(int) Math.floor(z));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -557,9 +557,9 @@ public class Vector {
|
||||
* @return point
|
||||
*/
|
||||
public BlockVector toBlockPoint() {
|
||||
return new BlockVector((int)Math.floor(x),
|
||||
(int)Math.floor(y),
|
||||
(int)Math.floor(z));
|
||||
return new BlockVector((int) Math.floor(x),
|
||||
(int) Math.floor(y),
|
||||
(int) Math.floor(z));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,8 +44,8 @@ public class Vector2D {
|
||||
* @param z
|
||||
*/
|
||||
public Vector2D(int x, int z) {
|
||||
this.x = (double)x;
|
||||
this.z = (double)z;
|
||||
this.x = (double) x;
|
||||
this.z = (double) z;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,8 +55,8 @@ public class Vector2D {
|
||||
* @param z
|
||||
*/
|
||||
public Vector2D(float x, float z) {
|
||||
this.x = (double)x;
|
||||
this.z = (double)z;
|
||||
this.x = (double) x;
|
||||
this.z = (double) z;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,27 +53,27 @@ public class WorldEdit {
|
||||
* Logger for debugging.
|
||||
*/
|
||||
public static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
||||
|
||||
|
||||
/**
|
||||
* Holds WorldEdit's version.
|
||||
*/
|
||||
private static String version;
|
||||
|
||||
|
||||
/**
|
||||
* Interface to the server.
|
||||
*/
|
||||
private ServerInterface server;
|
||||
|
||||
|
||||
/**
|
||||
* Configuration. This is a subclass.
|
||||
*/
|
||||
private LocalConfiguration config;
|
||||
|
||||
|
||||
/**
|
||||
* List of commands.
|
||||
*/
|
||||
private CommandsManager<LocalPlayer> commands;
|
||||
|
||||
|
||||
/**
|
||||
* Stores a list of WorldEdit sessions, keyed by players' names. Sessions
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
static {
|
||||
getVersion();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct an instance of the plugin
|
||||
*
|
||||
@ -99,13 +99,13 @@ public class WorldEdit {
|
||||
public WorldEdit(ServerInterface server, final LocalConfiguration config) {
|
||||
this.server = server;
|
||||
this.config = config;
|
||||
|
||||
|
||||
commands = new CommandsManager<LocalPlayer>() {
|
||||
@Override
|
||||
public boolean hasPermission(LocalPlayer player, String perm) {
|
||||
return player.hasPermission(perm);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invokeMethod(Method parent, String[] args,
|
||||
LocalPlayer player, Method method, Object instance,
|
||||
@ -135,20 +135,20 @@ public class WorldEdit {
|
||||
/* FALL-THROUGH */
|
||||
|
||||
case POSITION:
|
||||
msg += " - Position: "+position;
|
||||
msg += " - Position: " + position;
|
||||
break;
|
||||
|
||||
case ALL:
|
||||
msg += " - Position: "+position;
|
||||
msg += " - Position: " + position;
|
||||
/* FALL-THROUGH */
|
||||
|
||||
case ORIENTATION_REGION:
|
||||
msg += " - Orientation: "+player.getCardinalDirection().name();
|
||||
msg += " - Orientation: " + player.getCardinalDirection().name();
|
||||
/* FALL-THROUGH */
|
||||
|
||||
case REGION:
|
||||
try {
|
||||
msg += " - Region: "+session.getSelection(player.getWorld());
|
||||
msg += " - Region: " + session.getSelection(player.getWorld());
|
||||
} catch (IncompleteRegionException e) {
|
||||
break;
|
||||
}
|
||||
@ -194,20 +194,20 @@ public class WorldEdit {
|
||||
*/
|
||||
public LocalSession getSession(LocalPlayer player) {
|
||||
LocalSession session;
|
||||
|
||||
|
||||
synchronized (sessions) {
|
||||
if (sessions.containsKey(player.getName())) {
|
||||
return sessions.get(player.getName());
|
||||
}
|
||||
|
||||
|
||||
session = new LocalSession(config);
|
||||
|
||||
|
||||
// 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
|
||||
// is no limit. There is also a default limit
|
||||
if (!player.hasPermission("worldedit.limit.unrestricted")
|
||||
&& config.maxChangeLimit > -1) {
|
||||
|
||||
|
||||
// If the default limit is infinite but there is a maximum
|
||||
// limit, make sure to not have it be overridden
|
||||
if (config.defaultChangeLimit < 0) {
|
||||
@ -222,17 +222,17 @@ public class WorldEdit {
|
||||
// No change limit or override
|
||||
session.setBlockChangeLimit(config.defaultChangeLimit);
|
||||
}
|
||||
|
||||
|
||||
// Have the session use inventory if it's enabled and the player
|
||||
// doesn't have an override
|
||||
session.setUseInventory(config.useInventory
|
||||
&& (!config.useInventoryOverride
|
||||
|| !player.hasPermission("worldedit.inventory.unrestricted")));
|
||||
|
||||
|
||||
// Remember the session
|
||||
sessions.put(player.getName(), session);
|
||||
}
|
||||
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ public class WorldEdit {
|
||||
String[] typeAndData = blockAndExtraData[0].split(":", 2);
|
||||
String testID = typeAndData[0];
|
||||
int blockId = -1;
|
||||
|
||||
|
||||
int data = -1;
|
||||
|
||||
// Attempt to parse the item ID or otherwise resolve an item/block
|
||||
@ -295,7 +295,7 @@ public class WorldEdit {
|
||||
if (blockId == -1 && blockType == null) {
|
||||
// Maybe it's a cloth
|
||||
ClothColor col = ClothColor.lookup(testID);
|
||||
|
||||
|
||||
if (col != null) {
|
||||
blockType = BlockType.CLOTH;
|
||||
data = col.getID();
|
||||
@ -303,16 +303,16 @@ public class WorldEdit {
|
||||
throw new UnknownItemException(arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Read block ID
|
||||
if (blockId == -1) {
|
||||
blockId = blockType.getID();
|
||||
}
|
||||
|
||||
|
||||
if (!player.getWorld().isValidBlockType(blockId)) {
|
||||
throw new UnknownItemException(arg);
|
||||
}
|
||||
|
||||
|
||||
if (data == -1) { // Block data not yet detected
|
||||
// Parse the block data (optional)
|
||||
try {
|
||||
@ -324,7 +324,7 @@ public class WorldEdit {
|
||||
switch (blockType) {
|
||||
case CLOTH:
|
||||
ClothColor col = ClothColor.lookup(typeAndData[1]);
|
||||
|
||||
|
||||
if (col != null) {
|
||||
data = col.getID();
|
||||
} else {
|
||||
@ -335,7 +335,7 @@ public class WorldEdit {
|
||||
case STEP:
|
||||
case DOUBLE_STEP:
|
||||
BlockType dataType = BlockType.lookup(typeAndData[1]);
|
||||
|
||||
|
||||
if (dataType != null) {
|
||||
switch (dataType) {
|
||||
case STONE:
|
||||
@ -374,25 +374,24 @@ public class WorldEdit {
|
||||
}
|
||||
|
||||
// Check if the item is allowed
|
||||
if (allAllowed || player.hasPermission("worldedit.anyblock")
|
||||
|| !config.disallowedBlocks.contains(blockId)) {
|
||||
|
||||
// Allow special sign text syntax
|
||||
if (blockType == BlockType.SIGN_POST
|
||||
|| blockType == BlockType.WALL_SIGN) {
|
||||
if (allAllowed || player.hasPermission("worldedit.anyblock") || !config.disallowedBlocks.contains(blockId)) {
|
||||
switch (blockType) {
|
||||
case SIGN_POST:
|
||||
case WALL_SIGN:
|
||||
// Allow special sign text syntax
|
||||
String[] text = new String[4];
|
||||
text[0] = blockAndExtraData.length > 1 ? blockAndExtraData[1] : "";
|
||||
text[1] = blockAndExtraData.length > 2 ? blockAndExtraData[2] : "";
|
||||
text[2] = blockAndExtraData.length > 3 ? blockAndExtraData[3] : "";
|
||||
text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : "";
|
||||
return new SignBlock(blockType.getID(), data, text);
|
||||
|
||||
// Allow setting mob spawn type
|
||||
} else if (blockType == BlockType.MOB_SPAWNER) {
|
||||
|
||||
case MOB_SPAWNER:
|
||||
// Allow setting mob spawn type
|
||||
if (blockAndExtraData.length > 1) {
|
||||
String mobName = blockAndExtraData[1];
|
||||
for (MobType mobType : MobType.values()){
|
||||
if (mobType.getName().toLowerCase().equals(mobName.toLowerCase())){
|
||||
for (MobType mobType : MobType.values()) {
|
||||
if (mobType.getName().toLowerCase().equals(mobName.toLowerCase())) {
|
||||
mobName = mobType.getName();
|
||||
break;
|
||||
}
|
||||
@ -404,9 +403,9 @@ public class WorldEdit {
|
||||
} else {
|
||||
return new MobSpawnerBlock(data, MobType.PIG.getName());
|
||||
}
|
||||
|
||||
// Allow setting note
|
||||
} else if (blockType == BlockType.NOTE_BLOCK) {
|
||||
|
||||
case NOTE_BLOCK:
|
||||
// Allow setting note
|
||||
if (blockAndExtraData.length > 1) {
|
||||
byte note = Byte.parseByte(blockAndExtraData[1]);
|
||||
if (note < 0 || note > 24) {
|
||||
@ -415,11 +414,12 @@ public class WorldEdit {
|
||||
return new NoteBlock(data, note);
|
||||
}
|
||||
} 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);
|
||||
@ -439,7 +439,7 @@ public class WorldEdit {
|
||||
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 {
|
||||
String[] items = list.split(",");
|
||||
Set<BaseBlock> blocks = new HashSet<BaseBlock>();
|
||||
@ -473,20 +473,20 @@ public class WorldEdit {
|
||||
throws UnknownItemException, DisallowedItemException {
|
||||
|
||||
String[] items = patternString.split(",");
|
||||
|
||||
|
||||
// Handle special block pattern types
|
||||
if (patternString.charAt(0) == '#') {
|
||||
if (patternString.equals("#clipboard") || patternString.equals("#copy")) {
|
||||
LocalSession session = getSession(player);
|
||||
CuboidClipboard clipboard;
|
||||
|
||||
|
||||
try {
|
||||
clipboard = session.getClipboard();
|
||||
} catch (EmptyClipboardException e) {
|
||||
player.printError("Copy a selection first with //copy.");
|
||||
throw new UnknownItemException("#clipboard");
|
||||
}
|
||||
|
||||
|
||||
return new ClipboardPattern(clipboard);
|
||||
} else {
|
||||
throw new UnknownItemException(patternString);
|
||||
@ -502,9 +502,9 @@ public class WorldEdit {
|
||||
|
||||
for (String s : items) {
|
||||
BaseBlock block;
|
||||
|
||||
|
||||
double chance;
|
||||
|
||||
|
||||
// Parse special percentage syntax
|
||||
if (s.matches("[0-9]+(?:\\.(?:[0-9]+)?)?%.*")) {
|
||||
String[] p = s.split("%");
|
||||
@ -514,22 +514,22 @@ public class WorldEdit {
|
||||
chance = 1;
|
||||
block = getBlock(player, s);
|
||||
}
|
||||
|
||||
|
||||
blockChances.add(new BlockChance(block, chance));
|
||||
}
|
||||
|
||||
return new RandomFillPattern(blockChances);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Get a block mask. Block masks are used to determine which
|
||||
* blocks to include when replacing.
|
||||
*
|
||||
*
|
||||
* @param player
|
||||
* @param session
|
||||
* @param maskString
|
||||
* @return
|
||||
* @throws WorldEditException
|
||||
* @throws WorldEditException
|
||||
*/
|
||||
public Mask getBlockMask(LocalPlayer player, LocalSession session,
|
||||
String maskString) throws WorldEditException {
|
||||
@ -622,7 +622,7 @@ public class WorldEdit {
|
||||
public Set<Integer> getBlockIDs(LocalPlayer player,
|
||||
String list, boolean allBlocksAllowed)
|
||||
throws UnknownItemException, DisallowedItemException {
|
||||
|
||||
|
||||
String[] items = list.split(",");
|
||||
Set<Integer> blocks = new HashSet<Integer>();
|
||||
for (String s : items) {
|
||||
@ -630,7 +630,7 @@ public class WorldEdit {
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -650,7 +650,7 @@ public class WorldEdit {
|
||||
throws FilenameException {
|
||||
return getSafeFile(player, dir, filename, defaultExt, extensions, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -670,7 +670,7 @@ public class WorldEdit {
|
||||
throws FilenameException {
|
||||
return getSafeFile(player, dir, filename, defaultExt, extensions, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a safe path to a file.
|
||||
*
|
||||
@ -687,14 +687,14 @@ public class WorldEdit {
|
||||
String defaultExt, String[] extensions, boolean isSave)
|
||||
throws FilenameException {
|
||||
File f;
|
||||
|
||||
|
||||
if (filename.equals("#")) {
|
||||
if (isSave) {
|
||||
f = player.openFileSaveDialog(extensions);
|
||||
} else {
|
||||
f = player.openFileOpenDialog(extensions);
|
||||
}
|
||||
|
||||
|
||||
if (f == null) {
|
||||
throw new FileSelectionAbortedException("No file selected");
|
||||
}
|
||||
@ -702,11 +702,11 @@ public class WorldEdit {
|
||||
if (defaultExt != null && filename.lastIndexOf('.') == -1) {
|
||||
filename += "." + defaultExt;
|
||||
}
|
||||
|
||||
|
||||
if (!filename.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+\\.[A-Za-z0-9]+$")) {
|
||||
throw new InvalidFilenameException(filename, "Invalid characters or extension missing");
|
||||
}
|
||||
|
||||
|
||||
f = new File(dir, filename);
|
||||
}
|
||||
|
||||
@ -718,7 +718,7 @@ public class WorldEdit {
|
||||
throw new FilenameResolutionException(filename,
|
||||
"Path is outside allowable root");
|
||||
}
|
||||
|
||||
|
||||
return f;
|
||||
} catch (IOException e) {
|
||||
throw new FilenameResolutionException(filename,
|
||||
@ -737,7 +737,7 @@ public class WorldEdit {
|
||||
throw new MaxRadiusException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a file relative to the defined working directory. If the specified
|
||||
* path is absolute, then the working directory is not used.
|
||||
@ -793,7 +793,7 @@ public class WorldEdit {
|
||||
default:
|
||||
throw new UnknownDirectionException(dir.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PlayerDirection getPlayerDirection(LocalPlayer player, String dirStr) throws UnknownDirectionException {
|
||||
final PlayerDirection dir;
|
||||
@ -859,7 +859,7 @@ public class WorldEdit {
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get diagonal direction vector for a player's direction. May return
|
||||
* null if a direction could not be found.
|
||||
@ -870,7 +870,7 @@ public class WorldEdit {
|
||||
* @throws UnknownDirectionException
|
||||
*/
|
||||
public Vector getDiagonalDirection(LocalPlayer player, String dirStr)
|
||||
throws UnknownDirectionException {
|
||||
throws UnknownDirectionException {
|
||||
|
||||
return getPlayerDirection(player, dirStr.toLowerCase()).vector();
|
||||
}
|
||||
@ -924,7 +924,7 @@ public class WorldEdit {
|
||||
sessions.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Flush a block bag's changes to a player.
|
||||
*
|
||||
@ -933,35 +933,35 @@ public class WorldEdit {
|
||||
*/
|
||||
public void flushBlockBag(LocalPlayer player,
|
||||
EditSession editSession) {
|
||||
|
||||
|
||||
BlockBag blockBag = editSession.getBlockBag();
|
||||
|
||||
|
||||
if (blockBag != null) {
|
||||
blockBag.flushChanges();
|
||||
}
|
||||
|
||||
|
||||
Set<Integer> missingBlocks = editSession.popMissingBlocks();
|
||||
|
||||
|
||||
if (missingBlocks.size() > 0) {
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append("Missing these blocks: ");
|
||||
int size = missingBlocks.size();
|
||||
int i = 0;
|
||||
|
||||
|
||||
for (Integer id : missingBlocks) {
|
||||
BlockType type = BlockType.fromID(id);
|
||||
|
||||
|
||||
str.append(type != null
|
||||
? type.getName() + " (" + id + ")"
|
||||
: id.toString());
|
||||
|
||||
|
||||
++i;
|
||||
|
||||
|
||||
if (i != size) {
|
||||
str.append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
player.printError(str.toString());
|
||||
}
|
||||
}
|
||||
@ -972,7 +972,7 @@ public class WorldEdit {
|
||||
public Map<String, String> getCommands() {
|
||||
return commands.getCommands();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
@ -981,7 +981,7 @@ public class WorldEdit {
|
||||
public void handleDisconnect(LocalPlayer player) {
|
||||
forgetPlayer(player);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
@ -994,7 +994,7 @@ public class WorldEdit {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Forget a player.
|
||||
*
|
||||
@ -1003,14 +1003,14 @@ public class WorldEdit {
|
||||
public void forgetPlayer(LocalPlayer player) {
|
||||
removeSession(player);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Flush expired sessions.
|
||||
*/
|
||||
public void flushExpiredSessions(SessionCheck checker) {
|
||||
synchronized (sessions) {
|
||||
Iterator<Map.Entry<String, LocalSession>> it = sessions.entrySet().iterator();
|
||||
|
||||
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, LocalSession> entry = it.next();
|
||||
if (entry.getValue().hasExpired()
|
||||
@ -1127,7 +1127,7 @@ public class WorldEdit {
|
||||
Tool tool = session.getTool(player.getItemInHand());
|
||||
if (tool != null && tool instanceof BlockTool) {
|
||||
if (tool.canUse(player)) {
|
||||
((BlockTool)tool).actPrimary(server, config, player, session, clicked);
|
||||
((BlockTool) tool).actPrimary(server, config, player, session, clicked);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1172,7 +1172,7 @@ public class WorldEdit {
|
||||
Tool tool = session.getTool(player.getItemInHand());
|
||||
if (tool != null && tool instanceof DoubleActionBlockTool) {
|
||||
if (tool.canUse(player)) {
|
||||
((DoubleActionBlockTool)tool).actSecondary(server, config, player, session, clicked);
|
||||
((DoubleActionBlockTool) tool).actSecondary(server, config, player, session, clicked);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1191,7 +1191,7 @@ public class WorldEdit {
|
||||
public boolean handleCommand(LocalPlayer player, String[] split) {
|
||||
try {
|
||||
split[0] = split[0].substring(1);
|
||||
|
||||
|
||||
// Quick script shortcut
|
||||
if (split[0].matches("^[^/].*\\.js$")) {
|
||||
String[] newSplit = new String[split.length + 1];
|
||||
@ -1200,9 +1200,9 @@ public class WorldEdit {
|
||||
newSplit[1] = newSplit[1];
|
||||
split = newSplit;
|
||||
}
|
||||
|
||||
|
||||
String searchCmd = split[0].toLowerCase();
|
||||
|
||||
|
||||
// Try to detect the command
|
||||
if (commands.hasCommand(searchCmd)) {
|
||||
} else if (config.noDoubleSlash && commands.hasCommand("/" + searchCmd)) {
|
||||
@ -1211,12 +1211,12 @@ public class WorldEdit {
|
||||
&& commands.hasCommand(searchCmd.substring(1))) {
|
||||
split[0] = split[0].substring(1);
|
||||
}
|
||||
|
||||
|
||||
// No command found!
|
||||
if (!commands.hasCommand(split[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
LocalSession session = getSession(player);
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
editSession.enableQueue();
|
||||
@ -1254,14 +1254,14 @@ public class WorldEdit {
|
||||
player.printDebug((time / 1000.0) + "s elapsed.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
flushBlockBag(player, editSession);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
final Matcher matcher = numberFormatExceptionPattern.matcher(e.getMessage());
|
||||
|
||||
if (matcher.matches()) {
|
||||
player.printError("Number expected; string \""+matcher.group(1)+"\" given.");
|
||||
player.printError("Number expected; string \"" + matcher.group(1) + "\" given.");
|
||||
} else {
|
||||
player.printError("Number expected; string given.");
|
||||
}
|
||||
@ -1305,7 +1305,7 @@ public class WorldEdit {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Executes a WorldEdit script.
|
||||
*
|
||||
@ -1316,24 +1316,24 @@ public class WorldEdit {
|
||||
*/
|
||||
public void runScript(LocalPlayer player, File f, String[] args)
|
||||
throws WorldEditException {
|
||||
String filename = f.getPath();
|
||||
String filename = f.getPath();
|
||||
int index = filename.lastIndexOf(".");
|
||||
String ext = filename.substring(index + 1, filename.length());
|
||||
|
||||
|
||||
if (!ext.equalsIgnoreCase("js")) {
|
||||
player.printError("Only .js scripts are currently supported");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String script;
|
||||
|
||||
|
||||
try {
|
||||
InputStream file;
|
||||
|
||||
|
||||
if (!f.exists()) {
|
||||
file = WorldEdit.class.getResourceAsStream(
|
||||
"craftscripts/" + filename);
|
||||
|
||||
|
||||
if (file == null) {
|
||||
player.printError("Script does not exist: " + filename);
|
||||
return;
|
||||
@ -1341,7 +1341,7 @@ public class WorldEdit {
|
||||
} else {
|
||||
file = new FileInputStream(f);
|
||||
}
|
||||
|
||||
|
||||
DataInputStream in = new DataInputStream(file);
|
||||
byte[] data = new byte[in.available()];
|
||||
in.readFully(data);
|
||||
@ -1351,11 +1351,11 @@ public class WorldEdit {
|
||||
player.printError("Script read error: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
LocalSession session = getSession(player);
|
||||
CraftScriptContext scriptContext =
|
||||
new CraftScriptContext(this, server, config, session, player, args);
|
||||
|
||||
|
||||
CraftScriptEngine engine = null;
|
||||
|
||||
try {
|
||||
@ -1365,18 +1365,18 @@ public class WorldEdit {
|
||||
player.printError("Please see http://wiki.sk89q.com/wiki/WorldEdit/Installation");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
engine.setTimeLimit(config.scriptTimeout);
|
||||
|
||||
|
||||
Map<String, Object> vars = new HashMap<String, Object>();
|
||||
vars.put("argv", args);
|
||||
vars.put("context", scriptContext);
|
||||
vars.put("player", player);
|
||||
|
||||
|
||||
try {
|
||||
engine.evaluate(script, filename, vars);
|
||||
} catch (ScriptException e) {
|
||||
player.printError("Failed to execute:");;
|
||||
player.printError("Failed to execute:");
|
||||
player.printRaw(e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (NumberFormatException e) {
|
||||
@ -1394,7 +1394,7 @@ public class WorldEdit {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Worldedit's configuration.
|
||||
*
|
||||
@ -1403,7 +1403,7 @@ public class WorldEdit {
|
||||
public LocalConfiguration getConfiguration() {
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the server interface.
|
||||
*
|
||||
@ -1422,18 +1422,18 @@ public class WorldEdit {
|
||||
if (version != null) {
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
Package p = WorldEdit.class.getPackage();
|
||||
|
||||
|
||||
if (p == null) {
|
||||
p = Package.getPackage("com.sk89q.worldedit");
|
||||
}
|
||||
|
||||
|
||||
if (p == null) {
|
||||
version = "(unknown)";
|
||||
} else {
|
||||
version = p.getImplementationVersion();
|
||||
|
||||
|
||||
if (version == null) {
|
||||
version = "(unknown)";
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class WorldVector extends Vector {
|
||||
/**
|
||||
* Represents the world.
|
||||
*/
|
||||
private LocalWorld world;
|
||||
private LocalWorld world;
|
||||
|
||||
/**
|
||||
* Construct the Vector object.
|
||||
@ -89,7 +89,7 @@ public class WorldVector extends Vector {
|
||||
super();
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the world.
|
||||
*
|
||||
@ -110,9 +110,9 @@ public class WorldVector extends Vector {
|
||||
*/
|
||||
public static WorldVector toBlockPoint(LocalWorld world, double x, double y,
|
||||
double z) {
|
||||
return new WorldVector(world, (int)Math.floor(x),
|
||||
(int)Math.floor(y),
|
||||
(int)Math.floor(z));
|
||||
return new WorldVector(world, (int) Math.floor(x),
|
||||
(int) Math.floor(y),
|
||||
(int) Math.floor(z));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,7 +80,7 @@ public class WorldVector2D extends Vector2D {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (world.hashCode() >> 7) ^
|
||||
((int)(Double.doubleToLongBits(x)^(Double.doubleToLongBits(x)>>>32)) >> 13) ^
|
||||
(int)(Double.doubleToLongBits(z)^(Double.doubleToLongBits(z)>>>32));
|
||||
((int) (Double.doubleToLongBits(x) ^ (Double.doubleToLongBits(x) >>> 32)) >> 13) ^
|
||||
(int) (Double.doubleToLongBits(z) ^ (Double.doubleToLongBits(z) >>> 32));
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public abstract class BlockBag {
|
||||
public void storeDroppedBlock(int id) throws BlockBagException {
|
||||
storeDroppedBlock(id, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stores a block as if it was mined.
|
||||
*
|
||||
@ -55,7 +55,7 @@ public abstract class BlockBag {
|
||||
|
||||
storeItem(dropped);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
storeItem(new BaseItem(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store a block.
|
||||
*
|
||||
@ -161,7 +161,7 @@ public abstract class BlockBag {
|
||||
public void storeItem(BaseItem item) throws BlockBagException {
|
||||
storeBlock(item.getType());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks to see if a block exists without removing it.
|
||||
*
|
||||
@ -177,7 +177,7 @@ public abstract class BlockBag {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Flush any changes. This is called at the end.
|
||||
*/
|
||||
@ -189,6 +189,7 @@ public abstract class BlockBag {
|
||||
* @param pos
|
||||
*/
|
||||
public abstract void addSourcePosition(Vector pos);
|
||||
|
||||
/**
|
||||
* Adds a position to be used a source.
|
||||
*
|
||||
|
@ -25,7 +25,7 @@ package com.sk89q.worldedit.bags;
|
||||
*/
|
||||
public class OutOfSpaceException extends BlockBagException {
|
||||
private static final long serialVersionUID = -2962840237632916821L;
|
||||
|
||||
|
||||
/**
|
||||
* Stores the block ID.
|
||||
*/
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.bags;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sk89q
|
||||
|
@ -74,7 +74,7 @@ public class BaseBlock {
|
||||
* @return the data
|
||||
*/
|
||||
public int getData() {
|
||||
return (int)data;
|
||||
return (int) data;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,6 +130,7 @@ public class BaseBlock {
|
||||
data = (byte) BlockData.flip(type, data);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flip this block.
|
||||
* @param direction
|
||||
|
@ -61,7 +61,7 @@ public class BaseItemStack extends BaseItem {
|
||||
super(id, damage);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the amount
|
||||
*/
|
||||
|
@ -721,7 +721,7 @@ public final class BlockData {
|
||||
case ClothColor.ID.MAGENTA: return ClothColor.ID.PINK;
|
||||
case ClothColor.ID.PINK: 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.WHITE: return ClothColor.ID.PINK;
|
||||
}
|
||||
|
||||
|
||||
return ClothColor.ID.WHITE;
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ public enum BlockType {
|
||||
FENCE_GATE(BlockID.FENCE_GATE, "Fence gate", "fencegate", "gate"),
|
||||
BRICK_STAIRS(BlockID.BRICK_STAIRS, "Brick stairs", "brickstairs", "bricksteps"),
|
||||
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"),
|
||||
NETHER_BRICK(BlockID.NETHER_BRICK, "Nether brick", "netherbrick"),
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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 String name;
|
||||
private final String[] lookupKeys;
|
||||
|
||||
static {
|
||||
for(BlockType type : EnumSet.allOf(BlockType.class)) {
|
||||
for (BlockType type : EnumSet.allOf(BlockType.class)) {
|
||||
ids.put(type.id, type);
|
||||
for (String key : type.lookupKeys) {
|
||||
lookup.put(key, type);
|
||||
@ -200,7 +200,7 @@ public enum BlockType {
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
BlockType(int id, String name, String ... lookupKeys) {
|
||||
BlockType(int id, String name, String... lookupKeys) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lookupKeys = lookupKeys;
|
||||
@ -947,7 +947,7 @@ public enum BlockType {
|
||||
addIdentity(BlockID.STONE_PRESSURE_PLATE); // rule 1
|
||||
addIdentities(BlockID.IRON_DOOR, 8); // rule 2
|
||||
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.REDSTONE_TORCH_OFF, new BaseItem(BlockID.REDSTONE_TORCH_ON)); // rule 3
|
||||
addIdentity(BlockID.REDSTONE_TORCH_ON); // rule 1
|
||||
@ -1029,7 +1029,7 @@ public enum BlockType {
|
||||
private static void addIdentity(int type) {
|
||||
nonDataBlockBagItems.put(type, new BaseItem(type));
|
||||
}
|
||||
|
||||
|
||||
private static void addIdentities(int type, int maxData) {
|
||||
for (int data = 0; data < maxData; ++data) {
|
||||
dataBlockBagItems.put(typeDataKey(type, data), new BaseItem(type, (short) data));
|
||||
|
@ -97,22 +97,22 @@ public class ChestBlock extends BaseBlock implements TileEntityBlock, ContainerB
|
||||
* @return map of values
|
||||
* @throws DataException
|
||||
*/
|
||||
public Map<String,Tag> toTileEntityNBT()
|
||||
public Map<String, Tag> toTileEntityNBT()
|
||||
throws DataException {
|
||||
List<Tag> itemsList = new ArrayList<Tag>();
|
||||
for (int i = 0; i < items.length; ++i) {
|
||||
BaseItemStack item = items[i];
|
||||
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);
|
||||
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("Count", new ByteTag("Count", (byte)item.getAmount()));
|
||||
data.put("Slot", new ByteTag("Slot", (byte)i));
|
||||
data.put("Count", new ByteTag("Count", (byte) item.getAmount()));
|
||||
data.put("Slot", new ByteTag("Slot", (byte) i));
|
||||
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));
|
||||
return values;
|
||||
}
|
||||
@ -123,19 +123,18 @@ public class ChestBlock extends BaseBlock implements TileEntityBlock, ContainerB
|
||||
* @param values
|
||||
* @throws DataException
|
||||
*/
|
||||
public void fromTileEntityNBT(Map<String,Tag> values)
|
||||
throws DataException {
|
||||
public void fromTileEntityNBT(Map<String, Tag> values)
|
||||
throws DataException {
|
||||
if (values == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
ListTag items = (ListTag)Chunk.getChildTag(values, "Items", ListTag.class);
|
||||
ListTag items = (ListTag) Chunk.getChildTag(values, "Items", ListTag.class);
|
||||
BaseItemStack[] newItems = new BaseItemStack[27];
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
CompoundTag item = (CompoundTag)tag;
|
||||
Map<String,Tag> itemValues = item.getValue();
|
||||
CompoundTag item = (CompoundTag) tag;
|
||||
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();
|
||||
short damage = (Short)((ShortTag)Chunk.getChildTag(itemValues, "Damage", ShortTag.class))
|
||||
short damage = (Short) ((ShortTag) Chunk.getChildTag(itemValues, "Damage", ShortTag.class))
|
||||
.getValue();
|
||||
byte count = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Count", ByteTag.class))
|
||||
byte count = (Byte) ((ByteTag) Chunk.getChildTag(itemValues, "Count", ByteTag.class))
|
||||
.getValue();
|
||||
byte slot = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Slot", ByteTag.class))
|
||||
byte slot = (Byte) ((ByteTag) Chunk.getChildTag(itemValues, "Slot", ByteTag.class))
|
||||
.getValue();
|
||||
|
||||
if (slot >= 0 && slot <= 26) {
|
||||
|
@ -35,14 +35,14 @@ public enum ClothColor {
|
||||
LIGHT_BLUE(ID.LIGHT_BLUE, "Light blue", "lightblue"),
|
||||
YELLOW(ID.YELLOW, "Yellow", "yellow"),
|
||||
LIGHT_GREEN(ID.LIGHT_GREEN, "Light green", "lightgreen"),
|
||||
PINK(ID.PINK, "Pink", new String[] {"pink", "lightred"}),
|
||||
GRAY(ID.GRAY, "Gray", new String[] {"grey", "gray"}),
|
||||
LIGHT_GRAY(ID.LIGHT_GRAY, "Light gray", new String[] {"lightgrey", "lightgray"}),
|
||||
CYAN(ID.CYAN, "Cyan", new String[] {"cyan", "turquoise"}),
|
||||
PURPLE(ID.PURPLE, "Purple", new String[] {"purple", "violet"}),
|
||||
PINK(ID.PINK, "Pink", new String[] { "pink", "lightred" }),
|
||||
GRAY(ID.GRAY, "Gray", new String[] { "grey", "gray" }),
|
||||
LIGHT_GRAY(ID.LIGHT_GRAY, "Light gray", new String[] { "lightgrey", "lightgray" }),
|
||||
CYAN(ID.CYAN, "Cyan", new String[] { "cyan", "turquoise" }),
|
||||
PURPLE(ID.PURPLE, "Purple", new String[] { "purple", "violet" }),
|
||||
BLUE(ID.BLUE, "Blue", "blue"),
|
||||
BROWN(ID.BROWN, "Brown", new String[] {"brown", "cocoa", "coffee"}),
|
||||
DARK_GREEN(ID.DARK_GREEN, "Dark green", new String[] {"green", "darkgreen", "cactusgreen", "cactigreen"}),
|
||||
BROWN(ID.BROWN, "Brown", new String[] { "brown", "cocoa", "coffee" }),
|
||||
DARK_GREEN(ID.DARK_GREEN, "Dark green", new String[] { "green", "darkgreen", "cactusgreen", "cactigreen" }),
|
||||
RED(ID.RED, "Red", "red"),
|
||||
BLACK(ID.BLACK, "Black", "black");
|
||||
|
||||
@ -68,11 +68,11 @@ public enum ClothColor {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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 String name;
|
||||
@ -97,7 +97,7 @@ public enum ClothColor {
|
||||
ClothColor(int id, String name, String lookupKey) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lookupKeys = new String[]{lookupKey};
|
||||
this.lookupKeys = new String[] { lookupKey };
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,4 +149,4 @@ public enum ClothColor {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,22 +97,22 @@ public class DispenserBlock extends BaseBlock implements TileEntityBlock, Contai
|
||||
* @return map of values
|
||||
* @throws DataException
|
||||
*/
|
||||
public Map<String,Tag> toTileEntityNBT()
|
||||
public Map<String, Tag> toTileEntityNBT()
|
||||
throws DataException {
|
||||
List<Tag> itemsList = new ArrayList<Tag>();
|
||||
for (int i = 0; i < items.length; ++i) {
|
||||
BaseItemStack item = items[i];
|
||||
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);
|
||||
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("Count", new ByteTag("Count", (byte)item.getAmount()));
|
||||
data.put("Slot", new ByteTag("Slot", (byte)i));
|
||||
data.put("Count", new ByteTag("Count", (byte) item.getAmount()));
|
||||
data.put("Slot", new ByteTag("Slot", (byte) i));
|
||||
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));
|
||||
return values;
|
||||
}
|
||||
@ -123,19 +123,18 @@ public class DispenserBlock extends BaseBlock implements TileEntityBlock, Contai
|
||||
* @param values
|
||||
* @throws DataException
|
||||
*/
|
||||
public void fromTileEntityNBT(Map<String,Tag> values)
|
||||
throws DataException {
|
||||
public void fromTileEntityNBT(Map<String, Tag> values)
|
||||
throws DataException {
|
||||
if (values == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
ListTag items = (ListTag)Chunk.getChildTag(values, "Items", ListTag.class);
|
||||
ListTag items = (ListTag) Chunk.getChildTag(values, "Items", ListTag.class);
|
||||
BaseItemStack[] newItems = new BaseItemStack[27];
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
CompoundTag item = (CompoundTag)tag;
|
||||
Map<String,Tag> itemValues = item.getValue();
|
||||
CompoundTag item = (CompoundTag) tag;
|
||||
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();
|
||||
short damage = (Short)((ShortTag)Chunk.getChildTag(itemValues, "Damage", ShortTag.class))
|
||||
short damage = (Short) ((ShortTag) Chunk.getChildTag(itemValues, "Damage", ShortTag.class))
|
||||
.getValue();
|
||||
byte count = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Count", ByteTag.class))
|
||||
byte count = (Byte) ((ByteTag) Chunk.getChildTag(itemValues, "Count", ByteTag.class))
|
||||
.getValue();
|
||||
byte slot = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Slot", ByteTag.class))
|
||||
byte slot = (Byte) ((ByteTag) Chunk.getChildTag(itemValues, "Slot", ByteTag.class))
|
||||
.getValue();
|
||||
|
||||
if (slot >= 0 && slot <= 8) {
|
||||
|
@ -36,7 +36,7 @@ public class FurnaceBlock extends BaseBlock implements TileEntityBlock, Containe
|
||||
* Store the list of items.
|
||||
*/
|
||||
private BaseItemStack[] items;
|
||||
|
||||
|
||||
/**
|
||||
* Fuel time.
|
||||
*/
|
||||
@ -95,7 +95,7 @@ public class FurnaceBlock extends BaseBlock implements TileEntityBlock, Containe
|
||||
public void setItems(BaseItemStack[] items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the burnTime
|
||||
*/
|
||||
@ -139,22 +139,22 @@ public class FurnaceBlock extends BaseBlock implements TileEntityBlock, Containe
|
||||
* @return map of values
|
||||
* @throws DataException
|
||||
*/
|
||||
public Map<String,Tag> toTileEntityNBT()
|
||||
public Map<String, Tag> toTileEntityNBT()
|
||||
throws DataException {
|
||||
List<Tag> itemsList = new ArrayList<Tag>();
|
||||
for (int i = 0; i < items.length; ++i) {
|
||||
BaseItemStack item = items[i];
|
||||
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);
|
||||
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("Count", new ByteTag("Count", (byte)item.getAmount()));
|
||||
data.put("Slot", new ByteTag("Slot", (byte)i));
|
||||
data.put("Count", new ByteTag("Count", (byte) item.getAmount()));
|
||||
data.put("Slot", new ByteTag("Slot", (byte) i));
|
||||
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("BurnTime", new ShortTag("BurnTime", burnTime));
|
||||
values.put("CookTime", new ShortTag("CookTime", cookTime));
|
||||
@ -167,18 +167,18 @@ public class FurnaceBlock extends BaseBlock implements TileEntityBlock, Containe
|
||||
* @param values
|
||||
* @throws DataException
|
||||
*/
|
||||
public void fromTileEntityNBT(Map<String,Tag> values)
|
||||
throws DataException {
|
||||
public void fromTileEntityNBT(Map<String, Tag> values)
|
||||
throws DataException {
|
||||
if (values == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
ListTag items = (ListTag)Chunk.getChildTag(values, "Items", ListTag.class);
|
||||
ListTag items = (ListTag) Chunk.getChildTag(values, "Items", ListTag.class);
|
||||
BaseItemStack[] newItems = new BaseItemStack[27];
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
CompoundTag item = (CompoundTag)tag;
|
||||
Map<String,Tag> itemValues = item.getValue();
|
||||
CompoundTag item = (CompoundTag) tag;
|
||||
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();
|
||||
short damage = (Short)((ShortTag)Chunk.getChildTag(itemValues, "Damage", ShortTag.class))
|
||||
short damage = (Short) ((ShortTag) Chunk.getChildTag(itemValues, "Damage", ShortTag.class))
|
||||
.getValue();
|
||||
byte count = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Count", ByteTag.class))
|
||||
byte count = (Byte) ((ByteTag) Chunk.getChildTag(itemValues, "Count", ByteTag.class))
|
||||
.getValue();
|
||||
byte slot = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Slot", ByteTag.class))
|
||||
byte slot = (Byte) ((ByteTag) Chunk.getChildTag(itemValues, "Slot", ByteTag.class))
|
||||
.getValue();
|
||||
|
||||
if (slot >= 0 && slot <= 26) {
|
||||
@ -207,12 +207,12 @@ public class FurnaceBlock extends BaseBlock implements TileEntityBlock, Containe
|
||||
|
||||
t = values.get("BurnTime");
|
||||
if (t instanceof ShortTag) {
|
||||
burnTime = ((ShortTag)t).getValue();
|
||||
burnTime = ((ShortTag) t).getValue();
|
||||
}
|
||||
|
||||
t = values.get("CookTime");
|
||||
if (t instanceof ShortTag) {
|
||||
cookTime = ((ShortTag)t).getValue();
|
||||
cookTime = ((ShortTag) t).getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,6 +163,6 @@ public final class ItemID {
|
||||
public static final int DISC_MELLOHI = 2262;
|
||||
public static final int DISC_STAL = 2263;
|
||||
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;
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ public enum ItemType {
|
||||
FENCE_GATE(BlockID.FENCE_GATE, "Fence gate", "fencegate", "gate"),
|
||||
BRICK_STAIRS(BlockID.BRICK_STAIRS, "Brick stairs", "brickstairs", "bricksteps"),
|
||||
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"),
|
||||
NETHER_BRICK(BlockID.NETHER_BRICK, "Nether brick", "netherbrick"),
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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 String name;
|
||||
@ -335,7 +335,7 @@ public enum ItemType {
|
||||
ItemType(int id, String name, String lookupKey) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lookupKeys = new String[] {lookupKey};
|
||||
this.lookupKeys = new String[] { lookupKey };
|
||||
}
|
||||
|
||||
/**
|
||||
@ -344,7 +344,7 @@ public enum ItemType {
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
ItemType(int id, String name, String ... lookupKeys) {
|
||||
ItemType(int id, String name, String... lookupKeys) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lookupKeys = lookupKeys;
|
||||
@ -412,32 +412,32 @@ public enum ItemType {
|
||||
*/
|
||||
public static ItemType lookup(String name, boolean fuzzy) {
|
||||
String testName = name.replace(" ", "").toLowerCase();
|
||||
|
||||
|
||||
ItemType type = lookup.get(testName);
|
||||
|
||||
|
||||
if (type != null) {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
if (!fuzzy) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
int minDist = -1;
|
||||
|
||||
|
||||
for (Entry<String, ItemType> entry : lookup.entrySet()) {
|
||||
if (entry.getKey().charAt(0) != testName.charAt(0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
int dist = StringUtil.getLevenshteinDistance(entry.getKey(), testName);
|
||||
|
||||
|
||||
if ((dist < minDist || minDist == -1) && dist < 2) {
|
||||
minDist = dist;
|
||||
type = entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -126,9 +126,9 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock {
|
||||
* @return map of values
|
||||
* @throws DataException
|
||||
*/
|
||||
public Map<String,Tag> toTileEntityNBT()
|
||||
public Map<String, Tag> toTileEntityNBT()
|
||||
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("Delay", new ShortTag("Delay", delay));
|
||||
return values;
|
||||
@ -140,19 +140,19 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock {
|
||||
* @param values
|
||||
* @throws DataException
|
||||
*/
|
||||
public void fromTileEntityNBT(Map<String,Tag> values)
|
||||
throws DataException {
|
||||
public void fromTileEntityNBT(Map<String, Tag> values)
|
||||
throws DataException {
|
||||
if (values == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
StringTag mobTypeTag = (StringTag)Chunk.getChildTag(values, "EntityId", StringTag.class);
|
||||
ShortTag delayTag = (ShortTag)Chunk.getChildTag(values, "Delay", ShortTag.class);
|
||||
StringTag mobTypeTag = (StringTag) Chunk.getChildTag(values, "EntityId", StringTag.class);
|
||||
ShortTag delayTag = (ShortTag) Chunk.getChildTag(values, "Delay", ShortTag.class);
|
||||
|
||||
this.mobType = mobTypeTag.getValue();
|
||||
this.delay = delayTag.getValue();
|
||||
|
@ -85,16 +85,16 @@ public class NoteBlock extends BaseBlock implements TileEntityBlock {
|
||||
public String getTileEntityID() {
|
||||
return "Music";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store additional tile entity data. Returns true if the data is used.
|
||||
*
|
||||
* @return map of values
|
||||
* @throws DataException
|
||||
*/
|
||||
public Map<String,Tag> toTileEntityNBT()
|
||||
public Map<String, Tag> toTileEntityNBT()
|
||||
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));
|
||||
return values;
|
||||
}
|
||||
@ -105,22 +105,22 @@ public class NoteBlock extends BaseBlock implements TileEntityBlock {
|
||||
* @param values
|
||||
* @throws DataException
|
||||
*/
|
||||
public void fromTileEntityNBT(Map<String,Tag> values)
|
||||
throws DataException {
|
||||
public void fromTileEntityNBT(Map<String, Tag> values)
|
||||
throws DataException {
|
||||
if (values == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Tag t;
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
t = values.get("note");
|
||||
if (t instanceof ByteTag) {
|
||||
note = ((ByteTag)t).getValue();
|
||||
note = ((ByteTag) t).getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class SignBlock extends BaseBlock implements TileEntityBlock {
|
||||
*/
|
||||
public SignBlock(int type, int 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
|
||||
* @throws DataException
|
||||
*/
|
||||
public Map<String,Tag> toTileEntityNBT()
|
||||
public Map<String, Tag> toTileEntityNBT()
|
||||
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("Text2", new StringTag("Text2", text[1]));
|
||||
values.put("Text3", new StringTag("Text3", text[2]));
|
||||
@ -102,39 +102,39 @@ public class SignBlock extends BaseBlock implements TileEntityBlock {
|
||||
* @param values
|
||||
* @throws DataException
|
||||
*/
|
||||
public void fromTileEntityNBT(Map<String,Tag> values)
|
||||
throws DataException {
|
||||
public void fromTileEntityNBT(Map<String, Tag> values)
|
||||
throws DataException {
|
||||
if (values == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tag t;
|
||||
|
||||
text = new String[]{ "", "", "", "" };
|
||||
text = new String[] { "", "", "", "" };
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
t = values.get("Text1");
|
||||
if (t instanceof StringTag) {
|
||||
text[0] = ((StringTag)t).getValue();
|
||||
text[0] = ((StringTag) t).getValue();
|
||||
}
|
||||
|
||||
t = values.get("Text2");
|
||||
if (t instanceof StringTag) {
|
||||
text[1] = ((StringTag)t).getValue();
|
||||
text[1] = ((StringTag) t).getValue();
|
||||
}
|
||||
|
||||
t = values.get("Text3");
|
||||
if (t instanceof StringTag) {
|
||||
text[2] = ((StringTag)t).getValue();
|
||||
text[2] = ((StringTag) t).getValue();
|
||||
}
|
||||
|
||||
t = values.get("Text4");
|
||||
if (t instanceof StringTag) {
|
||||
text[3] = ((StringTag)t).getValue();
|
||||
text[3] = ((StringTag) t).getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,20 +35,22 @@ public interface TileEntityBlock {
|
||||
* @return title entity ID
|
||||
*/
|
||||
public String getTileEntityID();
|
||||
|
||||
/**
|
||||
* Store additional tile entity data.
|
||||
*
|
||||
* @return map of values
|
||||
* @throws DataException
|
||||
*/
|
||||
public Map<String,Tag> toTileEntityNBT()
|
||||
public Map<String, Tag> toTileEntityNBT()
|
||||
throws DataException;
|
||||
|
||||
/**
|
||||
* Get additional information from the title entity data.
|
||||
*
|
||||
* @param values
|
||||
* @throws DataException
|
||||
*/
|
||||
public void fromTileEntityNBT(Map<String,Tag> values)
|
||||
public void fromTileEntityNBT(Map<String, Tag> values)
|
||||
throws DataException;
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ public class BukkitConfiguration extends LocalConfiguration {
|
||||
private YAMLProcessor config;
|
||||
private Logger logger;
|
||||
private FileHandler logFileHandler;
|
||||
|
||||
|
||||
public boolean noOpPermissions = false;
|
||||
|
||||
|
||||
public BukkitConfiguration(YAMLProcessor config, Logger logger) {
|
||||
this.config = config;
|
||||
this.logger = logger;
|
||||
@ -53,7 +53,7 @@ public class BukkitConfiguration extends LocalConfiguration {
|
||||
e.printStackTrace();
|
||||
}
|
||||
showFirstUseVersion = false;
|
||||
|
||||
|
||||
profile = config.getBoolean("debug", profile);
|
||||
wandItem = config.getInt("wand-item", wandItem);
|
||||
defaultChangeLimit = Math.max(-1, config.getInt(
|
||||
@ -74,7 +74,7 @@ public class BukkitConfiguration extends LocalConfiguration {
|
||||
useInventoryOverride = config.getBoolean("use-inventory.allow-override",
|
||||
useInventoryOverride);
|
||||
maxBrushRadius = config.getInt("limits.max-brush-radius", maxBrushRadius);
|
||||
|
||||
|
||||
navigationWand = config.getInt("navigation-wand.item", navigationWand);
|
||||
navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance);
|
||||
|
||||
@ -82,18 +82,18 @@ public class BukkitConfiguration extends LocalConfiguration {
|
||||
scriptsDir = config.getString("scripting.dir", scriptsDir);
|
||||
|
||||
saveDir = config.getString("saving.dir", saveDir);
|
||||
|
||||
|
||||
disallowedBlocks = new HashSet<Integer>(config.getIntList("limits.disallowed-blocks", null));
|
||||
|
||||
allowedDataCycleBlocks = new HashSet<Integer>(config.getIntList("limits.allowed-data-cycle-blocks", null));
|
||||
|
||||
noOpPermissions = config.getBoolean("no-op-permissions", false);
|
||||
|
||||
|
||||
LocalSession.MAX_HISTORY_SIZE = Math.max(0, config.getInt("history.size", 15));
|
||||
LocalSession.EXPIRATION_GRACE = config.getInt("history.expiration", 10) * 60 * 1000;
|
||||
|
||||
|
||||
String snapshotsDir = config.getString("snapshots.directory", "");
|
||||
if (!snapshotsDir.isEmpty()){
|
||||
if (!snapshotsDir.isEmpty()) {
|
||||
snapshotRepo = new SnapshotRepository(snapshotsDir);
|
||||
}
|
||||
|
||||
@ -116,11 +116,10 @@ public class BukkitConfiguration extends LocalConfiguration {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void unload() {
|
||||
if (logFileHandler != null) {
|
||||
logFileHandler.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import com.sk89q.worldedit.cui.CUIEvent;
|
||||
public class BukkitPlayer extends LocalPlayer {
|
||||
private Player player;
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
|
||||
public BukkitPlayer(WorldEditPlugin plugin, ServerInterface server, Player player) {
|
||||
super(server);
|
||||
this.plugin = plugin;
|
||||
@ -117,11 +117,11 @@ public class BukkitPlayer extends LocalPlayer {
|
||||
public LocalWorld getWorld() {
|
||||
return new BukkitWorld(player.getWorld());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dispatchCUIEvent(CUIEvent event) {
|
||||
String[] params = event.getParameters();
|
||||
|
||||
|
||||
if (params.length > 0) {
|
||||
player.sendRawMessage("\u00A75\u00A76\u00A74\u00A75" + event.getTypeId()
|
||||
+ "|" + StringUtil.joinString(params, "|"));
|
||||
@ -129,7 +129,7 @@ public class BukkitPlayer extends LocalPlayer {
|
||||
player.sendRawMessage("\u00A75\u00A76\u00A74\u00A75" + event.getTypeId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dispatchCUIHandshake() {
|
||||
player.sendRawMessage("\u00A75\u00A76\u00A74\u00A75");
|
||||
|
@ -37,7 +37,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
||||
* The player's inventory;
|
||||
*/
|
||||
private ItemStack[] items;
|
||||
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
@ -46,7 +46,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
||||
public BukkitPlayerBlockBag(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads inventory on first use.
|
||||
*/
|
||||
@ -55,7 +55,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
||||
items = player.getInventory().getContents();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the player.
|
||||
*
|
||||
@ -64,7 +64,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a block.
|
||||
*
|
||||
@ -113,7 +113,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
||||
bukkitItem.setAmount(currentAmount - 1);
|
||||
found = true;
|
||||
} else {
|
||||
items[slot] = null;
|
||||
items[slot] = null;
|
||||
found = true;
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
||||
|
||||
throw new OutOfSpaceException(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Flush any changes. This is called at the end.
|
||||
*/
|
||||
@ -216,7 +216,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
||||
@Override
|
||||
public void addSourcePosition(Vector pos) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a position to be used a source.
|
||||
*
|
||||
|
@ -26,7 +26,7 @@ import com.sk89q.worldedit.ServerInterface;
|
||||
public class BukkitServerInterface extends ServerInterface {
|
||||
public Server server;
|
||||
public WorldEditPlugin plugin;
|
||||
|
||||
|
||||
public BukkitServerInterface(WorldEditPlugin plugin, Server server) {
|
||||
this.plugin = plugin;
|
||||
this.server = server;
|
||||
|
@ -30,10 +30,10 @@ import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
|
||||
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) {
|
||||
LocalWorld lw = wlw.get(w);
|
||||
@ -43,27 +43,27 @@ public class BukkitUtil {
|
||||
}
|
||||
return lw;
|
||||
}
|
||||
|
||||
|
||||
public static BlockVector toVector(Block block) {
|
||||
return new BlockVector(block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
|
||||
public static BlockVector toVector(BlockFace face) {
|
||||
return new BlockVector(face.getModX(), face.getModY(), face.getModZ());
|
||||
}
|
||||
|
||||
|
||||
public static BlockWorldVector toWorldVector(Block block) {
|
||||
return new BlockWorldVector(getLocalWorld(block.getWorld()), block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
|
||||
public static Vector toVector(Location loc) {
|
||||
return new Vector(loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
|
||||
public static Vector toVector(org.bukkit.util.Vector vector) {
|
||||
return new Vector(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
|
||||
|
||||
public static Location toLocation(WorldVector pt) {
|
||||
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) {
|
||||
return new Location(world, pt.getX(), pt.getY(), pt.getZ());
|
||||
}
|
||||
|
||||
|
||||
public static Location center(Location loc) {
|
||||
return new Location(
|
||||
loc.getWorld(),
|
||||
loc.getBlockX()+0.5,
|
||||
loc.getBlockY()+0.5,
|
||||
loc.getBlockZ()+0.5,
|
||||
loc.getBlockX() + 0.5,
|
||||
loc.getBlockY() + 0.5,
|
||||
loc.getBlockZ() + 0.5,
|
||||
loc.getPitch(),
|
||||
loc.getYaw()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static Player matchSinglePlayer(Server server, String name) {
|
||||
List<Player> players = server.matchPlayer(name);
|
||||
if (players.size() == 0) {
|
||||
@ -96,18 +96,19 @@ public class BukkitUtil {
|
||||
}
|
||||
|
||||
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
|
||||
* precision.
|
||||
*/
|
||||
public static boolean equals(Location a, Location b) {
|
||||
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.getZ()-b.getZ()) > 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.getZ() - b.getZ()) > EQUALS_PRECISION) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final double EQUALS_PRECISION = 0.0001;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
public class BukkitWorld extends LocalWorld {
|
||||
private World world;
|
||||
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
* @param world
|
||||
@ -69,7 +69,7 @@ public class BukkitWorld extends LocalWorld {
|
||||
public BukkitWorld(World world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the world handle.
|
||||
*
|
||||
@ -78,7 +78,7 @@ public class BukkitWorld extends LocalWorld {
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the name of the world
|
||||
*
|
||||
@ -130,10 +130,10 @@ public class BukkitWorld extends LocalWorld {
|
||||
* @return
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set block type & data
|
||||
* @param pt
|
||||
@ -142,7 +142,7 @@ public class BukkitWorld extends LocalWorld {
|
||||
* @return
|
||||
*/
|
||||
@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());
|
||||
if (fastLightingAvailable) {
|
||||
type = type & 255;
|
||||
@ -175,7 +175,7 @@ public class BukkitWorld extends LocalWorld {
|
||||
*/
|
||||
@Override
|
||||
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
|
||||
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
|
||||
public boolean regenerate(Region region, EditSession editSession) {
|
||||
BaseBlock[] history = new BaseBlock[16 * 16 * 128];
|
||||
|
||||
|
||||
for (Vector2D chunk : region.getChunks()) {
|
||||
Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
||||
|
||||
|
||||
// First save all the blocks inside
|
||||
for (int x = 0; x < 16; ++x) {
|
||||
for (int y = 0; y < 128; ++y) {
|
||||
@ -235,20 +235,20 @@ public class BukkitWorld extends LocalWorld {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
world.regenerateChunk(chunk.getBlockX(), chunk.getBlockZ());
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// Then restore
|
||||
for (int x = 0; x < 16; ++x) {
|
||||
for (int y = 0; y < 128; ++y) {
|
||||
for (int z = 0; z < 16; ++z) {
|
||||
Vector pt = min.add(x, y, z);
|
||||
int index = y * 16 * 16 + z * 16 + x;
|
||||
|
||||
|
||||
// We have to restore the block if it was outside
|
||||
if (!region.contains(pt)) {
|
||||
editSession.smartSetBlock(pt, history[index]);
|
||||
@ -260,7 +260,7 @@ public class BukkitWorld extends LocalWorld {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -273,51 +273,55 @@ public class BukkitWorld extends LocalWorld {
|
||||
*/
|
||||
@Override
|
||||
public boolean copyToWorld(Vector pt, BaseBlock block) {
|
||||
// Signs
|
||||
if (block instanceof SignBlock) {
|
||||
setSignText(pt, ((SignBlock)block).getText());
|
||||
// Signs
|
||||
setSignText(pt, ((SignBlock) block).getText());
|
||||
return true;
|
||||
|
||||
// Furnaces
|
||||
} else if (block instanceof FurnaceBlock) {
|
||||
}
|
||||
|
||||
if (block instanceof FurnaceBlock) {
|
||||
// Furnaces
|
||||
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (bukkitBlock == null) return false;
|
||||
BlockState state = bukkitBlock.getState();
|
||||
if (!(state instanceof Furnace)) return false;
|
||||
Furnace bukkit = (Furnace)state;
|
||||
FurnaceBlock we = (FurnaceBlock)block;
|
||||
Furnace bukkit = (Furnace) state;
|
||||
FurnaceBlock we = (FurnaceBlock) block;
|
||||
bukkit.setBurnTime(we.getBurnTime());
|
||||
bukkit.setCookTime(we.getCookTime());
|
||||
return setContainerBlockContents(pt, ((ContainerBlock)block).getItems());
|
||||
|
||||
// Chests/dispenser
|
||||
} else if (block instanceof ContainerBlock) {
|
||||
return setContainerBlockContents(pt, ((ContainerBlock)block).getItems());
|
||||
|
||||
// Mob spawners
|
||||
} else if (block instanceof MobSpawnerBlock) {
|
||||
return setContainerBlockContents(pt, ((ContainerBlock) block).getItems());
|
||||
}
|
||||
|
||||
if (block instanceof ContainerBlock) {
|
||||
// Chests/dispenser
|
||||
return setContainerBlockContents(pt, ((ContainerBlock) block).getItems());
|
||||
}
|
||||
|
||||
if (block instanceof MobSpawnerBlock) {
|
||||
// Mob spawners
|
||||
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (bukkitBlock == null) return false;
|
||||
BlockState state = bukkitBlock.getState();
|
||||
if (!(state instanceof CreatureSpawner)) return false;
|
||||
CreatureSpawner bukkit = (CreatureSpawner)state;
|
||||
MobSpawnerBlock we = (MobSpawnerBlock)block;
|
||||
CreatureSpawner bukkit = (CreatureSpawner) state;
|
||||
MobSpawnerBlock we = (MobSpawnerBlock) block;
|
||||
bukkit.setCreatureTypeId(we.getMobType());
|
||||
bukkit.setDelay(we.getDelay());
|
||||
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());
|
||||
if (bukkitBlock == null) return false;
|
||||
BlockState state = bukkitBlock.getState();
|
||||
if (!(state instanceof org.bukkit.block.NoteBlock)) return false;
|
||||
org.bukkit.block.NoteBlock bukkit = (org.bukkit.block.NoteBlock)state;
|
||||
NoteBlock we = (NoteBlock)block;
|
||||
org.bukkit.block.NoteBlock bukkit = (org.bukkit.block.NoteBlock) state;
|
||||
NoteBlock we = (NoteBlock) block;
|
||||
bukkit.setRawNote(we.getNote());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -330,13 +334,14 @@ public class BukkitWorld extends LocalWorld {
|
||||
*/
|
||||
@Override
|
||||
public boolean copyFromWorld(Vector pt, BaseBlock block) {
|
||||
// Signs
|
||||
if (block instanceof SignBlock) {
|
||||
// Signs
|
||||
((SignBlock) block).setText(getSignText(pt));
|
||||
return true;
|
||||
|
||||
// Furnaces
|
||||
} else if (block instanceof FurnaceBlock) {
|
||||
}
|
||||
|
||||
if (block instanceof FurnaceBlock) {
|
||||
// Furnaces
|
||||
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (bukkitBlock == null) return false;
|
||||
BlockState state = bukkitBlock.getState();
|
||||
@ -347,14 +352,16 @@ public class BukkitWorld extends LocalWorld {
|
||||
we.setCookTime(bukkit.getCookTime());
|
||||
((ContainerBlock) block).setItems(getContainerBlockContents(pt));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Chests/dispenser
|
||||
} else if (block instanceof ContainerBlock) {
|
||||
if (block instanceof ContainerBlock) {
|
||||
// Chests/dispenser
|
||||
((ContainerBlock) block).setItems(getContainerBlockContents(pt));
|
||||
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());
|
||||
if (bukkitBlock == null) return false;
|
||||
BlockState state = bukkitBlock.getState();
|
||||
@ -364,18 +371,19 @@ public class BukkitWorld extends LocalWorld {
|
||||
we.setMobType(bukkit.getCreatureTypeId());
|
||||
we.setDelay((short) bukkit.getDelay());
|
||||
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());
|
||||
if (bukkitBlock == null) return false;
|
||||
BlockState state = bukkitBlock.getState();
|
||||
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;
|
||||
we.setNote(bukkit.getRawNote());
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -395,7 +403,7 @@ public class BukkitWorld extends LocalWorld {
|
||||
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();
|
||||
inven.clear();
|
||||
return true;
|
||||
@ -472,7 +480,7 @@ public class BukkitWorld extends LocalWorld {
|
||||
ItemStack bukkitItem = new ItemStack(item.getType(), item.getAmount(),
|
||||
(byte) item.getDamage());
|
||||
world.dropItemNaturally(toLocation(pt), bukkitItem);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -499,7 +507,7 @@ public class BukkitWorld extends LocalWorld {
|
||||
public int killMobs(Vector origin, int radius, boolean killPets) {
|
||||
int num = 0;
|
||||
double radiusSq = Math.pow(radius, 2);
|
||||
|
||||
|
||||
for (LivingEntity ent : world.getLivingEntities()) {
|
||||
if (!killPets && ent instanceof Tameable && ((Tameable) ent).isTamed()) {
|
||||
continue; // tamed wolf
|
||||
@ -512,10 +520,10 @@ public class BukkitWorld extends LocalWorld {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove entities in an area.
|
||||
*
|
||||
@ -527,54 +535,68 @@ public class BukkitWorld extends LocalWorld {
|
||||
public int removeEntities(EntityType type, Vector origin, int radius) {
|
||||
int num = 0;
|
||||
double radiusSq = Math.pow(radius, 2);
|
||||
|
||||
|
||||
for (Entity ent : world.getEntities()) {
|
||||
if (radius != -1
|
||||
&& origin.distanceSq(BukkitUtil.toVector(ent.getLocation())) > radiusSq) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type == EntityType.ARROWS) {
|
||||
|
||||
switch (type) {
|
||||
case ARROWS:
|
||||
if (ent instanceof Arrow) {
|
||||
ent.remove();
|
||||
++num;
|
||||
}
|
||||
} else if (type == EntityType.BOATS) {
|
||||
break;
|
||||
|
||||
case BOATS:
|
||||
if (ent instanceof Boat) {
|
||||
ent.remove();
|
||||
++num;
|
||||
}
|
||||
} else if (type == EntityType.ITEMS) {
|
||||
break;
|
||||
|
||||
case ITEMS:
|
||||
if (ent instanceof Item) {
|
||||
ent.remove();
|
||||
++num;
|
||||
}
|
||||
} else if (type == EntityType.MINECARTS) {
|
||||
break;
|
||||
|
||||
case MINECARTS:
|
||||
if (ent instanceof Minecart) {
|
||||
ent.remove();
|
||||
++num;
|
||||
}
|
||||
} else if (type == EntityType.PAINTINGS) {
|
||||
break;
|
||||
|
||||
case PAINTINGS:
|
||||
if (ent instanceof Painting) {
|
||||
ent.remove();
|
||||
++num;
|
||||
}
|
||||
} else if (type == EntityType.TNT) {
|
||||
break;
|
||||
|
||||
case TNT:
|
||||
if (ent instanceof TNTPrimed) {
|
||||
ent.remove();
|
||||
++num;
|
||||
}
|
||||
} else if (type == EntityType.XP_ORBS) {
|
||||
break;
|
||||
|
||||
case XP_ORBS:
|
||||
if (ent instanceof ExperienceOrb) {
|
||||
ent.remove();
|
||||
++num;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
private Location toLocation(Vector pt) {
|
||||
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)) {
|
||||
return new BaseItemStack[0];
|
||||
}
|
||||
|
||||
|
||||
org.bukkit.block.ContainerBlock container = (org.bukkit.block.ContainerBlock) state;
|
||||
Inventory inven = container.getInventory();
|
||||
int size = inven.getSize();
|
||||
BaseItemStack[] contents = new BaseItemStack[size];
|
||||
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
ItemStack bukkitStack = inven.getItem(i);
|
||||
if (bukkitStack.getTypeId() > 0) {
|
||||
contents[i] = new BaseItemStack(
|
||||
bukkitStack.getTypeId(),
|
||||
bukkitStack.getAmount(),
|
||||
bukkitStack.getAmount(),
|
||||
bukkitStack.getDurability());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return contents;
|
||||
}
|
||||
|
||||
@ -674,11 +696,11 @@ public class BukkitWorld extends LocalWorld {
|
||||
if (!(state instanceof org.bukkit.block.ContainerBlock)) {
|
||||
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();
|
||||
int size = inven.getSize();
|
||||
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
if (i >= contents.length) {
|
||||
break;
|
||||
@ -686,16 +708,16 @@ public class BukkitWorld extends LocalWorld {
|
||||
|
||||
if (contents[i] != null) {
|
||||
inven.setItem(i, new ItemStack(contents[i].getType(),
|
||||
contents[i].getAmount(),
|
||||
contents[i].getAmount(),
|
||||
(byte) contents[i].getDamage()));
|
||||
} else {
|
||||
inven.setItem(i, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether a block has a valid ID.
|
||||
*
|
||||
@ -719,7 +741,7 @@ public class BukkitWorld extends LocalWorld {
|
||||
if (!(other instanceof BukkitWorld)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return ((BukkitWorld) other).world.equals(world);
|
||||
}
|
||||
|
||||
@ -761,7 +783,7 @@ public class BukkitWorld extends LocalWorld {
|
||||
final Object notchChunk = World_getChunkFromChunkCoords.invoke(notchWorld, chunkX, chunkZ);
|
||||
|
||||
// Fix skylight
|
||||
final byte[] blocks = (byte[])Chunk_blocks.get(notchChunk);
|
||||
final byte[] blocks = (byte[]) Chunk_blocks.get(notchChunk);
|
||||
final int length = blocks.length;
|
||||
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) {
|
||||
final int index = y + z * chunkSizeY + x * chunkSizeY * chunkSizeZ;
|
||||
byte blockID = blocks[index];
|
||||
if (!BlockType.emitsLight(blockID)) {
|
||||
if (!BlockType.emitsLight(blockID)) {
|
||||
if (xBorder || zBorder && BlockType.isTranslucent(blockID)) {
|
||||
lightEmitters.add(chunk.getBlock(x, y, z).getState());
|
||||
if (blockID == 20) {
|
||||
@ -789,7 +811,7 @@ public class BukkitWorld extends LocalWorld {
|
||||
} else {
|
||||
blocks[index] = 20;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean setRawTypeIdAndData(int x, int y, int z, int typeId, int data) {
|
||||
try {
|
||||
return editSession.setBlock(new Vector(x, y, z), new BaseBlock(typeId, data));
|
||||
|
@ -30,10 +30,10 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
* @author sk89q
|
||||
*/
|
||||
public class SessionTimer implements Runnable {
|
||||
|
||||
|
||||
private WorldEdit worldEdit;
|
||||
private SessionCheck checker;
|
||||
|
||||
|
||||
public SessionTimer(WorldEdit worldEdit, final Server server) {
|
||||
this.worldEdit = worldEdit;
|
||||
this.checker = new SessionCheck() {
|
||||
|
@ -22,13 +22,13 @@ package com.sk89q.worldedit.bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
|
||||
public class WorldEditAPI {
|
||||
public class WorldEditAPI {
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
|
||||
public WorldEditAPI(WorldEditPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the session for a player.
|
||||
*
|
||||
|
@ -32,7 +32,7 @@ public class WorldEditCriticalPlayerListener extends PlayerListener {
|
||||
* Plugin.
|
||||
*/
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
|
||||
/**
|
||||
* Construct the object;
|
||||
*
|
||||
|
@ -88,7 +88,7 @@ public class WorldEditPlayerListener extends PlayerListener {
|
||||
}
|
||||
|
||||
private boolean ignoreLeftClickAir = false;
|
||||
|
||||
|
||||
/**
|
||||
* Called when a player interacts
|
||||
*
|
||||
@ -115,9 +115,11 @@ public class WorldEditPlayerListener extends PlayerListener {
|
||||
}
|
||||
|
||||
if (!ignoreLeftClickAir) {
|
||||
final int taskId = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { public void run() {
|
||||
ignoreLeftClickAir = false;
|
||||
}}, 2);
|
||||
final int taskId = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
ignoreLeftClickAir = false;
|
||||
}
|
||||
}, 2);
|
||||
|
||||
if (taskId != -1) {
|
||||
ignoreLeftClickAir = true;
|
||||
|
@ -53,7 +53,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
* WorldEdit messages get sent here.
|
||||
*/
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
||||
|
||||
|
||||
/**
|
||||
* The server interface that all server-related API goes through.
|
||||
*/
|
||||
@ -66,7 +66,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
* Deprecated API.
|
||||
*/
|
||||
private WorldEditAPI api;
|
||||
|
||||
|
||||
/**
|
||||
* Holds the configuration for WorldEdit.
|
||||
*/
|
||||
@ -93,15 +93,15 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
|
||||
// Create the default configuration file
|
||||
createDefaultConfiguration("config.yml");
|
||||
|
||||
|
||||
// Set up configuration and such, including the permissions
|
||||
// resolver
|
||||
config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config.yml"), true), logger);
|
||||
perms = new PermissionsResolverManager(this, "WorldEdit", logger);
|
||||
|
||||
|
||||
// Load the configuration
|
||||
loadConfiguration();
|
||||
|
||||
|
||||
// Setup interfaces
|
||||
server = new BukkitServerInterface(this, getServer());
|
||||
controller = new WorldEdit(server, config);
|
||||
@ -109,8 +109,8 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
|
||||
// Now we can register events!
|
||||
registerEvents();
|
||||
|
||||
getServer().getScheduler().scheduleAsyncRepeatingTask(this,
|
||||
|
||||
getServer().getScheduler().scheduleAsyncRepeatingTask(this,
|
||||
new SessionTimer(controller, getServer()), 120, 120);
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
config.unload();
|
||||
this.getServer().getScheduler().cancelTasks(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads and reloads all configuration.
|
||||
*/
|
||||
@ -200,20 +200,22 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
while ((length = input.read(buf)) > 0) {
|
||||
output.write(buf, 0, length);
|
||||
}
|
||||
|
||||
|
||||
logger.info(getDescription().getName()
|
||||
+ ": Default configuration file written: " + name);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (input != null)
|
||||
if (input != null) {
|
||||
input.close();
|
||||
}
|
||||
} catch (IOException e) {}
|
||||
|
||||
try {
|
||||
if (output != null)
|
||||
if (output != null) {
|
||||
output.close();
|
||||
}
|
||||
} catch (IOException e) {}
|
||||
}
|
||||
}
|
||||
@ -231,20 +233,20 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player)sender;
|
||||
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
// Add the command to the array because the underlying command handling
|
||||
// code of WorldEdit expects it
|
||||
String[] split = new String[args.length + 1];
|
||||
System.arraycopy(args, 0, split, 1, args.length);
|
||||
split[0] = "/" + cmd.getName();
|
||||
|
||||
|
||||
controller.handleCommand(wrapPlayer(player), split);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the session for the player.
|
||||
*
|
||||
@ -254,7 +256,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
public LocalSession getSession(Player player) {
|
||||
return controller.getSession(wrapPlayer(player));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the session for the player.
|
||||
*
|
||||
@ -265,15 +267,14 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
LocalPlayer wePlayer = wrapPlayer(player);
|
||||
LocalSession session = controller.getSession(wePlayer);
|
||||
BlockBag blockBag = session.getBlockBag(wePlayer);
|
||||
|
||||
|
||||
EditSession editSession =
|
||||
new EditSession(wePlayer.getWorld(),
|
||||
session.getBlockChangeLimit(), blockBag);
|
||||
new EditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag);
|
||||
editSession.enableQueue();
|
||||
|
||||
|
||||
return editSession;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remember an edit session.
|
||||
*
|
||||
@ -283,13 +284,13 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
public void remember(Player player, EditSession editSession) {
|
||||
LocalPlayer wePlayer = wrapPlayer(player);
|
||||
LocalSession session = controller.getSession(wePlayer);
|
||||
|
||||
|
||||
session.remember(editSession);
|
||||
editSession.flushQueue();
|
||||
|
||||
|
||||
controller.flushBlockBag(wePlayer, editSession);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wrap an operation into an EditSession.
|
||||
*
|
||||
@ -301,7 +302,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
throws Throwable {
|
||||
LocalPlayer wePlayer = wrapPlayer(player);
|
||||
LocalSession session = controller.getSession(wePlayer);
|
||||
|
||||
|
||||
EditSession editSession = createEditSession(player);
|
||||
try {
|
||||
op.run(session, wePlayer, editSession);
|
||||
@ -309,7 +310,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
remember(player, editSession);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the API.
|
||||
*
|
||||
@ -319,7 +320,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
public WorldEditAPI getAPI() {
|
||||
return api;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the configuration used by WorldEdit.
|
||||
*
|
||||
@ -328,7 +329,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
public BukkitConfiguration getLocalConfiguration() {
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the permissions resolver in use.
|
||||
*
|
||||
@ -337,7 +338,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
public PermissionsResolverManager getPermissionsResolver() {
|
||||
return perms;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to wrap a Bukkit Player as a LocalPlayer.
|
||||
*
|
||||
@ -347,7 +348,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
public BukkitPlayer wrapPlayer(Player player) {
|
||||
return new BukkitPlayer(this, this.server, player);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the server interface.
|
||||
*
|
||||
@ -356,7 +357,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
public ServerInterface getServerInterface() {
|
||||
return server;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get WorldEdit.
|
||||
*
|
||||
@ -365,7 +366,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
public WorldEdit getWorldEdit() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the region selection for the player.
|
||||
*
|
||||
@ -379,18 +380,18 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
if (!player.isOnline()) {
|
||||
throw new IllegalArgumentException("Offline player not allowed");
|
||||
}
|
||||
|
||||
|
||||
LocalSession session = controller.getSession(wrapPlayer(player));
|
||||
RegionSelector selector = session.getRegionSelector();
|
||||
|
||||
|
||||
try {
|
||||
Region region = selector.getRegion();
|
||||
World world = ((BukkitWorld) session.getSelectionWorld()).getWorld();
|
||||
|
||||
|
||||
if (region instanceof CuboidRegion) {
|
||||
return new CuboidSelection(world, selector, (CuboidRegion)region);
|
||||
return new CuboidSelection(world, selector, (CuboidRegion) region);
|
||||
} else if (region instanceof Polygonal2DRegion) {
|
||||
return new Polygonal2DSelection(world, selector, (Polygonal2DRegion)region);
|
||||
return new Polygonal2DSelection(world, selector, (Polygonal2DRegion) region);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -398,7 +399,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the region selection for a player.
|
||||
*
|
||||
@ -415,8 +416,8 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
if (selection == null) {
|
||||
throw new IllegalArgumentException("Null selection not allowed");
|
||||
}
|
||||
|
||||
LocalSession session = controller.getSession(wrapPlayer(player));
|
||||
|
||||
LocalSession session = controller.getSession(wrapPlayer(player));
|
||||
RegionSelector sel = selection.getRegionSelector();
|
||||
session.setRegionSelector(new BukkitWorld(player.getWorld()), sel);
|
||||
session.dispatchCUISelection(wrapPlayer(player));
|
||||
|
@ -29,26 +29,26 @@ import com.sk89q.worldedit.regions.*;
|
||||
public class CuboidSelection extends RegionSelection {
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
public CuboidSelection(World world, Vector pt1, Vector pt2) {
|
||||
|
||||
public CuboidSelection(World world, Vector pt1, Vector pt2) {
|
||||
super(world);
|
||||
|
||||
if (pt1 == null) {
|
||||
throw new IllegalArgumentException("Null point 1 not permitted");
|
||||
}
|
||||
|
||||
|
||||
if (pt2 == null) {
|
||||
throw new IllegalArgumentException("Null point 2 not permitted");
|
||||
}
|
||||
|
||||
|
||||
CuboidRegionSelector sel = new CuboidRegionSelector();
|
||||
sel.selectPrimary(pt1);
|
||||
sel.selectSecondary(pt2);
|
||||
|
||||
|
||||
try {
|
||||
cuboid = sel.getRegion();
|
||||
} catch (IncompleteRegionException e) {
|
||||
@ -58,7 +58,7 @@ public class CuboidSelection extends RegionSelection {
|
||||
setRegionSelector(sel);
|
||||
setRegion(cuboid);
|
||||
}
|
||||
|
||||
|
||||
public CuboidSelection(World world, RegionSelector sel, CuboidRegion region) {
|
||||
super(world, sel, region);
|
||||
this.cuboid = region;
|
||||
|
@ -28,13 +28,13 @@ import com.sk89q.worldedit.regions.*;
|
||||
public class Polygonal2DSelection extends RegionSelection {
|
||||
|
||||
protected Polygonal2DRegion poly2d;
|
||||
|
||||
|
||||
public Polygonal2DSelection(World world, RegionSelector sel, Polygonal2DRegion region) {
|
||||
super(world, sel, 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);
|
||||
|
||||
minY = Math.min(Math.max(0, minY), 127);
|
||||
@ -48,7 +48,7 @@ public class Polygonal2DSelection extends RegionSelection {
|
||||
setRegionSelector(sel);
|
||||
setRegion(poly2d);
|
||||
}
|
||||
|
||||
|
||||
public List<BlockVector2D> getNativePoints() {
|
||||
return Collections.unmodifiableList(poly2d.getPoints());
|
||||
}
|
||||
|
@ -32,29 +32,29 @@ public abstract class RegionSelection implements Selection {
|
||||
private World world;
|
||||
private RegionSelector selector;
|
||||
private Region region;
|
||||
|
||||
|
||||
public RegionSelection(World world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
|
||||
public RegionSelection(World world, RegionSelector selector, Region region) {
|
||||
this.world = world;
|
||||
this.region = region;
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
|
||||
protected Region getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
|
||||
protected void setRegion(Region region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
|
||||
public RegionSelector getRegionSelector() {
|
||||
return selector;
|
||||
}
|
||||
|
||||
|
||||
protected void setRegionSelector(RegionSelector selector) {
|
||||
this.selector = selector;
|
||||
}
|
||||
@ -99,7 +99,7 @@ public abstract class RegionSelection implements Selection {
|
||||
if (!pt.getWorld().equals(world)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return region.contains(toVector(pt));
|
||||
}
|
||||
|
||||
|
@ -31,70 +31,70 @@ public interface Selection {
|
||||
* @return min. point
|
||||
*/
|
||||
public Location getMinimumPoint();
|
||||
|
||||
|
||||
/**
|
||||
* Get the lower point of a region.
|
||||
*
|
||||
* @return min. point
|
||||
*/
|
||||
public Vector getNativeMinimumPoint();
|
||||
|
||||
|
||||
/**
|
||||
* Get the upper point of a region.
|
||||
*
|
||||
* @return max. point
|
||||
*/
|
||||
public Location getMaximumPoint();
|
||||
|
||||
|
||||
/**
|
||||
* Get the upper point of a region.
|
||||
*
|
||||
* @return max. point
|
||||
*/
|
||||
public Vector getNativeMaximumPoint();
|
||||
|
||||
|
||||
/**
|
||||
* Get the region selector. This is for internal use.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RegionSelector getRegionSelector();
|
||||
|
||||
|
||||
/**
|
||||
* Get the world.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public World getWorld();
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of blocks in the region.
|
||||
*
|
||||
* @return number of blocks
|
||||
*/
|
||||
public int getArea();
|
||||
|
||||
|
||||
/**
|
||||
* Get X-size.
|
||||
*
|
||||
* @return width
|
||||
*/
|
||||
public int getWidth();
|
||||
|
||||
|
||||
/**
|
||||
* Get Y-size.
|
||||
*
|
||||
* @return height
|
||||
*/
|
||||
public int getHeight();
|
||||
|
||||
|
||||
/**
|
||||
* Get Z-size.
|
||||
*
|
||||
* @return length
|
||||
*/
|
||||
public int getLength();
|
||||
|
||||
|
||||
/**
|
||||
* Returns true based on whether the region contains the point,
|
||||
*
|
||||
|
@ -75,7 +75,7 @@ public class BrushCommands {
|
||||
Pattern fill = we.getBlockPattern(player, args.getString(0));
|
||||
tool.setFill(fill);
|
||||
tool.setSize(radius);
|
||||
|
||||
|
||||
if (args.hasFlag('h')) {
|
||||
tool.setBrush(new HollowSphereBrush(), "worldedit.brush.sphere");
|
||||
} else {
|
||||
@ -119,13 +119,13 @@ public class BrushCommands {
|
||||
Pattern fill = we.getBlockPattern(player, args.getString(0));
|
||||
tool.setFill(fill);
|
||||
tool.setSize(radius);
|
||||
|
||||
|
||||
if (args.hasFlag('h')) {
|
||||
tool.setBrush(new HollowCylinderBrush(height), "worldedit.brush.cylinder");
|
||||
} else {
|
||||
tool.setBrush(new CylinderBrush(height), "worldedit.brush.cylinder");
|
||||
}
|
||||
|
||||
|
||||
player.print(String.format("Cylinder brush shape equipped (%.0f by %d).",
|
||||
radius, height));
|
||||
}
|
||||
@ -144,14 +144,14 @@ public class BrushCommands {
|
||||
throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
|
||||
CuboidClipboard clipboard = session.getClipboard();
|
||||
|
||||
|
||||
if (clipboard == null) {
|
||||
player.printError("Copy something first.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Vector size = clipboard.getSize();
|
||||
|
||||
if (size.getBlockX() > config.maxBrushRadius
|
||||
@ -164,7 +164,7 @@ public class BrushCommands {
|
||||
|
||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||
tool.setBrush(new ClipboardBrush(clipboard, args.hasFlag('a')), "worldedit.brush.clipboard");
|
||||
|
||||
|
||||
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") + ").",
|
||||
radius, iterations));
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "ex", "extinguish" },
|
||||
usage = "[radius]",
|
||||
|
@ -97,7 +97,7 @@ public class ChunkCommands {
|
||||
|
||||
player.print("Note that this command does not yet support the mcregion format.");
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
|
||||
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
|
||||
FileOutputStream out = null;
|
||||
|
||||
@ -129,7 +129,9 @@ public class ChunkCommands {
|
||||
player.printError("Error occurred: " + e.getMessage());
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try { out.close(); } catch (IOException ie) {}
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException ie) { }
|
||||
}
|
||||
}
|
||||
} else if (config.shellSaveType.equalsIgnoreCase("bash")) {
|
||||
|
@ -82,7 +82,7 @@ public class ClipboardCommands {
|
||||
if (args.argsLength() > 0) {
|
||||
block = we.getBlock(player, args.getString(0));
|
||||
}
|
||||
|
||||
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector max = region.getMaximumPoint();
|
||||
@ -97,7 +97,7 @@ public class ClipboardCommands {
|
||||
editSession.setBlocks(session.getSelection(player.getWorld()), block);
|
||||
player.print("Block(s) cut.");
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "/paste" },
|
||||
usage = "",
|
||||
@ -114,7 +114,7 @@ public class ClipboardCommands {
|
||||
|
||||
boolean atOrigin = args.hasFlag('o');
|
||||
boolean pasteNoAir = args.hasFlag('a');
|
||||
|
||||
|
||||
if (atOrigin) {
|
||||
Vector pos = session.getClipboard().getOrigin();
|
||||
session.getClipboard().place(editSession, pos, pasteNoAir);
|
||||
@ -141,7 +141,7 @@ public class ClipboardCommands {
|
||||
throws WorldEditException {
|
||||
|
||||
int angle = args.getInteger(0);
|
||||
|
||||
|
||||
if (angle % 90 == 0) {
|
||||
CuboidClipboard clipboard = session.getClipboard();
|
||||
clipboard.rotate2D(angle);
|
||||
@ -171,7 +171,7 @@ public class ClipboardCommands {
|
||||
clipboard.flip(dir, args.hasFlag('p'));
|
||||
player.print("Clipboard flipped.");
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "/load" },
|
||||
usage = "<filename>",
|
||||
@ -189,7 +189,7 @@ public class ClipboardCommands {
|
||||
String filename = args.getString(0);
|
||||
File dir = we.getWorkingDirectoryFile(config.saveDir);
|
||||
File f = we.getSafeOpenFile(player, dir, filename, "schematic",
|
||||
new String[] {"schematic"});
|
||||
new String[] { "schematic" });
|
||||
|
||||
try {
|
||||
String filePath = f.getCanonicalPath();
|
||||
@ -208,7 +208,7 @@ public class ClipboardCommands {
|
||||
player.printError("Schematic could not read or it does not exist: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "/save" },
|
||||
usage = "<filename>",
|
||||
@ -227,7 +227,7 @@ public class ClipboardCommands {
|
||||
|
||||
File dir = we.getWorkingDirectoryFile(config.saveDir);
|
||||
File f = we.getSafeSaveFile(player, dir, filename, "schematic",
|
||||
new String[] {"schematic"});
|
||||
new String[] { "schematic" });
|
||||
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkdir()) {
|
||||
@ -252,7 +252,7 @@ public class ClipboardCommands {
|
||||
player.printError("Schematic could not written: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "clearclipboard" },
|
||||
usage = "",
|
||||
|
@ -56,7 +56,7 @@ public class GeneralCommands {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
session.setBlockChangeLimit(limit);
|
||||
player.print("Block change limit set to " + limit + ".");
|
||||
}
|
||||
@ -147,27 +147,27 @@ public class GeneralCommands {
|
||||
String query = args.getString(0).trim().toLowerCase();
|
||||
boolean blocksOnly = args.hasFlag('b');
|
||||
boolean itemsOnly = args.hasFlag('i');
|
||||
|
||||
|
||||
try {
|
||||
int id = Integer.parseInt(query);
|
||||
|
||||
|
||||
ItemType type = ItemType.fromID(id);
|
||||
|
||||
|
||||
if (type != null) {
|
||||
player.print("#" + type.getID() + " (" + type.getName() + ")");
|
||||
} else {
|
||||
player.printError("No item found by ID " + id);
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
|
||||
if (query.length() <= 2) {
|
||||
player.printError("Enter a longer search string (len > 2).");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!blocksOnly && !itemsOnly) {
|
||||
player.print("Searching for: " + query);
|
||||
} else if (blocksOnly && itemsOnly) {
|
||||
@ -178,23 +178,23 @@ public class GeneralCommands {
|
||||
} else {
|
||||
player.print("Searching for items: " + query);
|
||||
}
|
||||
|
||||
|
||||
int found = 0;
|
||||
|
||||
|
||||
for (ItemType type : ItemType.values()) {
|
||||
if (found >= 15) {
|
||||
player.print("Too many results!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (blocksOnly && type.getID() > 255) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (itemsOnly && type.getID() <= 255) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
for (String alias : type.getAliases()) {
|
||||
if (alias.contains(query)) {
|
||||
player.print("#" + type.getID() + " (" + type.getName() + ")");
|
||||
@ -203,7 +203,7 @@ public class GeneralCommands {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (found == 0) {
|
||||
player.printError("No items found.");
|
||||
}
|
||||
|
@ -229,12 +229,12 @@ public class GenerationCommands {
|
||||
player.printError("Tree type '" + args.getString(1) + "' is unknown.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int affected = editSession.makeForest(player.getPosition(),
|
||||
size, density, new TreeGenerator(type));
|
||||
player.print(affected + " trees created.");
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "pumpkins" },
|
||||
usage = "[size]",
|
||||
@ -253,7 +253,7 @@ public class GenerationCommands {
|
||||
int affected = editSession.makePumpkinPatches(player.getPosition(), size);
|
||||
player.print(affected + " pumpkin patches created.");
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "/pyramid" },
|
||||
usage = "<block> <size>",
|
||||
@ -270,13 +270,13 @@ public class GenerationCommands {
|
||||
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||
int size = Math.max(1, args.getInteger(1));
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
|
||||
|
||||
int affected = editSession.makePyramid(pos, block, size, true);
|
||||
|
||||
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "/hpyramid" },
|
||||
usage = "<block> <size>",
|
||||
@ -293,9 +293,9 @@ public class GenerationCommands {
|
||||
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||
int size = Math.max(1, args.getInteger(1));
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
|
||||
|
||||
int affected = editSession.makePyramid(pos, block, size, false);
|
||||
|
||||
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class HistoryCommands {
|
||||
} else {
|
||||
player.checkPermission("worldedit.history.undo.other");
|
||||
LocalSession sess = we.getSession(args.getString(1));
|
||||
if (sess == null){
|
||||
if (sess == null) {
|
||||
player.printError("Unable to find session for " + args.getString(1));
|
||||
break;
|
||||
}
|
||||
@ -65,7 +65,7 @@ public class HistoryCommands {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "/redo", "redo" },
|
||||
usage = "[times] [player]",
|
||||
@ -79,7 +79,7 @@ public class HistoryCommands {
|
||||
throws WorldEditException {
|
||||
|
||||
int times = Math.max(1, args.getInteger(0, 1));
|
||||
|
||||
|
||||
for (int i = 0; i < times; ++i) {
|
||||
EditSession redone;
|
||||
if (args.argsLength() < 2) {
|
||||
@ -87,7 +87,7 @@ public class HistoryCommands {
|
||||
} else {
|
||||
player.checkPermission("worldedit.history.redo.other");
|
||||
LocalSession sess = we.getSession(args.getString(1));
|
||||
if (sess == null){
|
||||
if (sess == null) {
|
||||
player.printError("Unable to find session for " + args.getString(1));
|
||||
break;
|
||||
}
|
||||
|
@ -74,7 +74,6 @@ public class NavigationCommands {
|
||||
} else {
|
||||
player.print((ascentLevels != 1) ? "Ascended " + Integer.toString(ascentLevels) + " levels." : "Ascended a level.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -103,7 +102,6 @@ public class NavigationCommands {
|
||||
} else {
|
||||
player.print((descentLevels != 1) ? "Descended " + Integer.toString(descentLevels) + " levels." : "Descended a level.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -128,7 +126,7 @@ public class NavigationCommands {
|
||||
player.printError("No free spot above you found.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "thru" },
|
||||
usage = "",
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.commands;
|
||||
|
||||
|
||||
import java.util.Set;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
@ -57,16 +56,16 @@ public class RegionCommands {
|
||||
throws WorldEditException {
|
||||
|
||||
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||
|
||||
|
||||
int affected;
|
||||
|
||||
|
||||
if (pattern instanceof SingleBlockPattern) {
|
||||
affected = editSession.setBlocks(session.getSelection(player.getWorld()),
|
||||
((SingleBlockPattern) pattern).getBlock());
|
||||
} else {
|
||||
affected = editSession.setBlocks(session.getSelection(player.getWorld()), pattern);
|
||||
}
|
||||
|
||||
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
}
|
||||
|
||||
@ -101,10 +100,10 @@ public class RegionCommands {
|
||||
} else {
|
||||
affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from, to);
|
||||
}
|
||||
|
||||
|
||||
player.print(affected + " block(s) have been replaced.");
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "/overlay" },
|
||||
usage = "<block>",
|
||||
@ -169,7 +168,7 @@ public class RegionCommands {
|
||||
} else {
|
||||
affected = editSession.makeCuboidWalls(session.getSelection(player.getWorld()), pattern);
|
||||
}
|
||||
|
||||
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
}
|
||||
|
||||
@ -220,7 +219,7 @@ public class RegionCommands {
|
||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
||||
int affected = heightMap.applyFilter(filter, iterations);
|
||||
player.print("Terrain's height map smoothed. " + affected + " block(s) changed.");
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -267,7 +266,6 @@ public class RegionCommands {
|
||||
|
||||
player.print(affected + " blocks moved.");
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "/stack" },
|
||||
|
@ -48,7 +48,7 @@ public class ScriptingCommands {
|
||||
|
||||
String[] scriptArgs = args.getSlice(1);
|
||||
String name = args.getString(0);
|
||||
|
||||
|
||||
if (!player.hasPermission("worldedit.scripting.execute." + name)) {
|
||||
player.printError("You don't have permission to use that script.");
|
||||
return;
|
||||
@ -58,8 +58,8 @@ public class ScriptingCommands {
|
||||
|
||||
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
|
||||
File f = we.getSafeOpenFile(player, dir, name, "js",
|
||||
new String[] {"js"});
|
||||
|
||||
new String[] { "js" });
|
||||
|
||||
we.runScript(player, f, scriptArgs);
|
||||
}
|
||||
|
||||
@ -77,12 +77,12 @@ public class ScriptingCommands {
|
||||
throws WorldEditException {
|
||||
|
||||
String lastScript = session.getLastScript();
|
||||
|
||||
|
||||
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {
|
||||
player.printError("You don't have permission to use that script.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (lastScript == null) {
|
||||
player.printError("Use /cs with a script name first.");
|
||||
return;
|
||||
@ -92,8 +92,8 @@ public class ScriptingCommands {
|
||||
|
||||
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
|
||||
File f = we.getSafeOpenFile(player, dir, lastScript, "js",
|
||||
new String[] {"js"});
|
||||
|
||||
new String[] { "js" });
|
||||
|
||||
we.runScript(player, f, scriptArgs);
|
||||
}
|
||||
}
|
||||
|
@ -87,11 +87,11 @@ public class SelectionCommands {
|
||||
throws WorldEditException {
|
||||
|
||||
Vector pos;
|
||||
if(args.argsLength() == 1) {
|
||||
if(args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
|
||||
if (args.argsLength() == 1) {
|
||||
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
|
||||
String[] coords = args.getString(0).split(",");
|
||||
pos = new Vector(Integer.parseInt(coords[0]),
|
||||
Integer.parseInt(coords[1]),
|
||||
pos = new Vector(Integer.parseInt(coords[0]),
|
||||
Integer.parseInt(coords[1]),
|
||||
Integer.parseInt(coords[2]));
|
||||
} else {
|
||||
player.printError("Invalid coordinates " + args.getString(0));
|
||||
@ -106,7 +106,6 @@ public class SelectionCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
session.getRegionSelector(player.getWorld())
|
||||
.explainSecondarySelection(player, session, pos);
|
||||
}
|
||||
@ -124,7 +123,7 @@ public class SelectionCommands {
|
||||
throws WorldEditException {
|
||||
|
||||
Vector pos = player.getBlockTrace(300);
|
||||
|
||||
|
||||
if (pos != null) {
|
||||
if (!session.getRegionSelector(player.getWorld())
|
||||
.selectPrimary(pos)) {
|
||||
@ -152,7 +151,7 @@ public class SelectionCommands {
|
||||
throws WorldEditException {
|
||||
|
||||
Vector pos = player.getBlockTrace(300);
|
||||
|
||||
|
||||
if (pos != null) {
|
||||
if (!session.getRegionSelector(player.getWorld())
|
||||
.selectSecondary(pos)) {
|
||||
@ -208,11 +207,11 @@ public class SelectionCommands {
|
||||
selector.selectPrimary(min);
|
||||
selector.selectSecondary(max);
|
||||
session.setRegionSelector(player.getWorld(), selector);
|
||||
|
||||
|
||||
session.dispatchCUISelection(player);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "/wand" },
|
||||
usage = "",
|
||||
@ -228,7 +227,7 @@ public class SelectionCommands {
|
||||
player.giveItem(we.getConfiguration().wandItem, 1);
|
||||
player.print("Left click: select pos #1; Right click: select pos #2");
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "toggleeditwand" },
|
||||
usage = "",
|
||||
@ -242,7 +241,7 @@ public class SelectionCommands {
|
||||
throws WorldEditException {
|
||||
|
||||
session.setToolControl(!session.isToolControlEnabled());
|
||||
|
||||
|
||||
if (session.isToolControlEnabled()) {
|
||||
player.print("Edit wand enabled.");
|
||||
} else {
|
||||
@ -281,13 +280,13 @@ public class SelectionCommands {
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int change = args.getInteger(0);
|
||||
int reverseChange = 0;
|
||||
|
||||
|
||||
switch (args.argsLength()) {
|
||||
case 2:
|
||||
// Either a reverse amount or a direction
|
||||
@ -300,7 +299,7 @@ public class SelectionCommands {
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case 3:
|
||||
// Both reverse amount and direction
|
||||
reverseChange = args.getInteger(1) * -1;
|
||||
dir = we.getDirection(player,
|
||||
@ -313,16 +312,16 @@ public class SelectionCommands {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
int oldSize = region.getArea();
|
||||
region.expand(dir.multiply(change));
|
||||
|
||||
|
||||
if (reverseChange != 0) {
|
||||
region.expand(dir.multiply(reverseChange));
|
||||
}
|
||||
|
||||
session.getRegionSelector().learnChanges();
|
||||
int newSize = region.getArea();
|
||||
|
||||
|
||||
session.getRegionSelector().explainRegionAdjust(player, session);
|
||||
|
||||
|
||||
player.print("Region expanded " + (newSize - oldSize) + " blocks.");
|
||||
}
|
||||
|
||||
@ -353,7 +352,7 @@ public class SelectionCommands {
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case 3:
|
||||
// Both reverse amount and direction
|
||||
reverseChange = args.getInteger(1) * -1;
|
||||
dir = we.getDirection(player, args.getString(2).toLowerCase());
|
||||
@ -371,9 +370,9 @@ public class SelectionCommands {
|
||||
}
|
||||
session.getRegionSelector().learnChanges();
|
||||
int newSize = region.getArea();
|
||||
|
||||
|
||||
session.getRegionSelector().explainRegionAdjust(player, session);
|
||||
|
||||
|
||||
player.print("Region contracted " + (oldSize - newSize) + " blocks.");
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
@ -392,7 +391,7 @@ public class SelectionCommands {
|
||||
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||
throws WorldEditException {
|
||||
Vector dir;
|
||||
|
||||
|
||||
int change = args.getInteger(0);
|
||||
if (args.argsLength() == 2) {
|
||||
dir = we.getDirection(player, args.getString(1).toLowerCase());
|
||||
@ -405,9 +404,9 @@ public class SelectionCommands {
|
||||
region.expand(dir.multiply(change));
|
||||
region.contract(dir.multiply(change));
|
||||
session.getRegionSelector().learnChanges();
|
||||
|
||||
|
||||
session.getRegionSelector().explainRegionAdjust(player, session);
|
||||
|
||||
|
||||
player.print("Region shifted.");
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
@ -429,13 +428,13 @@ public class SelectionCommands {
|
||||
int change = args.getInteger(0);
|
||||
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
|
||||
|
||||
try {
|
||||
if (!args.hasFlag('h')) {
|
||||
region.expand((new Vector(0, 1, 0)).multiply(change));
|
||||
region.expand((new Vector(0, -1, 0)).multiply(change));
|
||||
}
|
||||
|
||||
|
||||
if (!args.hasFlag('v')) {
|
||||
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().explainRegionAdjust(player, session);
|
||||
|
||||
|
||||
player.print("Region outset.");
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
@ -468,12 +467,12 @@ public class SelectionCommands {
|
||||
int change = args.getInteger(0);
|
||||
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
|
||||
|
||||
if (!args.hasFlag('h')) {
|
||||
region.contract((new Vector(0, 1, 0)).multiply(change));
|
||||
region.contract((new Vector(0, -1, 0)).multiply(change));
|
||||
}
|
||||
|
||||
|
||||
if (!args.hasFlag('v')) {
|
||||
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().explainRegionAdjust(player, session);
|
||||
|
||||
|
||||
player.print("Region inset.");
|
||||
}
|
||||
|
||||
@ -506,11 +505,11 @@ public class SelectionCommands {
|
||||
.add(1, 1, 1);
|
||||
|
||||
player.print("Type: " + session.getRegionSelector().getTypeName());
|
||||
|
||||
|
||||
for (String line : session.getRegionSelector().getInformationLines()) {
|
||||
player.print(line);
|
||||
}
|
||||
|
||||
|
||||
player.print("Size: " + size);
|
||||
player.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint()));
|
||||
player.print("# of blocks: " + region.getArea());
|
||||
@ -548,28 +547,28 @@ public class SelectionCommands {
|
||||
throws WorldEditException {
|
||||
|
||||
List<Countable<Integer>> distribution =
|
||||
editSession.getBlockDistribution(session.getSelection(player.getWorld()));
|
||||
|
||||
editSession.getBlockDistribution(session.getSelection(player.getWorld()));
|
||||
|
||||
Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
||||
|
||||
|
||||
if (distribution.size() > 0) { // *Should* always be true
|
||||
int size = session.getSelection(player.getWorld()).getArea();
|
||||
|
||||
|
||||
player.print("# total blocks: " + size);
|
||||
|
||||
|
||||
if (args.hasFlag('c')) {
|
||||
logger.info("Block distribution (req. by " + player.getName() + "):");
|
||||
logger.info("# total blocks: " + size);
|
||||
}
|
||||
|
||||
|
||||
for (Countable<Integer> c : distribution) {
|
||||
BlockType block = BlockType.fromID(c.getID());
|
||||
String str = String.format("%-7s (%.3f%%) %s #%d",
|
||||
String.valueOf(c.getAmount()),
|
||||
c.getAmount() / (double)size * 100,
|
||||
c.getAmount() / (double) size * 100,
|
||||
block == null ? "Unknown" : block.getName(), c.getID());
|
||||
player.print(str);
|
||||
|
||||
|
||||
if (args.hasFlag('c')) {
|
||||
logger.info(str);
|
||||
}
|
||||
|
@ -65,9 +65,9 @@ public class SnapshotCommands {
|
||||
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName());
|
||||
|
||||
if (snapshots.size() > 0) {
|
||||
|
||||
|
||||
int num = args.argsLength() > 0 ? Math.min(40, Math.max(5, args.getInteger(0))) : 5;
|
||||
|
||||
|
||||
player.print("Snapshots for world: '" + player.getWorld().getName() + "'");
|
||||
for (byte i = 0; i < Math.min(num, snapshots.size()); i++) {
|
||||
player.print((i + 1) + ". " + snapshots.get(i).getName());
|
||||
|
@ -32,7 +32,7 @@ import com.sk89q.worldedit.tools.AreaPickaxe;
|
||||
import com.sk89q.worldedit.tools.RecursivePickaxe;
|
||||
import com.sk89q.worldedit.tools.SinglePickaxe;
|
||||
|
||||
public class SuperPickaxeCommands {
|
||||
public class SuperPickaxeCommands {
|
||||
@Command(
|
||||
aliases = { "single" },
|
||||
usage = "",
|
||||
@ -49,7 +49,7 @@ public class SuperPickaxeCommands {
|
||||
session.enableSuperPickAxe();
|
||||
player.print("Mode changed. Left click with a pickaxe. // to disable.");
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "area" },
|
||||
usage = "<radius>",
|
||||
@ -64,17 +64,17 @@ public class SuperPickaxeCommands {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
int range = args.getInteger(0);
|
||||
|
||||
|
||||
if (range > config.maxSuperPickaxeSize) {
|
||||
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
session.setSuperPickaxe(new AreaPickaxe(range));
|
||||
session.enableSuperPickAxe();
|
||||
player.print("Mode changed. Left click with a pickaxe. // to disable.");
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "recur", "recursive" },
|
||||
usage = "<radius>",
|
||||
@ -89,12 +89,12 @@ public class SuperPickaxeCommands {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
double range = args.getDouble(0);
|
||||
|
||||
|
||||
if (range > config.maxSuperPickaxeSize) {
|
||||
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
session.setSuperPickaxe(new RecursivePickaxe(range));
|
||||
session.enableSuperPickAxe();
|
||||
player.print("Mode changed. Left click with a pickaxe. // to disable.");
|
||||
|
@ -138,7 +138,7 @@ public class ToolCommands {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
int range = args.getInteger(1);
|
||||
|
||||
|
||||
if (range > config.maxSuperPickaxeSize) {
|
||||
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
|
||||
return;
|
||||
@ -159,7 +159,7 @@ public class ToolCommands {
|
||||
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||
throws WorldEditException {
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "deltree" },
|
||||
usage = "",
|
||||
|
@ -151,14 +151,14 @@ public class ToolUtilCommands {
|
||||
throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
|
||||
int radius = args.getInteger(0);
|
||||
if (radius > config.maxBrushRadius) {
|
||||
player.printError("Maximum allowed brush radius: "
|
||||
+ config.maxBrushRadius);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
session.getBrushTool(player.getItemInHand()).setSize(radius);
|
||||
player.print("Brush size set.");
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.commands;
|
||||
|
||||
|
||||
import java.util.Set;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
@ -97,7 +96,7 @@ public class UtilityCommands {
|
||||
}
|
||||
player.print(affected + " block(s) have been created.");
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "/drain" },
|
||||
usage = "<radius>",
|
||||
@ -260,7 +259,7 @@ public class UtilityCommands {
|
||||
}
|
||||
player.print(affected + " block(s) have been replaced.");
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "/snow", "snow" },
|
||||
usage = "[radius]",
|
||||
@ -332,7 +331,7 @@ public class UtilityCommands {
|
||||
throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
|
||||
int defaultRadius = config.maxRadius != -1 ? Math.min(40, config.maxRadius) : 40;
|
||||
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0))
|
||||
: defaultRadius;
|
||||
@ -378,12 +377,12 @@ public class UtilityCommands {
|
||||
|
||||
String typeStr = args.getString(0);
|
||||
int radius = args.getInteger(1);
|
||||
|
||||
|
||||
if (radius < -1) {
|
||||
player.printError("Use -1 to remove all entities in loaded chunks");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
EntityType type = null;
|
||||
|
||||
if (typeStr.matches("arrows?")) {
|
||||
|
@ -34,7 +34,7 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
|
||||
public class WorldEditCommands {
|
||||
private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "version", "ver" },
|
||||
usage = "",
|
||||
|
@ -21,5 +21,6 @@ package com.sk89q.worldedit.cui;
|
||||
|
||||
public interface CUIEvent {
|
||||
public String getTypeId();
|
||||
|
||||
public String[] getParameters();
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class SelectionMinMaxEvent implements CUIEvent {
|
||||
|
||||
protected int min;
|
||||
protected int max;
|
||||
|
||||
|
||||
public SelectionMinMaxEvent(int min, int max) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
|
@ -26,7 +26,7 @@ public class SelectionPointEvent implements CUIEvent {
|
||||
protected int id;
|
||||
protected Vector pos;
|
||||
protected int area;
|
||||
|
||||
|
||||
public SelectionPointEvent(int id, Vector pos, int area) {
|
||||
this.id = id;
|
||||
this.pos = pos;
|
||||
|
@ -20,9 +20,9 @@
|
||||
package com.sk89q.worldedit.cui;
|
||||
|
||||
public class SelectionShapeEvent implements CUIEvent {
|
||||
|
||||
|
||||
protected String shapeName;
|
||||
|
||||
|
||||
public SelectionShapeEvent(String shapeName) {
|
||||
this.shapeName = shapeName;
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.sk89q.worldedit.data;
|
||||
|
||||
import java.util.List;
|
||||
@ -38,7 +37,7 @@ public class Chunk {
|
||||
private byte[] data;
|
||||
private int rootX;
|
||||
private int rootZ;
|
||||
private Map<BlockVector,Map<String,Tag>> tileEntities;
|
||||
private Map<BlockVector, Map<String, Tag>> tileEntities;
|
||||
|
||||
/**
|
||||
* Construct the chunk with a compound tag.
|
||||
@ -49,13 +48,13 @@ public class Chunk {
|
||||
public Chunk(CompoundTag tag) throws DataException {
|
||||
rootTag = tag;
|
||||
|
||||
blocks = ((ByteArrayTag)getChildTag(
|
||||
blocks = ((ByteArrayTag) getChildTag(
|
||||
rootTag.getValue(), "Blocks", ByteArrayTag.class)).getValue();
|
||||
data = ((ByteArrayTag)getChildTag(
|
||||
data = ((ByteArrayTag) getChildTag(
|
||||
rootTag.getValue(), "Data", ByteArrayTag.class)).getValue();
|
||||
rootX = ((IntTag)getChildTag(
|
||||
rootX = ((IntTag) getChildTag(
|
||||
rootTag.getValue(), "xPos", IntTag.class)).getValue();
|
||||
rootZ = ((IntTag)getChildTag(
|
||||
rootZ = ((IntTag) getChildTag(
|
||||
rootTag.getValue(), "zPos", IntTag.class)).getValue();
|
||||
|
||||
if (blocks.length != 32768) {
|
||||
@ -121,37 +120,37 @@ public class Chunk {
|
||||
* @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))
|
||||
.getValue();
|
||||
|
||||
tileEntities = new HashMap<BlockVector,Map<String,Tag>>();
|
||||
tileEntities = new HashMap<BlockVector, Map<String, Tag>>();
|
||||
|
||||
for (Tag tag : tags) {
|
||||
if (!(tag instanceof CompoundTag)) {
|
||||
throw new InvalidFormatException("CompoundTag expected in TileEntities");
|
||||
}
|
||||
|
||||
CompoundTag t = (CompoundTag)tag;
|
||||
CompoundTag t = (CompoundTag) tag;
|
||||
|
||||
int x = 0;
|
||||
int y = 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.getValue() instanceof IntTag) {
|
||||
x = ((IntTag)entry.getValue()).getValue();
|
||||
x = ((IntTag) entry.getValue()).getValue();
|
||||
}
|
||||
} else if (entry.getKey().equals("y")) {
|
||||
if (entry.getValue() instanceof IntTag) {
|
||||
y = ((IntTag)entry.getValue()).getValue();
|
||||
y = ((IntTag) entry.getValue()).getValue();
|
||||
}
|
||||
} else if (entry.getKey().equals("z")) {
|
||||
if (entry.getValue() instanceof IntTag) {
|
||||
z = ((IntTag)entry.getValue()).getValue();
|
||||
z = ((IntTag) entry.getValue()).getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,9 +171,10 @@ public class Chunk {
|
||||
* @return
|
||||
* @throws DataException
|
||||
*/
|
||||
private Map<String,Tag> getBlockTileEntity(Vector pos) throws DataException {
|
||||
if (tileEntities == null)
|
||||
private Map<String, Tag> getBlockTileEntity(Vector pos) throws DataException {
|
||||
if (tileEntities == null) {
|
||||
populateTileEntities();
|
||||
}
|
||||
|
||||
return tileEntities.get(new BlockVector(pos));
|
||||
}
|
||||
@ -208,8 +208,8 @@ public class Chunk {
|
||||
}
|
||||
|
||||
if (block instanceof TileEntityBlock) {
|
||||
Map<String,Tag> tileEntity = getBlockTileEntity(pos);
|
||||
((TileEntityBlock)block).fromTileEntityNBT(tileEntity);
|
||||
Map<String, Tag> tileEntity = getBlockTileEntity(pos);
|
||||
((TileEntityBlock) block).fromTileEntityNBT(tileEntity);
|
||||
}
|
||||
|
||||
return block;
|
||||
@ -224,7 +224,7 @@ public class Chunk {
|
||||
* @return child tag
|
||||
* @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)
|
||||
throws InvalidFormatException {
|
||||
if (!items.containsKey(key)) {
|
||||
@ -232,8 +232,7 @@ public class Chunk {
|
||||
}
|
||||
Tag tag = items.get(key);
|
||||
if (!expected.isInstance(tag)) {
|
||||
throw new InvalidFormatException(
|
||||
key + " tag is not of tag type " + expected.getName());
|
||||
throw new InvalidFormatException(key + " tag is not of tag type " + expected.getName());
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
@ -36,8 +36,8 @@ public abstract class ChunkStore {
|
||||
* @return
|
||||
*/
|
||||
public static BlockVector2D toChunk(Vector pos) {
|
||||
int chunkX = (int)Math.floor(pos.getBlockX() / 16.0);
|
||||
int chunkZ = (int)Math.floor(pos.getBlockZ() / 16.0);
|
||||
int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
|
||||
int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
|
||||
|
||||
return new BlockVector2D(chunkX, chunkZ);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class FileMcRegionChunkStore extends McRegionChunkStore {
|
||||
if (!file.exists()) {
|
||||
file = new File(path, "DIM-1" + File.separator + fileName);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
return new FileInputStream(file);
|
||||
} catch (FileNotFoundException e) {
|
||||
|
@ -23,10 +23,10 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class ForwardSeekableInputStream extends InputStream {
|
||||
|
||||
|
||||
protected InputStream parent;
|
||||
protected long position = 0;
|
||||
|
||||
|
||||
public ForwardSeekableInputStream(InputStream parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
@ -83,18 +83,18 @@ public class ForwardSeekableInputStream extends InputStream {
|
||||
position += skipped;
|
||||
return skipped;
|
||||
}
|
||||
|
||||
|
||||
public void seek(long n) throws IOException {
|
||||
long diff = n - position;
|
||||
|
||||
|
||||
if (diff < 0) {
|
||||
throw new IOException("Can't seek backwards");
|
||||
}
|
||||
|
||||
|
||||
if (diff == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (skip(diff) < diff) {
|
||||
throw new IOException("Failed to seek " + diff + " bytes");
|
||||
}
|
||||
|
@ -96,14 +96,14 @@ public abstract class LegacyChunkStore extends ChunkStore {
|
||||
+ 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;
|
||||
|
||||
// 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.getValue() instanceof CompoundTag) {
|
||||
rootTag = (CompoundTag)entry.getValue();
|
||||
rootTag = (CompoundTag) entry.getValue();
|
||||
break;
|
||||
} else {
|
||||
throw new ChunkStoreException("CompoundTag expected for 'Level'; got "
|
||||
@ -130,7 +130,7 @@ public abstract class LegacyChunkStore extends ChunkStore {
|
||||
* @return
|
||||
*/
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ import com.sk89q.worldedit.Vector2D;
|
||||
public abstract class McRegionChunkStore extends ChunkStore {
|
||||
protected String curFilename = null;
|
||||
protected McRegionReader cachedReader = null;
|
||||
|
||||
|
||||
/**
|
||||
* Get the filename of a region file.
|
||||
*
|
||||
@ -40,12 +40,12 @@ public abstract class McRegionChunkStore extends ChunkStore {
|
||||
public static String getFilename(Vector2D pos) {
|
||||
int x = pos.getBlockX();
|
||||
int z = pos.getBlockZ();
|
||||
|
||||
|
||||
String filename = "r." + (x >> 5) + "." + (z >> 5) + ".mcr";
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
||||
protected McRegionReader getReader(Vector2D pos, String worldname) throws DataException, IOException {
|
||||
String filename = getFilename(pos);
|
||||
if (curFilename != null) {
|
||||
@ -67,7 +67,7 @@ public abstract class McRegionChunkStore extends ChunkStore {
|
||||
@Override
|
||||
public CompoundTag getChunkTag(Vector2D pos, String worldname) throws DataException,
|
||||
IOException {
|
||||
|
||||
|
||||
McRegionReader reader = getReader(pos, worldname);
|
||||
InputStream stream = reader.getChunkInputStream(pos);
|
||||
NBTInputStream nbt = new NBTInputStream(stream);
|
||||
@ -80,14 +80,14 @@ public abstract class McRegionChunkStore extends ChunkStore {
|
||||
+ 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;
|
||||
|
||||
// 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.getValue() instanceof CompoundTag) {
|
||||
rootTag = (CompoundTag)entry.getValue();
|
||||
rootTag = (CompoundTag) entry.getValue();
|
||||
break;
|
||||
} else {
|
||||
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)
|
||||
throws IOException, DataException;
|
||||
|
||||
|
||||
/**
|
||||
* Close resources.
|
||||
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren