当前位置: 首页>>代码示例>>Java>>正文


Java FileConfiguration.load方法代码示例

本文整理汇总了Java中org.bukkit.configuration.file.FileConfiguration.load方法的典型用法代码示例。如果您正苦于以下问题:Java FileConfiguration.load方法的具体用法?Java FileConfiguration.load怎么用?Java FileConfiguration.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.configuration.file.FileConfiguration的用法示例。


在下文中一共展示了FileConfiguration.load方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: load

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
private void load(JavaPlugin plugin) {
    try {
        final FileConfiguration configuration = new YamlConfiguration();
        final File file = new File(plugin.getDataFolder(), "bungeecord_signs.yml");
        if (!file.exists()) {
            if (!file.createNewFile()) {
                Bukkit.getLogger().log(Level.WARNING, "File cannot get created.");
            }
        }
        configuration.load(file);
        if (configuration.getConfigurationSection("signs") != null) {
            final Map<String, Object> data = configuration.getConfigurationSection("signs").getValues(false);
            for (final String s : data.keySet()) {
                this.signs.add(new BungeeCordSignInfo.Container(((ConfigurationSection) data.get(s)).getValues(true)));
            }
        }
    } catch (IOException | InvalidConfigurationException e) {
        Bukkit.getLogger().log(Level.WARNING, "Save load location.", e);
    }
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:21,代码来源:BungeeCordController.java

示例2: save

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
void save(Arena item) {
    if (item != null && item.getName() != null) {
        try {
            final FileConfiguration configuration = new YamlConfiguration();
            final File file = new File(this.getFolder(), "arena_" + item.getName() + ".yml");
            if (file.exists()) {
                if (!file.delete())
                    throw new IllegalStateException("Cannot delete file!");
            }
            if (!file.createNewFile())
                throw new IllegalStateException("Cannot create file!");
            configuration.load(file);
            final Map<String, Object> data = item.serialize();
            for (final String key : data.keySet()) {
                configuration.set("arena." + key, data.get(key));
            }
            configuration.save(file);
        } catch (IOException | InvalidConfigurationException ex) {
            Bukkit.getLogger().log(Level.WARNING,"Cannot save arena." ,ex.getMessage());
        }
    }
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:23,代码来源:ArenaFileManager.java

示例3: load

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
Arena[] load() {
    final List<Arena> items = new ArrayList<>();
    for (int i = 0; (this.getFolder() != null) && (i < this.getFolder().list().length); i++) {
        final String s = this.getFolder().list()[i];
        try {
            if (s.contains("arena_")) {
                final FileConfiguration configuration = new YamlConfiguration();
                final File file = new File(this.getFolder(), s);
                configuration.load(file);
                final Map<String, Object> data = configuration.getConfigurationSection("arena").getValues(true);
                final Arena arenaEntity = new ArenaEntity(data, configuration.getStringList("arena.properties.wall-bouncing"));
                items.add(arenaEntity);
            }
        } catch (final Exception ex) {
            Bukkit.getLogger().log(Level.WARNING, "Cannot read arena file " + s + '.', ex);
        }
    }
    return items.toArray(new Arena[items.size()]);
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:20,代码来源:ArenaFileManager.java

示例4: loadConfig

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
private void loadConfig() {
    FileConfiguration config = new YamlConfiguration();
    try {
        config.load(new File(getDataFolder(), "config.yml"));
        config.options().copyDefaults(true);

        String user = config.getString("jdbc-username", "root");
        String password = config.getString("jdbc-password", "password");
        String jdbcUrl = config.getString("jdbc-url", "jdbc:mysql://localhost:3306/minecraft");

        databaseManager = new DatabaseManager(jdbcUrl, user, password);
        databaseManager.connect();

        ConfigurationSection definitions = config.getConfigurationSection("definitions");
        for (String definitionKey : definitions.getKeys(false)) {
            ConfigurationSection definition = definitions.getConfigurationSection(definitionKey);

            int priority = definition.getInt("priority", 1);
            ImageType type = ImageType.valueOf(definition.getString("type", ImageType.OVERLAY.name()));
            String permission = definition.getString("permission");
            List<String> images = definition.getStringList("images");

            SpigotImageDetails imageDetails = new SpigotImageDetails(priority, type, permission, images);
            imageHandler.addImage(imageDetails);
        }

        config.save(new File(getDataFolder(), "config.yml"));
    } catch (IOException | InvalidConfigurationException e) {
        e.printStackTrace();
    }
}
 
开发者ID:me4502,项目名称:AdvancedServerListIcons,代码行数:32,代码来源:AdvancedServerListIconsSpigot.java

示例5: getConfig

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public FileConfiguration getConfig(){
	FileConfiguration config = new YamlConfiguration();
	File userFile = new File(mainFolder, "AllowedUsers.yml");
	if(userFile.exists()){
		try {
			config.load(userFile);
		} catch (IOException | InvalidConfigurationException e) {
			e.printStackTrace();
			config.set("Data", allowedUsers);
		}
	}
	return config;		
}
 
开发者ID:Kitt3120,项目名称:ViperBot,代码行数:14,代码来源:DDoSManager.java


注:本文中的org.bukkit.configuration.file.FileConfiguration.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。