From 9ca364a19ed7ea3b182b95b3fd9c8ce430c1aa68 Mon Sep 17 00:00:00 2001 From: Melledy <121644117+Melledy@users.noreply.github.com> Date: Wed, 6 Dec 2023 21:42:51 -0800 Subject: [PATCH] Add warnings in case people are missing resource files --- .../emu/lunarcore/data/ResourceLoader.java | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/main/java/emu/lunarcore/data/ResourceLoader.java b/src/main/java/emu/lunarcore/data/ResourceLoader.java index ea7e19bd3..85895704f 100644 --- a/src/main/java/emu/lunarcore/data/ResourceLoader.java +++ b/src/main/java/emu/lunarcore/data/ResourceLoader.java @@ -169,18 +169,17 @@ private static int loadFromResource(Class c, ResourceType type, String fi // Might be better to cache private static void loadFloorInfos() { - // - LunarCore.getLogger().info("Loading floor infos... this may take a while."); - // Load floor infos + LunarCore.getLogger().info("Loading floor infos... this may take a while."); File floorDir = new File(LunarCore.getConfig().getResourceDir() + "/Config/LevelOutput/Floor/"); + boolean missingGroupInfos = false; if (!floorDir.exists()) { - LunarCore.getLogger().warn("Floor infos are missing, please check your resources."); + LunarCore.getLogger().warn("Floor infos are missing, please check your resources folder: {resources}/Config/Level/Floor. Teleports and natural world spawns may not work!"); return; } - // Dump + // Load floor infos for (File file : floorDir.listFiles()) { try (FileReader reader = new FileReader(file)) { FloorInfo floor = gson.fromJson(reader, FloorInfo.class); @@ -195,25 +194,33 @@ private static void loadFloorInfos() { for (FloorInfo floor : GameData.getFloorInfos().values()) { for (FloorGroupSimpleInfo simpleGroup : floor.getSimpleGroupList()) { File file = new File(LunarCore.getConfig().getResourceDir() + "/" + simpleGroup.getGroupPath()); - - if (!file.exists()) { - continue; - } + if (!file.exists()) continue; // TODO optimize try (FileReader reader = new FileReader(file)) { GroupInfo group = gson.fromJson(reader, GroupInfo.class); group.setId(simpleGroup.getID()); + floor.getGroups().put(simpleGroup.getID(), group); } catch (Exception e) { e.printStackTrace(); } } + + // Check if we are missing group infos + if (floor.getGroups().size() == 0) { + missingGroupInfos = true; + } // Post load callback to cache floor info floor.onLoad(); } - + + // Notify the server owner if we are missing any files + if (missingGroupInfos) { + LunarCore.getLogger().warn("Group infos are missing, please check your resources folder: {resources}/Config/Level/Group. Teleports and natural world spawns may not work!"); + } + // Done LunarCore.getLogger().info("Loaded " + GameData.getFloorInfos().size() + " floor infos."); } @@ -237,6 +244,11 @@ private static void loadMazeAbilities() { e.printStackTrace(); } } + + // Notify the server owner if we are missing any files + if (count < GameData.getAvatarExcelMap().size()) { + LunarCore.getLogger().warn("Maze abilities are missing, please check your resources folder: {resources}/Config/ConfigAdventureAbility/LocalPlayer. Character techniques may not work!"); + } // Done LunarCore.getLogger().info("Loaded " + count + " maze abilities for avatars.");