Generic cleanup of warnings, whitespace and style.

By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
Bukkit/Spigot
2011-12-25 16:02:30 +01:00
parent 98960fd73e
commit aaab1cba23
257 changed files with 1408 additions and 1152 deletions

View File

@@ -15,27 +15,27 @@ import java.util.NoSuchElementException;
public class BlockIterator implements Iterator<Block> {
private final World world;
private final int maxDistance;
private final World world;
private final int maxDistance;
private static final int gridSize = 1 << 24;
private static final int gridSize = 1 << 24;
private boolean end = false;
private boolean end = false;
private Block[] blockQueue = new Block[3];
private int currentBlock = 0;
private int currentDistance = 0;
private int maxDistanceInt;
private Block[] blockQueue = new Block[3];
private int currentBlock = 0;
private int currentDistance = 0;
private int maxDistanceInt;
private int secondError;
private int thirdError;
private int secondError;
private int thirdError;
private int secondStep;
private int thirdStep;
private int secondStep;
private int thirdStep;
private BlockFace mainFace;
private BlockFace secondFace;
private BlockFace thirdFace;
private BlockFace mainFace;
private BlockFace secondFace;
private BlockFace thirdFace;
/**
* Constructs the BlockIterator
@@ -66,7 +66,7 @@ public class BlockIterator implements Iterator<Block> {
double secondPosition = 0;
double thirdPosition = 0;
Block startBlock = world.getBlockAt((int) Math.floor(startClone.getX()), (int) Math.floor(startClone.getY()), (int) Math.floor(startClone.getZ()));
Block startBlock = this.world.getBlockAt((int) Math.floor(startClone.getX()), (int) Math.floor(startClone.getY()), (int) Math.floor(startClone.getZ()));
if (getXLength(direction) > mainDirection) {
mainFace = getXFace(direction);
@@ -214,15 +214,15 @@ public class BlockIterator implements Iterator<Block> {
}
private double getXLength(Vector direction) {
return(Math.abs(direction.getX()));
return Math.abs(direction.getX());
}
private double getYLength(Vector direction) {
return(Math.abs(direction.getY()));
return Math.abs(direction.getY());
}
private double getZLength(Vector direction) {
return(Math.abs(direction.getZ()));
return Math.abs(direction.getZ());
}
private double getPosition(double direction, double position, int blockPosition) {
@@ -281,7 +281,7 @@ public class BlockIterator implements Iterator<Block> {
* Constructs the BlockIterator.
*
* @param entity Information from the entity is used to set up the trace
* @param maxDistance This is the maximum distance in blocks for the trace. Setting this value above 140 may lead to problems with unloaded chunks. A value of 0 indicates no limit
* @param maxDistance This is the maximum distance in blocks for the trace. Setting this value above 140 may lead to problems with unloaded chunks. A value of 0 indicates no limit
*
*/

View File

@@ -23,6 +23,7 @@ public class BlockVector extends Vector {
/**
* Construct the vector with another vector.
*
* @param vec The other vector.
*/
public BlockVector(Vector vec) {
@@ -111,22 +112,22 @@ public class BlockVector extends Vector {
v.z = z;
return v;
}
public static BlockVector deserialize(Map<String, Object> args) {
double x = 0;
double y = 0;
double z = 0;
if (args.containsKey("x")) {
x = (Double)args.get("x");
x = (Double) args.get("x");
}
if (args.containsKey("y")) {
y = (Double)args.get("y");
y = (Double) args.get("y");
}
if (args.containsKey("z")) {
z = (Double)args.get("z");
z = (Double) args.get("z");
}
return new BlockVector(x, y, z);
}
}

View File

@@ -8,12 +8,12 @@ public final class NumberConversions {
public static int toInt(Object object) {
if (object instanceof Number) {
return ((Number)object).intValue();
return ((Number) object).intValue();
} else {
int result = 0;
try {
result = Integer.valueOf((String)object);
result = Integer.valueOf((String) object);
} catch (Throwable ex) {}
return result;
@@ -22,12 +22,12 @@ public final class NumberConversions {
public static float toFloat(Object object) {
if (object instanceof Number) {
return ((Number)object).floatValue();
return ((Number) object).floatValue();
} else {
float result = 0;
try {
result = Float.valueOf((String)object);
result = Float.valueOf((String) object);
} catch (Throwable ex) {}
return result;
@@ -36,12 +36,12 @@ public final class NumberConversions {
public static double toDouble(Object object) {
if (object instanceof Number) {
return ((Number)object).doubleValue();
return ((Number) object).doubleValue();
} else {
double result = 0;
try {
result = Double.valueOf((String)object);
result = Double.valueOf((String) object);
} catch (Throwable ex) {}
return result;
@@ -50,12 +50,12 @@ public final class NumberConversions {
public static long toLong(Object object) {
if (object instanceof Number) {
return ((Number)object).longValue();
return ((Number) object).longValue();
} else {
long result = 0;
try {
result = Long.valueOf((String)object);
result = Long.valueOf((String) object);
} catch (Throwable ex) {}
return result;
@@ -64,12 +64,12 @@ public final class NumberConversions {
public static short toShort(Object object) {
if (object instanceof Number) {
return ((Number)object).shortValue();
return ((Number) object).shortValue();
} else {
short result = 0;
try {
result = Short.valueOf((String)object);
result = Short.valueOf((String) object);
} catch (Throwable ex) {}
return result;
@@ -78,12 +78,12 @@ public final class NumberConversions {
public static byte toByte(Object object) {
if (object instanceof Number) {
return ((Number)object).byteValue();
return ((Number) object).byteValue();
} else {
byte result = 0;
try {
result = Byte.valueOf((String)object);
result = Byte.valueOf((String) object);
} catch (Throwable ex) {}
return result;

View File

@@ -165,7 +165,7 @@ public class Vector implements Cloneable, ConfigurationSerializable {
}
/**
* Get the distance between this vector and another. The value
* Get the distance between this vector and another. The value
* of this method is not cached and uses a costly square-root function, so
* do not repeatedly call this method to get the vector's magnitude. NaN
* will be returned if the inner result of the sqrt() function overflows,
@@ -641,29 +641,29 @@ public class Vector implements Cloneable, ConfigurationSerializable {
public Map<String, Object> serialize() {
Map<String, Object> result = new LinkedHashMap<String, Object>();
result.put("x", getX());
result.put("y", getY());
result.put("z", getZ());
return result;
}
public static Vector deserialize(Map<String, Object> args) {
double x = 0;
double y = 0;
double z = 0;
if (args.containsKey("x")) {
x = (Double)args.get("x");
x = (Double) args.get("x");
}
if (args.containsKey("y")) {
y = (Double)args.get("y");
y = (Double) args.get("y");
}
if (args.containsKey("z")) {
z = (Double)args.get("z");
z = (Double) args.get("z");
}
return new Vector(x, y, z);
}
}

View File

@@ -29,9 +29,11 @@ import org.yaml.snakeyaml.representer.Representer;
* select child nodes by delimiting node names with periods.
*
* <p>
* For example, given the following configuration file:</p>
* For example, given the following configuration file:
* </p>
*
* <pre>members:
* <pre>
* members:
* - Hollie
* - Jason
* - Bobo
@@ -44,13 +46,14 @@ import org.yaml.snakeyaml.representer.Representer;
* sturmeh:
* cool: false
* eats:
* babies: true</pre>
* babies: true
* </pre>
*
* <p>Calling code could access sturmeh's baby eating state by using
* <code>getBoolean("sturmeh.eats.babies", false)</code>. For lists, there are
* methods such as <code>getStringList</code> that will return a type safe list.
* <p>
* Calling code could access sturmeh's baby eating state by using <code>getBoolean("sturmeh.eats.babies", false)</code>. For lists, there are methods such as <code>getStringList</code> that will return a type safe list.
*
* <p>This class is currently incomplete. It is not yet possible to get a node.
* <p>
* This class is currently incomplete. It is not yet possible to get a node.
* </p>
*
* @deprecated See {@link YamlConfiguration}
@@ -163,7 +166,8 @@ public class Configuration extends ConfigurationNode {
}
yaml.dump(root, writer);
return true;
} catch (IOException e) {} finally {
} catch (IOException e) {
} finally {
try {
if (stream != null) {
stream.close();
@@ -190,6 +194,7 @@ public class Configuration extends ConfigurationNode {
/**
* This method returns an empty ConfigurationNode for using as a
* default in methods that select a node from a node list.
*
* @return The empty node.
*/
public static ConfigurationNode getEmptyNode() {

View File

@@ -40,17 +40,16 @@ public class ConfigurationNode {
Map<String, Object> map = new TreeMap<String, Object>();
Set<String> keys = node.keySet();
for( String k : keys ) {
for (String k : keys) {
Object tmp = node.get(k);
if( tmp instanceof Map<?,?> ) {
Map<String, Object> rec = recursiveBuilder((Map <String,Object>) tmp);
if (tmp instanceof Map<?, ?>) {
Map<String, Object> rec = recursiveBuilder((Map<String, Object>) tmp);
Set<String> subkeys = rec.keySet();
for( String sk : subkeys ) {
for (String sk : subkeys) {
map.put(k + "." + sk, rec.get(sk));
}
}
else {
} else {
map.put(k, tmp);
}
}

View File

@@ -1,4 +1,3 @@
package org.bukkit.util.noise;
/**
@@ -12,7 +11,7 @@ public abstract class NoiseGenerator {
/**
* Speedy floor, faster than (int)Math.floor(x)
*
*
* @param x Value to floor
* @return Floored value
*/

View File

@@ -1,4 +1,3 @@
package org.bukkit.util.noise;
/**

View File

@@ -5,7 +5,7 @@ import org.bukkit.World;
/**
* Generates noise using the "classic" perlin generator
*
*
* @see SimplexNoiseGenerator "Improved" and faster version with slighly different results
*/
public class PerlinNoiseGenerator extends NoiseGenerator {

View File

@@ -1,4 +1,3 @@
package org.bukkit.util.noise;
import java.util.Random;

View File

@@ -1,4 +1,3 @@
package org.bukkit.util.noise;
import java.util.Random;
@@ -9,7 +8,7 @@ import org.bukkit.World;
*/
public class SimplexOctaveGenerator extends OctaveGenerator {
private double wScale = 1;
/**
* Creates a simplex octave generator for the given world
*
@@ -102,8 +101,8 @@ public class SimplexOctaveGenerator extends OctaveGenerator {
z *= zScale;
w *= wScale;
for (int i = 0; i < octaves.length; i++) {
result += ((SimplexNoiseGenerator)octaves[i]).noise(x * freq, y * freq, z * freq, w * freq) * amp;
for (NoiseGenerator octave : octaves) {
result += ((SimplexNoiseGenerator) octave).noise(x * freq, y * freq, z * freq, w * freq) * amp;
max += amp;
freq *= frequency;
amp *= amplitude;

View File

@@ -7,9 +7,8 @@ import org.bukkit.permissions.PermissionDefault;
public final class DefaultPermissions {
private static final String ROOT = "craftbukkit";
private static final String PREFIX = ROOT + ".";
private static final String LEGACY_PREFIX = "craft";
private DefaultPermissions() {}
public static Permission registerPermission(Permission perm) {