當前位置: 首頁>>代碼示例>>Java>>正文


Java FileConfiguration.getKeys方法代碼示例

本文整理匯總了Java中org.bukkit.configuration.file.FileConfiguration.getKeys方法的典型用法代碼示例。如果您正苦於以下問題:Java FileConfiguration.getKeys方法的具體用法?Java FileConfiguration.getKeys怎麽用?Java FileConfiguration.getKeys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.configuration.file.FileConfiguration的用法示例。


在下文中一共展示了FileConfiguration.getKeys方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadUsers

import org.bukkit.configuration.file.FileConfiguration; //導入方法依賴的package包/類
public void loadUsers(){
	allowedUsers.clear();
	FileConfiguration config = getConfig();
	for(String key : config.getKeys(false)){
		allowedUsers.put(key.replace("_(dot)_", "."), (Date) config.get(key));
	}
	ArrayList<String> toRemove = new ArrayList<>();
	for(Entry<String, Date> ent : allowedUsers.entrySet()){
		if(Calendar.getInstance().getTime().after(ent.getValue())){
			try {
				Core.send(Core.skype.getOrLoadContact(ent.getKey()).getPrivateConversation(), "You DDoS-Attack permission is over");
			} catch (ConnectionException | ChatNotFoundException e) {
				e.printStackTrace();
			}
			toRemove.add(ent.getKey());
		}
	}
	for(String user : toRemove){
		allowedUsers.remove(user);
	}
}
 
開發者ID:Kitt3120,項目名稱:ViperBot,代碼行數:22,代碼來源:DDoSManager.java

示例2: buildFromConfig

import org.bukkit.configuration.file.FileConfiguration; //導入方法依賴的package包/類
private static Object buildFromConfig(FileConfiguration config, Class clazz, Object instance) {
    for (String key : config.getKeys(false)) {
        try {
            Field field = clazz.getField(key);

            field.setAccessible(true);
            fieldSet(field, config, instance, key);
        } catch (NoSuchFieldException ignored) {
            Logger.log(Level.FINER, "A key in YAML was not found in the class it is being rebuilt to.");
        } catch (IllegalAccessException e) {
            Logger.err("Couldn't access a field when rebuilding a config!");
        }
    }

    return instance;
}
 
開發者ID:CyR1en,項目名稱:Minecordbot,代碼行數:17,代碼來源:ConfigurationBuilder.java

示例3: updateConfig

import org.bukkit.configuration.file.FileConfiguration; //導入方法依賴的package包/類
/**
 * Update the configuration file
 * 
 * @param currentVersion the version of the configuration file
 */
public void updateConfig(int currentVersion) {
	InputStream in = plugin.getResource("config.yml");
	try (InputStreamReader inReader = new InputStreamReader(in)) {
		FileConfiguration defaultConfig = YamlConfiguration.loadConfiguration(inReader);
		
		if (defaultConfig.getInt("version") == currentVersion) {
			return;
		}
		
		Set<String> newKeys = defaultConfig.getKeys(false);
		for (String key : plugin.getConfig().getKeys(false)) {
			if (key.equalsIgnoreCase("version")) {
				continue;
			}
			if (newKeys.contains(key)) {
				defaultConfig.set(key, plugin.getConfig().get(key));
			}
		}
		
		defaultConfig.save(new File(plugin.getDataFolder() + "/config.yml"));
	} catch (IOException e) { e.printStackTrace(); }
}
 
開發者ID:2008Choco,項目名稱:DragonEggDrop,代碼行數:28,代碼來源:ConfigUtil.java


注:本文中的org.bukkit.configuration.file.FileConfiguration.getKeys方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。