mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2025-01-15 12:51:38 +01:00
Account for possible integer-parse exception if there are WAY too many digits in the file-name-pattern
This commit is contained in:
parent
0a1dbbe3c7
commit
91e0cdf283
@ -25,6 +25,7 @@
|
|||||||
package de.bluecolored.bluemap.core.world.mca.region;
|
package de.bluecolored.bluemap.core.world.mca.region;
|
||||||
|
|
||||||
import com.flowpowered.math.vector.Vector2i;
|
import com.flowpowered.math.vector.Vector2i;
|
||||||
|
import de.bluecolored.bluemap.core.logger.Logger;
|
||||||
import de.bluecolored.bluemap.core.util.Key;
|
import de.bluecolored.bluemap.core.util.Key;
|
||||||
import de.bluecolored.bluemap.core.util.Keyed;
|
import de.bluecolored.bluemap.core.util.Keyed;
|
||||||
import de.bluecolored.bluemap.core.util.Registry;
|
import de.bluecolored.bluemap.core.util.Registry;
|
||||||
@ -114,16 +115,24 @@ public String getRegionFileName(int regionX, int regionZ) {
|
|||||||
Matcher matcher = regionFileNamePattern.matcher(fileName);
|
Matcher matcher = regionFileNamePattern.matcher(fileName);
|
||||||
if (!matcher.matches()) return null;
|
if (!matcher.matches()) return null;
|
||||||
|
|
||||||
int regionX = Integer.parseInt(matcher.group(1));
|
try {
|
||||||
int regionZ = Integer.parseInt(matcher.group(2));
|
|
||||||
|
|
||||||
// sanity-check for roughly minecraft max boundaries (-30 000 000 to 30 000 000)
|
int regionX = Integer.parseInt(matcher.group(1));
|
||||||
if (
|
int regionZ = Integer.parseInt(matcher.group(2));
|
||||||
regionX < -100000 || regionX > 100000 ||
|
|
||||||
regionZ < -100000 || regionZ > 100000
|
|
||||||
) return null;
|
|
||||||
|
|
||||||
return new Vector2i(regionX, regionZ);
|
// sanity-check for roughly minecraft max boundaries (-30 000 000 to 30 000 000)
|
||||||
|
if (
|
||||||
|
regionX < -100000 || regionX > 100000 ||
|
||||||
|
regionZ < -100000 || regionZ > 100000
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Vector2i(regionX, regionZ);
|
||||||
|
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user