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

Try to show characters' stories and voices #94

Merged
merged 5 commits into from
Apr 22, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
cache fetters
  • Loading branch information
Yazawazi committed Apr 22, 2022
commit d37543beaf4385482e672fdc07e259399c47e0fc
20 changes: 12 additions & 8 deletions src/main/java/emu/grasscutter/data/GenshinData.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public class GenshinData {

private static final Int2ObjectMap<SceneData> sceneDataMap = new Int2ObjectLinkedOpenHashMap<>();
private static final Int2ObjectMap<FetterData> fetterDataMap = new Int2ObjectOpenHashMap<>();

// Cache
private static Map<Integer, List<Integer>> fetters = new HashMap<>();

public static Int2ObjectMap<?> getMapByResourceDef(Class<?> resourceDefinition) {
Int2ObjectMap<?> map = null;
Expand Down Expand Up @@ -226,14 +229,15 @@ public static Int2ObjectMap<SceneData> getSceneDataMap() {
}

public static Map<Integer, List<Integer>> getFetterDataEntries() {
// Can I do this?
Map<Integer, List<Integer>> fetters = new HashMap<>();
fetterDataMap.forEach((k, v) -> {
if (!fetters.containsKey(v.getAvatarId())) {
fetters.put(v.getAvatarId(), new ArrayList<>());
}
fetters.get(v.getAvatarId()).add(k);
});
if (fetters.isEmpty()) {
fetterDataMap.forEach((k, v) -> {
if (!fetters.containsKey(v.getAvatarId())) {
fetters.put(v.getAvatarId(), new ArrayList<>());
}
fetters.get(v.getAvatarId()).add(k);
});
}

return fetters;
}
}