Skip to content

Commit

Permalink
Fix NPE related to out of sequence startup
Browse files Browse the repository at this point in the history
  • Loading branch information
OreCruncher committed Mar 9, 2024
1 parent 431c12d commit d9279ec
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.orecruncher.dsurround.lib.resources;

import com.google.common.collect.ImmutableList;
import net.minecraft.server.packs.PackType;
import org.orecruncher.dsurround.lib.Library;
import org.orecruncher.dsurround.lib.platform.IPlatform;

import java.nio.file.Files;
Expand All @@ -16,13 +18,17 @@ public class ResourceLookupHelper {

public ResourceLookupHelper(PackType packType) {
this.packType = packType;
this.rootPaths = ImmutableList.of();
}

public void refresh(IPlatform platform) {
this.rootPaths = platform.getResourceRootPaths(this.packType);
}

public Collection<Path> findResourcePaths(String fileNamePattern) {
if (this.rootPaths.isEmpty())
Library.LOGGER.warn("No root paths defined for ResourceLookupHelper");

return this.rootPaths.stream()
.map(path -> this.findPath(fileNamePattern, path))
.filter(Optional::isPresent)
Expand Down

0 comments on commit d9279ec

Please sign in to comment.