Updated com.sk89q.worldedit.Point to use generics.

Dieser Commit ist enthalten in:
sk89q 2010-10-02 15:12:45 -07:00
Ursprung 7387e36016
Commit 8e2c6ece61
2 geänderte Dateien mit 13 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -29,8 +29,8 @@ public class EditSession {
/**
* Stores the original blocks before modification.
*/
private HashMap<Point,Integer> original = new HashMap<Point,Integer>();
private HashMap<Point,Integer> current = new HashMap<Point,Integer>();
private HashMap<Point<Integer>,Integer> original = new HashMap<Point<Integer>,Integer>();
private HashMap<Point<Integer>,Integer> current = new HashMap<Point<Integer>,Integer>();
/**
* Sets a block without changing history.
@ -55,7 +55,7 @@ public class EditSession {
* @return Whether the block changed
*/
public boolean setBlock(int x, int y, int z, int blockType) {
Point pt = new Point(x, y, z);
Point<Integer> pt = new Point<Integer>(x, y, z);
if (!original.containsKey(pt)) {
original.put(pt, getBlock(x, y, z));
}
@ -79,9 +79,9 @@ public class EditSession {
* Restores all blocks to their initial state.
*/
public void undo() {
for (Map.Entry<Point,Integer> entry : original.entrySet()) {
for (Map.Entry<Point<Integer>,Integer> entry : original.entrySet()) {
Point pt = (Point)entry.getKey();
rawSetBlock((int)pt.getX(), (int)pt.getY(),(int)pt.getZ(),
rawSetBlock((Integer)pt.getX(), (Integer)pt.getY(),(Integer)pt.getZ(),
(int)entry.getValue());
}
}
@ -90,9 +90,9 @@ public class EditSession {
* Sets to new state.
*/
public void redo() {
for (Map.Entry<Point,Integer> entry : current.entrySet()) {
for (Map.Entry<Point<Integer>,Integer> entry : current.entrySet()) {
Point pt = (Point)entry.getKey();
rawSetBlock((int)pt.getX(), (int)pt.getY(),(int)pt.getZ(),
rawSetBlock((Integer)pt.getX(), (Integer)pt.getY(),(Integer)pt.getZ(),
(int)entry.getValue());
}
}

Datei anzeigen

@ -25,10 +25,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
*
* @author Albert
*/
public final class Point {
private final double x, y, z;
public final class Point<T> {
private final T x, y, z;
public Point(double x, double y, double z) {
public Point(T x, T y, T z) {
this.x = x;
this.y = y;
this.z = z;
@ -37,7 +37,7 @@ public final class Point {
/**
* @return the x
*/
public double getX() {
public T getX() {
return x;
}
@ -45,14 +45,14 @@ public final class Point {
/**
* @return the y
*/
public double getY() {
public T getY() {
return y;
}
/**
* @return the z
*/
public double getZ() {
public T getZ() {
return z;
}