fix: protect against NPE with mod-provided packs in root directories of (virtual) file systems
This commit is contained in:
parent
ecc95648ff
commit
cba440978b
|
@ -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!");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue