From 2efabc73e6a3ba9e50d0f456100600af5f9b43ca Mon Sep 17 00:00:00 2001 From: Melledy <121644117+Melledy@users.noreply.github.com> Date: Thu, 23 Nov 2023 18:59:32 -0800 Subject: [PATCH] Allow handbook generation in other languages --- README.md | 19 ++++++++++--------- src/main/java/emu/lunarcore/Config.java | 1 + .../java/emu/lunarcore/util/Handbook.java | 9 +++++---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 7064c08..387338e 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ A game server reimplementation for version 1.5.0 of a certain turn based anime g - Npc shops handled - Gacha system - Mail system +- Friend system (Assists are not working yet) - Forgotten hall (with 1.4.0 features) - Simulated universe (Runs can be finished, but many features are missing) @@ -52,17 +53,17 @@ class Handlers Server commands can be run in the server console or in-game. There is a dummy user named "Server" in every player's friends list that you can message to use in-game commands. ``` -/mail [content]. Sends the targeted player a system mail. -/avatar lv(level) p(ascension) r(eidolon) s(skill levels). Sets the current avatar's properties -/giveall {materials | avatars}. Gives the targeted player items. /account {create | delete} [username] (reserved player uid). Creates or deletes an account. -/unstuck @[player id]. Unstucks an offline player if theyre in a scene that doesnt load. -/gender {male | female}. Sets the player gender. -/spawn [monster/prop id] x[amount] s[stage id]. Spawns a monster or prop near the targeted player. -/give [item id] x[amount]. Gives the targetted player an item. -/permission {add | remove | clear} [permission]. Gives/removes a permission from the targeted player. +/avatar lv(level) p(ascension) r(eidolon) s(skill levels). Sets the current avatar's properties /clear {relics | lightcones | materials | items}. Removes filtered items from the player inventory. -/worldlevel [world level]. Sets the targeted player's equilibrium level. +/gender {male | female}. Sets the player gender. +/give [item id] x[amount]. Gives the targetted player an item. +/giveall {materials | avatars}. Gives the targeted player items. +/mail [content]. Sends the targeted player a system mail. +/permission {add | remove | clear} [permission]. Gives/removes a permission from the targeted player. /reload. Reloads the server config. /scene [scene id] [floor id]. Teleports the player to the specified scene. +/spawn [monster/prop id] x[amount] s[stage id]. Spawns a monster or prop near the targeted player. +/unstuck @[player id]. Unstucks an offline player if theyre in a scene that doesnt load. +/worldlevel [world level]. Sets the targeted player's equilibrium level. ``` \ No newline at end of file diff --git a/src/main/java/emu/lunarcore/Config.java b/src/main/java/emu/lunarcore/Config.java index 6d5a454..3e2ef22 100644 --- a/src/main/java/emu/lunarcore/Config.java +++ b/src/main/java/emu/lunarcore/Config.java @@ -89,6 +89,7 @@ public class Config { public boolean unlockAllChallenges = true; public int staminaRecoveryRate = 5 * 60; public int staminaReserveRecoveryRate = 18 * 60; + public String language = "EN"; public Set defaultPermissions = Set.of("*"); public int getStaminaRecoveryRate() { diff --git a/src/main/java/emu/lunarcore/util/Handbook.java b/src/main/java/emu/lunarcore/util/Handbook.java index 3657204..3a0a850 100644 --- a/src/main/java/emu/lunarcore/util/Handbook.java +++ b/src/main/java/emu/lunarcore/util/Handbook.java @@ -22,9 +22,10 @@ public class Handbook { // Load text map Map textMap = null; List list = null; + String language = LunarCore.getConfig().getServerOptions().language; try { - textMap = JsonUtils.loadToMap(LunarCore.getConfig().getResourceDir() + "/TextMap/TextMapEN.json", Long.class, String.class); + textMap = JsonUtils.loadToMap(LunarCore.getConfig().getResourceDir() + "/TextMap/TextMap" + language + ".json", Long.class, String.class); } catch (Exception e) { e.printStackTrace(); return; @@ -45,9 +46,9 @@ public class Handbook { // Dump commands writer.println(System.lineSeparator()); writer.println("# Commands"); - list = GameData.getAvatarExcelMap().keySet().intStream().sorted().boxed().toList(); - for (var entry : LunarCore.getCommandManager().getLabels().entrySet()) { - Command command = entry.getValue().getClass().getAnnotation(Command.class); + var labels = LunarCore.getCommandManager().getLabels().keySet().stream().sorted().toList(); + for (var label : labels) { + Command command = LunarCore.getCommandManager().getLabels().get(label).getClass().getAnnotation(Command.class); if (command == null) continue; writer.println(command.desc());