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