mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2025-01-15 04:41:44 +01:00
Add sanity-check for min/max expected minecraft region coordinates
This commit is contained in:
parent
77e793c958
commit
0a1dbbe3c7
@ -113,10 +113,17 @@ public String getRegionFileName(int regionX, int regionZ) {
|
||||
public @Nullable Vector2i getRegionFromFileName(String fileName) {
|
||||
Matcher matcher = regionFileNamePattern.matcher(fileName);
|
||||
if (!matcher.matches()) return null;
|
||||
return new Vector2i(
|
||||
Integer.parseInt(matcher.group(1)),
|
||||
Integer.parseInt(matcher.group(2))
|
||||
);
|
||||
|
||||
int regionX = Integer.parseInt(matcher.group(1));
|
||||
int regionZ = Integer.parseInt(matcher.group(2));
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user