Dieser Commit ist enthalten in:
TomyLobo 2011-11-23 02:29:48 +01:00
Ursprung 1a57f6e95d
Commit 7e13b60a51
161 geänderte Dateien mit 1433 neuen und 1412 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -67,5 +67,4 @@ public @interface Command {
* meaning that if it is given it must have a value * meaning that if it is given it must have a value
*/ */
String flags() default ""; String flags() default "";
} }

Datei anzeigen

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

Datei anzeigen

@ -56,7 +56,6 @@ import com.sk89q.util.StringUtil;
* @param <T> command sender class * @param <T> command sender class
*/ */
public abstract class CommandsManager<T> { public abstract class CommandsManager<T> {
/** /**
* Logger for general errors. * Logger for general errors.
*/ */
@ -70,8 +69,7 @@ public abstract class CommandsManager<T> {
* the key of the command name (one for each alias) with the * the key of the command name (one for each alias) with the
* method. * method.
*/ */
protected Map<Method, Map<String, Method>> commands protected Map<Method, Map<String, Method>> commands = new HashMap<Method, Map<String, Method>>();
= new HashMap<Method, Map<String, Method>>();
/** /**
* Used to store the instances associated with a method. * Used to store the instances associated with a method.
@ -256,7 +254,8 @@ public abstract class CommandsManager<T> {
char[] flags = cmd.flags().toCharArray(); char[] flags = cmd.flags().toCharArray();
for (int i = 0; i < flags.length; ++i) { for (int i = 0; i < flags.length; ++i) {
if (flags.length > i + 1 && flags[i + 1] == ':') { if (flags.length > i + 1 && flags[i + 1] == ':') {
i++; continue; i++;
continue;
} }
flagChars.add(flags[i]); flagChars.add(flags[i]);
} }
@ -294,7 +293,6 @@ public abstract class CommandsManager<T> {
command.append(args[i] + " "); command.append(args[i] + " ");
} }
Map<String, Method> map = commands.get(method); Map<String, Method> map = commands.get(method);
boolean found = false; boolean found = false;
@ -340,7 +338,7 @@ public abstract class CommandsManager<T> {
* @throws CommandException * @throws CommandException
*/ */
public void execute(String cmd, String[] args, T player, public void execute(String cmd, String[] args, T player,
Object ... methodArgs) throws CommandException { Object... methodArgs) throws CommandException {
String[] newArgs = new String[args.length + 1]; String[] newArgs = new String[args.length + 1];
System.arraycopy(args, 0, newArgs, 1, args.length); System.arraycopy(args, 0, newArgs, 1, args.length);
@ -360,7 +358,7 @@ public abstract class CommandsManager<T> {
* @throws CommandException * @throws CommandException
*/ */
public void execute(String[] args, T player, public void execute(String[] args, T player,
Object ... methodArgs) throws CommandException { Object... methodArgs) throws CommandException {
Object[] newMethodArgs = new Object[methodArgs.length + 1]; Object[] newMethodArgs = new Object[methodArgs.length + 1];
System.arraycopy(methodArgs, 0, newMethodArgs, 1, methodArgs.length); System.arraycopy(methodArgs, 0, newMethodArgs, 1, methodArgs.length);
@ -430,16 +428,19 @@ public abstract class CommandsManager<T> {
CommandContext context = new CommandContext(newArgs, valueFlags); CommandContext context = new CommandContext(newArgs, valueFlags);
if (context.argsLength() < cmd.min()) if (context.argsLength() < cmd.min()) {
throw new CommandUsageException("Too few arguments.", getUsage(args, level, cmd)); throw new CommandUsageException("Too few arguments.", getUsage(args, level, cmd));
}
if (cmd.max() != -1 && context.argsLength() > cmd.max()) if (cmd.max() != -1 && context.argsLength() > cmd.max()) {
throw new CommandUsageException("Too many arguments.", getUsage(args, level, cmd)); throw new CommandUsageException("Too many arguments.", getUsage(args, level, cmd));
}
for (char flag : context.getFlags()) { for (char flag : context.getFlags()) {
if (!newFlags.contains(flag)) if (!newFlags.contains(flag)) {
throw new CommandUsageException("Unknown flag: " + flag, getUsage(args, level, cmd)); throw new CommandUsageException("Unknown flag: " + flag, getUsage(args, level, cmd));
} }
}
methodArgs[0] = context; methodArgs[0] = context;

Datei anzeigen

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

Datei anzeigen

@ -36,6 +36,7 @@ import java.util.Map;
public class YAMLNode { public class YAMLNode {
protected Map<String, Object> root; protected Map<String, Object> root;
private boolean writeDefaults; private boolean writeDefaults;
public YAMLNode(Map<String, Object> root, boolean writeDefaults) { public YAMLNode(Map<String, Object> root, boolean writeDefaults) {
this.root = root; this.root = root;
this.writeDefaults = writeDefaults; this.writeDefaults = writeDefaults;
@ -92,7 +93,7 @@ public class YAMLNode {
} }
try { try {
node = (Map<String, Object>)o; node = (Map<String, Object>) o;
} catch (ClassCastException e) { } catch (ClassCastException e) {
return null; return null;
} }
@ -155,7 +156,7 @@ public class YAMLNode {
node.put(parts[i], o); node.put(parts[i], o);
} }
node = (Map<String, Object>)o; node = (Map<String, Object>) o;
} }
} }
@ -402,7 +403,7 @@ public class YAMLNode {
if (o == null) { if (o == null) {
return null; return null;
} else if (o instanceof Map) { } else if (o instanceof Map) {
return new ArrayList<String>(((Map<String,Object>)o).keySet()); return new ArrayList<String>(((Map<String, Object>) o).keySet());
} else { } else {
return null; return null;
} }
@ -421,7 +422,7 @@ public class YAMLNode {
if (o == null) { if (o == null) {
return null; return null;
} else if (o instanceof List) { } else if (o instanceof List) {
return (List<Object>)o; return (List<Object>) o;
} else { } else {
return null; return null;
} }
@ -656,7 +657,7 @@ public class YAMLNode {
List<YAMLNode> list = new ArrayList<YAMLNode>(); List<YAMLNode> list = new ArrayList<YAMLNode>();
for (Object o : raw) { for (Object o : raw) {
if (o instanceof Map) { if (o instanceof Map) {
list.add(new YAMLNode((Map<String, Object>)o, writeDefaults)); list.add(new YAMLNode((Map<String, Object>) o, writeDefaults));
} }
} }
@ -675,7 +676,7 @@ public class YAMLNode {
public YAMLNode getNode(String path) { public YAMLNode getNode(String path) {
Object raw = getProperty(path); Object raw = getProperty(path);
if (raw instanceof Map) { if (raw instanceof Map) {
return new YAMLNode((Map<String, Object>)raw, writeDefaults); return new YAMLNode((Map<String, Object>) raw, writeDefaults);
} }
return null; return null;
@ -697,7 +698,7 @@ public class YAMLNode {
Map<String, YAMLNode> nodes = Map<String, YAMLNode> nodes =
new HashMap<String, YAMLNode>(); new HashMap<String, YAMLNode>();
for (Map.Entry<String, Object> entry : ((Map<String, Object>)o).entrySet()) { for (Map.Entry<String, Object> entry : ((Map<String, Object>) o).entrySet()) {
if (entry.getValue() instanceof Map) { if (entry.getValue() instanceof Map) {
nodes.put(entry.getKey(), nodes.put(entry.getKey(),
new YAMLNode((Map<String, Object>) entry.getValue(), writeDefaults)); new YAMLNode((Map<String, Object>) entry.getValue(), writeDefaults));
@ -720,7 +721,7 @@ public class YAMLNode {
if (o == null) { if (o == null) {
return null; return null;
} else if (o instanceof Number) { } else if (o instanceof Number) {
return ((Number)o).intValue(); return ((Number) o).intValue();
} else { } else {
return null; return null;
} }
@ -736,7 +737,7 @@ public class YAMLNode {
if (o == null) { if (o == null) {
return null; return null;
} else if (o instanceof Number) { } else if (o instanceof Number) {
return ((Number)o).doubleValue(); return ((Number) o).doubleValue();
} else { } else {
return null; return null;
} }
@ -752,7 +753,7 @@ public class YAMLNode {
if (o == null) { if (o == null) {
return null; return null;
} else if (o instanceof Boolean) { } else if (o instanceof Boolean) {
return (Boolean)o; return (Boolean) o;
} else { } else {
return null; return null;
} }
@ -783,7 +784,7 @@ public class YAMLNode {
return; return;
} }
node = (Map<String, Object>)o; node = (Map<String, Object>) o;
} }
} }

Datei anzeigen

@ -171,7 +171,8 @@ public class YAMLProcessor extends YAMLNode {
} }
yaml.dump(root, writer); yaml.dump(root, writer);
return true; return true;
} catch (IOException e) {} finally { } catch (IOException e) {
} finally {
try { try {
if (stream != null) { if (stream != null) {
stream.close(); stream.close();
@ -185,10 +186,10 @@ public class YAMLProcessor extends YAMLNode {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void read(Object input) throws YAMLProcessorException { private void read(Object input) throws YAMLProcessorException {
try { try {
if ( null == input ) { if (null == input) {
root = new HashMap<String, Object>(); root = new HashMap<String, Object>();
} else { } else {
root = (Map<String, Object>)input; root = (Map<String, Object>) input;
} }
} catch (ClassCastException e) { } catch (ClassCastException e) {
throw new YAMLProcessorException("Root document must be an key-value structure"); throw new YAMLProcessorException("Root document must be an key-value structure");

Datei anzeigen

@ -38,9 +38,9 @@ public abstract class ArbitraryShape {
Vector min = extent.getMinimumPoint(); Vector min = extent.getMinimumPoint();
Vector max = extent.getMaximumPoint(); Vector max = extent.getMaximumPoint();
cacheSizeX = (int)(max.getX() - min.getX() + 1 + 2); cacheSizeX = (int) (max.getX() - min.getX() + 1 + 2);
cacheSizeY = (int)(max.getY() - min.getY() + 1 + 2); cacheSizeY = (int) (max.getY() - min.getY() + 1 + 2);
cacheSizeZ = (int)(max.getZ() - min.getZ() + 1 + 2); cacheSizeZ = (int) (max.getZ() - min.getZ() + 1 + 2);
cacheX = min.getBlockX() - 1; cacheX = min.getBlockX() - 1;
cacheY = min.getBlockY() - 1; cacheY = min.getBlockY() - 1;
@ -79,7 +79,7 @@ public abstract class ArbitraryShape {
return null; return null;
} }
short newCacheEntry = (short) (material.getType() | ((material.getData()+1) << 8)); short newCacheEntry = (short) (material.getType() | ((material.getData() + 1) << 8));
if (newCacheEntry == 0) { if (newCacheEntry == 0) {
// type and data 0 // type and data 0
newCacheEntry = -2; newCacheEntry = -2;

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -327,20 +327,17 @@ public class EditSession {
if (BlockType.shouldPlaceLast(block.getType())) { if (BlockType.shouldPlaceLast(block.getType())) {
// Place torches, etc. last // Place torches, etc. last
queueLast.put(pt.toBlockVector(), block); queueLast.put(pt.toBlockVector(), block);
return !(getBlockType(pt) == block.getType() return !(getBlockType(pt) == block.getType() && getBlockData(pt) == block.getData());
&& getBlockData(pt) == block.getData());
} else if (BlockType.shouldPlaceFinal(block.getType())) { } else if (BlockType.shouldPlaceFinal(block.getType())) {
// Place signs, reed, etc even later // Place signs, reed, etc even later
queueFinal.put(pt.toBlockVector(), block); queueFinal.put(pt.toBlockVector(), block);
return !(getBlockType(pt) == block.getType() return !(getBlockType(pt) == block.getType() && getBlockData(pt) == block.getData());
&& getBlockData(pt) == block.getData());
} else if (BlockType.shouldPlaceLast(getBlockType(pt))) { } else if (BlockType.shouldPlaceLast(getBlockType(pt))) {
// Destroy torches, etc. first // Destroy torches, etc. first
rawSetBlock(pt, new BaseBlock(BlockID.AIR)); rawSetBlock(pt, new BaseBlock(BlockID.AIR));
} else { } else {
queueAfter.put(pt.toBlockVector(), block); queueAfter.put(pt.toBlockVector(), block);
return !(getBlockType(pt) == block.getType() return !(getBlockType(pt) == block.getType() && getBlockData(pt) == block.getData());
&& getBlockData(pt) == block.getData());
} }
} }
@ -403,6 +400,7 @@ public class EditSession {
return world.getBlockData(pt); return world.getBlockData(pt);
} }
/** /**
* Gets the block type at a position x, y, z. * Gets the block type at a position x, y, z.
* *
@ -1962,7 +1960,7 @@ public class EditSession {
visited.add(cur); visited.add(cur);
if (setBlock(cur, stationaryBlock)){ if (setBlock(cur, stationaryBlock)) {
++affected; ++affected;
} }
@ -2033,13 +2031,11 @@ public class EditSession {
final int ceilRadiusZ = (int) Math.ceil(radiusZ); final int ceilRadiusZ = (int) Math.ceil(radiusZ);
double nextXn = 0; double nextXn = 0;
forX: forX: for (int x = 0; x <= ceilRadiusX; ++x) {
for (int x = 0; x <= ceilRadiusX; ++x) {
final double xn = nextXn; final double xn = nextXn;
nextXn = (x + 1) * invRadiusX; nextXn = (x + 1) * invRadiusX;
double nextZn = 0; double nextZn = 0;
forZ: forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
for (int z = 0; z <= ceilRadiusZ; ++z) {
final double zn = nextZn; final double zn = nextZn;
nextZn = (z + 1) * invRadiusZ; nextZn = (z + 1) * invRadiusZ;
@ -2119,18 +2115,15 @@ public class EditSession {
final int ceilRadiusZ = (int) Math.ceil(radiusZ); final int ceilRadiusZ = (int) Math.ceil(radiusZ);
double nextXn = 0; double nextXn = 0;
forX: forX: for (int x = 0; x <= ceilRadiusX; ++x) {
for (int x = 0; x <= ceilRadiusX; ++x) {
final double xn = nextXn; final double xn = nextXn;
nextXn = (x + 1) * invRadiusX; nextXn = (x + 1) * invRadiusX;
double nextYn = 0; double nextYn = 0;
forY: forY: for (int y = 0; y <= ceilRadiusY; ++y) {
for (int y = 0; y <= ceilRadiusY; ++y) {
final double yn = nextYn; final double yn = nextYn;
nextYn = (y + 1) * invRadiusY; nextYn = (y + 1) * invRadiusY;
double nextZn = 0; double nextZn = 0;
forZ: forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
for (int z = 0; z <= ceilRadiusZ; ++z) {
final double zn = nextZn; final double zn = nextZn;
nextZn = (z + 1) * invRadiusZ; nextZn = (z + 1) * invRadiusZ;
@ -2244,7 +2237,7 @@ public class EditSession {
public int thaw(Vector pos, double radius) public int thaw(Vector pos, double radius)
throws MaxChangedBlocksException { throws MaxChangedBlocksException {
int affected = 0; int affected = 0;
double radiusSq = radius*radius; double radiusSq = radius * radius;
int ox = pos.getBlockX(); int ox = pos.getBlockX();
int oy = pos.getBlockY(); int oy = pos.getBlockY();
@ -2303,7 +2296,7 @@ public class EditSession {
public int simulateSnow(Vector pos, double radius) public int simulateSnow(Vector pos, double radius)
throws MaxChangedBlocksException { throws MaxChangedBlocksException {
int affected = 0; int affected = 0;
double radiusSq = radius*radius; double radiusSq = radius * radius;
int ox = pos.getBlockX(); int ox = pos.getBlockX();
int oy = pos.getBlockY(); int oy = pos.getBlockY();
@ -2368,7 +2361,7 @@ public class EditSession {
public int green(Vector pos, double radius) public int green(Vector pos, double radius)
throws MaxChangedBlocksException { throws MaxChangedBlocksException {
int affected = 0; int affected = 0;
double radiusSq = radius*radius; double radiusSq = radius * radius;
int ox = pos.getBlockX(); int ox = pos.getBlockX();
int oy = pos.getBlockY(); int oy = pos.getBlockY();
@ -2655,7 +2648,7 @@ public class EditSession {
return null; return null;
} }
return new BaseBlock((int)typeVariable.getValue(), (int)dataVariable.getValue()); return new BaseBlock((int) typeVariable.getValue(), (int) dataVariable.getValue());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;

Datei anzeigen

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

Datei anzeigen

@ -26,7 +26,6 @@ import java.io.File;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
/** /**
* Represents WorldEdit's configuration. * Represents WorldEdit's configuration.
* *

Datei anzeigen

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

Datei anzeigen

@ -75,7 +75,6 @@ public class LocalSession {
private boolean fastMode = false; private boolean fastMode = false;
private Mask mask; private Mask mask;
private TimeZone timezone = TimeZone.getDefault(); private TimeZone timezone = TimeZone.getDefault();
//private Boolean jumptoBlock = true;
/** /**
* Construct the object. * Construct the object.
@ -465,7 +464,7 @@ public class LocalSession {
setTool(item, tool); setTool(item, tool);
} }
return (BrushTool)tool; return (BrushTool) tool;
} }
/** /**

Datei anzeigen

@ -248,10 +248,16 @@ public abstract class LocalWorld {
*/ */
public void simulateBlockMine(Vector pt) { public void simulateBlockMine(Vector pt) {
BaseItemStack stack = BlockType.getBlockDrop(getBlockType(pt), (short) getBlockData(pt)); BaseItemStack stack = BlockType.getBlockDrop(getBlockType(pt), (short) getBlockData(pt));
if (stack != null) dropItem(pt, if (stack == null) {
stack.getAmount() > 1 ? new BaseItemStack(stack.getType(), return;
1, stack.getDamage()) : stack, stack.getAmount()); }
final int amount = stack.getAmount();
if (amount > 1) {
dropItem(pt, new BaseItemStack(stack.getType(), 1, stack.getDamage()), amount);
} else {
dropItem(pt, stack, amount);
}
} }
/** /**
@ -298,7 +304,8 @@ public abstract class LocalWorld {
* *
* @param pt Position to check * @param pt Position to check
*/ */
public void checkLoadedChunk(Vector pt) {} public void checkLoadedChunk(Vector pt) {
}
/** /**
* Compare if the other world is equal. * Compare if the other world is equal.
@ -331,7 +338,9 @@ public abstract class LocalWorld {
* *
* @param chunks the chunks to fix * @param chunks the chunks to fix
*/ */
public void fixAfterFastMode(Iterable<BlockVector2D> chunks) {} public void fixAfterFastMode(Iterable<BlockVector2D> chunks) {
}
public void fixLighting(Iterable<BlockVector2D> chunks) {} public void fixLighting(Iterable<BlockVector2D> chunks) {
}
} }

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -81,7 +81,7 @@ public class WorldEdit {
* without any WorldEdit abilities or never use WorldEdit in a session will * without any WorldEdit abilities or never use WorldEdit in a session will
* not have a session object generated for them. * not have a session object generated for them.
*/ */
private HashMap<String,LocalSession> sessions = new HashMap<String,LocalSession>(); private HashMap<String, LocalSession> sessions = new HashMap<String, LocalSession>();
/** /**
* Initialize statically. * Initialize statically.
@ -135,20 +135,20 @@ public class WorldEdit {
/* FALL-THROUGH */ /* FALL-THROUGH */
case POSITION: case POSITION:
msg += " - Position: "+position; msg += " - Position: " + position;
break; break;
case ALL: case ALL:
msg += " - Position: "+position; msg += " - Position: " + position;
/* FALL-THROUGH */ /* FALL-THROUGH */
case ORIENTATION_REGION: case ORIENTATION_REGION:
msg += " - Orientation: "+player.getCardinalDirection().name(); msg += " - Orientation: " + player.getCardinalDirection().name();
/* FALL-THROUGH */ /* FALL-THROUGH */
case REGION: case REGION:
try { try {
msg += " - Region: "+session.getSelection(player.getWorld()); msg += " - Region: " + session.getSelection(player.getWorld());
} catch (IncompleteRegionException e) { } catch (IncompleteRegionException e) {
break; break;
} }
@ -374,12 +374,11 @@ public class WorldEdit {
} }
// Check if the item is allowed // Check if the item is allowed
if (allAllowed || player.hasPermission("worldedit.anyblock") if (allAllowed || player.hasPermission("worldedit.anyblock") || !config.disallowedBlocks.contains(blockId)) {
|| !config.disallowedBlocks.contains(blockId)) { switch (blockType) {
case SIGN_POST:
case WALL_SIGN:
// Allow special sign text syntax // Allow special sign text syntax
if (blockType == BlockType.SIGN_POST
|| blockType == BlockType.WALL_SIGN) {
String[] text = new String[4]; String[] text = new String[4];
text[0] = blockAndExtraData.length > 1 ? blockAndExtraData[1] : ""; text[0] = blockAndExtraData.length > 1 ? blockAndExtraData[1] : "";
text[1] = blockAndExtraData.length > 2 ? blockAndExtraData[2] : ""; text[1] = blockAndExtraData.length > 2 ? blockAndExtraData[2] : "";
@ -387,12 +386,12 @@ public class WorldEdit {
text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : ""; text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : "";
return new SignBlock(blockType.getID(), data, text); return new SignBlock(blockType.getID(), data, text);
case MOB_SPAWNER:
// Allow setting mob spawn type // Allow setting mob spawn type
} else if (blockType == BlockType.MOB_SPAWNER) {
if (blockAndExtraData.length > 1) { if (blockAndExtraData.length > 1) {
String mobName = blockAndExtraData[1]; String mobName = blockAndExtraData[1];
for (MobType mobType : MobType.values()){ for (MobType mobType : MobType.values()) {
if (mobType.getName().toLowerCase().equals(mobName.toLowerCase())){ if (mobType.getName().toLowerCase().equals(mobName.toLowerCase())) {
mobName = mobType.getName(); mobName = mobType.getName();
break; break;
} }
@ -405,8 +404,8 @@ public class WorldEdit {
return new MobSpawnerBlock(data, MobType.PIG.getName()); return new MobSpawnerBlock(data, MobType.PIG.getName());
} }
case NOTE_BLOCK:
// Allow setting note // Allow setting note
} else if (blockType == BlockType.NOTE_BLOCK) {
if (blockAndExtraData.length > 1) { if (blockAndExtraData.length > 1) {
byte note = Byte.parseByte(blockAndExtraData[1]); byte note = Byte.parseByte(blockAndExtraData[1]);
if (note < 0 || note > 24) { if (note < 0 || note > 24) {
@ -415,12 +414,13 @@ public class WorldEdit {
return new NoteBlock(data, note); return new NoteBlock(data, note);
} }
} else { } else {
return new NoteBlock(data, (byte)0); return new NoteBlock(data, (byte) 0);
}
} }
default:
return new BaseBlock(blockId, data); return new BaseBlock(blockId, data);
} }
}
throw new DisallowedItemException(arg); throw new DisallowedItemException(arg);
} }
@ -439,7 +439,7 @@ public class WorldEdit {
return getBlock(player, id, false); return getBlock(player, id, false);
} }
public Set<BaseBlock> getBlocks (LocalPlayer player, String list, boolean allAllowed, boolean allowNoData) public Set<BaseBlock> getBlocks(LocalPlayer player, String list, boolean allAllowed, boolean allowNoData)
throws DisallowedItemException, UnknownItemException { throws DisallowedItemException, UnknownItemException {
String[] items = list.split(","); String[] items = list.split(",");
Set<BaseBlock> blocks = new HashSet<BaseBlock>(); Set<BaseBlock> blocks = new HashSet<BaseBlock>();
@ -793,7 +793,7 @@ public class WorldEdit {
default: default:
throw new UnknownDirectionException(dir.name()); throw new UnknownDirectionException(dir.name());
} }
} }
private PlayerDirection getPlayerDirection(LocalPlayer player, String dirStr) throws UnknownDirectionException { private PlayerDirection getPlayerDirection(LocalPlayer player, String dirStr) throws UnknownDirectionException {
final PlayerDirection dir; final PlayerDirection dir;
@ -1127,7 +1127,7 @@ public class WorldEdit {
Tool tool = session.getTool(player.getItemInHand()); Tool tool = session.getTool(player.getItemInHand());
if (tool != null && tool instanceof BlockTool) { if (tool != null && tool instanceof BlockTool) {
if (tool.canUse(player)) { if (tool.canUse(player)) {
((BlockTool)tool).actPrimary(server, config, player, session, clicked); ((BlockTool) tool).actPrimary(server, config, player, session, clicked);
return true; return true;
} }
} }
@ -1172,7 +1172,7 @@ public class WorldEdit {
Tool tool = session.getTool(player.getItemInHand()); Tool tool = session.getTool(player.getItemInHand());
if (tool != null && tool instanceof DoubleActionBlockTool) { if (tool != null && tool instanceof DoubleActionBlockTool) {
if (tool.canUse(player)) { if (tool.canUse(player)) {
((DoubleActionBlockTool)tool).actSecondary(server, config, player, session, clicked); ((DoubleActionBlockTool) tool).actSecondary(server, config, player, session, clicked);
return true; return true;
} }
} }
@ -1261,7 +1261,7 @@ public class WorldEdit {
final Matcher matcher = numberFormatExceptionPattern.matcher(e.getMessage()); final Matcher matcher = numberFormatExceptionPattern.matcher(e.getMessage());
if (matcher.matches()) { if (matcher.matches()) {
player.printError("Number expected; string \""+matcher.group(1)+"\" given."); player.printError("Number expected; string \"" + matcher.group(1) + "\" given.");
} else { } else {
player.printError("Number expected; string given."); player.printError("Number expected; string given.");
} }
@ -1376,7 +1376,7 @@ public class WorldEdit {
try { try {
engine.evaluate(script, filename, vars); engine.evaluate(script, filename, vars);
} catch (ScriptException e) { } catch (ScriptException e) {
player.printError("Failed to execute:");; player.printError("Failed to execute:");
player.printRaw(e.getMessage()); player.printRaw(e.getMessage());
e.printStackTrace(); e.printStackTrace();
} catch (NumberFormatException e) { } catch (NumberFormatException e) {

Datei anzeigen

@ -110,9 +110,9 @@ public class WorldVector extends Vector {
*/ */
public static WorldVector toBlockPoint(LocalWorld world, double x, double y, public static WorldVector toBlockPoint(LocalWorld world, double x, double y,
double z) { double z) {
return new WorldVector(world, (int)Math.floor(x), return new WorldVector(world, (int) Math.floor(x),
(int)Math.floor(y), (int) Math.floor(y),
(int)Math.floor(z)); (int) Math.floor(z));
} }
/** /**

Datei anzeigen

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

Datei anzeigen

@ -189,6 +189,7 @@ public abstract class BlockBag {
* @param pos * @param pos
*/ */
public abstract void addSourcePosition(Vector pos); public abstract void addSourcePosition(Vector pos);
/** /**
* Adds a position to be used a source. * Adds a position to be used a source.
* *

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -146,7 +146,7 @@ public enum BlockType {
FENCE_GATE(BlockID.FENCE_GATE, "Fence gate", "fencegate", "gate"), FENCE_GATE(BlockID.FENCE_GATE, "Fence gate", "fencegate", "gate"),
BRICK_STAIRS(BlockID.BRICK_STAIRS, "Brick stairs", "brickstairs", "bricksteps"), BRICK_STAIRS(BlockID.BRICK_STAIRS, "Brick stairs", "brickstairs", "bricksteps"),
STONE_BRICK_STAIRS(BlockID.STONE_BRICK_STAIRS, "Stone brick stairs", "stonebrickstairs", "smoothstonebrickstairs"), STONE_BRICK_STAIRS(BlockID.STONE_BRICK_STAIRS, "Stone brick stairs", "stonebrickstairs", "smoothstonebrickstairs"),
MYCELIUM(BlockID.MYCELIUM, "Mycelium", "fungus" ,"mycel"), MYCELIUM(BlockID.MYCELIUM, "Mycelium", "fungus", "mycel"),
LILY_PAD(BlockID.LILY_PAD, "Lily pad", "lilypad", "waterlily"), LILY_PAD(BlockID.LILY_PAD, "Lily pad", "lilypad", "waterlily"),
NETHER_BRICK(BlockID.NETHER_BRICK, "Nether brick", "netherbrick"), NETHER_BRICK(BlockID.NETHER_BRICK, "Nether brick", "netherbrick"),
NETHER_BRICK_FENCE(BlockID.NETHER_BRICK_FENCE, "Nether brick fence", "netherbrickfence", "netherfence"), NETHER_BRICK_FENCE(BlockID.NETHER_BRICK_FENCE, "Nether brick fence", "netherbrickfence", "netherfence"),
@ -162,18 +162,18 @@ public enum BlockType {
/** /**
* Stores a map of the IDs for fast access. * Stores a map of the IDs for fast access.
*/ */
private static final Map<Integer,BlockType> ids = new HashMap<Integer,BlockType>(); private static final Map<Integer, BlockType> ids = new HashMap<Integer, BlockType>();
/** /**
* Stores a map of the names for fast access. * Stores a map of the names for fast access.
*/ */
private static final Map<String,BlockType> lookup = new HashMap<String,BlockType>(); private static final Map<String, BlockType> lookup = new HashMap<String, BlockType>();
private final int id; private final int id;
private final String name; private final String name;
private final String[] lookupKeys; private final String[] lookupKeys;
static { static {
for(BlockType type : EnumSet.allOf(BlockType.class)) { for (BlockType type : EnumSet.allOf(BlockType.class)) {
ids.put(type.id, type); ids.put(type.id, type);
for (String key : type.lookupKeys) { for (String key : type.lookupKeys) {
lookup.put(key, type); lookup.put(key, type);
@ -200,7 +200,7 @@ public enum BlockType {
* @param id * @param id
* @param name * @param name
*/ */
BlockType(int id, String name, String ... lookupKeys) { BlockType(int id, String name, String... lookupKeys) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.lookupKeys = lookupKeys; this.lookupKeys = lookupKeys;

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -146,7 +146,7 @@ public enum ItemType {
FENCE_GATE(BlockID.FENCE_GATE, "Fence gate", "fencegate", "gate"), FENCE_GATE(BlockID.FENCE_GATE, "Fence gate", "fencegate", "gate"),
BRICK_STAIRS(BlockID.BRICK_STAIRS, "Brick stairs", "brickstairs", "bricksteps"), BRICK_STAIRS(BlockID.BRICK_STAIRS, "Brick stairs", "brickstairs", "bricksteps"),
STONE_BRICK_STAIRS(BlockID.STONE_BRICK_STAIRS, "Stone brick stairs", "stonebrickstairs", "smoothstonebrickstairs"), STONE_BRICK_STAIRS(BlockID.STONE_BRICK_STAIRS, "Stone brick stairs", "stonebrickstairs", "smoothstonebrickstairs"),
MYCELIUM(BlockID.MYCELIUM, "Mycelium", "fungus" ,"mycel"), MYCELIUM(BlockID.MYCELIUM, "Mycelium", "fungus", "mycel"),
LILY_PAD(BlockID.LILY_PAD, "Lily pad", "lilypad", "waterlily"), LILY_PAD(BlockID.LILY_PAD, "Lily pad", "lilypad", "waterlily"),
NETHER_BRICK(BlockID.NETHER_BRICK, "Nether brick", "netherbrick"), NETHER_BRICK(BlockID.NETHER_BRICK, "Nether brick", "netherbrick"),
NETHER_BRICK_FENCE(BlockID.NETHER_BRICK_FENCE, "Nether brick fence", "netherbrickfence", "netherfence"), NETHER_BRICK_FENCE(BlockID.NETHER_BRICK_FENCE, "Nether brick fence", "netherbrickfence", "netherfence"),
@ -306,11 +306,11 @@ public enum ItemType {
/** /**
* Stores a map of the IDs for fast access. * Stores a map of the IDs for fast access.
*/ */
private static final Map<Integer,ItemType> ids = new HashMap<Integer,ItemType>(); private static final Map<Integer, ItemType> ids = new HashMap<Integer, ItemType>();
/** /**
* Stores a map of the names for fast access. * Stores a map of the names for fast access.
*/ */
private static final Map<String,ItemType> lookup = new LinkedHashMap<String,ItemType>(); private static final Map<String, ItemType> lookup = new LinkedHashMap<String, ItemType>();
private final int id; private final int id;
private final String name; private final String name;
@ -335,7 +335,7 @@ public enum ItemType {
ItemType(int id, String name, String lookupKey) { ItemType(int id, String name, String lookupKey) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.lookupKeys = new String[] {lookupKey}; this.lookupKeys = new String[] { lookupKey };
} }
/** /**
@ -344,7 +344,7 @@ public enum ItemType {
* @param id * @param id
* @param name * @param name
*/ */
ItemType(int id, String name, String ... lookupKeys) { ItemType(int id, String name, String... lookupKeys) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.lookupKeys = lookupKeys; this.lookupKeys = lookupKeys;

Datei anzeigen

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

Datei anzeigen

@ -92,9 +92,9 @@ public class NoteBlock extends BaseBlock implements TileEntityBlock {
* @return map of values * @return map of values
* @throws DataException * @throws DataException
*/ */
public Map<String,Tag> toTileEntityNBT() public Map<String, Tag> toTileEntityNBT()
throws DataException { throws DataException {
Map<String,Tag> values = new HashMap<String,Tag>(); Map<String, Tag> values = new HashMap<String, Tag>();
values.put("note", new ByteTag("note", note)); values.put("note", new ByteTag("note", note));
return values; return values;
} }
@ -105,7 +105,7 @@ public class NoteBlock extends BaseBlock implements TileEntityBlock {
* @param values * @param values
* @throws DataException * @throws DataException
*/ */
public void fromTileEntityNBT(Map<String,Tag> values) public void fromTileEntityNBT(Map<String, Tag> values)
throws DataException { throws DataException {
if (values == null) { if (values == null) {
return; return;
@ -114,13 +114,13 @@ public class NoteBlock extends BaseBlock implements TileEntityBlock {
Tag t; Tag t;
t = values.get("id"); t = values.get("id");
if (!(t instanceof StringTag) || !((StringTag)t).getValue().equals("Music")) { if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Music")) {
throw new DataException("'Music' tile entity expected"); throw new DataException("'Music' tile entity expected");
} }
t = values.get("note"); t = values.get("note");
if (t instanceof ByteTag) { if (t instanceof ByteTag) {
note = ((ByteTag)t).getValue(); note = ((ByteTag) t).getValue();
} }
} }
} }

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -93,7 +93,7 @@ public class BukkitConfiguration extends LocalConfiguration {
LocalSession.EXPIRATION_GRACE = config.getInt("history.expiration", 10) * 60 * 1000; LocalSession.EXPIRATION_GRACE = config.getInt("history.expiration", 10) * 60 * 1000;
String snapshotsDir = config.getString("snapshots.directory", ""); String snapshotsDir = config.getString("snapshots.directory", "");
if (!snapshotsDir.isEmpty()){ if (!snapshotsDir.isEmpty()) {
snapshotRepo = new SnapshotRepository(snapshotsDir); snapshotRepo = new SnapshotRepository(snapshotsDir);
} }
@ -122,5 +122,4 @@ public class BukkitConfiguration extends LocalConfiguration {
logFileHandler.close(); logFileHandler.close();
} }
} }
} }

Datei anzeigen

@ -33,7 +33,7 @@ public class BukkitUtil {
private BukkitUtil() { private BukkitUtil() {
} }
private static final Map<World,LocalWorld> wlw = new HashMap<World,LocalWorld>(); private static final Map<World, LocalWorld> wlw = new HashMap<World, LocalWorld>();
public static LocalWorld getLocalWorld(World w) { public static LocalWorld getLocalWorld(World w) {
LocalWorld lw = wlw.get(w); LocalWorld lw = wlw.get(w);
@ -75,9 +75,9 @@ public class BukkitUtil {
public static Location center(Location loc) { public static Location center(Location loc) {
return new Location( return new Location(
loc.getWorld(), loc.getWorld(),
loc.getBlockX()+0.5, loc.getBlockX() + 0.5,
loc.getBlockY()+0.5, loc.getBlockY() + 0.5,
loc.getBlockZ()+0.5, loc.getBlockZ() + 0.5,
loc.getPitch(), loc.getPitch(),
loc.getYaw() loc.getYaw()
); );
@ -96,7 +96,7 @@ public class BukkitUtil {
} }
public static World toWorld(WorldVector pt) { public static World toWorld(WorldVector pt) {
return ((BukkitWorld)pt.getWorld()).getWorld(); return ((BukkitWorld) pt.getWorld()).getWorld();
} }
/** /**
@ -104,10 +104,11 @@ public class BukkitUtil {
* precision. * precision.
*/ */
public static boolean equals(Location a, Location b) { public static boolean equals(Location a, Location b) {
if (Math.abs(a.getX()-b.getX()) > EQUALS_PRECISION) return false; if (Math.abs(a.getX() - b.getX()) > EQUALS_PRECISION) return false;
if (Math.abs(a.getY()-b.getY()) > EQUALS_PRECISION) return false; if (Math.abs(a.getY() - b.getY()) > EQUALS_PRECISION) return false;
if (Math.abs(a.getZ()-b.getZ()) > EQUALS_PRECISION) return false; if (Math.abs(a.getZ() - b.getZ()) > EQUALS_PRECISION) return false;
return true; return true;
} }
public static final double EQUALS_PRECISION = 0.0001; public static final double EQUALS_PRECISION = 0.0001;
} }

Datei anzeigen

@ -130,7 +130,7 @@ public class BukkitWorld extends LocalWorld {
* @return * @return
*/ */
@Override @Override
public boolean setTypeIdAndData(Vector pt, int type, int data){ public boolean setTypeIdAndData(Vector pt, int type, int data) {
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setTypeIdAndData(type, (byte) data, true); return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setTypeIdAndData(type, (byte) data, true);
} }
@ -142,7 +142,7 @@ public class BukkitWorld extends LocalWorld {
* @return * @return
*/ */
@Override @Override
public boolean setTypeIdAndDataFast(Vector pt, int type, int data){ public boolean setTypeIdAndDataFast(Vector pt, int type, int data) {
final Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); final Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (fastLightingAvailable) { if (fastLightingAvailable) {
type = type & 255; type = type & 255;
@ -175,7 +175,7 @@ public class BukkitWorld extends LocalWorld {
*/ */
@Override @Override
public void setBlockData(Vector pt, int data) { public void setBlockData(Vector pt, int data) {
world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setData((byte)data); world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setData((byte) data);
} }
/** /**
@ -186,7 +186,7 @@ public class BukkitWorld extends LocalWorld {
*/ */
@Override @Override
public void setBlockDataFast(Vector pt, int data) { public void setBlockDataFast(Vector pt, int data) {
world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setData((byte)data, false); world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setData((byte) data, false);
} }
/** /**
@ -273,47 +273,51 @@ public class BukkitWorld extends LocalWorld {
*/ */
@Override @Override
public boolean copyToWorld(Vector pt, BaseBlock block) { public boolean copyToWorld(Vector pt, BaseBlock block) {
// Signs
if (block instanceof SignBlock) { if (block instanceof SignBlock) {
setSignText(pt, ((SignBlock)block).getText()); // Signs
setSignText(pt, ((SignBlock) block).getText());
return true; return true;
}
if (block instanceof FurnaceBlock) {
// Furnaces // Furnaces
} else if (block instanceof FurnaceBlock) {
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
if (!(state instanceof Furnace)) return false; if (!(state instanceof Furnace)) return false;
Furnace bukkit = (Furnace)state; Furnace bukkit = (Furnace) state;
FurnaceBlock we = (FurnaceBlock)block; FurnaceBlock we = (FurnaceBlock) block;
bukkit.setBurnTime(we.getBurnTime()); bukkit.setBurnTime(we.getBurnTime());
bukkit.setCookTime(we.getCookTime()); bukkit.setCookTime(we.getCookTime());
return setContainerBlockContents(pt, ((ContainerBlock)block).getItems()); return setContainerBlockContents(pt, ((ContainerBlock) block).getItems());
}
if (block instanceof ContainerBlock) {
// Chests/dispenser // Chests/dispenser
} else if (block instanceof ContainerBlock) { return setContainerBlockContents(pt, ((ContainerBlock) block).getItems());
return setContainerBlockContents(pt, ((ContainerBlock)block).getItems()); }
if (block instanceof MobSpawnerBlock) {
// Mob spawners // Mob spawners
} else if (block instanceof MobSpawnerBlock) {
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
if (!(state instanceof CreatureSpawner)) return false; if (!(state instanceof CreatureSpawner)) return false;
CreatureSpawner bukkit = (CreatureSpawner)state; CreatureSpawner bukkit = (CreatureSpawner) state;
MobSpawnerBlock we = (MobSpawnerBlock)block; MobSpawnerBlock we = (MobSpawnerBlock) block;
bukkit.setCreatureTypeId(we.getMobType()); bukkit.setCreatureTypeId(we.getMobType());
bukkit.setDelay(we.getDelay()); bukkit.setDelay(we.getDelay());
return true; return true;
}
if (block instanceof NoteBlock) {
// Note block // Note block
} else if (block instanceof NoteBlock) {
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
if (!(state instanceof org.bukkit.block.NoteBlock)) return false; if (!(state instanceof org.bukkit.block.NoteBlock)) return false;
org.bukkit.block.NoteBlock bukkit = (org.bukkit.block.NoteBlock)state; org.bukkit.block.NoteBlock bukkit = (org.bukkit.block.NoteBlock) state;
NoteBlock we = (NoteBlock)block; NoteBlock we = (NoteBlock) block;
bukkit.setRawNote(we.getNote()); bukkit.setRawNote(we.getNote());
return true; return true;
} }
@ -330,13 +334,14 @@ public class BukkitWorld extends LocalWorld {
*/ */
@Override @Override
public boolean copyFromWorld(Vector pt, BaseBlock block) { public boolean copyFromWorld(Vector pt, BaseBlock block) {
// Signs
if (block instanceof SignBlock) { if (block instanceof SignBlock) {
// Signs
((SignBlock) block).setText(getSignText(pt)); ((SignBlock) block).setText(getSignText(pt));
return true; return true;
}
if (block instanceof FurnaceBlock) {
// Furnaces // Furnaces
} else if (block instanceof FurnaceBlock) {
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
@ -347,14 +352,16 @@ public class BukkitWorld extends LocalWorld {
we.setCookTime(bukkit.getCookTime()); we.setCookTime(bukkit.getCookTime());
((ContainerBlock) block).setItems(getContainerBlockContents(pt)); ((ContainerBlock) block).setItems(getContainerBlockContents(pt));
return true; return true;
}
if (block instanceof ContainerBlock) {
// Chests/dispenser // Chests/dispenser
} else if (block instanceof ContainerBlock) {
((ContainerBlock) block).setItems(getContainerBlockContents(pt)); ((ContainerBlock) block).setItems(getContainerBlockContents(pt));
return true; return true;
}
if (block instanceof MobSpawnerBlock) {
// Mob spawners // Mob spawners
} else if (block instanceof MobSpawnerBlock) {
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
@ -364,14 +371,15 @@ public class BukkitWorld extends LocalWorld {
we.setMobType(bukkit.getCreatureTypeId()); we.setMobType(bukkit.getCreatureTypeId());
we.setDelay((short) bukkit.getDelay()); we.setDelay((short) bukkit.getDelay());
return true; return true;
}
if (block instanceof NoteBlock) {
// Note block // Note block
} else if (block instanceof NoteBlock) {
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (bukkitBlock == null) return false; if (bukkitBlock == null) return false;
BlockState state = bukkitBlock.getState(); BlockState state = bukkitBlock.getState();
if (!(state instanceof org.bukkit.block.NoteBlock)) return false; if (!(state instanceof org.bukkit.block.NoteBlock)) return false;
org.bukkit.block.NoteBlock bukkit = (org.bukkit.block.NoteBlock)state; org.bukkit.block.NoteBlock bukkit = (org.bukkit.block.NoteBlock) state;
NoteBlock we = (NoteBlock) block; NoteBlock we = (NoteBlock) block;
we.setNote(bukkit.getRawNote()); we.setNote(bukkit.getRawNote());
} }
@ -395,7 +403,7 @@ public class BukkitWorld extends LocalWorld {
return false; return false;
} }
org.bukkit.block.ContainerBlock chest = (org.bukkit.block.ContainerBlock)state; org.bukkit.block.ContainerBlock chest = (org.bukkit.block.ContainerBlock) state;
Inventory inven = chest.getInventory(); Inventory inven = chest.getInventory();
inven.clear(); inven.clear();
return true; return true;
@ -534,41 +542,55 @@ public class BukkitWorld extends LocalWorld {
continue; continue;
} }
if (type == EntityType.ARROWS) { switch (type) {
case ARROWS:
if (ent instanceof Arrow) { if (ent instanceof Arrow) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.BOATS) { break;
case BOATS:
if (ent instanceof Boat) { if (ent instanceof Boat) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.ITEMS) { break;
case ITEMS:
if (ent instanceof Item) { if (ent instanceof Item) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.MINECARTS) { break;
case MINECARTS:
if (ent instanceof Minecart) { if (ent instanceof Minecart) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.PAINTINGS) { break;
case PAINTINGS:
if (ent instanceof Painting) { if (ent instanceof Painting) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.TNT) { break;
case TNT:
if (ent instanceof TNTPrimed) { if (ent instanceof TNTPrimed) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.XP_ORBS) { break;
case XP_ORBS:
if (ent instanceof ExperienceOrb) { if (ent instanceof ExperienceOrb) {
ent.remove(); ent.remove();
++num; ++num;
} }
break;
} }
} }
@ -675,7 +697,7 @@ public class BukkitWorld extends LocalWorld {
return false; return false;
} }
org.bukkit.block.ContainerBlock chest = (org.bukkit.block.ContainerBlock)state; org.bukkit.block.ContainerBlock chest = (org.bukkit.block.ContainerBlock) state;
Inventory inven = chest.getInventory(); Inventory inven = chest.getInventory();
int size = inven.getSize(); int size = inven.getSize();
@ -761,7 +783,7 @@ public class BukkitWorld extends LocalWorld {
final Object notchChunk = World_getChunkFromChunkCoords.invoke(notchWorld, chunkX, chunkZ); final Object notchChunk = World_getChunkFromChunkCoords.invoke(notchWorld, chunkX, chunkZ);
// Fix skylight // Fix skylight
final byte[] blocks = (byte[])Chunk_blocks.get(notchChunk); final byte[] blocks = (byte[]) Chunk_blocks.get(notchChunk);
final int length = blocks.length; final int length = blocks.length;
Chunk_skylightMap.set(notchChunk, NibbleArray_ctor.newInstance(length, 7)); Chunk_skylightMap.set(notchChunk, NibbleArray_ctor.newInstance(length, 7));

Datei anzeigen

@ -115,9 +115,11 @@ public class WorldEditPlayerListener extends PlayerListener {
} }
if (!ignoreLeftClickAir) { if (!ignoreLeftClickAir) {
final int taskId = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { public void run() { final int taskId = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
ignoreLeftClickAir = false; ignoreLeftClickAir = false;
}}, 2); }
}, 2);
if (taskId != -1) { if (taskId != -1) {
ignoreLeftClickAir = true; ignoreLeftClickAir = true;

Datei anzeigen

@ -207,13 +207,15 @@ public class WorldEditPlugin extends JavaPlugin {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
try { try {
if (input != null) if (input != null) {
input.close(); input.close();
}
} catch (IOException e) {} } catch (IOException e) {}
try { try {
if (output != null) if (output != null) {
output.close(); output.close();
}
} catch (IOException e) {} } catch (IOException e) {}
} }
} }
@ -232,7 +234,7 @@ public class WorldEditPlugin extends JavaPlugin {
return true; return true;
} }
Player player = (Player)sender; Player player = (Player) sender;
// Add the command to the array because the underlying command handling // Add the command to the array because the underlying command handling
// code of WorldEdit expects it // code of WorldEdit expects it
@ -267,8 +269,7 @@ public class WorldEditPlugin extends JavaPlugin {
BlockBag blockBag = session.getBlockBag(wePlayer); BlockBag blockBag = session.getBlockBag(wePlayer);
EditSession editSession = EditSession editSession =
new EditSession(wePlayer.getWorld(), new EditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag);
session.getBlockChangeLimit(), blockBag);
editSession.enableQueue(); editSession.enableQueue();
return editSession; return editSession;
@ -388,9 +389,9 @@ public class WorldEditPlugin extends JavaPlugin {
World world = ((BukkitWorld) session.getSelectionWorld()).getWorld(); World world = ((BukkitWorld) session.getSelectionWorld()).getWorld();
if (region instanceof CuboidRegion) { if (region instanceof CuboidRegion) {
return new CuboidSelection(world, selector, (CuboidRegion)region); return new CuboidSelection(world, selector, (CuboidRegion) region);
} else if (region instanceof Polygonal2DRegion) { } else if (region instanceof Polygonal2DRegion) {
return new Polygonal2DSelection(world, selector, (Polygonal2DRegion)region); return new Polygonal2DSelection(world, selector, (Polygonal2DRegion) region);
} else { } else {
return null; return null;
} }

Datei anzeigen

@ -129,7 +129,9 @@ public class ChunkCommands {
player.printError("Error occurred: " + e.getMessage()); player.printError("Error occurred: " + e.getMessage());
} finally { } finally {
if (out != null) { if (out != null) {
try { out.close(); } catch (IOException ie) {} try {
out.close();
} catch (IOException ie) { }
} }
} }
} else if (config.shellSaveType.equalsIgnoreCase("bash")) { } else if (config.shellSaveType.equalsIgnoreCase("bash")) {

Datei anzeigen

@ -189,7 +189,7 @@ public class ClipboardCommands {
String filename = args.getString(0); String filename = args.getString(0);
File dir = we.getWorkingDirectoryFile(config.saveDir); File dir = we.getWorkingDirectoryFile(config.saveDir);
File f = we.getSafeOpenFile(player, dir, filename, "schematic", File f = we.getSafeOpenFile(player, dir, filename, "schematic",
new String[] {"schematic"}); new String[] { "schematic" });
try { try {
String filePath = f.getCanonicalPath(); String filePath = f.getCanonicalPath();
@ -227,7 +227,7 @@ public class ClipboardCommands {
File dir = we.getWorkingDirectoryFile(config.saveDir); File dir = we.getWorkingDirectoryFile(config.saveDir);
File f = we.getSafeSaveFile(player, dir, filename, "schematic", File f = we.getSafeSaveFile(player, dir, filename, "schematic",
new String[] {"schematic"}); new String[] { "schematic" });
if (!dir.exists()) { if (!dir.exists()) {
if (!dir.mkdir()) { if (!dir.mkdir()) {

Datei anzeigen

@ -50,7 +50,7 @@ public class HistoryCommands {
} else { } else {
player.checkPermission("worldedit.history.undo.other"); player.checkPermission("worldedit.history.undo.other");
LocalSession sess = we.getSession(args.getString(1)); LocalSession sess = we.getSession(args.getString(1));
if (sess == null){ if (sess == null) {
player.printError("Unable to find session for " + args.getString(1)); player.printError("Unable to find session for " + args.getString(1));
break; break;
} }
@ -87,7 +87,7 @@ public class HistoryCommands {
} else { } else {
player.checkPermission("worldedit.history.redo.other"); player.checkPermission("worldedit.history.redo.other");
LocalSession sess = we.getSession(args.getString(1)); LocalSession sess = we.getSession(args.getString(1));
if (sess == null){ if (sess == null) {
player.printError("Unable to find session for " + args.getString(1)); player.printError("Unable to find session for " + args.getString(1));
break; break;
} }

Datei anzeigen

@ -74,7 +74,6 @@ public class NavigationCommands {
} else { } else {
player.print((ascentLevels != 1) ? "Ascended " + Integer.toString(ascentLevels) + " levels." : "Ascended a level."); player.print((ascentLevels != 1) ? "Ascended " + Integer.toString(ascentLevels) + " levels." : "Ascended a level.");
} }
} }
@Command( @Command(
@ -103,7 +102,6 @@ public class NavigationCommands {
} else { } else {
player.print((descentLevels != 1) ? "Descended " + Integer.toString(descentLevels) + " levels." : "Descended a level."); player.print((descentLevels != 1) ? "Descended " + Integer.toString(descentLevels) + " levels." : "Descended a level.");
} }
} }
@Command( @Command(

Datei anzeigen

@ -19,7 +19,6 @@
package com.sk89q.worldedit.commands; package com.sk89q.worldedit.commands;
import java.util.Set; import java.util.Set;
import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandContext;
@ -268,7 +267,6 @@ public class RegionCommands {
player.print(affected + " blocks moved."); player.print(affected + " blocks moved.");
} }
@Command( @Command(
aliases = { "/stack" }, aliases = { "/stack" },
usage = "[count] [direction]", usage = "[count] [direction]",

Datei anzeigen

@ -58,7 +58,7 @@ public class ScriptingCommands {
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir); File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
File f = we.getSafeOpenFile(player, dir, name, "js", File f = we.getSafeOpenFile(player, dir, name, "js",
new String[] {"js"}); new String[] { "js" });
we.runScript(player, f, scriptArgs); we.runScript(player, f, scriptArgs);
} }
@ -92,7 +92,7 @@ public class ScriptingCommands {
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir); File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
File f = we.getSafeOpenFile(player, dir, lastScript, "js", File f = we.getSafeOpenFile(player, dir, lastScript, "js",
new String[] {"js"}); new String[] { "js" });
we.runScript(player, f, scriptArgs); we.runScript(player, f, scriptArgs);
} }

Datei anzeigen

@ -87,8 +87,8 @@ public class SelectionCommands {
throws WorldEditException { throws WorldEditException {
Vector pos; Vector pos;
if(args.argsLength() == 1) { if (args.argsLength() == 1) {
if(args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) { if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
String[] coords = args.getString(0).split(","); String[] coords = args.getString(0).split(",");
pos = new Vector(Integer.parseInt(coords[0]), pos = new Vector(Integer.parseInt(coords[0]),
Integer.parseInt(coords[1]), Integer.parseInt(coords[1]),
@ -106,7 +106,6 @@ public class SelectionCommands {
return; return;
} }
session.getRegionSelector(player.getWorld()) session.getRegionSelector(player.getWorld())
.explainSecondarySelection(player, session, pos); .explainSecondarySelection(player, session, pos);
} }
@ -566,7 +565,7 @@ public class SelectionCommands {
BlockType block = BlockType.fromID(c.getID()); BlockType block = BlockType.fromID(c.getID());
String str = String.format("%-7s (%.3f%%) %s #%d", String str = String.format("%-7s (%.3f%%) %s #%d",
String.valueOf(c.getAmount()), String.valueOf(c.getAmount()),
c.getAmount() / (double)size * 100, c.getAmount() / (double) size * 100,
block == null ? "Unknown" : block.getName(), c.getID()); block == null ? "Unknown" : block.getName(), c.getID());
player.print(str); player.print(str);

Datei anzeigen

@ -19,7 +19,6 @@
package com.sk89q.worldedit.commands; package com.sk89q.worldedit.commands;
import java.util.Set; import java.util.Set;
import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandContext;

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -80,14 +80,14 @@ public abstract class McRegionChunkStore extends ChunkStore {
+ tag.getClass().getName()); + tag.getClass().getName());
} }
Map<String,Tag> children = (Map<String,Tag>)((CompoundTag)tag).getValue(); Map<String, Tag> children = (Map<String, Tag>) ((CompoundTag) tag).getValue();
CompoundTag rootTag = null; CompoundTag rootTag = null;
// Find Level tag // Find Level tag
for (Map.Entry<String,Tag> entry : children.entrySet()) { for (Map.Entry<String, Tag> entry : children.entrySet()) {
if (entry.getKey().equals("Level")) { if (entry.getKey().equals("Level")) {
if (entry.getValue() instanceof CompoundTag) { if (entry.getValue() instanceof CompoundTag) {
rootTag = (CompoundTag)entry.getValue(); rootTag = (CompoundTag) entry.getValue();
break; break;
} else { } else {
throw new ChunkStoreException("CompoundTag expected for 'Level'; got " throw new ChunkStoreException("CompoundTag expected for 'Level'; got "
@ -116,7 +116,6 @@ public abstract class McRegionChunkStore extends ChunkStore {
protected abstract InputStream getInputStream(String name, String worldname) protected abstract InputStream getInputStream(String name, String worldname)
throws IOException, DataException; throws IOException, DataException;
/** /**
* Close resources. * Close resources.
* *

Datei anzeigen

@ -112,10 +112,9 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore {
// So not there either... // So not there either...
if (testEntry == null) { if (testEntry == null) {
for (Enumeration<? extends ZipEntry> e = zip.entries(); for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements();) {
e.hasMoreElements(); ) {
testEntry = (ZipEntry)e.nextElement(); testEntry = (ZipEntry) e.nextElement();
// Whoo, found level.dat! // Whoo, found level.dat!
if (pattern.matcher(testEntry.getName()).matches()) { if (pattern.matcher(testEntry.getName()).matches()) {

Datei anzeigen

@ -100,8 +100,7 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
Pattern pattern = Pattern.compile(".*\\.mcr$"); Pattern pattern = Pattern.compile(".*\\.mcr$");
// World pattern // World pattern
Pattern worldPattern = Pattern.compile(worldname + "\\$"); Pattern worldPattern = Pattern.compile(worldname + "\\$");
for (Enumeration<? extends ZipEntry> e = zip.entries(); for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
e.hasMoreElements();) {
ZipEntry testEntry = (ZipEntry) e.nextElement(); ZipEntry testEntry = (ZipEntry) e.nextElement();
// Check for world // Check for world
if (worldPattern.matcher(worldname).matches()) { if (worldPattern.matcher(worldname).matches()) {
@ -158,8 +157,7 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean isValid() { public boolean isValid() {
for (Enumeration<? extends ZipEntry> e = zip.entries(); for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
e.hasMoreElements();) {
ZipEntry testEntry = e.nextElement(); ZipEntry testEntry = e.nextElement();

Datei anzeigen

@ -109,10 +109,9 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore {
// So not there either... // So not there either...
if (testEntry == null) { if (testEntry == null) {
for (Enumeration<? extends ZipEntry> e = zip.entries(); for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
e.hasMoreElements(); ) {
testEntry = (ZipEntry)e.nextElement(); testEntry = (ZipEntry) e.nextElement();
// Whoo, found level.dat! // Whoo, found level.dat!
if (pattern.matcher(testEntry.getName()).matches()) { if (pattern.matcher(testEntry.getName()).matches()) {

Datei anzeigen

@ -95,8 +95,7 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
} }
} else { } else {
Pattern pattern = Pattern.compile(".*\\.mcr$"); Pattern pattern = Pattern.compile(".*\\.mcr$");
for (Enumeration<? extends ZipEntry> e = zip.entries(); for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
e.hasMoreElements();) {
ZipEntry testEntry = (ZipEntry) e.nextElement(); ZipEntry testEntry = (ZipEntry) e.nextElement();
// Check for world // Check for world
if (testEntry.getName().startsWith(worldname + "/")) { if (testEntry.getName().startsWith(worldname + "/")) {
@ -152,8 +151,7 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
@Override @Override
public boolean isValid() { public boolean isValid() {
for (Enumeration<? extends ZipEntry> e = zip.entries(); for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
e.hasMoreElements();) {
ZipEntry testEntry = e.nextElement(); ZipEntry testEntry = e.nextElement();

Datei anzeigen

@ -100,8 +100,7 @@ public class Expression {
try { try {
return root.getValue(); return root.getValue();
} } catch (ReturnException e) {
catch (ReturnException e) {
return e.getValue(); return e.getValue();
} }
} }

Datei anzeigen

@ -182,8 +182,7 @@ public class Parser {
if (peek().id() == ';') { if (peek().id() == ';') {
++position; ++position;
break; break;
} } else {
else {
break loop; break loop;
} }
@ -205,8 +204,7 @@ public class Parser {
break loop; break loop;
} }
break; break;
} } else {
else {
break loop; break loop;
} }
} }
@ -253,7 +251,7 @@ public class Parser {
} else { } else {
RValue variable = variables.get(identifierToken.value); RValue variable = variables.get(identifierToken.value);
if (variable == null) { if (variable == null) {
if (next instanceof OperatorToken && ((OperatorToken)next).operator.equals("=")) { if (next instanceof OperatorToken && ((OperatorToken) next).operator.equals("=")) {
// Ugly hack to make temporary variables work while not sacrificing error reporting. // Ugly hack to make temporary variables work while not sacrificing error reporting.
variables.put(identifierToken.value, variable = new Variable(0)); variables.put(identifierToken.value, variable = new Variable(0));
} else { } else {

Datei anzeigen

@ -230,19 +230,17 @@ public final class ParserProcessors {
final Identifiable last = input.removeLast(); final Identifiable last = input.removeLast();
if (last instanceof OperatorToken) { if (last instanceof OperatorToken) {
postfixes.addLast(new UnaryOperator(last.getPosition(), "x"+((OperatorToken)last).operator)); postfixes.addLast(new UnaryOperator(last.getPosition(), "x" + ((OperatorToken) last).operator));
} } else if (last instanceof UnaryOperator) {
else if (last instanceof UnaryOperator) { postfixes.addLast(new UnaryOperator(last.getPosition(), "x" + ((UnaryOperator) last).operator));
postfixes.addLast(new UnaryOperator(last.getPosition(), "x"+((UnaryOperator)last).operator)); } else {
}
else {
center = last; center = last;
break; break;
} }
} while (true); } while (true);
if (!(center instanceof RValue)) { if (!(center instanceof RValue)) {
throw new ParserException(center.getPosition(), "Expected expression, found "+center); throw new ParserException(center.getPosition(), "Expected expression, found " + center);
} }
input.addAll(postfixes); input.addAll(postfixes);

Datei anzeigen

@ -17,8 +17,7 @@ public class Conditional extends Node {
public double getValue() throws EvaluationException { public double getValue() throws EvaluationException {
if (condition.getValue() > 0.0) { if (condition.getValue() > 0.0) {
return truePart.getValue(); return truePart.getValue();
} } else {
else {
return falsePart == null ? 0 : falsePart.getValue(); return falsePart == null ? 0 : falsePart.getValue();
} }
} }
@ -31,9 +30,9 @@ public class Conditional extends Node {
@Override @Override
public String toString() { public String toString() {
if (falsePart == null) { if (falsePart == null) {
return "if ("+condition+") { "+truePart+" }"; return "if (" + condition + ") { " + truePart + " }";
} else { } else {
return "if ("+condition+") { "+truePart+" } else { "+falsePart+" }"; return "if (" + condition + ") { " + truePart + " } else { " + falsePart + " }";
} }
} }

Datei anzeigen

@ -28,8 +28,7 @@ public class For extends Node {
try { try {
ret = body.getValue(); ret = body.getValue();
} } catch (BreakException e) {
catch (BreakException e) {
if (e.doContinue) { if (e.doContinue) {
continue; continue;
} else { } else {
@ -48,7 +47,7 @@ public class For extends Node {
@Override @Override
public String toString() { public String toString() {
return "for ("+init+"; "+condition+"; "+increment+") { "+body+" }"; return "for (" + init + "; " + condition + "; " + increment + ") { " + body + " }";
} }
//TODO: optimizer //TODO: optimizer

Datei anzeigen

@ -90,14 +90,12 @@ public final class Functions {
} }
} }
public static final Function getFunction(int position, String name, RValue... args) throws NoSuchMethodException { public static final Function getFunction(int position, String name, RValue... args) throws NoSuchMethodException {
final Method getter = getMethod(name, false, args); final Method getter = getMethod(name, false, args);
try { try {
Method setter = getMethod(name, true, args); Method setter = getMethod(name, true, args);
return new LValueFunction(position, getter, setter, args); return new LValueFunction(position, getter, setter, args);
} } catch (NoSuchMethodException e) {
catch (NoSuchMethodException e) {
return new Function(position, getter, args); return new Function(position, getter, args);
} }
} }

Datei anzeigen

@ -28,5 +28,6 @@ import com.sk89q.worldedit.expression.Identifiable;
*/ */
public interface RValue extends Identifiable { public interface RValue extends Identifiable {
public double getValue() throws EvaluationException; public double getValue() throws EvaluationException;
public Node optimize() throws EvaluationException; public Node optimize() throws EvaluationException;
} }

Datei anzeigen

@ -21,7 +21,7 @@ public class Return extends Node {
@Override @Override
public String toString() { public String toString() {
return "return "+value; return "return " + value;
} }
//TODO: optimizer //TODO: optimizer

Datei anzeigen

@ -27,8 +27,7 @@ public class While extends Node {
try { try {
ret = body.getValue(); ret = body.getValue();
} } catch (BreakException e) {
catch (BreakException e) {
if (e.doContinue) { if (e.doContinue) {
continue; continue;
} else { } else {
@ -45,8 +44,7 @@ public class While extends Node {
try { try {
ret = body.getValue(); ret = body.getValue();
} } catch (BreakException e) {
catch (BreakException e) {
if (e.doContinue) { if (e.doContinue) {
continue; continue;
} else { } else {
@ -67,9 +65,9 @@ public class While extends Node {
@Override @Override
public String toString() { public String toString() {
if (footChecked) { if (footChecked) {
return "do { "+body+" } while ("+condition+")"; return "do { " + body + " } while (" + condition + ")";
} else { } else {
return "while ("+condition+") { "+body+" }"; return "while (" + condition + ") { " + body + " }";
} }
} }

Datei anzeigen

@ -42,13 +42,13 @@ public class GaussianKernel extends Kernel {
private static float[] createKernel(int radius, double sigma) { private static float[] createKernel(int radius, double sigma) {
int diameter = radius * 2 + 1; int diameter = radius * 2 + 1;
float[] data = new float[diameter*diameter]; float[] data = new float[diameter * diameter];
double sigma22 = 2 * sigma * sigma; double sigma22 = 2 * sigma * sigma;
double constant = Math.PI * sigma22; double constant = Math.PI * sigma22;
for (int y = -radius; y <= radius; ++y) { for (int y = -radius; y <= radius; ++y) {
for (int x = -radius; x <= radius; ++x) { for (int x = -radius; x <= radius; ++x) {
data[(y+radius) * diameter + x+radius] = (float) (Math.exp(-(x * x + y * y) / sigma22) / constant); data[(y + radius) * diameter + x + radius] = (float) (Math.exp(-(x * x + y * y) / sigma22) / constant);
} }
} }

Datei anzeigen

@ -75,7 +75,7 @@ public class HeightMapFilter {
* @param height * @param height
* @return the modified heightmap * @return the modified heightmap
*/ */
public int[] filter(int[] inData, int width, int height ) { public int[] filter(int[] inData, int width, int height) {
int index = 0; int index = 0;
float[] matrix = kernel.getKernelData(null); float[] matrix = kernel.getKernelData(null);
int[] outData = new int[inData.length]; int[] outData = new int[inData.length];
@ -92,8 +92,9 @@ public class HeightMapFilter {
for (int ky = 0; ky < kh; ++ky) { for (int ky = 0; ky < kh; ++ky) {
int offsetY = y + ky - koy; int offsetY = y + ky - koy;
// Clamp coordinates inside data // Clamp coordinates inside data
if (offsetY < 0 || offsetY >= height) if (offsetY < 0 || offsetY >= height) {
offsetY = y; offsetY = y;
}
offsetY *= width; offsetY *= width;
@ -104,8 +105,9 @@ public class HeightMapFilter {
int offsetX = x + kx - kox; int offsetX = x + kx - kox;
// Clamp coordinates inside data // Clamp coordinates inside data
if (offsetX < 0 || offsetX >= width) if (offsetX < 0 || offsetX >= width) {
offsetX = x; offsetX = x;
}
z += f * inData[offsetY + offsetX]; z += f * inData[offsetY + offsetX];
} }

Datei anzeigen

@ -35,9 +35,9 @@ public class LinearKernel extends Kernel {
private static float[] createKernel(int radius) { private static float[] createKernel(int radius) {
int diameter = radius * 2 + 1; int diameter = radius * 2 + 1;
float[] data = new float[diameter*diameter]; float[] data = new float[diameter * diameter];
for (int i = 0; i < data.length; data[i++] = 1.0f/data.length) ; for (int i = 0; i < data.length; data[i++] = 1.0f / data.length) ;
return data; return data;
} }

Datei anzeigen

@ -40,7 +40,7 @@ public class UnderOverlayMask implements Mask {
this.overlay = overlay; this.overlay = overlay;
} }
public void addAll(Set<Integer> ids){ public void addAll(Set<Integer> ids) {
this.ids.addAll(ids); this.ids.addAll(ids);
} }
@ -50,4 +50,3 @@ public class UnderOverlayMask implements Mask {
} }
} }

Datei anzeigen

@ -97,7 +97,7 @@ public class CuboidRegion implements Region {
Vector min = getMinimumPoint(); Vector min = getMinimumPoint();
Vector max = getMaximumPoint(); Vector max = getMaximumPoint();
return (int)(max.getX() - min.getX() + 1); return (int) (max.getX() - min.getX() + 1);
} }
/** /**
@ -109,7 +109,7 @@ public class CuboidRegion implements Region {
Vector min = getMinimumPoint(); Vector min = getMinimumPoint();
Vector max = getMaximumPoint(); Vector max = getMaximumPoint();
return (int)(max.getY() - min.getY() + 1); return (int) (max.getY() - min.getY() + 1);
} }
/** /**
@ -121,7 +121,7 @@ public class CuboidRegion implements Region {
Vector min = getMinimumPoint(); Vector min = getMinimumPoint();
Vector max = getMaximumPoint(); Vector max = getMaximumPoint();
return (int)(max.getZ() - min.getZ() + 1); return (int) (max.getZ() - min.getZ() + 1);
} }
/** /**

Datei anzeigen

@ -198,7 +198,7 @@ public class Polygonal2DRegion implements Region {
j = i; j = i;
} }
return (int)Math.floor(Math.abs(area * 0.5) return (int) Math.floor(Math.abs(area * 0.5)
* (maxY - minY + 1)); * (maxY - minY + 1));
} }

Datei anzeigen

@ -35,36 +35,42 @@ public interface Region extends Iterable<BlockVector> {
* @return min. point * @return min. point
*/ */
public Vector getMinimumPoint(); public Vector getMinimumPoint();
/** /**
* Get the upper point of a region. * Get the upper point of a region.
* *
* @return max. point * @return max. point
*/ */
public Vector getMaximumPoint(); public Vector getMaximumPoint();
/** /**
* Get the number of blocks in the region. * Get the number of blocks in the region.
* *
* @return number of blocks * @return number of blocks
*/ */
public int getArea(); public int getArea();
/** /**
* Get X-size. * Get X-size.
* *
* @return width * @return width
*/ */
public int getWidth(); public int getWidth();
/** /**
* Get Y-size. * Get Y-size.
* *
* @return height * @return height
*/ */
public int getHeight(); public int getHeight();
/** /**
* Get Z-size. * Get Z-size.
* *
* @return length * @return length
*/ */
public int getLength(); public int getLength();
/** /**
* Expand the region. * Expand the region.
* *
@ -72,6 +78,7 @@ public interface Region extends Iterable<BlockVector> {
* @throws RegionOperationException * @throws RegionOperationException
*/ */
public void expand(Vector change) throws RegionOperationException; public void expand(Vector change) throws RegionOperationException;
/** /**
* Contract the region. * Contract the region.
* *
@ -79,6 +86,7 @@ public interface Region extends Iterable<BlockVector> {
* @throws RegionOperationException * @throws RegionOperationException
*/ */
public void contract(Vector change) throws RegionOperationException; public void contract(Vector change) throws RegionOperationException;
/** /**
* Returns true based on whether the region contains the point, * Returns true based on whether the region contains the point,
* *
@ -86,6 +94,7 @@ public interface Region extends Iterable<BlockVector> {
* @return * @return
*/ */
public boolean contains(Vector pt); public boolean contains(Vector pt);
/** /**
* Get a list of chunks. * Get a list of chunks.
* *

Datei anzeigen

@ -24,7 +24,9 @@ import javax.script.ScriptException;
public interface CraftScriptEngine { public interface CraftScriptEngine {
public void setTimeLimit(int milliseconds); public void setTimeLimit(int milliseconds);
public int getTimeLimit(); public int getTimeLimit();
public Object evaluate(String script, String filename, Map<String, Object> args) public Object evaluate(String script, String filename, Map<String, Object> args)
throws ScriptException, Throwable; throws ScriptException, Throwable;
} }

Datei anzeigen

@ -37,7 +37,7 @@ public class RhinoContextFactory extends ContextFactory {
@Override @Override
protected void observeInstructionCount(Context cx, int instructionCount) { protected void observeInstructionCount(Context cx, int instructionCount) {
RhinoContext mcx = (RhinoContext)cx; RhinoContext mcx = (RhinoContext) cx;
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
if (currentTime - mcx.startTime > timeLimit) { if (currentTime - mcx.startTime > timeLimit) {
@ -48,7 +48,7 @@ public class RhinoContextFactory extends ContextFactory {
@Override @Override
protected Object doTopCall(Callable callable, Context cx, Scriptable scope, protected Object doTopCall(Callable callable, Context cx, Scriptable scope,
Scriptable thisObj, Object[] args) { Scriptable thisObj, Object[] args) {
RhinoContext mcx = (RhinoContext)cx; RhinoContext mcx = (RhinoContext) cx;
mcx.startTime = System.currentTimeMillis(); mcx.startTime = System.currentTimeMillis();
return super.doTopCall(callable, cx, scope, thisObj, args); return super.doTopCall(callable, cx, scope, thisObj, args);

Datei anzeigen

@ -72,7 +72,7 @@ public class RhinoScriptEngineFactory implements ScriptEngineFactory {
return "1.8"; return "1.8";
} }
public String getMethodCallSyntax(String obj, String m, String ... args) { public String getMethodCallSyntax(String obj, String m, String... args) {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
s.append(obj); s.append(obj);
s.append("."); s.append(".");
@ -123,7 +123,7 @@ public class RhinoScriptEngineFactory implements ScriptEngineFactory {
} }
} }
public String getProgram(String ... statements) { public String getProgram(String... statements) {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
for (String stmt : statements) { for (String stmt : statements) {
s.append(stmt); s.append(stmt);

Datei anzeigen

@ -1,4 +1,3 @@
package com.sk89q.worldedit.snapshots;
// $Id$ // $Id$
/* /*
* WorldEdit * WorldEdit
@ -18,6 +17,8 @@ package com.sk89q.worldedit.snapshots;
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldedit.snapshots;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
import com.sk89q.worldedit.regions.*; import com.sk89q.worldedit.regions.*;
import com.sk89q.worldedit.blocks.*; import com.sk89q.worldedit.blocks.*;
@ -36,8 +37,8 @@ public class SnapshotRestore {
/** /**
* Store a list of chunks that are needed and the points in them. * Store a list of chunks that are needed and the points in them.
*/ */
private Map<BlockVector2D,ArrayList<Vector>> neededChunks = private Map<BlockVector2D, ArrayList<Vector>> neededChunks =
new LinkedHashMap<BlockVector2D,ArrayList<Vector>>(); new LinkedHashMap<BlockVector2D, ArrayList<Vector>>();
/** /**
* Chunk store. * Chunk store.
*/ */
@ -141,8 +142,7 @@ public class SnapshotRestore {
errorChunks = new ArrayList<Vector2D>(); errorChunks = new ArrayList<Vector2D>();
// Now let's start restoring! // Now let's start restoring!
for (Map.Entry<BlockVector2D,ArrayList<Vector>> entry : for (Map.Entry<BlockVector2D, ArrayList<Vector>> entry : neededChunks.entrySet()) {
neededChunks.entrySet()) {
BlockVector2D chunkPos = entry.getKey(); BlockVector2D chunkPos = entry.getKey();
Chunk chunk; Chunk chunk;

Datei anzeigen

@ -113,7 +113,7 @@ public class FloatingTreeRemover implements BlockTool {
visited.add(pos); visited.add(pos);
int block = editSession.getBlock(pos).getType(); int block = editSession.getBlock(pos).getType();
if (block == BlockID.AIR || block == BlockID.SNOW){ if (block == BlockID.AIR || block == BlockID.SNOW) {
return true; return true;
} }
if (block != BlockID.LOG if (block != BlockID.LOG

Datei anzeigen

@ -48,10 +48,10 @@ public class QueryTool implements BlockTool {
if (block instanceof MobSpawnerBlock) { if (block instanceof MobSpawnerBlock) {
player.printRaw("\u00A7e" + "Mob Type: " player.printRaw("\u00A7e" + "Mob Type: "
+ ((MobSpawnerBlock)block).getMobType()); + ((MobSpawnerBlock) block).getMobType());
} else if (block instanceof NoteBlock) { } else if (block instanceof NoteBlock) {
player.printRaw("\u00A7e" + "Note block: " player.printRaw("\u00A7e" + "Note block: "
+ ((NoteBlock)block).getNote()); + ((NoteBlock) block).getNote());
} else if (block.getType() == BlockID.CLOTH) { } else if (block.getType() == BlockID.CLOTH) {
// Should never be null // Should never be null
player.printRaw("\u00A7e" + "Color: " player.printRaw("\u00A7e" + "Color: "

Datei anzeigen

@ -113,7 +113,7 @@ public class TargetBlock {
BlockWorldVector lastBlock = null; BlockWorldVector lastBlock = null;
while (getNextBlock() != null) { while (getNextBlock() != null) {
if (world.getBlockType(getCurrentBlock()) == BlockID.AIR) { if (world.getBlockType(getCurrentBlock()) == BlockID.AIR) {
if(searchForLastBlock) { if (searchForLastBlock) {
lastBlock = getCurrentBlock(); lastBlock = getCurrentBlock();
if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= 127) { if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= 127) {
searchForLastBlock = false; searchForLastBlock = false;
@ -134,8 +134,7 @@ public class TargetBlock {
* @return Block * @return Block
*/ */
public BlockWorldVector getTargetBlock() { public BlockWorldVector getTargetBlock() {
while ((getNextBlock() != null) while (getNextBlock() != null && world.getBlockType(getCurrentBlock()) == 0) ;
&& (world.getBlockType(getCurrentBlock()) == 0));
return getCurrentBlock(); return getCurrentBlock();
} }
@ -146,8 +145,7 @@ public class TargetBlock {
* @return Block * @return Block
*/ */
public BlockWorldVector getSolidTargetBlock() { public BlockWorldVector getSolidTargetBlock() {
while ((getNextBlock() != null) while (getNextBlock() != null && BlockType.canPassThrough(world.getBlockType(getCurrentBlock()))) ;
&& BlockType.canPassThrough(world.getBlockType(getCurrentBlock())));
return getCurrentBlock(); return getCurrentBlock();
} }

Datei anzeigen

@ -37,19 +37,19 @@ import com.sk89q.worldedit.blocks.BlockID;
*/ */
public class TreeGenerator { public class TreeGenerator {
public enum TreeType { public enum TreeType {
TREE("Regular tree", new String[] {"tree", "regular"}), TREE("Regular tree", new String[] { "tree", "regular" }),
BIG_TREE("Big tree", new String[] {"big", "bigtree"}), BIG_TREE("Big tree", new String[] { "big", "bigtree" }),
REDWOOD("Redwood", new String[] {"redwood", "sequoia", "sequoioideae"}), REDWOOD("Redwood", new String[] { "redwood", "sequoia", "sequoioideae" }),
TALL_REDWOOD("Tall redwood", new String[] {"tallredwood", "tallsequoia", "tallsequoioideae"}), TALL_REDWOOD("Tall redwood", new String[] { "tallredwood", "tallsequoia", "tallsequoioideae" }),
BIRCH("Birch", new String[] {"birch", "white", "whitebark"}), BIRCH("Birch", new String[] { "birch", "white", "whitebark" }),
PINE("Pine", new String[] {"pine"}), PINE("Pine", new String[] { "pine" }),
RANDOM_REDWOOD("Random redwood", new String[] {"randredwood", "randomredwood", "anyredwood"}), RANDOM_REDWOOD("Random redwood", new String[] { "randredwood", "randomredwood", "anyredwood" }),
RANDOM("Random", new String[] {"rand", "random"}); RANDOM("Random", new String[] { "rand", "random" });
/** /**
* Stores a map of the names for fast access. * Stores a map of the names for fast access.
*/ */
private static final Map<String,TreeType> lookup = new HashMap<String,TreeType>(); private static final Map<String, TreeType> lookup = new HashMap<String, TreeType>();
private final String name; private final String name;
private final String[] lookupKeys; private final String[] lookupKeys;
@ -64,7 +64,7 @@ public class TreeGenerator {
TreeType(String name, String lookupKey) { TreeType(String name, String lookupKey) {
this.name = name; this.name = name;
this.lookupKeys = new String[]{ lookupKey }; this.lookupKeys = new String[] { lookupKey };
} }
TreeType(String name, String[] lookupKeys) { TreeType(String name, String[] lookupKeys) {

Datei anzeigen

@ -32,7 +32,7 @@ public class CommandContextTest {
CommandContext firstCommand; CommandContext firstCommand;
@Before @Before
public void setUpTest(){ public void setUpTest() {
try { try {
firstCommand = new CommandContext(firstCmdString, new HashSet<Character>(Arrays.asList('o', 'w'))); firstCommand = new CommandContext(firstCmdString, new HashSet<Character>(Arrays.asList('o', 'w')));
} catch (CommandException e) { } catch (CommandException e) {

Datei anzeigen

@ -35,7 +35,7 @@ public class BlockDataTest {
public void testRotateFlip() { public void testRotateFlip() {
for (int type = 0; type < 256; ++type) { for (int type = 0; type < 256; ++type) {
for (int data = 0; data < 16; ++data) { for (int data = 0; data < 16; ++data) {
final String message = type+"/"+data; final String message = type + "/" + data;
//Test r90(r-90(x))==x //Test r90(r-90(x))==x
assertEquals(message, data, BlockData.rotate90(type, BlockData.rotate90Reverse(type, data))); assertEquals(message, data, BlockData.rotate90(type, BlockData.rotate90Reverse(type, data)));
@ -75,11 +75,10 @@ public class BlockDataTest {
public void testCycle() { public void testCycle() {
// Test monotony // Test monotony
for (int type = 0; type < 256; ++type) { for (int type = 0; type < 256; ++type) {
if (type == BlockID.CLOTH) if (type == BlockID.CLOTH) continue;
continue;
for (int data = 0; data < 16; ++data) { for (int data = 0; data < 16; ++data) {
final String message = type+"/"+data; final String message = type + "/" + data;
final int cycled = BlockData.cycle(type, data, 1); final int cycled = BlockData.cycle(type, data, 1);
@ -87,7 +86,7 @@ public class BlockDataTest {
continue; continue;
} }
assertEquals(message, data+1, cycled); assertEquals(message, data + 1, cycled);
} }
} }
@ -104,14 +103,14 @@ public class BlockDataTest {
final TreeSet<Integer> datas = (TreeSet<Integer>) datasTemplate.clone(); final TreeSet<Integer> datas = (TreeSet<Integer>) datasTemplate.clone();
while (!datas.isEmpty()) { while (!datas.isEmpty()) {
final int start = datas.pollFirst(); final int start = datas.pollFirst();
String message = type+"/"+start; String message = type + "/" + start;
int current = start; int current = start;
boolean first = true; boolean first = true;
while (true) { while (true) {
current = BlockData.cycle(type, current, increment); current = BlockData.cycle(type, current, increment);
if (first && current == -1) break; if (first && current == -1) break;
first = false; first = false;
message += "->"+current; message += "->" + current;
assertTrue(message, current >= 0); assertTrue(message, current >= 0);
assertTrue(message, current < 16); assertTrue(message, current < 16);
if (current == start) break; if (current == start) break;

Datei anzeigen

@ -12,16 +12,16 @@ public class ExpressionTest {
@Test @Test
public void testEvaluate() throws ExpressionException { public void testEvaluate() throws ExpressionException {
// check // check
assertEquals(1-2+3, simpleEval("1-2+3"), 0); assertEquals(1 - 2 + 3, simpleEval("1 - 2 + 3"), 0);
// check unary ops // check unary ops
assertEquals(2+ +4, simpleEval("2+ +4"), 0); assertEquals(2 + +4, simpleEval("2 + +4"), 0);
assertEquals(2- -4, simpleEval("2- -4"), 0); assertEquals(2 - -4, simpleEval("2 - -4"), 0);
assertEquals(2*-4, simpleEval("2*-4"), 0); assertEquals(2 * -4, simpleEval("2 * -4"), 0);
// check functions // check functions
assertEquals(sin(5), simpleEval("sin(5)"), 0); assertEquals(sin(5), simpleEval("sin(5)"), 0);
assertEquals(atan2(3,4), simpleEval("atan2(3,4)"), 0); assertEquals(atan2(3, 4), simpleEval("atan2(3, 4)"), 0);
// check variables // check variables
assertEquals(8, Expression.compile("foo+bar", "foo", "bar").evaluate(5, 3), 0); assertEquals(8, Expression.compile("foo+bar", "foo", "bar").evaluate(5, 3), 0);