diff --git a/Core/src/main/java/com/plotsquared/core/location/Location.java b/Core/src/main/java/com/plotsquared/core/location/Location.java index 0505137b1..fa9175892 100644 --- a/Core/src/main/java/com/plotsquared/core/location/Location.java +++ b/Core/src/main/java/com/plotsquared/core/location/Location.java @@ -34,6 +34,7 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import lombok.Getter; import lombok.Setter; +import org.jetbrains.annotations.NotNull; import org.khelekore.prtree.MBR; import org.khelekore.prtree.SimpleMBR; @@ -103,6 +104,16 @@ public class Location implements Cloneable, Comparable { } } + /** + * Return a copy of the location. This will pass {@link #equals(Object)} + * but will have a different identity. + * + * @return Copy of the location + */ + @NotNull public Location copy() { + return new Location(this.world, this.x, this.y, this.z, this.yaw, this.pitch); + } + public PlotArea getPlotArea() { return PlotSquared.get().getPlotAreaAbs(this); } diff --git a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java index 13efa6bfb..b11a33ba6 100644 --- a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java @@ -367,7 +367,7 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer @NotNull public Location getLocation() { Location location = getMeta("location"); if (location != null) { - return location; + return location.copy(); // Always return a copy of the location } return getLocationFull(); }