From caef3a923b091f2c744f9161c9a9d0eb4fde1d9e Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Sat, 8 Oct 2022 15:11:16 +0200 Subject: [PATCH] Deprecate PlotId#copy (#3821) --- .../java/com/plotsquared/core/command/DatabaseCommand.java | 2 +- Core/src/main/java/com/plotsquared/core/plot/Plot.java | 6 +++--- Core/src/main/java/com/plotsquared/core/plot/PlotId.java | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java index 73b678e5b..76c1c8dc5 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java @@ -176,7 +176,7 @@ public class DatabaseCommand extends SubCommand { ); worldFile.renameTo(newFile); } - plot.setId(newId.copy()); + plot.setId(newId); plot.setArea(pa); plots.add(plot); continue; diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index fd3e68046..757f89012 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -1836,8 +1836,8 @@ public class Plot { } // Swap cached final PlotId temp = PlotId.of(this.getId().getX(), this.getId().getY()); - this.id = plot.getId().copy(); - plot.id = temp.copy(); + this.id = plot.getId(); + plot.id = temp; this.area.removePlot(this.getId()); plot.area.removePlot(plot.getId()); this.area.addPlotAbs(this); @@ -1863,7 +1863,7 @@ public class Plot { return false; } this.area.removePlot(this.id); - this.id = plot.getId().copy(); + this.id = plot.getId(); this.area.addPlotAbs(this); DBFunc.movePlot(this, plot); TaskManager.runTaskLater(whenDone, TaskTime.ticks(1L)); diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotId.java b/Core/src/main/java/com/plotsquared/core/plot/PlotId.java index 552831c1f..4d0bb8fb7 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotId.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotId.java @@ -110,9 +110,11 @@ public final class PlotId { * Get a copy of the plot ID * * @return Plot ID copy + * @deprecated PlotId is immutable, copy is not required. */ + @Deprecated(forRemoval = true, since = "TODO") public @NonNull PlotId copy() { - return of(this.getX(), this.getY()); + return this; } /**