Unverified Commit 668461a6 authored by KingRainbow44's avatar KingRainbow44
Browse files

Clean-Up Startup Sequence

hey i like it clean ok.. dont judge..
parent fe80290b
...@@ -112,7 +112,7 @@ public final class Grasscutter { ...@@ -112,7 +112,7 @@ public final class Grasscutter {
ScriptLoader.init(); ScriptLoader.init();
// Generate handbooks. // Generate handbooks.
Tools.createGmHandbooks(); Tools.createGmHandbooks(false);
// Initialize database. // Initialize database.
DatabaseManager.initialize(); DatabaseManager.initialize();
......
...@@ -92,7 +92,7 @@ public class DataLoader { ...@@ -92,7 +92,7 @@ public class DataLoader {
public static <T> List<T> loadTableToList(String resourcePath, Class<T> classType) throws IOException { public static <T> List<T> loadTableToList(String resourcePath, Class<T> classType) throws IOException {
val path = FileUtils.getDataPathTsjJsonTsv(resourcePath); val path = FileUtils.getDataPathTsjJsonTsv(resourcePath);
Grasscutter.getLogger().info("Loading data table from: "+path); Grasscutter.getLogger().debug("Loading data table from: "+path);
return switch (FileUtils.getFileExtension(path)) { return switch (FileUtils.getFileExtension(path)) {
case "json" -> JsonUtils.loadToList(path, classType); case "json" -> JsonUtils.loadToList(path, classType);
case "tsj" -> TsvUtils.loadTsjToListSetField(path, classType); case "tsj" -> TsvUtils.loadTsjToListSetField(path, classType);
......
...@@ -30,12 +30,24 @@ import it.unimi.dsi.fastutil.ints.Int2IntRBTreeMap; ...@@ -30,12 +30,24 @@ import it.unimi.dsi.fastutil.ints.Int2IntRBTreeMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap; import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap;
import lombok.val; import lombok.val;
import static emu.grasscutter.config.Configuration.*;
import static emu.grasscutter.utils.FileUtils.getResourcePath; import static emu.grasscutter.utils.FileUtils.getResourcePath;
import static emu.grasscutter.utils.Language.getTextMapKey; import static emu.grasscutter.utils.Language.getTextMapKey;
public final class Tools { public final class Tools {
/**
* This generates the GM handbooks with a message by default.
* @throws Exception If an error occurs while generating the handbooks.
*/
public static void createGmHandbooks() throws Exception { public static void createGmHandbooks() throws Exception {
Tools.createGmHandbooks(true);
}
/**
* Generates a GM handbook for each language.
* @param message Should a message be printed to the console?
* @throws Exception If an error occurs while generating the handbooks.
*/
public static void createGmHandbooks(boolean message) throws Exception {
val languages = Language.TextStrings.getLanguages(); val languages = Language.TextStrings.getLanguages();
ResourceLoader.loadAll(); ResourceLoader.loadAll();
...@@ -48,7 +60,7 @@ public final class Tools { ...@@ -48,7 +60,7 @@ public final class Tools {
val sceneDataMap = new Int2ObjectRBTreeMap<>(GameData.getSceneDataMap()); val sceneDataMap = new Int2ObjectRBTreeMap<>(GameData.getSceneDataMap());
val questDataMap = new Int2ObjectRBTreeMap<>(GameData.getQuestDataMap()); val questDataMap = new Int2ObjectRBTreeMap<>(GameData.getQuestDataMap());
Function<SortedMap, String> getPad = m -> "%" + m.lastKey().toString().length() + "s : "; Function<SortedMap<?, ?>, String> getPad = m -> "%" + m.lastKey().toString().length() + "s : ";
// Create builders and helper functions // Create builders and helper functions
val handbookBuilders = IntStream.range(0, TextStrings.NUM_LANGUAGES).mapToObj(i -> new StringBuilder()).toList(); val handbookBuilders = IntStream.range(0, TextStrings.NUM_LANGUAGES).mapToObj(i -> new StringBuilder()).toList();
...@@ -143,7 +155,8 @@ public final class Tools { ...@@ -143,7 +155,8 @@ public final class Tools {
writer.write(handbookBuilders.get(i).toString()); writer.write(handbookBuilders.get(i).toString());
} }
} }
Grasscutter.getLogger().info("GM Handbooks generated!");
if (message) Grasscutter.getLogger().info("GM Handbooks generated!");
} }
public static List<String> createGachaMappingJsons() { public static List<String> createGachaMappingJsons() {
......
...@@ -417,7 +417,7 @@ public final class Language { ...@@ -417,7 +417,7 @@ public final class Language {
Grasscutter.getLogger().debug("Cache modified %d, textmap modified %d".formatted(cacheModified, textmapsModified)); Grasscutter.getLogger().debug("Cache modified %d, textmap modified %d".formatted(cacheModified, textmapsModified));
if (textmapsModified < cacheModified) { if (textmapsModified < cacheModified) {
// Try loading from cache // Try loading from cache
Grasscutter.getLogger().info("Loading cached TextMaps"); Grasscutter.getLogger().info("Loading cached 'TextMaps'...");
textMapStrings = loadTextMapsCache(); textMapStrings = loadTextMapsCache();
return; return;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment