Fix Javadocs and code issues.

This commit is contained in:
sk89q
2014-07-29 11:04:04 -07:00
parent 8834af7538
commit 1dc84d2511
230 changed files with 1646 additions and 1882 deletions

View File

@@ -80,6 +80,8 @@ import com.sk89q.worldedit.world.biome.BaseBiome;
import javax.annotation.Nullable;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -96,6 +98,8 @@ import static com.sk89q.worldedit.regions.Regions.*;
@SuppressWarnings("FieldCanBeLocal")
public class EditSession implements Extent {
private static final Logger log = Logger.getLogger(EditSession.class.getCanonicalName());
/**
* Used by {@link #setBlock(Vector, BaseBlock, Stage)} to
* determine which {@link Extent}s should be bypassed.
@@ -317,8 +321,9 @@ public class EditSession implements Extent {
/**
* Set whether fast mode is enabled.
* </p>
* Fast mode may skip lighting checks or adjacent block notification.
*
* <p>Fast mode may skip lighting checks or adjacent block
* notification.</p>
*
* @param enabled true to enable
*/
@@ -330,13 +335,14 @@ public class EditSession implements Extent {
/**
* Return fast mode status.
* </p>
* Fast mode may skip lighting checks or adjacent block notification.
*
* <p>Fast mode may skip lighting checks or adjacent block
* notification.</p>
*
* @return true if enabled
*/
public boolean hasFastMode() {
return fastModeExtent != null ? fastModeExtent.isEnabled() : false;
return fastModeExtent != null && fastModeExtent.isEnabled();
}
/**
@@ -369,8 +375,8 @@ public class EditSession implements Extent {
/**
* Get the number of blocks changed, including repeated block changes.
* </p>
* This number may not be accurate.
*
* <p>This number may not be accurate.</p>
*
* @return the number of block changes
*/
@@ -1486,15 +1492,14 @@ public class EditSession implements Extent {
/**
* Makes a pyramid.
*
* @param pos
* @param block
* @param size
* @param filled
* @param position a position
* @param block a block
* @param size size of pyramid
* @param filled true if filled
* @return number of blocks changed
* @throws MaxChangedBlocksException
*/
public int makePyramid(Vector pos, Pattern block, int size,
boolean filled) throws MaxChangedBlocksException {
public int makePyramid(Vector position, Pattern block, int size, boolean filled) throws MaxChangedBlocksException {
int affected = 0;
int height = size;
@@ -1506,16 +1511,16 @@ public class EditSession implements Extent {
if ((filled && z <= size && x <= size) || z == size || x == size) {
if (setBlock(pos.add(x, y, z), block)) {
if (setBlock(position.add(x, y, z), block)) {
++affected;
}
if (setBlock(pos.add(-x, y, z), block)) {
if (setBlock(position.add(-x, y, z), block)) {
++affected;
}
if (setBlock(pos.add(x, y, -z), block)) {
if (setBlock(position.add(x, y, -z), block)) {
++affected;
}
if (setBlock(pos.add(-x, y, -z), block)) {
if (setBlock(position.add(-x, y, -z), block)) {
++affected;
}
}
@@ -1527,21 +1532,21 @@ public class EditSession implements Extent {
}
/**
* Thaw.
* Thaw blocks in a radius.
*
* @param pos
* @param radius
* @param position the position
* @param radius the radius
* @return number of blocks affected
* @throws MaxChangedBlocksException
*/
public int thaw(Vector pos, double radius)
public int thaw(Vector position, double radius)
throws MaxChangedBlocksException {
int affected = 0;
double radiusSq = radius * radius;
int ox = pos.getBlockX();
int oy = pos.getBlockY();
int oz = pos.getBlockZ();
int ox = position.getBlockX();
int oy = position.getBlockY();
int oz = position.getBlockZ();
BaseBlock air = new BaseBlock(0);
BaseBlock water = new BaseBlock(BlockID.STATIONARY_WATER);
@@ -1549,7 +1554,7 @@ public class EditSession implements Extent {
int ceilRadius = (int) Math.ceil(radius);
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
if ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) {
if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) {
continue;
}
@@ -1586,21 +1591,20 @@ public class EditSession implements Extent {
}
/**
* Make snow.
* Make snow in a radius.
*
* @param pos
* @param radius
* @param position a position
* @param radius a radius
* @return number of blocks affected
* @throws MaxChangedBlocksException
*/
public int simulateSnow(Vector pos, double radius)
throws MaxChangedBlocksException {
public int simulateSnow(Vector position, double radius) throws MaxChangedBlocksException {
int affected = 0;
double radiusSq = radius * radius;
int ox = pos.getBlockX();
int oy = pos.getBlockY();
int oz = pos.getBlockZ();
int ox = position.getBlockX();
int oy = position.getBlockY();
int oz = position.getBlockZ();
BaseBlock ice = new BaseBlock(BlockID.ICE);
BaseBlock snow = new BaseBlock(BlockID.SNOW);
@@ -1608,7 +1612,7 @@ public class EditSession implements Extent {
int ceilRadius = (int) Math.ceil(radius);
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
if ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) {
if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) {
continue;
}
@@ -1651,44 +1655,43 @@ public class EditSession implements Extent {
}
/**
* Green.
* Make dirt green.
*
* @param pos
* @param radius
* @param position a position
* @param radius a radius
* @return number of blocks affected
* @throws MaxChangedBlocksException
* @deprecated Use {@link #green(Vector, double, boolean)}.
*/
@Deprecated
public int green(Vector pos, double radius)
throws MaxChangedBlocksException {
return green(pos, radius, true);
public int green(Vector position, double radius) throws MaxChangedBlocksException {
return green(position, radius, true);
}
/**
* Green.
* Make dirt green.
*
* @param pos
* @param radius
* @param position a position
* @param radius a radius
* @param onlyNormalDirt only affect normal dirt (data value 0)
* @return number of blocks affected
* @throws MaxChangedBlocksException
*/
public int green(Vector pos, double radius, boolean onlyNormalDirt)
public int green(Vector position, double radius, boolean onlyNormalDirt)
throws MaxChangedBlocksException {
int affected = 0;
final double radiusSq = radius * radius;
final int ox = pos.getBlockX();
final int oy = pos.getBlockY();
final int oz = pos.getBlockZ();
final int ox = position.getBlockX();
final int oy = position.getBlockY();
final int oz = position.getBlockZ();
final BaseBlock grass = new BaseBlock(BlockID.GRASS);
final int ceilRadius = (int) Math.ceil(radius);
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
if ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) {
if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) {
continue;
}
@@ -1758,23 +1761,22 @@ public class EditSession implements Extent {
/**
* Makes a forest.
*
* @param basePos
* @param size
* @param density
* @param treeGenerator
* @param basePosition a position
* @param size a size
* @param density between 0 and 1, inclusive
* @param treeGenerator the tree genreator
* @return number of trees created
* @throws MaxChangedBlocksException
*/
public int makeForest(Vector basePos, int size, double density,
TreeGenerator treeGenerator) throws MaxChangedBlocksException {
public int makeForest(Vector basePosition, int size, double density, TreeGenerator treeGenerator) throws MaxChangedBlocksException {
int affected = 0;
for (int x = basePos.getBlockX() - size; x <= basePos.getBlockX()
for (int x = basePosition.getBlockX() - size; x <= basePosition.getBlockX()
+ size; ++x) {
for (int z = basePos.getBlockZ() - size; z <= basePos.getBlockZ()
for (int z = basePosition.getBlockZ() - size; z <= basePosition.getBlockZ()
+ size; ++z) {
// Don't want to be in the ground
if (!getBlock(new Vector(x, basePos.getBlockY(), z)).isAir()) {
if (!getBlock(new Vector(x, basePosition.getBlockY(), z)).isAir()) {
continue;
}
// The gods don't want a tree here
@@ -1782,7 +1784,7 @@ public class EditSession implements Extent {
continue;
} // def 0.05
for (int y = basePos.getBlockY(); y >= basePos.getBlockY() - 10; --y) {
for (int y = basePosition.getBlockY(); y >= basePosition.getBlockY() - 10; --y) {
// Check if we hit the ground
int t = getBlock(new Vector(x, y, z)).getType();
if (t == BlockID.GRASS || t == BlockID.DIRT) {
@@ -1804,8 +1806,8 @@ public class EditSession implements Extent {
/**
* Get the block distribution inside a region.
*
* @param region
* @return
* @param region a region
* @return the results
*/
public List<Countable<Integer>> getBlockDistribution(Region region) {
List<Countable<Integer>> distribution = new ArrayList<Countable<Integer>>();
@@ -1862,8 +1864,8 @@ public class EditSession implements Extent {
/**
* Get the block distribution (with data values) inside a region.
*
* @param region
* @return
* @param region a region
* @return the results
*/
// TODO reduce code duplication - probably during ops-redux
public List<Countable<BaseBlock>> getBlockDistributionWithData(Region region) {
@@ -1942,7 +1944,7 @@ public class EditSession implements Extent {
return new BaseBlock((int) typeVariable.getValue(), (int) dataVariable.getValue());
} catch (Exception e) {
e.printStackTrace();
log.log(Level.WARNING, "Failed to create shape", e);
return null;
}
}
@@ -2161,12 +2163,12 @@ public class EditSession implements Extent {
throws MaxChangedBlocksException {
Set<Vector> vset = new HashSet<Vector>();
List<Node> nodes = new ArrayList(nodevectors.size());
List<Node> nodes = new ArrayList<Node>(nodevectors.size());
Interpolation interpol = new KochanekBartelsInterpolation();
for (int loop = 0; loop < nodevectors.size(); loop++) {
Node n = new Node(nodevectors.get(loop));
for (Vector nodevector : nodevectors) {
Node n = new Node(nodevector);
n.setTension(tension);
n.setBias(bias);
n.setContinuity(continuity);
@@ -2285,7 +2287,7 @@ public class EditSession implements Extent {
// TODO: Allow biome setting via a script variable (needs BiomeType<->int mapping)
return defaultBiomeType;
} catch (Exception e) {
e.printStackTrace();
log.log(Level.WARNING, "Failed to create shape", e);
return null;
}
}
@@ -2303,11 +2305,11 @@ public class EditSession implements Extent {
PlayerDirection.DOWN.vector(),
};
private static final double lengthSq(double x, double y, double z) {
private static double lengthSq(double x, double y, double z) {
return (x * x) + (y * y) + (z * z);
}
private static final double lengthSq(double x, double z) {
private static double lengthSq(double x, double z) {
return (x * x) + (z * z);
}