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;
|
int X = 0, Y = 0, Z = 0;
|
||||||
boolean matched = false;
|
boolean matched = false;
|
||||||
Matcher shortForm = Pattern.compile("\\((-?\\d+),(-?\\d+)\\)").matcher(stringOfCoords);
|
Matcher shortForm = Pattern.compile("\\((-?\\d+),(-?\\d+)\\)").matcher(stringOfCoords);
|
||||||
|
Matcher normalForm =
|
||||||
|
Pattern.compile("\\[(-?\\d+),(-?\\d+),(-?\\d+)\\]").matcher(stringOfCoords);
|
||||||
|
|
||||||
if (shortForm.matches()) {
|
if (shortForm.matches()) {
|
||||||
X = Integer.parseInt(shortForm.group(1));
|
X = Integer.parseInt(shortForm.group(1));
|
||||||
Y = 64;
|
Y = 64;
|
||||||
Z = Integer.parseInt(shortForm.group(2));
|
Z = Integer.parseInt(shortForm.group(2));
|
||||||
matched = true;
|
matched = true;
|
||||||
}
|
}
|
||||||
Matcher normalForm =
|
|
||||||
Pattern.compile("\\[(-?\\d+),(-?\\d+),(-?\\d+)\\]").matcher(stringOfCoords);
|
|
||||||
if (normalForm.matches()) {
|
if (normalForm.matches()) {
|
||||||
X = Integer.parseInt(normalForm.group(1));
|
X = Integer.parseInt(normalForm.group(1));
|
||||||
Y = Integer.parseInt(normalForm.group(2));
|
Y = Integer.parseInt(normalForm.group(2));
|
||||||
Z = Integer.parseInt(normalForm.group(3));
|
Z = Integer.parseInt(normalForm.group(3));
|
||||||
matched = true;
|
matched = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!matched) {
|
if (!matched) {
|
||||||
System.err.println("Invalid coordinate format: " + stringOfCoords);
|
System.err.println("Invalid coordinate format: " + stringOfCoords);
|
||||||
System.err.println();
|
System.err.println();
|
||||||
|
@ -98,6 +98,8 @@ public class WorldVerify {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
props.close();
|
||||||
|
|
||||||
} catch (final FileNotFoundException ex) {
|
} catch (final FileNotFoundException ex) {
|
||||||
Main.err("Could not open " + Main.serverPath + Main.fileSeparator + "server.properties");
|
Main.err("Could not open " + Main.serverPath + Main.fileSeparator + "server.properties");
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user