本文整理匯總了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);
}
}
示例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;
}
示例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(); }
}