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[] {
"worldedit.reload",
"worldedit.selection",
"worlds.creative.worldedit.region"});
section.setProperty("permissions.groups.admins.permissions", new String[] {"*"});
section.setProperty("permissions.users.sk89q.permissions", new String[] {"worldedit"});
section.setProperty("permissions.users.sk89q.groups", new String[] {"admins"});
"worlds.creative.worldedit.region" });
section.setProperty("permissions.groups.admins.permissions", new String[] { "*" });
section.setProperty("permissions.users.sk89q.permissions", new String[] { "worldedit" });
section.setProperty("permissions.users.sk89q.groups", new String[] { "admins" });
return section;
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -36,6 +36,7 @@ import java.util.Map;
public class YAMLNode {
protected Map<String, Object> root;
private boolean writeDefaults;
public YAMLNode(Map<String, Object> root, boolean writeDefaults) {
this.root = root;
this.writeDefaults = writeDefaults;
@ -92,7 +93,7 @@ public class YAMLNode {
}
try {
node = (Map<String, Object>)o;
node = (Map<String, Object>) o;
} catch (ClassCastException e) {
return null;
}
@ -155,7 +156,7 @@ public class YAMLNode {
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) {
return null;
} else if (o instanceof Map) {
return new ArrayList<String>(((Map<String,Object>)o).keySet());
return new ArrayList<String>(((Map<String, Object>) o).keySet());
} else {
return null;
}
@ -421,7 +422,7 @@ public class YAMLNode {
if (o == null) {
return null;
} else if (o instanceof List) {
return (List<Object>)o;
return (List<Object>) o;
} else {
return null;
}
@ -656,7 +657,7 @@ public class YAMLNode {
List<YAMLNode> list = new ArrayList<YAMLNode>();
for (Object o : raw) {
if (o instanceof Map) {
list.add(new YAMLNode((Map<String, Object>)o, writeDefaults));
list.add(new YAMLNode((Map<String, Object>) o, writeDefaults));
}
}
@ -675,7 +676,7 @@ public class YAMLNode {
public YAMLNode getNode(String path) {
Object raw = getProperty(path);
if (raw instanceof Map) {
return new YAMLNode((Map<String, Object>)raw, writeDefaults);
return new YAMLNode((Map<String, Object>) raw, writeDefaults);
}
return null;
@ -697,7 +698,7 @@ public class YAMLNode {
Map<String, YAMLNode> nodes =
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) {
nodes.put(entry.getKey(),
new YAMLNode((Map<String, Object>) entry.getValue(), writeDefaults));
@ -720,7 +721,7 @@ public class YAMLNode {
if (o == null) {
return null;
} else if (o instanceof Number) {
return ((Number)o).intValue();
return ((Number) o).intValue();
} else {
return null;
}
@ -736,7 +737,7 @@ public class YAMLNode {
if (o == null) {
return null;
} else if (o instanceof Number) {
return ((Number)o).doubleValue();
return ((Number) o).doubleValue();
} else {
return null;
}
@ -752,7 +753,7 @@ public class YAMLNode {
if (o == null) {
return null;
} else if (o instanceof Boolean) {
return (Boolean)o;
return (Boolean) o;
} else {
return null;
}
@ -783,7 +784,7 @@ public class YAMLNode {
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);
return true;
} catch (IOException e) {} finally {
} catch (IOException e) {
} finally {
try {
if (stream != null) {
stream.close();
@ -185,10 +186,10 @@ public class YAMLProcessor extends YAMLNode {
@SuppressWarnings("unchecked")
private void read(Object input) throws YAMLProcessorException {
try {
if ( null == input ) {
if (null == input) {
root = new HashMap<String, Object>();
} else {
root = (Map<String, Object>)input;
root = (Map<String, Object>) input;
}
} catch (ClassCastException e) {
throw new YAMLProcessorException("Root document must be an key-value structure");

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -115,9 +115,11 @@ public class WorldEditPlayerListener extends PlayerListener {
}
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;
}}, 2);
}
}, 2);
if (taskId != -1) {
ignoreLeftClickAir = true;

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -182,8 +182,7 @@ public class Parser {
if (peek().id() == ';') {
++position;
break;
}
else {
} else {
break loop;
}
@ -205,8 +204,7 @@ public class Parser {
break loop;
}
break;
}
else {
} else {
break loop;
}
}
@ -253,7 +251,7 @@ public class Parser {
} else {
RValue variable = variables.get(identifierToken.value);
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.
variables.put(identifierToken.value, variable = new Variable(0));
} else {

Datei anzeigen

@ -230,19 +230,17 @@ public final class ParserProcessors {
final Identifiable last = input.removeLast();
if (last instanceof OperatorToken) {
postfixes.addLast(new UnaryOperator(last.getPosition(), "x"+((OperatorToken)last).operator));
}
else if (last instanceof UnaryOperator) {
postfixes.addLast(new UnaryOperator(last.getPosition(), "x"+((UnaryOperator)last).operator));
}
else {
postfixes.addLast(new UnaryOperator(last.getPosition(), "x" + ((OperatorToken) last).operator));
} else if (last instanceof UnaryOperator) {
postfixes.addLast(new UnaryOperator(last.getPosition(), "x" + ((UnaryOperator) last).operator));
} else {
center = last;
break;
}
} while (true);
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);

Datei anzeigen

@ -17,8 +17,7 @@ public class Conditional extends Node {
public double getValue() throws EvaluationException {
if (condition.getValue() > 0.0) {
return truePart.getValue();
}
else {
} else {
return falsePart == null ? 0 : falsePart.getValue();
}
}
@ -31,9 +30,9 @@ public class Conditional extends Node {
@Override
public String toString() {
if (falsePart == null) {
return "if ("+condition+") { "+truePart+" }";
return "if (" + condition + ") { " + truePart + " }";
} 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 {
ret = body.getValue();
}
catch (BreakException e) {
} catch (BreakException e) {
if (e.doContinue) {
continue;
} else {
@ -48,7 +47,7 @@ public class For extends Node {
@Override
public String toString() {
return "for ("+init+"; "+condition+"; "+increment+") { "+body+" }";
return "for (" + init + "; " + condition + "; " + increment + ") { " + body + " }";
}
//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 {
final Method getter = getMethod(name, false, args);
try {
Method setter = getMethod(name, true, args);
return new LValueFunction(position, getter, setter, args);
}
catch (NoSuchMethodException e) {
} catch (NoSuchMethodException e) {
return new Function(position, getter, args);
}
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -27,8 +27,7 @@ public class While extends Node {
try {
ret = body.getValue();
}
catch (BreakException e) {
} catch (BreakException e) {
if (e.doContinue) {
continue;
} else {
@ -45,8 +44,7 @@ public class While extends Node {
try {
ret = body.getValue();
}
catch (BreakException e) {
} catch (BreakException e) {
if (e.doContinue) {
continue;
} else {
@ -67,9 +65,9 @@ public class While extends Node {
@Override
public String toString() {
if (footChecked) {
return "do { "+body+" } while ("+condition+")";
return "do { " + body + " } while (" + condition + ")";
} 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) {
int diameter = radius * 2 + 1;
float[] data = new float[diameter*diameter];
float[] data = new float[diameter * diameter];
double sigma22 = 2 * sigma * sigma;
double constant = Math.PI * sigma22;
for (int y = -radius; y <= radius; ++y) {
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
* @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;
float[] matrix = kernel.getKernelData(null);
int[] outData = new int[inData.length];
@ -92,8 +92,9 @@ public class HeightMapFilter {
for (int ky = 0; ky < kh; ++ky) {
int offsetY = y + ky - koy;
// Clamp coordinates inside data
if (offsetY < 0 || offsetY >= height)
if (offsetY < 0 || offsetY >= height) {
offsetY = y;
}
offsetY *= width;
@ -104,8 +105,9 @@ public class HeightMapFilter {
int offsetX = x + kx - kox;
// Clamp coordinates inside data
if (offsetX < 0 || offsetX >= width)
if (offsetX < 0 || offsetX >= width) {
offsetX = x;
}
z += f * inData[offsetY + offsetX];
}

Datei anzeigen

@ -35,9 +35,9 @@ public class LinearKernel extends Kernel {
private static float[] createKernel(int radius) {
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;
}

Datei anzeigen

@ -40,7 +40,7 @@ public class UnderOverlayMask implements Mask {
this.overlay = overlay;
}
public void addAll(Set<Integer> ids){
public void addAll(Set<Integer> 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 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 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 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;
}
return (int)Math.floor(Math.abs(area * 0.5)
return (int) Math.floor(Math.abs(area * 0.5)
* (maxY - minY + 1));
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -72,7 +72,7 @@ public class RhinoScriptEngineFactory implements ScriptEngineFactory {
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();
s.append(obj);
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();
for (String stmt : statements) {
s.append(stmt);

Datei anzeigen

@ -1,4 +1,3 @@
package com.sk89q.worldedit.snapshots;
// $Id$
/*
* WorldEdit
@ -18,6 +17,8 @@ package com.sk89q.worldedit.snapshots;
* 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.regions.*;
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.
*/
private Map<BlockVector2D,ArrayList<Vector>> neededChunks =
new LinkedHashMap<BlockVector2D,ArrayList<Vector>>();
private Map<BlockVector2D, ArrayList<Vector>> neededChunks =
new LinkedHashMap<BlockVector2D, ArrayList<Vector>>();
/**
* Chunk store.
*/
@ -141,8 +142,7 @@ public class SnapshotRestore {
errorChunks = new ArrayList<Vector2D>();
// Now let's start restoring!
for (Map.Entry<BlockVector2D,ArrayList<Vector>> entry :
neededChunks.entrySet()) {
for (Map.Entry<BlockVector2D, ArrayList<Vector>> entry : neededChunks.entrySet()) {
BlockVector2D chunkPos = entry.getKey();
Chunk chunk;

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -37,19 +37,19 @@ import com.sk89q.worldedit.blocks.BlockID;
*/
public class TreeGenerator {
public enum TreeType {
TREE("Regular tree", new String[] {"tree", "regular"}),
BIG_TREE("Big tree", new String[] {"big", "bigtree"}),
REDWOOD("Redwood", new String[] {"redwood", "sequoia", "sequoioideae"}),
TALL_REDWOOD("Tall redwood", new String[] {"tallredwood", "tallsequoia", "tallsequoioideae"}),
BIRCH("Birch", new String[] {"birch", "white", "whitebark"}),
PINE("Pine", new String[] {"pine"}),
RANDOM_REDWOOD("Random redwood", new String[] {"randredwood", "randomredwood", "anyredwood"}),
RANDOM("Random", new String[] {"rand", "random"});
TREE("Regular tree", new String[] { "tree", "regular" }),
BIG_TREE("Big tree", new String[] { "big", "bigtree" }),
REDWOOD("Redwood", new String[] { "redwood", "sequoia", "sequoioideae" }),
TALL_REDWOOD("Tall redwood", new String[] { "tallredwood", "tallsequoia", "tallsequoioideae" }),
BIRCH("Birch", new String[] { "birch", "white", "whitebark" }),
PINE("Pine", new String[] { "pine" }),
RANDOM_REDWOOD("Random redwood", new String[] { "randredwood", "randomredwood", "anyredwood" }),
RANDOM("Random", new String[] { "rand", "random" });
/**
* 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[] lookupKeys;
@ -64,7 +64,7 @@ public class TreeGenerator {
TreeType(String name, String lookupKey) {
this.name = name;
this.lookupKeys = new String[]{ lookupKey };
this.lookupKeys = new String[] { lookupKey };
}
TreeType(String name, String[] lookupKeys) {

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -12,16 +12,16 @@ public class ExpressionTest {
@Test
public void testEvaluate() throws ExpressionException {
// check
assertEquals(1-2+3, simpleEval("1-2+3"), 0);
assertEquals(1 - 2 + 3, simpleEval("1 - 2 + 3"), 0);
// 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
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
assertEquals(8, Expression.compile("foo+bar", "foo", "bar").evaluate(5, 3), 0);