Location implements cloneable
This commit is contained in:
@@ -9,15 +9,17 @@ import lombok.Data;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class Location {
|
||||
public class Location implements Cloneable {
|
||||
private double x, y, z;
|
||||
|
||||
public static Location copyOf(Location location) {
|
||||
return new Location(
|
||||
location.x,
|
||||
location.y,
|
||||
location.z
|
||||
);
|
||||
return location.clone();
|
||||
}
|
||||
|
||||
public Location (Location location) {
|
||||
this.x = location.getX();
|
||||
this.y = location.getY();
|
||||
this.z = location.getZ();
|
||||
}
|
||||
|
||||
public void set(Location location) {
|
||||
@@ -45,4 +47,13 @@ public class Location {
|
||||
public int getBlockZ() {
|
||||
return (int) z;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Location clone() {
|
||||
try {
|
||||
return (Location) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user