Allow handbook generation in other languages

This commit is contained in:
Melledy
2023-11-23 18:59:32 -08:00
parent 502323a1c7
commit 2efabc73e6
3 changed files with 16 additions and 13 deletions

View File

@@ -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<String> defaultPermissions = Set.of("*");
public int getStaminaRecoveryRate() {

View File

@@ -22,9 +22,10 @@ public class Handbook {
// Load text map
Map<Long, String> textMap = null;
List<Integer> 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());