org.bukkit.configuration.file.FileConfiguration#createSection ( )源码实例Demo

下面列出了org.bukkit.configuration.file.FileConfiguration#createSection ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: BedWars   文件: Configurator.java
private static void checkOrSet(AtomicBoolean modify, FileConfiguration config, String path, Object value) {
    if (!config.isSet(path)) {
        if (value instanceof Map) {
            config.createSection(path, (Map<?, ?>) value);
        } else {
            config.set(path, value);
        }
        modify.set(true);
    }
}
 
源代码2 项目: BedWars   文件: Configurator.java
private static void checkOrSet(AtomicBoolean modify, FileConfiguration config, String path, Object value) {
    if (!config.isSet(path)) {
        if (value instanceof Map) {
            config.createSection(path, (Map<?, ?>) value);
        } else {
            config.set(path, value);
        }
        modify.set(true);
    }
}
 
源代码3 项目: uSkyBlock   文件: ChallengeCompletionLogic.java
private void saveToConfiguration(FileConfiguration configuration, Map<String, ChallengeCompletion> map) {
    for (Map.Entry<String, ChallengeCompletion> entry : map.entrySet()) {
        String challengeName = entry.getKey();
        ChallengeCompletion completion = entry.getValue();
        ConfigurationSection section = configuration.createSection(challengeName);
        section.set("firstCompleted", completion.getCooldownUntil());
        section.set("timesCompleted", completion.getTimesCompleted());
        section.set("timesCompletedSinceTimer", completion.getTimesCompletedInCooldown());
    }
}
 
源代码4 项目: uSkyBlock   文件: PlayerInfo.java
private void setupPlayer() {
    FileConfiguration playerConfig = playerData;
    ConfigurationSection pSection = playerConfig.createSection("player");
    pSection.set("islandX", 0);
    pSection.set("islandY", 0);
    pSection.set("islandZ", 0);
    pSection.set("homeX", 0);
    pSection.set("homeY", 0);
    pSection.set("homeZ", 0);
    pSection.set("homeYaw", 0);
    pSection.set("homePitch", 0);
    pSection.set("perms", null);
}
 
源代码5 项目: skUtilities   文件: SExprYaml.java
@SuppressWarnings("unchecked")
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
  File pth = new File(skUtilities.getDefaultPath(path.getSingle(e)));
  String ypth = ypath.getSingle(e);
  FileConfiguration con = YamlConfiguration.loadConfiguration(pth);
  try {
    if (mode == Changer.ChangeMode.DELETE) {
      con.set(ypth, null);
    } else {
      Object v = (delta[0] == null ? "" : delta[0]);
      switch (ty) {
        case 0: {
          if (mode == Changer.ChangeMode.SET) {
            con.set(ypth, delta[0]);
          }
          break;
        }
        case 1:
        case 2:
          if (mode == Changer.ChangeMode.ADD) {
            con.createSection(ypth);
          } else if (mode == Changer.ChangeMode.REMOVE) {
            con.set(ypth + "." + v, null);
          }
          break;
        case 3: {
          if (mode == Changer.ChangeMode.ADD) {
            List obj = con.getList(ypth);
            if (obj == null) {
              obj = new ArrayList<>();
              obj.add(delta[0]);
              con.set(ypth, obj);
            } else {
              obj.add(delta[0]);
            }
          } else if (mode == Changer.ChangeMode.REMOVE) {
            con.getList(ypth).remove(delta[0]);
          }
        }
      }
    }
  } finally {
    try {
      con.save(pth);
    } catch (IOException x) {
      skUtilities.prSysE("Failed to save: '" + pth + "'", getClass().getSimpleName(), x);
    }
  }
}