gpt4 book ai didi

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

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

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

YamlConfiguration.set介绍

暂无

代码示例

代码示例来源:origin: GlowstoneMC/Glowstone

/**
 * Change a configuration value at runtime.
 *
 * @param key   the config key to write the value to
 * @param value value to write to config key
 * @see ServerConfig#save()
 */
public void set(Key key, Object value) {
  parameters.replace(key, value);
  config.set(key.path, value);
}

代码示例来源:origin: GlowstoneMC/Glowstone

/**
 * Change a configuration value at runtime.
 *
 * @param key the config key to write the value to
 * @param value value to write to config key
 * @see #save()
 */
public void set(Key key, Object value) {
  cache.replace(key, value);
  config.set(key.path, value);
}

代码示例来源:origin: GlowstoneMC/Glowstone

config.set(key.path, bukkit.get(key.migratePath));
    migrateStatus = true;
config.set("aliases", bukkit.get("aliases"));
config.set("worlds", bukkit.get("worlds"));
    if (key.def instanceof Integer) {
      try {
        config.set(key.path, Integer.parseInt(value));
      } catch (NumberFormatException e) {
        GlowServer.logger.log(Level.WARNING,
      config.set(key.path, Boolean.parseBoolean(value));
    } else {
      config.set(key.path, value);

代码示例来源:origin: GlowstoneMC/Glowstone

config.set(key.path, key.def);
  config.set(key.path, key.def);
  changed = true;

代码示例来源:origin: GlowstoneMC/Glowstone

config.set(key.path, key.def);
  config.set(key.path, key.def);
  changed = true;
} else if (key.validator != null) {
        "Invalid config value for '" + key.path + "' (" + val + "), "
            + "resetting to default (" + key.def + ")");
    config.set(key.path, key.def);
    changed = true;

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

/**
 * Set an object in the config.yml
 *
 * @param path   The path in the config.
 * @param object What to be saved.
 * @param conf   Where to save the object.
 */
public <T> void setInConfig(String path, T object, YamlConfiguration conf) {
  conf.set(path, object);
}

代码示例来源:origin: sgtcaze/NametagEdit

private void handlePlayer(YamlConfiguration config, String line) {
  String[] initialSplit = line.split("=");
  String prefix = initialSplit[1].trim().split("\"")[1];
  String[] whiteSpaces = initialSplit[0].trim().split(" ");
  String playerName = whiteSpaces[0];
  String type = whiteSpaces[1];
  OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerName);
  String uuid = offlinePlayer.getUniqueId().toString();
  config.set("Players." + uuid + ".Name", playerName);
  config.set("Players." + uuid + "." + type.substring(0, 1).toUpperCase() + type.substring(1).toLowerCase(), prefix);
  config.set("Players." + uuid + ".SortPriority", -1);
}

代码示例来源:origin: sgtcaze/NametagEdit

@Override
  public void response(UUID uuid) {
    if (players.contains("Players." + uuid.toString())) {
      players.set("Players." + uuid.toString(), priority);
      save(players, playersFile);
    }
  }
});

代码示例来源:origin: com.greatmancode/tools

@Override
public void setValue(String path, Object value) {
  configFile.set(path, value);
  try {
    configFile.save(file);
  } catch (IOException e) {
    serverCaller.getLogger().severe("Error while saving + " + file.getName() + ". Error: " + e.getMessage());
  }
}

代码示例来源:origin: sgtcaze/NametagEdit

@Override
public void save(PlayerData... data) {
  for (PlayerData playerData : data) {
    UUID uuid = playerData.getUuid();
    String name = playerData.getName();
    players.set("Players." + uuid + ".Name", name);
    players.set("Players." + uuid + ".Prefix", Utils.deformat(playerData.getPrefix()));
    players.set("Players." + uuid + ".Suffix", Utils.deformat(playerData.getSuffix()));
    players.set("Players." + uuid + ".SortPriority", playerData.getSortPriority());
  }
  save(players, playersFile);
}

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

public boolean onItemSerialize(Player player, ItemStack item) {
  YamlConfiguration configuration = new YamlConfiguration();
  configuration.set("item", item);
  String itemString = configuration.saveToString().replace("item:", "").replace(ChatColor.COLOR_CHAR, '&');
  player.sendMessage(itemString);
  return true;
}

代码示例来源:origin: sgtcaze/NametagEdit

@Override
public void delete(GroupData groupData) {
  groups.set("Groups." + groupData.getGroupName(), null);
  save(groups, groupsFile);
}

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

static YamlConfiguration toYaml() {
    YamlConfiguration yaml = new YamlConfiguration();
    for (Msg msg : values()) {
      // ARENA_END_GLOBAL => arena-end-global
      String key = msg.name().replace("_","-").toLowerCase();
      yaml.set(key, msg.value);
    }
    return yaml;
  }
}

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

private void convertToMaterial(String sectionPath) {
  ConfigurationSection section = configuration.getConfigurationSection(sectionPath);
  if (section != null) {
    for (String typeId : section.getKeys(false)) {
      Material material = Material.matchMaterial(typeId);
      if (material != null) {
        configuration.set(sectionPath + "." + material.toString().toLowerCase(), configuration.get(sectionPath + "." + typeId));
        configuration.set(sectionPath + "." + typeId, null);
      }
    }
  }
}

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

void save(SignStore signStore) {
  YamlConfiguration yaml = new YamlConfiguration();
  List<ArenaSign> values = new ArrayList<>(signStore.findAll());
  yaml.set("signs", values);
  try {
    File data = new File(plugin.getDataFolder(), "data");
    yaml.options().header("MobArena Sign Store\n\nPlease DON'T edit this file by hand!\n");
    yaml.save(new File(data, SignStore.FILENAME));
  } catch (IOException e) {
    throw new IllegalStateException(e);
  }
}

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

public long getSetLong(String path, long defaultInt) throws InvalidConfigurationException {
  if (config.isInt(path)) {
    return config.getLong(path);
  } else if (config.contains(path)) {
    throw new InvalidConfigurationException("Object " + config.get(path) + " found under " + path + " in file " + configFile.toAbsolutePath() + " is not a long");
  } else {
    logger.log(Level.INFO, "Setting {0} to {1} in file {2}", new Object[]{path, defaultInt, configFile});
    config.set(path, defaultInt);
    return defaultInt;
  }
}

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

private void createBackup() {
  YamlConfiguration yaml = new YamlConfiguration();
  yaml.set("contents", contents);
  backup = new File(inventories, player.getUniqueId().toString());
  try {
    yaml.save(backup);
  } catch (IOException e) {
    throw new RuntimeException("Failed to store inventory for " + player.getName(), e);
  }
  arena.getInventoryManager().put(player, contents);
}

代码示例来源:origin: artex-development/Lukkit

@Override
protected LuaBoolean clearVaule(LuaString path) throws StorageObjectException {
  if (this.yamlConfiguration.get(path.checkjstring()) == null) {
    this.yamlConfiguration.set(path.checkjstring(), null);
    return LuaValue.TRUE;
  }
  return LuaValue.FALSE;
}

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

public static void setReplacement(ItemStack itemStack, ItemStack replacement) {
  YamlConfiguration configuration = new YamlConfiguration();
  configuration.set("item", replacement);
  setMeta(itemStack, "replacement", configuration.saveToString());
}

代码示例来源:origin: artex-development/Lukkit

@Override
public LuaBoolean setDefaultValue(LuaString path, LuaValue value) throws StorageObjectException {
  if (this.yamlConfiguration.get(path.checkjstring()) == null) {
    this.yamlConfiguration.set(path.checkjstring(), Utilities.getObjectFromLuavalue(value));
    return LuaValue.TRUE;
  }
  return LuaValue.FALSE;
}

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