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

x33g5p2x  于2022-02-05 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(123)

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

YamlConfiguration.getDefaults介绍

暂无

代码示例

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

@Override
protected String buildHeader() {
  String header = options().header();
  if (options().copyHeader()) {
    Configuration def = getDefaults();
    if ((def != null) && (def instanceof FileConfiguration)) {
      FileConfiguration filedefaults = (FileConfiguration) def;
      String defaultsHeader = filedefaults.buildHeader();
      if ((defaultsHeader != null) && (defaultsHeader.length() > 0)) {
        return defaultsHeader;
      }
    }
  }
  if (header == null) {
    return "";
  }
  StringBuilder builder = new StringBuilder();
  String[] lines = header.split("\r?\n", -1);
  boolean startedHeader = false;
  for (int i = lines.length - 1; i >= 0; i--) {
    builder.insert(0, "\n");
    if ((startedHeader) || (lines[i].length() != 0)) {
      builder.insert(0, lines[i]);
      builder.insert(0, COMMENT_PREFIX);
      startedHeader = true;
    }
  }
  return builder.toString();
}

代码示例来源:origin: SpigotMC/Spigot-API

@Override
protected String buildHeader() {
  String header = options().header();
  if (options().copyHeader()) {
    Configuration def = getDefaults();
    if ((def != null) && (def instanceof FileConfiguration)) {
      FileConfiguration filedefaults = (FileConfiguration) def;
      String defaultsHeader = filedefaults.buildHeader();
      if ((defaultsHeader != null) && (defaultsHeader.length() > 0)) {
        return defaultsHeader;
      }
    }
  }
  if (header == null) {
    return "";
  }
  StringBuilder builder = new StringBuilder();
  String[] lines = header.split("\r?\n", -1);
  boolean startedHeader = false;
  for (int i = lines.length - 1; i >= 0; i--) {
    builder.insert(0, "\n");
    if ((startedHeader) || (lines[i].length() != 0)) {
      builder.insert(0, lines[i]);
      builder.insert(0, COMMENT_PREFIX);
      startedHeader = true;
    }
  }
  return builder.toString();
}

相关文章