All Downloads are FREE. Search and download functionalities are using the official Maven repository.

emu.grasscutter.data.GenshinData Maven / Gradle / Ivy

There is a newer version: 1.0.3-dev
Show newest version
package emu.grasscutter.data;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import emu.grasscutter.Grasscutter;
import emu.grasscutter.utils.Utils;
import emu.grasscutter.data.custom.AbilityEmbryoEntry;
import emu.grasscutter.data.custom.OpenConfigEntry;
import emu.grasscutter.data.custom.ScenePointEntry;
import emu.grasscutter.data.def.*;
import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;

public class GenshinData {
	// BinOutputs
	private static final Int2ObjectMap abilityHashes = new Int2ObjectOpenHashMap<>();
	private static final Map abilityEmbryos = new HashMap<>();
	private static final Map openConfigEntries = new HashMap<>();
	private static final Map scenePointEntries = new HashMap<>();
	
	// ExcelConfigs
	private static final Int2ObjectMap playerLevelDataMap = new Int2ObjectOpenHashMap<>();
	
	private static final Int2ObjectMap avatarDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap avatarLevelDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap avatarSkillDepotDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap avatarSkillDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap avatarCurveDataMap = new Int2ObjectLinkedOpenHashMap<>();
	private static final Int2ObjectMap avatarFetterLevelDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap avatarPromoteDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap avatarTalentDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap proudSkillDataMap = new Int2ObjectOpenHashMap<>();
	
	private static final Int2ObjectMap itemDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap reliquaryLevelDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap reliquaryAffixDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap reliquaryMainPropDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap reliquarySetDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap weaponLevelDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap weaponPromoteDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap weaponCurveDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap equipAffixDataMap = new Int2ObjectOpenHashMap<>();
	
	private static final Int2ObjectMap monsterDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap npcDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap gadgetDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap monsterCurveDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap monsterDescribeDataMap = new Int2ObjectOpenHashMap<>();
	
	private static final Int2ObjectMap avatarFlycloakDataMap = new Int2ObjectLinkedOpenHashMap<>();
	private static final Int2ObjectMap avatarCostumeDataMap = new Int2ObjectLinkedOpenHashMap<>();
	private static final Int2ObjectMap avatarCostumeDataItemIdMap = new Int2ObjectLinkedOpenHashMap<>();
	
	private static final Int2ObjectMap sceneDataMap = new Int2ObjectLinkedOpenHashMap<>();
	private static final Int2ObjectMap fetterDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap fetterCharacterCardDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap rewardDataMap = new Int2ObjectOpenHashMap<>();
	private static final Int2ObjectMap worldLevelDataMap = new Int2ObjectOpenHashMap<>();
	
	// Cache
	private static Map> fetters = new HashMap<>();
	
	public static Int2ObjectMap getMapByResourceDef(Class resourceDefinition) {
		Int2ObjectMap map = null;
		
		try {
			Field field = GenshinData.class.getDeclaredField(Utils.lowerCaseFirstChar(resourceDefinition.getSimpleName()) + "Map");
			field.setAccessible(true);
			
			map = (Int2ObjectMap) field.get(null);
			
			field.setAccessible(false);
		} catch (Exception e) {
			Grasscutter.getLogger().error("Error fetching resource map for " + resourceDefinition.getSimpleName(), e);
		}
		
		return map;
	}

	public static Int2ObjectMap getAbilityHashes() {
		return abilityHashes;
	}
	
	public static Map getAbilityEmbryoInfo() {
		return abilityEmbryos;
	}

	public static Map getOpenConfigEntries() {
		return openConfigEntries;
	}

	public static Map getScenePointEntries() {
		return scenePointEntries;
	}

	public static Int2ObjectMap getAvatarDataMap() {
		return avatarDataMap;
	}
	
	public static Int2ObjectMap getItemDataMap() {
		return itemDataMap;
	}

	public static Int2ObjectMap getAvatarSkillDepotDataMap() {
		return avatarSkillDepotDataMap;
	}
	
	public static Int2ObjectMap getAvatarSkillDataMap() {
		return avatarSkillDataMap;
	}

	public static Int2ObjectMap getPlayerLevelDataMap() {
		return playerLevelDataMap;
	}

	public static Int2ObjectMap getAvatarFetterLevelDataMap() {
		return avatarFetterLevelDataMap;
	}

	public static Int2ObjectMap getFetterCharacterCardDataMap() {
		return fetterCharacterCardDataMap;
	}

	public static Int2ObjectMap getAvatarLevelDataMap() {
		return avatarLevelDataMap;
	}

	public static Int2ObjectMap getWeaponLevelDataMap() {
		return weaponLevelDataMap;
	}
	
	public static Int2ObjectMap getReliquaryAffixDataMap() {
		return reliquaryAffixDataMap;
	}
	
	public static Int2ObjectMap getReliquaryMainPropDataMap() {
		return reliquaryMainPropDataMap;
	}

	public static Int2ObjectMap getWeaponPromoteDataMap() {
		return weaponPromoteDataMap;
	}

	public static Int2ObjectMap getWeaponCurveDataMap() {
		return weaponCurveDataMap;
	}
	
	public static Int2ObjectMap getAvatarCurveDataMap() {
		return avatarCurveDataMap;
	}

	public static int getRelicExpRequired(int rankLevel, int level) {
		ReliquaryLevelData levelData = reliquaryLevelDataMap.get((rankLevel << 8) + level);
		return levelData != null ? levelData.getExp() : 0;
	}
	
	public static ReliquaryLevelData getRelicLevelData(int rankLevel, int level) {
		return reliquaryLevelDataMap.get((rankLevel << 8) + level);
	}
	
	public static WeaponPromoteData getWeaponPromoteData(int promoteId, int promoteLevel) {
		return weaponPromoteDataMap.get((promoteId << 8) + promoteLevel);
	}

	public static int getWeaponExpRequired(int rankLevel, int level) {
		WeaponLevelData levelData = weaponLevelDataMap.get(level);
		if (levelData == null) {
			return 0;
		}
		try {
			return levelData.getRequiredExps()[rankLevel - 1];
		} catch (Exception e) {
			return 0;
		}
	}
	
	public static AvatarPromoteData getAvatarPromoteData(int promoteId, int promoteLevel) {
		return avatarPromoteDataMap.get((promoteId << 8) + promoteLevel);
	}

	public static int getAvatarLevelExpRequired(int level) {
		AvatarLevelData levelData = avatarLevelDataMap.get(level);
		return levelData != null ? levelData.getExp() : 0;
	}

	public static int getAvatarFetterLevelExpRequired(int level) {
		AvatarFetterLevelData levelData = avatarFetterLevelDataMap.get(level);
		return levelData != null ? levelData.getExp() : 0;
	}
	
	public static Int2ObjectMap getProudSkillDataMap() {
		return proudSkillDataMap;
	}

	public static Int2ObjectMap getMonsterDataMap() {
		return monsterDataMap;
	}

	public static Int2ObjectMap getNpcDataMap() {
		return npcDataMap;
	}

	public static Int2ObjectMap getGadgetDataMap() {
		return gadgetDataMap;
	}

	public static Int2ObjectMap getReliquarySetDataMap() {
		return reliquarySetDataMap;
	}

	public static Int2ObjectMap getEquipAffixDataMap() {
		return equipAffixDataMap;
	}

	public static Int2ObjectMap getMonsterCurveDataMap() {
		return monsterCurveDataMap;
	}

	public static Int2ObjectMap getMonsterDescribeDataMap() {
		return monsterDescribeDataMap;
	}

	public static Int2ObjectMap getAvatarTalentDataMap() {
		return avatarTalentDataMap;
	}

	public static Int2ObjectMap getAvatarFlycloakDataMap() {
		return avatarFlycloakDataMap;
	}

	public static Int2ObjectMap getAvatarCostumeDataMap() {
		return avatarCostumeDataMap;
	}
	
	public static Int2ObjectMap getAvatarCostumeDataItemIdMap() {
		return avatarCostumeDataItemIdMap;
	}

	public static Int2ObjectMap getSceneDataMap() {
		return sceneDataMap;
	}

	public static Int2ObjectMap getRewardDataMap() {
		return rewardDataMap;
	}

	public static Map> getFetterDataEntries() {
		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;
	}

	public static Int2ObjectMap getWorldLevelDataMap() {
		return worldLevelDataMap;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy