Add warnings in case people are missing resource files

This commit is contained in:
Melledy
2023-12-06 21:42:51 -08:00
parent 6d95f2b641
commit 9ca364a19e

View File

@@ -169,18 +169,17 @@ public class ResourceLoader {
// Might be better to cache // Might be better to cache
private static void loadFloorInfos() { private static void loadFloorInfos() {
//
LunarCore.getLogger().info("Loading floor infos... this may take a while.");
// Load floor infos // Load floor infos
LunarCore.getLogger().info("Loading floor infos... this may take a while.");
File floorDir = new File(LunarCore.getConfig().getResourceDir() + "/Config/LevelOutput/Floor/"); File floorDir = new File(LunarCore.getConfig().getResourceDir() + "/Config/LevelOutput/Floor/");
boolean missingGroupInfos = false;
if (!floorDir.exists()) { 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; return;
} }
// Dump // Load floor infos
for (File file : floorDir.listFiles()) { for (File file : floorDir.listFiles()) {
try (FileReader reader = new FileReader(file)) { try (FileReader reader = new FileReader(file)) {
FloorInfo floor = gson.fromJson(reader, FloorInfo.class); FloorInfo floor = gson.fromJson(reader, FloorInfo.class);
@@ -195,25 +194,33 @@ public class ResourceLoader {
for (FloorInfo floor : GameData.getFloorInfos().values()) { for (FloorInfo floor : GameData.getFloorInfos().values()) {
for (FloorGroupSimpleInfo simpleGroup : floor.getSimpleGroupList()) { for (FloorGroupSimpleInfo simpleGroup : floor.getSimpleGroupList()) {
File file = new File(LunarCore.getConfig().getResourceDir() + "/" + simpleGroup.getGroupPath()); File file = new File(LunarCore.getConfig().getResourceDir() + "/" + simpleGroup.getGroupPath());
if (!file.exists()) continue;
if (!file.exists()) {
continue;
}
// TODO optimize // TODO optimize
try (FileReader reader = new FileReader(file)) { try (FileReader reader = new FileReader(file)) {
GroupInfo group = gson.fromJson(reader, GroupInfo.class); GroupInfo group = gson.fromJson(reader, GroupInfo.class);
group.setId(simpleGroup.getID()); group.setId(simpleGroup.getID());
floor.getGroups().put(simpleGroup.getID(), group); floor.getGroups().put(simpleGroup.getID(), group);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
// Check if we are missing group infos
if (floor.getGroups().size() == 0) {
missingGroupInfos = true;
}
// Post load callback to cache floor info // Post load callback to cache floor info
floor.onLoad(); 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 // Done
LunarCore.getLogger().info("Loaded " + GameData.getFloorInfos().size() + " floor infos."); LunarCore.getLogger().info("Loaded " + GameData.getFloorInfos().size() + " floor infos.");
} }
@@ -237,6 +244,11 @@ public class ResourceLoader {
e.printStackTrace(); 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 // Done
LunarCore.getLogger().info("Loaded " + count + " maze abilities for avatars."); LunarCore.getLogger().info("Loaded " + count + " maze abilities for avatars.");