Commit 2dcdb839 authored by KingRainbow44's avatar KingRainbow44
Browse files

Move resource loading messages to the `debug` level

parent 091d8c69
...@@ -32,7 +32,7 @@ import static emu.grasscutter.Configuration.*; ...@@ -32,7 +32,7 @@ import static emu.grasscutter.Configuration.*;
public class ResourceLoader { public class ResourceLoader {
private static List<String> loadedResources = new ArrayList<String>(); private static final List<String> loadedResources = new ArrayList<>();
public static List<Class<?>> getResourceDefClasses() { public static List<Class<?>> getResourceDefClasses() {
Reflections reflections = new Reflections(ResourceLoader.class.getPackage().getName()); Reflections reflections = new Reflections(ResourceLoader.class.getPackage().getName());
...@@ -50,7 +50,7 @@ public class ResourceLoader { ...@@ -50,7 +50,7 @@ public class ResourceLoader {
return classList; return classList;
} }
public static void loadAll() { public static void loadAll() {
// Load ability lists // Load ability lists
loadAbilityEmbryos(); loadAbilityEmbryos();
...@@ -96,15 +96,15 @@ public class ResourceLoader { ...@@ -96,15 +96,15 @@ public class ResourceLoader {
} }
} }
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
protected static void loadFromResource(Class<?> c, ResourceType type, Int2ObjectMap map, boolean doReload) throws Exception { protected static void loadFromResource(Class<?> c, ResourceType type, Int2ObjectMap map, boolean doReload) throws Exception {
if(!loadedResources.contains(c.getSimpleName()) || doReload) { if(!loadedResources.contains(c.getSimpleName()) || doReload) {
for (String name : type.name()) { for (String name : type.name()) {
loadFromResource(c, name, map); loadFromResource(c, name, map);
} }
Grasscutter.getLogger().info("Loaded " + map.size() + " " + c.getSimpleName() + "s.");
loadedResources.add(c.getSimpleName()); loadedResources.add(c.getSimpleName());
Grasscutter.getLogger().debug("Loaded " + map.size() + " " + c.getSimpleName() + "s.");
} }
} }
...@@ -133,7 +133,7 @@ public class ResourceLoader { ...@@ -133,7 +133,7 @@ public class ResourceLoader {
List<ScenePointEntry> scenePointList = new ArrayList<>(); List<ScenePointEntry> scenePointList = new ArrayList<>();
for (File file : Objects.requireNonNull(folder.listFiles())) { for (File file : Objects.requireNonNull(folder.listFiles())) {
ScenePointConfig config; Integer sceneId; ScenePointConfig config; Integer sceneId;
Matcher matcher = pattern.matcher(file.getName()); Matcher matcher = pattern.matcher(file.getName());
if (matcher.find()) { if (matcher.find()) {
sceneId = Integer.parseInt(matcher.group(1)); sceneId = Integer.parseInt(matcher.group(1));
...@@ -159,7 +159,7 @@ public class ResourceLoader { ...@@ -159,7 +159,7 @@ public class ResourceLoader {
ScenePointEntry sl = new ScenePointEntry(sceneId + "_" + entry.getKey(), pointData); ScenePointEntry sl = new ScenePointEntry(sceneId + "_" + entry.getKey(), pointData);
scenePointList.add(sl); scenePointList.add(sl);
GameData.getScenePointIdList().add(pointData.getId()); GameData.getScenePointIdList().add(pointData.getId());
pointData.updateDailyDungeon(); pointData.updateDailyDungeon();
} }
...@@ -173,9 +173,9 @@ public class ResourceLoader { ...@@ -173,9 +173,9 @@ public class ResourceLoader {
List<AbilityEmbryoEntry> embryoList = null; List<AbilityEmbryoEntry> embryoList = null;
// Read from cached file if exists // Read from cached file if exists
try(InputStream embryoCache = DataLoader.load("AbilityEmbryos.json", false)) { try (InputStream embryoCache = DataLoader.load("AbilityEmbryos.json", false)) {
embryoList = Grasscutter.getGsonFactory().fromJson(new InputStreamReader(embryoCache), TypeToken.getParameterized(Collection.class, AbilityEmbryoEntry.class).getType()); embryoList = Grasscutter.getGsonFactory().fromJson(new InputStreamReader(embryoCache), TypeToken.getParameterized(Collection.class, AbilityEmbryoEntry.class).getType());
} catch(Exception ignored) {} } catch (Exception ignored) {}
if(embryoList == null) { if(embryoList == null) {
// Load from BinOutput // Load from BinOutput
...@@ -215,9 +215,9 @@ public class ResourceLoader { ...@@ -215,9 +215,9 @@ public class ResourceLoader {
AbilityEmbryoEntry al = new AbilityEmbryoEntry(avatarName, config.abilities.stream().map(Object::toString).toArray(size -> new String[s])); AbilityEmbryoEntry al = new AbilityEmbryoEntry(avatarName, config.abilities.stream().map(Object::toString).toArray(size -> new String[s]));
embryoList.add(al); embryoList.add(al);
} }
File playerElementsFile = new File(Utils.toFilePath(RESOURCE("BinOutput/AbilityGroup/AbilityGroup_Other_PlayerElementAbility.json"))); File playerElementsFile = new File(Utils.toFilePath(RESOURCE("BinOutput/AbilityGroup/AbilityGroup_Other_PlayerElementAbility.json")));
if (playerElementsFile.exists()) { if (playerElementsFile.exists()) {
try (FileReader fileReader = new FileReader(playerElementsFile)) { try (FileReader fileReader = new FileReader(playerElementsFile)) {
GameDepot.setPlayerAbilities(Grasscutter.getGsonFactory().fromJson(fileReader, new TypeToken<Map<String, AvatarConfig>>(){}.getType())); GameDepot.setPlayerAbilities(Grasscutter.getGsonFactory().fromJson(fileReader, new TypeToken<Map<String, AvatarConfig>>(){}.getType()));
...@@ -226,7 +226,7 @@ public class ResourceLoader { ...@@ -226,7 +226,7 @@ public class ResourceLoader {
} }
} }
} }
if (embryoList == null || embryoList.isEmpty()) { if (embryoList == null || embryoList.isEmpty()) {
Grasscutter.getLogger().error("No embryos loaded!"); Grasscutter.getLogger().error("No embryos loaded!");
return; return;
...@@ -236,7 +236,7 @@ public class ResourceLoader { ...@@ -236,7 +236,7 @@ public class ResourceLoader {
GameData.getAbilityEmbryoInfo().put(entry.getName(), entry); GameData.getAbilityEmbryoInfo().put(entry.getName(), entry);
} }
} }
private static void loadAbilityModifiers() { private static void loadAbilityModifiers() {
// Load from BinOutput // Load from BinOutput
File folder = new File(Utils.toFilePath(RESOURCE("BinOutput/Ability/Temp/AvatarAbilities/"))); File folder = new File(Utils.toFilePath(RESOURCE("BinOutput/Ability/Temp/AvatarAbilities/")));
...@@ -248,24 +248,24 @@ public class ResourceLoader { ...@@ -248,24 +248,24 @@ public class ResourceLoader {
for (File file : files) { for (File file : files) {
List<AbilityConfigData> abilityConfigList; List<AbilityConfigData> abilityConfigList;
try (FileReader fileReader = new FileReader(file)) { try (FileReader fileReader = new FileReader(file)) {
abilityConfigList = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, AbilityConfigData.class).getType()); abilityConfigList = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, AbilityConfigData.class).getType());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
continue; continue;
} }
for (AbilityConfigData data : abilityConfigList) { for (AbilityConfigData data : abilityConfigList) {
if (data.Default.modifiers == null || data.Default.modifiers.size() == 0) { if (data.Default.modifiers == null || data.Default.modifiers.size() == 0) {
continue; continue;
} }
AbilityModifierEntry modifierEntry = new AbilityModifierEntry(data.Default.abilityName); AbilityModifierEntry modifierEntry = new AbilityModifierEntry(data.Default.abilityName);
for (Entry<String, AbilityModifier> entry : data.Default.modifiers.entrySet()) { for (Entry<String, AbilityModifier> entry : data.Default.modifiers.entrySet()) {
AbilityModifier modifier = entry.getValue(); AbilityModifier modifier = entry.getValue();
// Stare. // Stare.
if (modifier.onAdded != null) { if (modifier.onAdded != null) {
for (AbilityModifierAction action : modifier.onAdded) { for (AbilityModifierAction action : modifier.onAdded) {
...@@ -275,7 +275,7 @@ public class ResourceLoader { ...@@ -275,7 +275,7 @@ public class ResourceLoader {
} }
} }
} }
if (modifier.onThinkInterval != null) { if (modifier.onThinkInterval != null) {
for (AbilityModifierAction action : modifier.onThinkInterval) { for (AbilityModifierAction action : modifier.onThinkInterval) {
if (action.$type.contains("HealHP")) { if (action.$type.contains("HealHP")) {
...@@ -284,7 +284,7 @@ public class ResourceLoader { ...@@ -284,7 +284,7 @@ public class ResourceLoader {
} }
} }
} }
if (modifier.onRemoved != null) { if (modifier.onRemoved != null) {
for (AbilityModifierAction action : modifier.onRemoved) { for (AbilityModifierAction action : modifier.onRemoved) {
if (action.$type.contains("HealHP")) { if (action.$type.contains("HealHP")) {
...@@ -294,12 +294,12 @@ public class ResourceLoader { ...@@ -294,12 +294,12 @@ public class ResourceLoader {
} }
} }
} }
GameData.getAbilityModifiers().put(modifierEntry.getName(), modifierEntry); GameData.getAbilityModifiers().put(modifierEntry.getName(), modifierEntry);
} }
} }
} }
private static void loadSpawnData() { private static void loadSpawnData() {
List<SpawnGroupEntry> spawnEntryList = null; List<SpawnGroupEntry> spawnEntryList = null;
...@@ -307,7 +307,7 @@ public class ResourceLoader { ...@@ -307,7 +307,7 @@ public class ResourceLoader {
try(InputStream spawnDataEntries = DataLoader.load("Spawns.json")) { try(InputStream spawnDataEntries = DataLoader.load("Spawns.json")) {
spawnEntryList = Grasscutter.getGsonFactory().fromJson(new InputStreamReader(spawnDataEntries), TypeToken.getParameterized(Collection.class, SpawnGroupEntry.class).getType()); spawnEntryList = Grasscutter.getGsonFactory().fromJson(new InputStreamReader(spawnDataEntries), TypeToken.getParameterized(Collection.class, SpawnGroupEntry.class).getType());
} catch (Exception ignored) {} } catch (Exception ignored) {}
if (spawnEntryList == null || spawnEntryList.isEmpty()) { if (spawnEntryList == null || spawnEntryList.isEmpty()) {
Grasscutter.getLogger().error("No spawn data loaded!"); Grasscutter.getLogger().error("No spawn data loaded!");
return; return;
...@@ -318,7 +318,7 @@ public class ResourceLoader { ...@@ -318,7 +318,7 @@ public class ResourceLoader {
GameDepot.getSpawnListById(entry.getSceneId()).insert(entry, entry.getPos().getX(), entry.getPos().getZ()); GameDepot.getSpawnListById(entry.getSceneId()).insert(entry, entry.getPos().getX(), entry.getPos().getZ());
} }
} }
private static void loadOpenConfig() { private static void loadOpenConfig() {
// Read from cached file if exists // Read from cached file if exists
List<OpenConfigEntry> list = null; List<OpenConfigEntry> list = null;
...@@ -331,69 +331,69 @@ public class ResourceLoader { ...@@ -331,69 +331,69 @@ public class ResourceLoader {
Map<String, OpenConfigEntry> map = new TreeMap<>(); Map<String, OpenConfigEntry> map = new TreeMap<>();
java.lang.reflect.Type type = new TypeToken<Map<String, OpenConfigData[]>>() {}.getType(); java.lang.reflect.Type type = new TypeToken<Map<String, OpenConfigData[]>>() {}.getType();
String[] folderNames = {"BinOutput/Talent/EquipTalents/", "BinOutput/Talent/AvatarTalents/"}; String[] folderNames = {"BinOutput/Talent/EquipTalents/", "BinOutput/Talent/AvatarTalents/"};
for (String name : folderNames) { for (String name : folderNames) {
File folder = new File(Utils.toFilePath(RESOURCE(name))); File folder = new File(Utils.toFilePath(RESOURCE(name)));
File[] files = folder.listFiles(); File[] files = folder.listFiles();
if(files == null) { if(files == null) {
Grasscutter.getLogger().error("Error loading open config: no files found in " + folder.getAbsolutePath()); return; Grasscutter.getLogger().error("Error loading open config: no files found in " + folder.getAbsolutePath()); return;
} }
for (File file : files) { for (File file : files) {
if (!file.getName().endsWith(".json")) { if (!file.getName().endsWith(".json")) {
continue; continue;
} }
Map<String, OpenConfigData[]> config; Map<String, OpenConfigData[]> config;
try (FileReader fileReader = new FileReader(file)) { try (FileReader fileReader = new FileReader(file)) {
config = Grasscutter.getGsonFactory().fromJson(fileReader, type); config = Grasscutter.getGsonFactory().fromJson(fileReader, type);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
continue; continue;
} }
for (Entry<String, OpenConfigData[]> e : config.entrySet()) { for (Entry<String, OpenConfigData[]> e : config.entrySet()) {
OpenConfigEntry entry = new OpenConfigEntry(e.getKey(), e.getValue()); OpenConfigEntry entry = new OpenConfigEntry(e.getKey(), e.getValue());
map.put(entry.getName(), entry); map.put(entry.getName(), entry);
} }
} }
} }
list = new ArrayList<>(map.values()); list = new ArrayList<>(map.values());
} }
if (list == null || list.isEmpty()) { if (list == null || list.isEmpty()) {
Grasscutter.getLogger().error("No openconfig entries loaded!"); Grasscutter.getLogger().error("No openconfig entries loaded!");
return; return;
} }
for (OpenConfigEntry entry : list) { for (OpenConfigEntry entry : list) {
GameData.getOpenConfigEntries().put(entry.getName(), entry); GameData.getOpenConfigEntries().put(entry.getName(), entry);
} }
} }
private static void loadQuests() { private static void loadQuests() {
File folder = new File(RESOURCE("BinOutput/Quest/")); File folder = new File(RESOURCE("BinOutput/Quest/"));
if (!folder.exists()) { if (!folder.exists()) {
return; return;
} }
for (File file : folder.listFiles()) { for (File file : folder.listFiles()) {
MainQuestData mainQuest = null; MainQuestData mainQuest = null;
try (FileReader fileReader = new FileReader(file)) { try (FileReader fileReader = new FileReader(file)) {
mainQuest = Grasscutter.getGsonFactory().fromJson(fileReader, MainQuestData.class); mainQuest = Grasscutter.getGsonFactory().fromJson(fileReader, MainQuestData.class);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
continue; continue;
} }
GameData.getMainQuestDataMap().put(mainQuest.getId(), mainQuest); GameData.getMainQuestDataMap().put(mainQuest.getId(), mainQuest);
} }
Grasscutter.getLogger().info("Loaded " + GameData.getMainQuestDataMap().size() + " MainQuestDatas."); Grasscutter.getLogger().debug("Loaded " + GameData.getMainQuestDataMap().size() + " MainQuestDatas.");
} }
@SneakyThrows @SneakyThrows
...@@ -413,7 +413,7 @@ public class ResourceLoader { ...@@ -413,7 +413,7 @@ public class ResourceLoader {
GameData.getHomeworldDefaultSaveData().put(Integer.parseInt(sceneId), data); GameData.getHomeworldDefaultSaveData().put(Integer.parseInt(sceneId), data);
} }
Grasscutter.getLogger().info("Loaded " + GameData.getHomeworldDefaultSaveData().size() + " HomeworldDefaultSaveDatas."); Grasscutter.getLogger().debug("Loaded " + GameData.getHomeworldDefaultSaveData().size() + " HomeworldDefaultSaveDatas.");
} }
@SneakyThrows @SneakyThrows
...@@ -434,37 +434,37 @@ public class ResourceLoader { ...@@ -434,37 +434,37 @@ public class ResourceLoader {
GameData.getSceneNpcBornData().put(data.getSceneId(), data); GameData.getSceneNpcBornData().put(data.getSceneId(), data);
} }
Grasscutter.getLogger().info("Loaded " + GameData.getSceneNpcBornData().size() + " SceneNpcBornDatas."); Grasscutter.getLogger().debug("Loaded " + GameData.getSceneNpcBornData().size() + " SceneNpcBornDatas.");
} }
// BinOutput configs // BinOutput configs
public static class AvatarConfig { public static class AvatarConfig {
@SerializedName(value="abilities", alternate={"targetAbilities"}) @SerializedName(value="abilities", alternate={"targetAbilities"})
public ArrayList<AvatarConfigAbility> abilities; public ArrayList<AvatarConfigAbility> abilities;
} }
public static class AvatarConfigAbility { public static class AvatarConfigAbility {
public String abilityName; public String abilityName;
public String toString() { public String toString() {
return abilityName; return abilityName;
} }
} }
private static class OpenConfig { private static class OpenConfig {
public OpenConfigData[] data; public OpenConfigData[] data;
} }
public static class OpenConfigData { public static class OpenConfigData {
public String $type; public String $type;
public String abilityName; public String abilityName;
@SerializedName(value="talentIndex", alternate={"OJOFFKLNAHN"}) @SerializedName(value="talentIndex", alternate={"OJOFFKLNAHN"})
public int talentIndex; public int talentIndex;
@SerializedName(value="skillID", alternate={"overtime"}) @SerializedName(value="skillID", alternate={"overtime"})
public int skillID; public int skillID;
@SerializedName(value="pointDelta", alternate={"IGEBKIHPOIF"}) @SerializedName(value="pointDelta", alternate={"IGEBKIHPOIF"})
public int pointDelta; public int pointDelta;
} }
......
...@@ -52,7 +52,7 @@ public class DungeonChallenge extends WorldChallenge { ...@@ -52,7 +52,7 @@ public class DungeonChallenge extends WorldChallenge {
dungeonDropData.put(entry.getDungeonId(), entry.getDrops()); dungeonDropData.put(entry.getDungeonId(), entry.getDrops());
} }
Grasscutter.getLogger().info("Loaded {} dungeon drop data entries.", dungeonDropData.size()); Grasscutter.getLogger().debug("Loaded {} dungeon drop data entries.", dungeonDropData.size());
} }
catch (Exception ex) { catch (Exception ex) {
Grasscutter.getLogger().error("Unable to load dungeon drop data.", ex); Grasscutter.getLogger().error("Unable to load dungeon drop data.", ex);
...@@ -92,7 +92,7 @@ public class DungeonChallenge extends WorldChallenge { ...@@ -92,7 +92,7 @@ public class DungeonChallenge extends WorldChallenge {
settle(); settle();
} }
} }
private void settle() { private void settle() {
if(!stage){ if(!stage){
getScene().getDungeonSettleObservers().forEach(o -> o.onDungeonSettle(getScene())); getScene().getDungeonSettleObservers().forEach(o -> o.onDungeonSettle(getScene()));
...@@ -100,7 +100,7 @@ public class DungeonChallenge extends WorldChallenge { ...@@ -100,7 +100,7 @@ public class DungeonChallenge extends WorldChallenge {
new ScriptArgs(this.isSuccess() ? 1 : 0)); new ScriptArgs(this.isSuccess() ? 1 : 0));
} }
} }
private List<GameItem> rollRewards(boolean useCondensed) { private List<GameItem> rollRewards(boolean useCondensed) {
List<GameItem> rewards = new ArrayList<>(); List<GameItem> rewards = new ArrayList<>();
int dungeonId = this.getScene().getDungeonData().getId(); int dungeonId = this.getScene().getDungeonData().getId();
...@@ -150,7 +150,7 @@ public class DungeonChallenge extends WorldChallenge { ...@@ -150,7 +150,7 @@ public class DungeonChallenge extends WorldChallenge {
for (ItemParamData param : getScene().getDungeonData().getRewardPreview().getPreviewItems()) { for (ItemParamData param : getScene().getDungeonData().getRewardPreview().getPreviewItems()) {
rewards.add(new GameItem(param.getId(), Math.max(param.getCount(), 1))); rewards.add(new GameItem(param.getId(), Math.max(param.getCount(), 1)));
} }
} }
return rewards; return rewards;
} }
...@@ -162,12 +162,12 @@ public class DungeonChallenge extends WorldChallenge { ...@@ -162,12 +162,12 @@ public class DungeonChallenge extends WorldChallenge {
if (!isSuccess() || dungeonData == null || dungeonData.getRewardPreview() == null || dungeonData.getRewardPreview().getPreviewItems().length == 0) { if (!isSuccess() || dungeonData == null || dungeonData.getRewardPreview() == null || dungeonData.getRewardPreview().getPreviewItems().length == 0) {
return; return;
} }
// Already rewarded // Already rewarded
if (getRewardedPlayers().contains(player.getUid())) { if (getRewardedPlayers().contains(player.getUid())) {
return; return;
} }
// Get rewards. // Get rewards.
List<GameItem> rewards = new ArrayList<>(); List<GameItem> rewards = new ArrayList<>();
...@@ -202,11 +202,11 @@ public class DungeonChallenge extends WorldChallenge { ...@@ -202,11 +202,11 @@ public class DungeonChallenge extends WorldChallenge {
// Roll rewards. // Roll rewards.
rewards.addAll(this.rollRewards(false)); rewards.addAll(this.rollRewards(false));
} }
// Add rewards to player and send notification. // Add rewards to player and send notification.
player.getInventory().addItems(rewards, ActionReason.DungeonStatueDrop); player.getInventory().addItems(rewards, ActionReason.DungeonStatueDrop);
player.sendPacket(new PacketGadgetAutoPickDropInfoNotify(rewards)); player.sendPacket(new PacketGadgetAutoPickDropInfoNotify(rewards));
getRewardedPlayers().add(player.getUid()); getRewardedPlayers().add(player.getUid());
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment