Fix minor config reloading issues

This commit is contained in:
dfsek 2020-10-07 12:43:39 -07:00
parent 94ec66a593
commit d2c8e862e7
4 changed files with 6 additions and 6 deletions

View File

@ -102,7 +102,7 @@ public class ConfigPack extends YamlConfiguration {
biomeList = getStringList("grids");
configs.put(id, this);
LangUtil.log("config-pack.load", Level.INFO, getID(), String.valueOf((System.nanoTime() - l)/1000000D));
LangUtil.log("config-pack.loaded", Level.INFO, getID(), String.valueOf((System.nanoTime() - l)/1000000D));
}
public Map<String, AbstractBiomeConfig> getAbstractBiomes() {

View File

@ -22,6 +22,7 @@ public final class ConfigUtil {
public static boolean masterDisableCaves;
public static void loadConfig(JavaPlugin main) {
main.saveDefaultConfig();
main.reloadConfig();
FileConfiguration config = main.getConfig();
LangUtil.load(config.getString("language", "en_us"), main);

View File

@ -68,7 +68,7 @@ public class WorldConfig {
fromImage = false;
}
}
} catch(IllegalArgumentException e) {
} catch(IllegalArgumentException | NullPointerException e) {
throw new InvalidConfigurationException(e.getCause());
}
Bukkit.getLogger().info("Loaded " + tConfig.biomeList.size() + " BiomeGrids from list.");

View File

@ -6,9 +6,7 @@ import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Language extends YamlConfiguration {
public Language(File file) throws IOException, InvalidConfigurationException {
@ -18,13 +16,14 @@ public class Language extends YamlConfiguration {
public void load(@NotNull File file) throws IOException, InvalidConfigurationException {
super.load(file);
}
@SuppressWarnings("unchecked")
public Message getMessage(String id) {
Object m = get(id);
Message temp;
if(m instanceof List) {
temp = new MultiLineMessage(getStringList(id));
temp = new MultiLineMessage((List<String>) m);
} else if(m instanceof String) {
temp = new SingleLineMessage(getString(id));
temp = new SingleLineMessage((String) m);
} else return new SingleLineMessage("message:" + id + ":translation_undefined");
if(temp.isEmpty()) return new SingleLineMessage("message:" + id + ":translation_undefined");
return temp;