From a1d94af242751bdb4f53b9693f07faa316b4abfb Mon Sep 17 00:00:00 2001 From: OneLiteFeather <77929075+OneLiteFeather@users.noreply.github.com> Date: Sat, 20 Jan 2024 00:34:46 +0100 Subject: [PATCH] Fix home command reset (#4295) * Add location not null check The issue lies within the equals implementation * Fix setposition method with default value. Also add a comment too. --------- Co-authored-by: OneLiteFeather --- .../main/java/com/plotsquared/core/database/SQLManager.java | 3 ++- Core/src/main/java/com/plotsquared/core/plot/Plot.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/database/SQLManager.java b/Core/src/main/java/com/plotsquared/core/database/SQLManager.java index 3c530b318..63d1af450 100644 --- a/Core/src/main/java/com/plotsquared/core/database/SQLManager.java +++ b/Core/src/main/java/com/plotsquared/core/database/SQLManager.java @@ -2401,7 +2401,8 @@ public class SQLManager implements AbstractDB { addPlotTask(plot, new UniqueStatement("setPosition") { @Override public void set(PreparedStatement statement) throws SQLException { - statement.setString(1, position == null ? "" : position); + // Please see the table creation statement. There is the default value of "default" + statement.setString(1, position == null ? "DEFAULT" : position); statement.setInt(2, getId(plot)); } 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 2c47ef322..67db8a698 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -1483,7 +1483,7 @@ public class Plot { */ public void setHome(BlockLoc location) { Plot plot = this.getBasePlot(false); - if (BlockLoc.ZERO.equals(location) || BlockLoc.MINY.equals(location)) { + if (location != null && (BlockLoc.ZERO.equals(location) || BlockLoc.MINY.equals(location))) { return; } plot.getSettings().setPosition(location);