Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing null handling to GroupResourcePack #342

Open
wants to merge 3 commits into
base: 1.20
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,13 @@ public GroupResourcePack(@NotNull ResourceType type, @NotNull List<? extends Res
* @return the list of the matching resource packs
*/
public @UnmodifiableView List<? extends ResourcePack> getPacks(String namespace) {
return Collections.unmodifiableList(this.namespacedPacks.get(namespace));
var packs = this.namespacedPacks.get(namespace);

if (packs != null) {
return Collections.unmodifiableList(packs);
}

return Collections.emptyList();
}

/**
Expand Down Expand Up @@ -131,9 +137,11 @@ public void listResources(ResourceType type, String namespace, String startingPa
ResourcePack.ResourceConsumer consumer) {
var packs = this.namespacedPacks.get(namespace);

// Iterating backwards as higher-priority packs are placed at the end.
for (var pack : packs) {
pack.listResources(type, namespace, startingPath, consumer);
if (packs != null) {
// Iterating backwards as higher-priority packs are placed at the end.
for (var pack : packs) {
Comment on lines +141 to +142
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment actually relevant ? It seems copy-pasted from above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same for statement, just moved under the null check, so the comment is still relevant.

pack.listResources(type, namespace, startingPath, consumer);
}
}
}

Expand Down