Skip to content

Commit

Permalink
Add warnings in case people are missing resource files
Browse files Browse the repository at this point in the history
  • Loading branch information
Melledy committed Dec 7, 2023
1 parent 6d95f2b commit 9ca364a
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/main/java/emu/lunarcore/data/ResourceLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,17 @@ private static <T> int loadFromResource(Class<T> 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);
Expand All @@ -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.");
}
Expand All @@ -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.");
Expand Down

0 comments on commit 9ca364a

Please sign in to comment.