Fix Towny support to handle 0.75.x and 0.74.x

This commit is contained in:
Mike Primm 2011-08-28 08:13:34 +08:00 committed by mikeprimm
parent a3573c7a64
commit 0c292dde12

View File

@ -125,34 +125,25 @@ public class TownyConfigHandler {
}
if(!worldmatch) continue;
java.util.regex.Matcher towny075Match = towny075Pattern.matcher(n);
if (towny075Match.matches()) {
// Towny Advanced >= 0.75
int bidx = n.indexOf(']');
if(bidx >= 0) { /* If 0.75 block type present, skip it (we don't care yet) */
n = n.substring(bidx+1);
}
String[] v = n.split(",");
if(v.length >= 2) { /* Price in 0.75 is third - don't care :) */
try {
//int plotType = Integer.valueOf(towny075Match.group(1));
int[] vv = new int[] { Integer.valueOf(towny075Match.group(2)), Integer.valueOf(towny075Match.group(3)) };
int[] vv = new int[] { Integer.valueOf(v[0]), Integer.valueOf(v[1]) };
blks.setFlag(vv[0], vv[1], true);
nodevals.add(vv);
} catch(NumberFormatException nfx) {
} catch (NumberFormatException nfx) {
Log.severe("Error parsing block list in Towny - " + townfile.getPath());
return null;
}
} else if(n.startsWith("|")){ /* End of list? */
} else {
// Towny Advanced < 0.75
String[] v = n.split(",");
if(v.length == 2) {
try {
int[] vv = new int[] { Integer.valueOf(v[0]), Integer.valueOf(v[1]) };
blks.setFlag(vv[0], vv[1], true);
nodevals.add(vv);
} catch (NumberFormatException nfx) {
Log.severe("Error parsing block list in Towny - " + townfile.getPath());
return null;
}
} else {
Log.severe("Invalid block list format in Towny - " + townfile.getPath());
return null;
}
Log.severe("Invalid block list format in Towny - " + townfile.getPath());
return null;
}
}
/* If nothing in this world, skip */