mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-05 23:36:06 +00:00
Successful default config load in Fabric
This commit is contained in:
@@ -1,31 +1,34 @@
|
||||
package com.dfsek.terra.api.gaea.lang;
|
||||
|
||||
|
||||
import com.dfsek.tectonic.config.Configuration;
|
||||
import com.dfsek.terra.api.generic.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Language {
|
||||
private final Configuration configuration;
|
||||
public Language(File file) throws IOException {
|
||||
load(file);
|
||||
}
|
||||
public void load(@NotNull File file) throws IOException {
|
||||
configuration = new Configuration(new FileInputStream(file));
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public Message getMessage(String id) {
|
||||
Object m = null;
|
||||
Message temp;
|
||||
if(m instanceof List) {
|
||||
temp = new MultiLineMessage((List<String>) m);
|
||||
} else if(m instanceof String) {
|
||||
temp = new SingleLineMessage((String) m);
|
||||
} else return new SingleLineMessage("message:" + id + ":translation_undefined");
|
||||
if(temp.isEmpty()) return new SingleLineMessage("message:" + id + ":translation_undefined");
|
||||
Message temp = null;
|
||||
if(configuration.contains(id)) {
|
||||
Object m = configuration.get(id);
|
||||
|
||||
if(m instanceof List) {
|
||||
temp = new MultiLineMessage((List<String>) m);
|
||||
} else if(m instanceof String) {
|
||||
temp = new SingleLineMessage((String) m);
|
||||
} else return new SingleLineMessage("message:" + id + ":translation_undefined");
|
||||
}
|
||||
if(temp == null || temp.isEmpty()) return new SingleLineMessage("message:" + id + ":translation_undefined");
|
||||
return temp;
|
||||
}
|
||||
public void log(String messageID, Level level, Logger logger, String... args) {
|
||||
|
||||
@@ -29,7 +29,10 @@ public final class LangUtil {
|
||||
Debug.error("Report this to Terra!");
|
||||
}
|
||||
try {
|
||||
language = new Language(new File(main.getDataFolder(), "lang" + File.separator + langID + ".yml"));
|
||||
File file1 = new File(file, langID + ".yml");
|
||||
logger.info(file1.getAbsolutePath());
|
||||
language = new Language(file1);
|
||||
logger.info("Loaded language " + langID);
|
||||
} catch(IOException e) {
|
||||
logger.severe("Unable to load language: " + langID);
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user