import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
public class Position implements ConfigurationSerializable{
private String world;
private double x, y, z;
public Position(Location location){
this(location.getWorld().getName(), location.getX(), location.getY(), location.getZ());
}
public Position(String world, double x, double y, double z){
setWorld(world);
setX(x);
setY(y);
setZ(z);
}
public String getWorld() {
return world;
}
public void setWorld(String world) {
this.world = world;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
public double getZ() {
return z;
}
public void setZ(double z) {
this.z = z;
}
public Location getLocation(){
return new Location(Bukkit.getWorld(getWorld()), getZ(), getY(), getZ());
}
@Override
public Map<String, Object> serialize() {
Map<String, Object> result = new HashMap<String, Object>();
result.put("world", getWorld());
result.put("x", getX());
result.put("y", getY());
result.put("z", getZ());
return result;
}
public static Position deserialize(Map<String, Object> args){
return new Position((String)args.get("world"), (Double)args.get("x"), (Double)args.get("y"), (Double)args.get("z"));
}
}
近期评论