當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。