mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 00:45:34 +00:00
Fix freeze on startup (#2368)
* DON'T load resources in static init!!! * Update src/main/java/emu/grasscutter/Grasscutter.java Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com> * Update src/main/java/emu/grasscutter/tools/Tools.java Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com> --------- Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com>
This commit is contained in:
parent
5f5e6c38b1
commit
fdad4218e7
@ -158,6 +158,8 @@ public final class Grasscutter {
|
||||
|
||||
// Generate handbooks.
|
||||
Tools.createGmHandbooks(false);
|
||||
// Generate gacha mappings.
|
||||
Tools.generateGachaMappings();
|
||||
}
|
||||
|
||||
// Start servers.
|
||||
|
@ -114,8 +114,6 @@ public class DataLoader {
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("An error occurred while trying to check the data folder.", e);
|
||||
}
|
||||
|
||||
generateGachaMappings();
|
||||
}
|
||||
|
||||
private static void checkAndCopyData(String name) {
|
||||
@ -131,16 +129,4 @@ public class DataLoader {
|
||||
FileUtils.copyResource("/defaults/data/" + name, filePath.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static void generateGachaMappings() {
|
||||
var path = GachaHandler.getGachaMappingsPath();
|
||||
if (!Files.exists(path)) {
|
||||
try {
|
||||
Grasscutter.getLogger().debug("Creating default '" + path + "' data");
|
||||
Tools.createGachaMappings(path);
|
||||
} catch (Exception exception) {
|
||||
Grasscutter.getLogger().warn("Failed to create gacha mappings. \n" + exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import emu.grasscutter.data.common.ItemUseData;
|
||||
import emu.grasscutter.data.excels.*;
|
||||
import emu.grasscutter.data.excels.achievement.AchievementData;
|
||||
import emu.grasscutter.data.excels.avatar.AvatarData;
|
||||
import emu.grasscutter.server.http.handlers.GachaHandler;
|
||||
import emu.grasscutter.utils.*;
|
||||
import emu.grasscutter.utils.lang.Language;
|
||||
import emu.grasscutter.utils.lang.Language.TextStrings;
|
||||
@ -311,8 +312,19 @@ public final class Tools {
|
||||
return sbs.stream().map(StringBuilder::toString).toList();
|
||||
}
|
||||
|
||||
public static void generateGachaMappings() {
|
||||
var path = GachaHandler.getGachaMappingsPath();
|
||||
if (!Files.exists(path)) {
|
||||
try {
|
||||
Grasscutter.getLogger().debug("Creating default '" + path + "' data");
|
||||
Tools.createGachaMappings(path);
|
||||
} catch (Exception exception) {
|
||||
Grasscutter.getLogger().warn("Failed to create gacha mappings. \n" + exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void createGachaMappings(Path location) throws IOException {
|
||||
ResourceLoader.loadResources();
|
||||
List<String> jsons = createGachaMappingJsons();
|
||||
var usedLocales = new HashSet<String>();
|
||||
StringBuilder sb = new StringBuilder("mappings = {\n");
|
||||
|
Loading…
Reference in New Issue
Block a user