mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Fix issue where PlotPlayer#getLocation returns a mutable location
This commit is contained in:
parent
699eb71e2a
commit
89cb6450fb
2 changed files with 12 additions and 1 deletions
|
@ -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<Location> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
|
|
@ -367,7 +367,7 @@ public abstract class PlotPlayer<P> 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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue