Account for possible integer-parse exception if there are WAY too many digits in the file-name-pattern

This commit is contained in:
Lukas Rieger (Blue) 2025-01-06 16:47:40 +01:00
parent 0a1dbbe3c7
commit 91e0cdf283
No known key found for this signature in database
GPG Key ID: AA33883B1BBA03E6

View File

@ -25,6 +25,7 @@
package de.bluecolored.bluemap.core.world.mca.region;
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.Keyed;
import de.bluecolored.bluemap.core.util.Registry;
@ -114,6 +115,8 @@ public String getRegionFileName(int regionX, int regionZ) {
Matcher matcher = regionFileNamePattern.matcher(fileName);
if (!matcher.matches()) return null;
try {
int regionX = Integer.parseInt(matcher.group(1));
int regionZ = Integer.parseInt(matcher.group(2));
@ -121,9 +124,15 @@ public String getRegionFileName(int regionX, int regionZ) {
if (
regionX < -100000 || regionX > 100000 ||
regionZ < -100000 || regionZ > 100000
) return null;
) {
return null;
}
return new Vector2i(regionX, regionZ);
} catch (NumberFormatException ex) {
return null;
}
}
}