1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 22:13:25 +01:00
Jobs/com/gamingmesh/jobs/container/LocaleReader.java

76 lines
1.8 KiB
Java
Raw Normal View History

2016-03-30 15:42:36 +02:00
package com.gamingmesh.jobs.container;
import java.util.List;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.ChatColor;
import com.gamingmesh.jobs.config.CommentedYamlConfiguration;
public class LocaleReader {
YamlConfiguration config;
CommentedYamlConfiguration writer;
public LocaleReader(YamlConfiguration config, CommentedYamlConfiguration writer) {
this.config = config;
this.writer = writer;
}
public CommentedYamlConfiguration getW() {
return writer;
}
public YamlConfiguration getC() {
return config;
}
public Boolean get(String path, Boolean boo) {
config.addDefault(path, boo);
copySetting(path);
return config.getBoolean(path);
}
public int get(String path, int boo) {
config.addDefault(path, boo);
copySetting(path);
return config.getInt(path);
}
public List<Integer> getIntList(String path, List<Integer> list) {
config.addDefault(path, list);
copySetting(path);
return config.getIntegerList(path);
}
public List<String> getStringList(String path, List<String> list) {
config.addDefault(path, list);
copySetting(path);
return config.getStringList(path);
}
public String get(String path, String boo) {
config.addDefault(path, boo);
copySetting(path);
return get(path, boo, true);
}
public String get(String path, String boo, boolean colorize) {
config.addDefault(path, boo);
copySetting(path);
if (colorize)
return ChatColor.translateAlternateColorCodes('&', config.getString(path));
else
return config.getString(path);
}
public Double get(String path, Double boo) {
config.addDefault(path, boo);
copySetting(path);
return config.getDouble(path);
}
public synchronized void copySetting(String path) {
writer.set(path, config.get(path));
}
}