otterlib language system

This commit is contained in:
Oth3r 2025-06-16 20:36:32 -05:00
commit 85cc76a022
9 changed files with 69 additions and 172 deletions

View file

@ -1,9 +1,15 @@
package one.oth3r.sit.file;
import net.minecraft.server.network.ServerPlayerEntity;
import one.oth3r.otterlib.file.LanguageReader;
import one.oth3r.sit.Sit;
import one.oth3r.sit.utl.Data;
import one.oth3r.sit.utl.Utl;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@ -56,11 +62,21 @@ public class FileData {
return playerSettings.getOrDefault(player, sittingConfig);
}
/// the language / text system for the mod
private static final LanguageReader langReader = new LanguageReader(
getLangPath(),Path.of(Data.CONFIG_DIR),"en_us","en_us");
public static LanguageReader getLangReader() {
return langReader;
}
/**
* loads all config files to memory
*/
public static void loadFiles() {
getServerConfig().load();
// load the language reader
langReader.updateLanguage(getServerConfig().getLang());
getSittingConfig().load();
// if loading file and is on supported server on client, send the new settings over
@ -77,6 +93,20 @@ public class FileData {
getServerConfig().save();
}
private static Path getLangPath() {
ClassLoader classLoader = Sit.class.getClassLoader();
URL resource = classLoader.getResource("assets/sit-oth3r/lang/");
if (resource == null) {
throw new RuntimeException("Language file not found.");
}
try {
return Paths.get(resource.toURI());
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
public static class Defaults {
public static final ArrayList<SittingBlock> SITTING_BLOCKS = new ArrayList<>(Arrays.asList(
new SittingBlock(new ArrayList<>(),new ArrayList<>(Arrays.asList("#minecraft:campfires")), new ArrayList<>(Arrays.asList("lit=false")),.437),