fix: protect against NPE with mod-provided packs in root directories of (virtual) file systems
ci/woodpecker/push/docs Pipeline was successful Details
ci/woodpecker/push/jfmod Pipeline was successful Details

This commit is contained in:
Johannes Frohnmeyer 2024-04-03 11:54:04 +02:00
parent ecc95648ff
commit cba440978b
Signed by: Johannes
GPG Key ID: E76429612C2929F4
1 changed files with 4 additions and 2 deletions

View File

@ -48,11 +48,13 @@ public class ResourcePackManagerMixin {
Path dataLocation = null;
if (rpi instanceof DirectoryResourcePack drp) {
Path pack = ((DirectoryResourcePackAccessor) drp).getRoot();
if (pack != null) dataLocation = pack.getParent().resolve(pack.getFileName() + Respackopts.FILE_EXTENSION);
Path parent = pack == null ? null : pack.getParent();
if (parent != null) dataLocation = parent.resolve(pack.getFileName() + Respackopts.FILE_EXTENSION);
else Respackopts.LOGGER.warn("Base path of directory resource pack " + rpi.getName() + " is null. This shouldn't happen!");
} else if (rpi instanceof ZipResourcePack zrp) {
File pack = ((ZipFileWrapperAccessor) ((ZipResourcePackAccessor) zrp).getZipFile()).getFile();
if (pack != null) dataLocation = pack.toPath().getParent().resolve(pack.getName() + Respackopts.FILE_EXTENSION);
Path parent = pack == null ? null : pack.toPath().getParent();
if (parent != null) dataLocation = parent.resolve(pack.getName() + Respackopts.FILE_EXTENSION);
else Respackopts.LOGGER.warn("Base path of zip resource pack " + rpi.getName() + " is null. This shouldn't happen!");
}