minor RegEx tweek, fixed potential resource leak

This commit is contained in:
Morlok8k 2012-08-19 02:20:27 -07:00
parent aa77cde46d
commit 65b21a34c0
2 changed files with 7 additions and 2 deletions

View File

@ -101,20 +101,23 @@ public class Coordinates {
int X = 0, Y = 0, Z = 0;
boolean matched = false;
Matcher shortForm = Pattern.compile("\\((-?\\d+),(-?\\d+)\\)").matcher(stringOfCoords);
Matcher normalForm =
Pattern.compile("\\[(-?\\d+),(-?\\d+),(-?\\d+)\\]").matcher(stringOfCoords);
if (shortForm.matches()) {
X = Integer.parseInt(shortForm.group(1));
Y = 64;
Z = Integer.parseInt(shortForm.group(2));
matched = true;
}
Matcher normalForm =
Pattern.compile("\\[(-?\\d+),(-?\\d+),(-?\\d+)\\]").matcher(stringOfCoords);
if (normalForm.matches()) {
X = Integer.parseInt(normalForm.group(1));
Y = Integer.parseInt(normalForm.group(2));
Z = Integer.parseInt(normalForm.group(3));
matched = true;
}
if (!matched) {
System.err.println("Invalid coordinate format: " + stringOfCoords);
System.err.println();

View File

@ -98,6 +98,8 @@ public class WorldVerify {
}
}
props.close();
} catch (final FileNotFoundException ex) {
Main.err("Could not open " + Main.serverPath + Main.fileSeparator + "server.properties");
return;