Java Code Examples for cn.nukkit.utils.Config#YAML

The following examples show how to use cn.nukkit.utils.Config#YAML . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Item.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private static void initCreativeItems() {
    clearCreativeItems();

    Config config = new Config(Config.YAML);
    config.load(Server.class.getClassLoader().getResourceAsStream("creativeitems.json"));
    List<Map> list = config.getMapList("items");

    for (Map map : list) {
        try {
            addCreativeItem(fromJson(map));
        } catch (Exception e) {
            MainLogger.getLogger().logException(e);
        }
    }
}
 
Example 2
Source File: YamlProvider.java    From EconomyAPI with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "serial" })
public void init(File path){
	file = new Config(new File(path, "Money.yml"), Config.YAML, new LinkedHashMap<String, Object>(){
		{
			put("version" , 2);
			put("money", new LinkedHashMap<String, Double>());
		}
	});
	
	LinkedHashMap<Object, Object> temp = (LinkedHashMap<Object, Object>) file.get("money");
	
	data = new LinkedHashMap<>();
	temp.forEach((key, money) -> {
		String username = key.toString();
		
		if(money instanceof Integer){
			data.put(username, ((Integer) money).doubleValue());
		}else if(money instanceof Double){
			data.put(username, (Double) money);
		}else if(money instanceof String){
			data.put(username, Double.parseDouble(money.toString()));
		}
	});
}
 
Example 3
Source File: YamlProvider.java    From EconomyAPI with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "serial" })
public void init(File path){
	file = new Config(new File(path, "Money.yml"), Config.YAML, new LinkedHashMap<String, Object>(){
		{
			put("version" , 2);
			put("money", new LinkedHashMap<String, Double>());
		}
	});
	
	LinkedHashMap<Object, Object> temp = (LinkedHashMap<Object, Object>) file.get("money");
	
	data = new LinkedHashMap<>();
	temp.forEach((key, money) -> {
		String username = key.toString();
		
		if(money instanceof Integer){
			data.put(username, ((Integer) money).doubleValue());
		}else if(money instanceof Double){
			data.put(username, (Double) money);
		}else if(money instanceof String){
			data.put(username, Double.parseDouble(money.toString()));
		}
	});
}
 
Example 4
Source File: EssentialsAPI.java    From EssentialsNK with GNU General Public License v3.0 5 votes vote down vote up
public EssentialsAPI(EssentialsNK plugin) {
    instance = this;
    this.plugin = plugin;
    this.homeConfig = new Config(new File(plugin.getDataFolder(), "home.yml"), Config.YAML);
    this.warpConfig = new Config(new File(plugin.getDataFolder(), "warp.yml"), Config.YAML);
    this.muteConfig = new Config(new File(plugin.getDataFolder(), "mute.yml"), Config.YAML);
}
 
Example 5
Source File: NukkitConfigAdapter.java    From LuckPerms with MIT License 4 votes vote down vote up
@Override
public void reload() {
    this.configuration = new Config(this.file, Config.YAML);
}