gpt4 book ai didi

org.bukkit.configuration.file.YamlConfiguration.getKeys()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 20:40:40 28 4
gpt4 key购买 nike

本文整理了Java中org.bukkit.configuration.file.YamlConfiguration.getKeys()方法的一些代码示例,展示了YamlConfiguration.getKeys()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlConfiguration.getKeys()方法的具体详情如下:
包路径:org.bukkit.configuration.file.YamlConfiguration
类名称:YamlConfiguration
方法名:getKeys

YamlConfiguration.getKeys介绍

暂无

代码示例

代码示例来源:origin: drtshock/PlayerVaults

/**
 * Gets the numbers belonging to all their vaults.
 *
 * @param holder
 * @return a set of Integers, which are player's vaults' numbers (fuck grammar).
 */
public Set<Integer> getVaultNumbers(String holder) {
  Set<Integer> vaults = new HashSet<>();
  YamlConfiguration file = getPlayerVaultFile(holder, true);
  if (file == null) {
    return vaults;
  }
  for (String s : file.getKeys(false)) {
    try {
      // vault%
      int number = Integer.valueOf(s.substring(4));
      vaults.add(number);
    } catch (NumberFormatException e) {
      // silent
    }
  }
  return vaults;
}

代码示例来源:origin: Bkm016/TabooLib

public void load(YamlConfiguration configuration, boolean cleanup) {
    int originNodes = map.size();
    int updateNodes = 0;
    if (cleanup) {
      map.clear();
    }
    for (String s : configuration.getKeys(true)) {
      boolean updated = false;
      Object value = configuration.get(s);
      if (value instanceof TLocaleSerialize) {
        updated = map.put(s, Collections.singletonList((TLocaleSerialize) value)) != null;
      } else if (value instanceof List && !((List) value).isEmpty()) {
        if (isListString((List) value)) {
          updated = map.put(s, Collections.singletonList(TLocaleText.of(value))) != null;
        } else {
          updated = map.put(s, ((List<?>) value).stream().map(o -> o instanceof TLocaleSerialize ? (TLocaleSerialize) o : TLocaleText.of(String.valueOf(o))).collect(Collectors.toList())) != null;
        }
      } else if (!(value instanceof ConfigurationSection)) {
        String str = String.valueOf(value);
        updated = map.put(s, Collections.singletonList(str.length() == 0 ? TLocaleSerialize.getEmpty() : TLocaleText.of(str))) != null;
      }
      if (updated) {
        updateNodes++;
      }
    }
    latestUpdateNodes.set(originNodes - updateNodes);
  }
}

代码示例来源:origin: BentoBoxWorld/BentoBox

/**
 * Merges a language YAML file to this locale
 * @param toBeMerged the YamlConfiguration of the language file
 */
public void merge(YamlConfiguration toBeMerged) {
  for (String key : toBeMerged.getKeys(true)) {
    if (!key.startsWith("meta") && !config.contains(key)) {
      config.set(key, toBeMerged.get(key));
    }
  }
  updateAuthors(toBeMerged);
}

代码示例来源:origin: garbagemule/MobArena

private static boolean process(YamlConfiguration defaults, ConfigurationSection section, boolean addOnlyIfEmpty, boolean removeObsolete) {
  boolean modified = false;
  Set<String> present = section.getKeys(true);
  Set<String> required = defaults.getKeys(true);
  if (!addOnlyIfEmpty || present.isEmpty()) {
    for (String req : required) {
      if (!present.remove(req)) {
        section.set(req, defaults.get(req));
        modified = true;
      }
    }
  }
  if (removeObsolete) {
    for (String obs : present) {
      section.set(obs, null);
      modified = true;
    }
  }
  return modified;
}

代码示例来源:origin: garbagemule/MobArena

TemplateStore read() {
  YamlConfiguration yaml = new YamlConfiguration();
  try {
    File file = new File(plugin.getDataFolder(), TemplateStore.FILENAME);
    if (!file.exists()) {
      plugin.getLogger().info(TemplateStore.FILENAME + " not found, creating default...");
      plugin.saveResource(TemplateStore.FILENAME, false);
    }
    yaml.load(file);
  } catch (InvalidConfigurationException e) {
    throw new IllegalStateException(TemplateStore.FILENAME + " is invalid!", e);
  } catch (FileNotFoundException e) {
    throw new IllegalStateException(TemplateStore.FILENAME + " is missing!", e);
  } catch (IOException e) {
    throw new IllegalStateException(e);
  }
  Map<String, Template> map = new HashMap<>();
  for (String key : yaml.getKeys(false)) {
    validateTemplateNode(key, yaml);
    String templateId = stripStateSuffix(key);
    map.computeIfAbsent(templateId, id -> loadTemplate(id, yaml));
  }
  plugin.getLogger().info("Loaded " + map.size() + " sign templates.");
  return new TemplateStore(map);
}

代码示例来源:origin: elBukkit/MagicPlugin

protected void describeParameters(CommandSender sender) {
  Collection<String> keys = parameters.getKeys(false);
  if (keys.size() == 0) {
    sender.sendMessage(ChatColor.GRAY + " (None)");
  }
  for (String key : keys) {
    String value = null;
    if (parameters.isConfigurationSection(key)) {
      ConfigurationSection child = parameters.getConfigurationSection(key);
      value = "(" + child.getKeys(false).size() + " values)";
    } else {
      value = parameters.getString(key);
    }
    sender.sendMessage(ChatColor.LIGHT_PURPLE + " " + key + ": " + value);
  }
}

代码示例来源:origin: ChestShop-authors/ChestShop-3

public DiscountModule() {
  config = YamlConfiguration.loadConfiguration(ChestShop.loadFile("discounts.yml"));
  config.options().header("This file is for discount management. You are able to do that:\n" +
      "group1: 75\n" +
      "That means that the person with ChestShop.discount.group1 permission will pay only 75% of the price. \n" +
      "For example, if the price is 100 dollars, the player pays only 75 dollars.\n" +
      "(Only works in buy-only Admin Shops!)");
  try {
    config.save(ChestShop.loadFile("discounts.yml"));
  } catch (IOException e) {
    e.printStackTrace();
  }
  groupList = config.getKeys(false);
}

代码示例来源:origin: drtshock/PlayerVaults

/**
 * Check if the location given is a sign, and if so, remove it from the signs.yml file
 *
 * @param location The location to check
 */
public void blockChangeCheck(Location location) {
  if (plugin.getSigns().getKeys(false).isEmpty()) {
    return; // Save us a check.
  }
  String world = location.getWorld().getName();
  int x = location.getBlockX();
  int y = location.getBlockY();
  int z = location.getBlockZ();
  if (plugin.getSigns().getKeys(false).contains(world + ";;" + x + ";;" + y + ";;" + z)) {
    plugin.getSigns().set(world + ";;" + x + ";;" + y + ";;" + z, null);
    plugin.saveSigns();
  }
}

代码示例来源:origin: elBukkit/MagicPlugin

Collection<String> allKeys = currentConfig.getKeys(true);
for (String key : allKeys) {
  Object defaultValue = defaultConfig.get(key);
int originalTopSize = currentConfig.getKeys(false).size();
int cleanTopSize = cleanConfig.getKeys(false).size();
int cleanSize = cleanConfig.getKeys(true).size();
int removedCount = allKeys.size() - cleanSize;
if (removedCount > 0) {

代码示例来源:origin: mcMMO-Dev/mcMMO

String sanitizedEntityName = entityName.replace(".", "_");
if (entitiesFile.getKeys(false).contains(sanitizedEntityName)) {
  return;

代码示例来源:origin: SkyWars/SkyWars

for (String key : config.getKeys(false)) {
  if (key.equals("configuration-version")) continue;
  if (config.isConfigurationSection(key)) {

代码示例来源:origin: bergerkiller/BKCommonLib

for (String key : this.getSource().getKeys(true)) {
  Object value = this.getSource().get(key);
  if (value instanceof String) {

代码示例来源:origin: libraryaddict/LibsDisguises

int dupes = 0;
for (String key : config.getKeys(false)) {
  String value = config.getString(key);

代码示例来源:origin: drtshock/PlayerVaults

} else {
  StringBuilder sb = new StringBuilder();
  for (String key : file.getKeys(false)) {
    sb.append(key.replace("vault", "")).append(" ");

代码示例来源:origin: elBukkit/MagicPlugin

info("Loading image map data from " + configurationFile.getName());
configuration.load(configurationFile);
Set<String> maps = configuration.getKeys(false);
boolean needsUpdate = false;
for (String mapIdString : maps) {

代码示例来源:origin: drtshock/PlayerVaults

int y = l.getBlockY();
int z = l.getBlockZ();
if (plugin.getSigns().getKeys(false).contains(world + ";;" + x + ";;" + y + ";;" + z)) {
  int num = PlayerVaults.getInstance().getSigns().getInt(world + ";;" + x + ";;" + y + ";;" + z + ".chest", 1);
  if (player.hasPermission("playervaults.signs.use") || player.hasPermission("playervaults.signs.bypass")) {

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com