gpt4 book ai didi

com.sk89q.util.yaml.YAMLProcessor.setComment()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 03:58:49 26 4
gpt4 key购买 nike

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

YAMLProcessor.setComment介绍

[英]Set a root-level comment.
[中]设置根级别的注释。

代码示例

代码示例来源:origin: EngineHub/WorldEdit

public void setComment(String key, String comment) {
  if (comment != null) {
    setComment(key, comment.split("\\r?\\n"));
  } else {
    comments.remove(key);
  }
}

代码示例来源:origin: EngineHub/CommandBook

/**
 * Loads the configuration.
 */
@Override
public YAMLProcessor createConfiguration() {
  final File configFile = new File(getDataFolder(), "config.yml");
  YAMLProcessor config = new YAMLProcessor(configFile, true, YAMLFormat.EXTENDED);
  YAMLProcessor comments = new DefaultsFileYAMLProcessor("config-comments.yml", false);
  try {
    if (!configFile.exists()) {
      configFile.getParentFile().mkdirs();
      configFile.createNewFile();
    }
    config.load();
    comments.load();
  } catch (Exception e) {
    getLogger().log(Level.WARNING, "Error loading configuration: ", e);
  }
  for (Map.Entry<String, Object> e : comments.getMap().entrySet()) {
    if (e.getValue() != null) {
      config.setComment(e.getKey(), e.getValue().toString());
    }
  }
  // Migrate the old configuration, if we need to
  final String result = new LegacyCommandBookConfigurationMigrator(configFile, config).migrate();
  if (result != null) {
    logger().severe("Error migrating CommandBook configuration: " + result);
  }
  return config;
}

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