From ed588476e00f4627f94a1bedae18d74611f91023 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Fri, 8 Nov 2019 22:31:01 +0000 Subject: [PATCH] Fix single plot areas --- .../plotsquared/plot/object/PlotId.java | 10 +++++++++- .../plot/object/worlds/SinglePlot.java | 2 +- .../plot/object/worlds/SinglePlotArea.java | 17 ++++++++++++----- .../object/worlds/SinglePlotAreaManager.java | 2 +- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotId.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotId.java index 21e7dc777..a777a6b6f 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotId.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotId.java @@ -25,6 +25,14 @@ public class PlotId { this.y = y; } + public int getX() { + return x; + } + + public int getY() { + return y; + } + /** * Get a Plot Id based on a string * @@ -40,7 +48,7 @@ public class PlotId { } @Nullable public static PlotId fromStringOrNull(@NotNull String string) { - String[] parts = string.split("[;|,]"); + String[] parts = string.split("[;,.]"); if (parts.length < 2) { return null; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java index a9a620daa..788e7a99a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java @@ -44,7 +44,7 @@ public class SinglePlot extends Plot { } @Override public String getWorldName() { - return getId().toCommaSeparatedString(); + return getId().getX() + "." + getId().getY(); } @Override public SinglePlotArea getArea() { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java index 1f5e70856..f04d340eb 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java @@ -47,7 +47,7 @@ public class SinglePlotArea extends GridPlotWorld { } public void loadWorld(final PlotId id) { - String worldName = id.toCommaSeparatedString(); + String worldName = id.getX() + "." + id.getY(); if (WorldUtil.IMP.isWorld(worldName)) { return; } @@ -59,12 +59,19 @@ public class SinglePlotArea extends GridPlotWorld { setup.step = new ConfigurationNode[0]; setup.world = worldName; + File container = PlotSquared.imp().getWorldContainer(); + File destination = new File(container, worldName); + + {// convert old + File oldFile = new File(container, id.toCommaSeparatedString()); + if (oldFile.exists()) { + oldFile.renameTo(destination); + } + } // Duplicate 0;0 if (setup.type != 0) { - File container = PlotSquared.imp().getWorldContainer(); - File destination = new File(container, worldName); if (!destination.exists()) { - File src = new File(container, "0,0"); + File src = new File(container, "0.0"); if (src.exists()) { if (!destination.exists()) { destination.mkdirs(); @@ -93,7 +100,7 @@ public class SinglePlotArea extends GridPlotWorld { TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Object value) { - String worldName = id.toCommaSeparatedString(); + String worldName = id.getX() + "." + id.getY(); if (WorldUtil.IMP.isWorld(worldName)) { return; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotAreaManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotAreaManager.java index 620a689b3..d35257b9b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotAreaManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotAreaManager.java @@ -44,7 +44,7 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager { } case 1: if ((c <= '/') || (c >= ':')) { - if (c == ';' || c == ',') { + if (c == '.') { mode = 2; continue; }