Fix area id parsing

This commit is contained in:
Jesse Boyd 2016-09-19 14:18:47 +10:00
parent d89274ce09
commit 364b4347d1

View File

@ -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 `<name>-<pos1>-<pos2>`");
}
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 `<name>-<x1;z1>-<x2;z2>`");
}