本文整理汇总了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(); }
}