From 668461a6f1cab2de0a0bce6d5da24c5d3ac5ec49 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Fri, 30 Dec 2022 20:31:27 -0500 Subject: [PATCH] Clean-Up Startup Sequence hey i like it clean ok.. dont judge.. --- .../java/emu/grasscutter/Grasscutter.java | 2 +- .../java/emu/grasscutter/data/DataLoader.java | 2 +- .../java/emu/grasscutter/tools/Tools.java | 19 ++++++++++++++++--- .../java/emu/grasscutter/utils/Language.java | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/java/emu/grasscutter/Grasscutter.java b/src/main/java/emu/grasscutter/Grasscutter.java index 6b6761d3b..49b6a9476 100644 --- a/src/main/java/emu/grasscutter/Grasscutter.java +++ b/src/main/java/emu/grasscutter/Grasscutter.java @@ -112,7 +112,7 @@ public final class Grasscutter { ScriptLoader.init(); // Generate handbooks. - Tools.createGmHandbooks(); + Tools.createGmHandbooks(false); // Initialize database. DatabaseManager.initialize(); diff --git a/src/main/java/emu/grasscutter/data/DataLoader.java b/src/main/java/emu/grasscutter/data/DataLoader.java index f40337dce..8b2b6b511 100644 --- a/src/main/java/emu/grasscutter/data/DataLoader.java +++ b/src/main/java/emu/grasscutter/data/DataLoader.java @@ -92,7 +92,7 @@ public class DataLoader { public static List loadTableToList(String resourcePath, Class classType) throws IOException { 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)) { case "json" -> JsonUtils.loadToList(path, classType); case "tsj" -> TsvUtils.loadTsjToListSetField(path, classType); diff --git a/src/main/java/emu/grasscutter/tools/Tools.java b/src/main/java/emu/grasscutter/tools/Tools.java index 4941e9197..9f0745ccf 100644 --- a/src/main/java/emu/grasscutter/tools/Tools.java +++ b/src/main/java/emu/grasscutter/tools/Tools.java @@ -30,12 +30,24 @@ import it.unimi.dsi.fastutil.ints.Int2IntRBTreeMap; import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap; import lombok.val; -import static emu.grasscutter.config.Configuration.*; import static emu.grasscutter.utils.FileUtils.getResourcePath; import static emu.grasscutter.utils.Language.getTextMapKey; 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 { + 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(); ResourceLoader.loadAll(); @@ -48,7 +60,7 @@ public final class Tools { val sceneDataMap = new Int2ObjectRBTreeMap<>(GameData.getSceneDataMap()); val questDataMap = new Int2ObjectRBTreeMap<>(GameData.getQuestDataMap()); - Function getPad = m -> "%" + m.lastKey().toString().length() + "s : "; + Function, String> getPad = m -> "%" + m.lastKey().toString().length() + "s : "; // Create builders and helper functions val handbookBuilders = IntStream.range(0, TextStrings.NUM_LANGUAGES).mapToObj(i -> new StringBuilder()).toList(); @@ -143,7 +155,8 @@ public final class Tools { writer.write(handbookBuilders.get(i).toString()); } } - Grasscutter.getLogger().info("GM Handbooks generated!"); + + if (message) Grasscutter.getLogger().info("GM Handbooks generated!"); } public static List createGachaMappingJsons() { diff --git a/src/main/java/emu/grasscutter/utils/Language.java b/src/main/java/emu/grasscutter/utils/Language.java index 07d9c6a5b..8b3ad253a 100644 --- a/src/main/java/emu/grasscutter/utils/Language.java +++ b/src/main/java/emu/grasscutter/utils/Language.java @@ -417,7 +417,7 @@ public final class Language { Grasscutter.getLogger().debug("Cache modified %d, textmap modified %d".formatted(cacheModified, textmapsModified)); if (textmapsModified < cacheModified) { // Try loading from cache - Grasscutter.getLogger().info("Loading cached TextMaps"); + Grasscutter.getLogger().info("Loading cached 'TextMaps'..."); textMapStrings = loadTextMapsCache(); return; }