minor RegEx tweek, fixed potential resource leak
This commit is contained in:
parent
aa77cde46d
commit
65b21a34c0
@ -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();
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user