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