Map.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:mczone 作者:
public static void load() {
      list.clear();
      File maps = new File(SurvivalGames.getInstance().getDataFolder(), "maps");
      for (File yml : Files.getFiles(maps)) {
          if (!yml.getName().endsWith(".yml"))
              continue;

          ConfigAPI api = new ConfigAPI(YamlConfiguration.loadConfiguration(yml));
          FileConfiguration config = api.getConfig();
          String title = config.getString("info.title");
          String worldName = config.getString("info.worldName");
          if (title == null || worldName == null) {
              Chat.log(Level.SEVERE, "Error with map file: " + yml.getName() + " (no title and/or world name)");
              continue;
          }
          List<Location> spawns = new ArrayList<Location>();
          for (String s : config.getConfigurationSection("spawns").getKeys(false)) {
            if (api.getString("spawns." + s + ".team") != null && api.getString("spawns." + s + ".team").equals("spec"))
                continue;
            Location l = api.getLocation("spawns." + s);
                spawns.add(l);
          }
          Location specSpawn = api.getLocation("spawns.spec");

          new Map(title, worldName, spawns, specSpawn);
      }

Comparator<Map> comp = new Comparator<Map>() {
    public int compare(Map m1, Map m2) {
        return m1.getTitle().compareTo(m2.getTitle());
    }
};

Collections.sort(list, comp);

      Chat.log("Loaded a total of " + Map.getList().size() + " maps!");
  }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号