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,22 +125,12 @@ 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);
try {
//int plotType = Integer.valueOf(towny075Match.group(1));
int[] vv = new int[] { Integer.valueOf(towny075Match.group(2)), Integer.valueOf(towny075Match.group(3)) };
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 {
// Towny Advanced < 0.75
String[] v = n.split(","); String[] v = n.split(",");
if(v.length == 2) { if(v.length >= 2) { /* Price in 0.75 is third - don't care :) */
try { try {
int[] vv = new int[] { Integer.valueOf(v[0]), Integer.valueOf(v[1]) }; int[] vv = new int[] { Integer.valueOf(v[0]), Integer.valueOf(v[1]) };
blks.setFlag(vv[0], vv[1], true); blks.setFlag(vv[0], vv[1], true);
@ -149,12 +139,13 @@ public class TownyConfigHandler {
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 {
Log.severe("Invalid block list format in Towny - " + townfile.getPath()); Log.severe("Invalid block list format in Towny - " + townfile.getPath());
return null; return null;
} }
} }
}
/* If nothing in this world, skip */ /* If nothing in this world, skip */
if(nodevals.size() == 0) if(nodevals.size() == 0)
return null; return null;