From 364b4347d16c821f65fbfca3f88672e40e5e7578 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 19 Sep 2016 14:18:47 +1000 Subject: [PATCH] Fix area id parsing --- .../main/java/com/intellectualcrafters/plot/PS.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index 592865ab0..0f858dc7e 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -1526,16 +1526,13 @@ public class PS { } for (String areaId : areasSection.getKeys(false)) { PS.log(C.PREFIX + "&3 - " + areaId); - int i1 = areaId.indexOf('-'); - int i2 = areaId.indexOf(';'); - if (i1 == -1 || i2 == -1) { + String[] split = areaId.split("(?<=[^;-])-"); + if (split.length != 3) { throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `--`"); } - String name = areaId.substring(0, i1); - String rest = areaId.substring(i1 + 1); - int i3 = rest.indexOf('-', i2 - name.length() - 1); - PlotId pos1 = PlotId.fromString(rest.substring(0, i3)); - PlotId pos2 = PlotId.fromString(rest.substring(i3 + 1)); + String name = split[0]; + PlotId pos1 = PlotId.fromString(split[1]); + PlotId pos2 = PlotId.fromString(split[2]); if (pos1 == null || pos2 == null || name.isEmpty()) { throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `--`"); }