mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 17:05:20 +01:00
Avoid NPE on CookingCompoundManager init
This commit is contained in:
@@ -34,17 +34,15 @@ public class CookingCompoundManager extends BasePlayerManager {
|
|||||||
public static void initialize() {
|
public static void initialize() {
|
||||||
defaultUnlockedCompounds = new HashSet<>();
|
defaultUnlockedCompounds = new HashSet<>();
|
||||||
compoundGroups = new HashMap<>();
|
compoundGroups = new HashMap<>();
|
||||||
for (var compound : GameData.getCompoundDataMap().values()) {
|
GameData.getCompoundDataMap().forEach((id, compound) -> {
|
||||||
if (compound.isDefaultUnlocked()) {
|
if (compound.isDefaultUnlocked()) {
|
||||||
defaultUnlockedCompounds.add(compound.getId());
|
defaultUnlockedCompounds.add(id);
|
||||||
}
|
|
||||||
if (!compoundGroups.containsKey(compound.getGroupId())) {
|
|
||||||
compoundGroups.put(compound.getGroupId(), new HashSet<>());
|
|
||||||
}
|
|
||||||
compoundGroups.get(compound.getGroupId()).add(compound.getId());
|
|
||||||
}
|
}
|
||||||
|
compoundGroups.computeIfAbsent(compound.getGroupId(), gid -> new HashSet<>()).add(id);
|
||||||
|
});
|
||||||
//TODO:Because we haven't implemented fishing feature,unlock all compounds related to fish.Besides,it should be bound to player rather than manager.
|
//TODO:Because we haven't implemented fishing feature,unlock all compounds related to fish.Besides,it should be bound to player rather than manager.
|
||||||
unlocked = new HashSet<>(defaultUnlockedCompounds);
|
unlocked = new HashSet<>(defaultUnlockedCompounds);
|
||||||
|
if (compoundGroups.containsKey(3)) // Avoid NPE from Resources error
|
||||||
unlocked.addAll(compoundGroups.get(3));
|
unlocked.addAll(compoundGroups.get(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user