gpt4 book ai didi

com.intellectualcrafters.configuration.file.YamlConfiguration类的使用及代码示例

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

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

YamlConfiguration介绍

[英]An implementation of Configuration which saves all files in Yaml. Note that this implementation is not synchronized.
[中]将所有文件保存在Yaml中的配置实现。请注意,此实现是不同步的。

代码示例

代码示例来源:origin: IntellectualSites/PlotSquared

String lastVersionString = this.config.getString("version");
if (lastVersionString != null) {
  String[] split = lastVersionString.split("\\.");
  if (checkVersion(new int[]{3, 4, 0}, lastVersion)) {
    Settings.convertLegacy(configFile);
    if (config.contains("worlds")) {
      ConfigurationSection worldSection = config.getConfigurationSection("worlds");
      worlds.set("worlds", worldSection);
      try {
        worlds.save(worldsFile);
      } catch (IOException e) {
        PS.debug("Failed to save " + IMP.getPluginName() + " worlds.yml");
config = YamlConfiguration.loadConfiguration(configFile);

代码示例来源:origin: IntellectualSites/PlotSquared

public static byte[] getBytes(PlotArea plotArea) {
  ConfigurationSection section = PS.get().worlds.getConfigurationSection("worlds." + plotArea.worldname);
  YamlConfiguration config = new YamlConfiguration();
  String generator = SetupUtils.manager.getGenerator(plotArea);
  if (generator != null) {
    config.set("generator.plugin", generator);
  }
  for (String key : section.getKeys(true)) {
    config.set(key, section.get(key));
  }
  return config.saveToString().getBytes();
}

代码示例来源:origin: IntellectualSites/PlotSquared

@Override
public String saveToString() {
  yamlOptions.setIndent(options().indent());
  yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
  yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
  String header = buildHeader();
  String dump = yaml.dump(getValues(false));
  if (dump.equals(BLANK_CONFIG)) {
    dump = "";
  }
  return header + dump;
}

代码示例来源:origin: IntellectualSites/PlotSquared

public static boolean load(File file, Class root) {
  if (!file.exists()) {
    return false;
  }
  YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
  for (String key : yml.getKeys(true)) {
    Object value = yml.get(key);
    if (value instanceof MemorySection) {
      continue;
    }
    set(key, value, root);
  }
  return true;
}

代码示例来源:origin: IntellectualSites/PlotSquared

/**
 * Setup the style.yml file
 */
private void setupStyle() {
  if (this.version != null) {
    this.style.set("version", this.version.toString());
  }
  Map<String, Object> o = new HashMap<>(4);
  o.put("color.1", "6");
  o.put("color.2", "7");
  o.put("color.3", "8");
  o.put("color.4", "3");
  if (!this.style.contains("color")) {
    for (Entry<String, Object> node : o.entrySet()) {
      this.style.set(node.getKey(), node.getValue());
    }
  }
}

代码示例来源:origin: IntellectualSites/PlotSquared

if (this.worlds.contains("worlds")) {
  worlds = this.worlds.getConfigurationSection("worlds").getKeys(false);
} else {
  worlds = new HashSet<>();
ConfigurationSection worldSection = this.worlds.getConfigurationSection(path);
int type;
if (worldSection != null) {
  PS.log(C.PREFIX + "&3 - plotworld: &7" + plotArea.getClass().getName());
  PS.log(C.PREFIX + "&3 - manager: &7" + plotManager.getClass().getName());
  if (!this.worlds.contains(path)) {
    this.worlds.createSection(path);
    worldSection = this.worlds.getConfigurationSection(path);
    this.worlds.save(this.worldsFile);
  } catch (IOException e) {
    e.printStackTrace();
        pa.loadDefaultConfiguration(worldSection);
        try {
          this.worlds.save(this.worldsFile);
        } catch (IOException e) {
          e.printStackTrace();
    pa.loadDefaultConfiguration(worldSection);
    try {
      this.worlds.save(this.worldsFile);
    } catch (IOException e) {

代码示例来源:origin: IntellectualSites/PlotSquared

@Override
  public void run() {
    String path = "worlds." + pa.worldname;
    if (!PS.get().worlds.contains(path)) {
      PS.get().worlds.createSection(path);
    }
    ConfigurationSection section = PS.get().worlds.getConfigurationSection(path);
    pa.saveConfiguration(section);
    pa.loadConfiguration(section);
    object.plotManager = PS.imp().getPluginName();
    object.setupGenerator = PS.imp().getPluginName();
    String world = SetupUtils.manager.setupWorld(object);
    if (WorldUtil.IMP.isWorld(world)) {
      C.SETUP_FINISHED.send(player);
      player.teleport(WorldUtil.IMP.getSpawn(world));
    } else {
      MainUtil.sendMessage(player, "An error occurred while creating the world: " + pa.worldname);
    }
    try {
      PS.get().worlds.save(PS.get().worldsFile);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
};

代码示例来源:origin: IntellectualSites/PlotSquared

file.createNewFile();
YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
Set<String> keys = yml.getKeys(true);
EnumSet<C> allEnums = EnumSet.allOf(C.class);
HashSet<String> allNames = new HashSet<>();
boolean changed = false;
for (String key : keys) {
  if (!yml.isString(key)) {
    if (!categories.contains(key)) {
      toRemove.add(key);
    String value = yml.getString(key);
    if (!split[0].equalsIgnoreCase(caption.category)) {
      changed = true;
      yml.set(key, null);
      yml.set(caption.category + '.' + caption.name().toLowerCase(), value);
  yml.set(remove, null);
ConfigurationSection config = PS.get().style.getConfigurationSection("color");
Set<String> styles = config.getKeys(false);
    yml.set(caption.category + '.' + caption.name().toLowerCase(), caption.def);
  yml.save(file);

代码示例来源:origin: IntellectualSites/PlotSquared

options.put("confirmation", declaration.confirmation());
boolean set = false;
YamlConfiguration commands = PS.get() == null ? new YamlConfiguration() : PS.get().commands;
for (Map.Entry<String, Object> entry : options.entrySet()) {
  String key = this.getFullId() + "." + entry.getKey();
  if (!commands.contains(key)) {
    commands.set(key, entry.getValue());
    set = true;
    commands.save(PS.get().commandsFile);
  } catch (IOException e) {
    e.printStackTrace();
this.aliases = commands.getStringList(this.getFullId() + ".aliases");
this.description = commands.getString(this.getFullId() + ".description");
this.usage = commands.getString(this.getFullId() + ".usage");
this.confirmation = commands.getBoolean(this.getFullId() + ".confirmation");
if (this.parent != null) {
  this.parent.register(this);

代码示例来源:origin: IntellectualSites/PlotSquared

@Override
public void run(PlotArea area) {
  ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection("worlds." + area.worldname);
  if (worldSection == null) {
    return;
    ConfigurationSection areaSection =
        worldSection.getConfigurationSection("areas." + area.id + "-" + area.getMin() + "-" + area.getMax());
    YamlConfiguration clone = new YamlConfiguration();
    for (String key : areaSection.getKeys(true)) {
      if (areaSection.get(key) instanceof MemorySection) {
        continue;
      if (!clone.contains(key)) {
        clone.set(key, areaSection.get(key));
      if (!key.startsWith("areas") && !clone.contains(key)) {
        clone.set(key, worldSection.get(key));
    for (String key : clone.getKeys(true)) {
      if (clone.get(key) instanceof MemorySection) {
        continue;
        worldSection.set(key, clone.get(key));
      } else {
        Object value = worldSection.get(key);
        if (Objects.equals(value, clone.get(key))) {
          areaSection.set(key, clone.get(key));

代码示例来源:origin: IntellectualSites/PlotSquared

YamlConfiguration worldConfig = YamlConfiguration.loadConfiguration(worldFile);
PS.get().worlds.set("worlds." + world, worldConfig.get(""));
try {
  PS.get().worlds.save(PS.get().worldsFile);
  PS.get().worlds.load(PS.get().worldsFile);
} catch (InvalidConfigurationException | IOException e) {
  e.printStackTrace();
String manager = worldConfig.getString("generator.plugin", PS.imp().getPluginName());
String generator = worldConfig.getString("generator.init", manager);
int type = worldConfig.getInt("generator.type");
int terrain = worldConfig.getInt("generator.terrain");

代码示例来源:origin: IntellectualSites/PlotSquared

YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
Redstone.DISABLE_OFFLINE = config.getBoolean("protection.redstone.disable-offline");
Redstone.DISABLE_UNOCCUPIED = config.getBoolean("protection.redstone.disable-unoccupied", Redstone.DISABLE_UNOCCUPIED);
Enabled_Components.PLOTME_CONVERTER = config.getBoolean("plotme-convert.enabled", Enabled_Components.PLOTME_CONVERTER);
PlotMe.CACHE_UUDS = config.getBoolean("plotme-convert.cache-uuids", PlotMe.CACHE_UUDS);
UUID.USE_SQLUUIDHANDLER = config.getBoolean("uuid.use_sqluuidhandler", UUID.USE_SQLUUIDHANDLER);
UUID.OFFLINE = config.getBoolean("UUID.offline", UUID.OFFLINE);
UUID.FORCE_LOWERCASE = config.getBoolean("UUID.force-lowercase", UUID.FORCE_LOWERCASE);
Enabled_Components.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs", Enabled_Components.KILL_ROAD_MOBS);
Enabled_Components.KILL_ROAD_VEHICLES = config.getBoolean("kill_road_vehicles", Enabled_Components.KILL_ROAD_VEHICLES);
Enabled_Components.PLOT_EXPIRY = config.getBoolean("clear.auto.enabled", Enabled_Components.PLOT_EXPIRY);
if (Enabled_Components.PLOT_EXPIRY) {
  Enabled_Components.BAN_DELETER = config.getBoolean("clear.on.ban");
  AUTO_CLEAR = new ConfigBlock<>();
  AUTO_CLEAR.put("task1", new Auto_Clear());
  task.DAYS = config.getInt("clear.auto.days", task.DAYS);
  task.THRESHOLD = config.getInt("clear.auto.threshold", task.THRESHOLD);
  task.CONFIRMATION = config.getBoolean("clear.auto.confirmation", task.CONFIRMATION);
  task.CALIBRATION.CHANGES = config.getInt("clear.auto.calibration.changes", task.CALIBRATION.CHANGES);
  task.CALIBRATION.FACES = config.getInt("clear.auto.calibration.faces", task.CALIBRATION.FACES);
  task.CALIBRATION.DATA = config.getInt("clear.auto.calibration.data", task.CALIBRATION.DATA);
  task.CALIBRATION.AIR = config.getInt("clear.auto.calibration.air", task.CALIBRATION.AIR);
  task.CALIBRATION.VARIETY = config.getInt("clear.auto.calibration.variety", task.CALIBRATION.VARIETY);

代码示例来源:origin: IntellectualSites/PlotSquared

case "s":
case "size":
  this.worlds.set(base + "plot.size", Configuration.INTEGER.parseString(value).shortValue());
  break;
case "g":
case "gap":
  this.worlds.set(base + "road.width", Configuration.INTEGER.parseString(value).shortValue());
  break;
case "h":
case "height":
  this.worlds.set(base + "road.height", Configuration.INTEGER.parseString(value).shortValue());
  this.worlds.set(base + "plot.height", Configuration.INTEGER.parseString(value).shortValue());
  this.worlds.set(base + "wall.height", Configuration.INTEGER.parseString(value).shortValue());
  break;
case "f":
case "floor":
  this.worlds.set(base + "plot.floor",
      new ArrayList<>(Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(","))));
  break;
case "m":
case "main":
  this.worlds.set(base + "plot.filling",
      new ArrayList<>(Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(","))));
  break;
case "w":
case "wall":
  this.worlds.set(base + "wall.filling", Configuration.BLOCK.parseString(value).toString());
  break;
case "b":

代码示例来源:origin: IntellectualSites/PlotSquared

try {
  HashSet<String> areas = new HashSet<>();
  if (PS.get().worlds.contains("worlds")) {
    ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection("worlds");
    if (worldSection != null) {
      for (String worldKey : worldSection.getKeys(false)) {

代码示例来源:origin: IntellectualSites/PlotSquared

SinglePlotArea area = ((SinglePlotAreaManager) manager).getArea();
addPlotArea(area);
ConfigurationSection section = worlds.getConfigurationSection("worlds.*");
if (section == null) {
  section = worlds.createSection("worlds.*");

代码示例来源:origin: IntellectualSites/PlotSquared

@Override
public void loadFromString(String contents) throws InvalidConfigurationException {
  Map<?, ?> input;
  try {
    input = (Map<?, ?>) yaml.load(contents);
  } catch (YAMLException e) {
    throw new InvalidConfigurationException(e);
  } catch (ClassCastException ignored) {
    throw new InvalidConfigurationException("Top level is not a Map.");
  }
  String header = parseHeader(contents);
  if (!header.isEmpty()) {
    options().header(header);
  }
  if (input != null) {
    convertMapsToSections(input, this);
  }
}

代码示例来源:origin: IntellectualSites/PlotSquared

/**
 * Check if a PlotArea is compatible (move/copy etc).
 * @param plotArea the {@code PlotArea} to compare
 * @return true if both areas are compatible
 */
public boolean isCompatible(PlotArea plotArea) {
  ConfigurationSection section = PS.get().worlds.getConfigurationSection("worlds");
  for (ConfigurationNode setting : plotArea.getSettingNodes()) {
    Object constant = section.get(plotArea.worldname + '.' + setting.getConstant());
    if (constant == null || !constant.equals(section.get(this.worldname + '.' + setting.getConstant()))) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: IntellectualSites/PlotSquared

PS.log("Could not create the worlds file, please create \"worlds.yml\" manually.");
  this.worlds = YamlConfiguration.loadConfiguration(this.worldsFile);
} catch (IOException ignored) {
  PS.log("Failed to save settings.yml");
    PS.log("Could not create the settings file, please create \"settings.yml\" manually.");
  this.config = YamlConfiguration.loadConfiguration(this.configFile);
  setupConfig();
} catch (IOException ignored) {
  this.style = YamlConfiguration.loadConfiguration(this.styleFile);
  setupStyle();
} catch (IOException err) {
  this.storage = YamlConfiguration.loadConfiguration(this.storageFile);
  setupStorage();
} catch (IOException ignored) {
  this.commands = YamlConfiguration.loadConfiguration(this.commandsFile);
} catch (IOException ignored) {
  PS.log("Failed to save commands.yml");
  this.style.save(this.styleFile);
  this.commands.save(this.commandsFile);
} catch (IOException e) {
  PS.log("Configuration file saving failed");

代码示例来源:origin: IntellectualSites/PlotSquared

YamlConfiguration config = new YamlConfiguration();
  config.load(file);
} catch (InvalidConfigurationException | IOException ex) {
  try {

代码示例来源:origin: IntellectualSites/PlotSquared

@Override
  public void run() {
    if (offsetX != 0) {
      PS.get().worlds.set(path + ".road.offset.x", offsetX);
    }
    if (offsetZ != 0) {
      PS.get().worlds.set(path + ".road.offset.z", offsetZ);
    }
    final String world = SetupUtils.manager.setupWorld(object);
    if (WorldUtil.IMP.isWorld(world)) {
      PS.get().loadWorld(world, null);
      C.SETUP_FINISHED.send(player);
      player.teleport(WorldUtil.IMP.getSpawn(world));
      if (area.TERRAIN != 3) {
        ChunkManager.largeRegionTask(world, region, new RunnableVal<ChunkLoc>() {
          @Override
          public void run(ChunkLoc value) {
            AugmentedUtils.generate(world, value.x, value.z, null);
          }
        }, null);
      }
    } else {
      MainUtil.sendMessage(player, "An error occurred while creating the world: " + area.worldname);
    }
  }
};

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