Exemplo n.º 1
0
 @Override
 public void run() {
   try { // TODO ASAP THREAD THIS!!!
     Benchmark.start("MapLoader");
     Logger.logInfo("loading map information...");
     Document doc =
         AppUtils.downloadXML(new URL(DownloadUtils.getStaticCreeperhostLink(Locations.MAPXML)));
     if (doc == null) {
       Logger.logError("Error: Could not load map data!");
     }
     NodeList maps = doc.getElementsByTagName("map");
     for (int i = 0; i < maps.getLength(); i++) {
       Node map = maps.item(i);
       NamedNodeMap mapAttr = map.getAttributes();
       Map.addMap(
           new Map(
               mapAttr.getNamedItem("name").getTextContent(),
               mapAttr.getNamedItem("author").getTextContent(),
               mapAttr.getNamedItem("version").getTextContent(),
               mapAttr.getNamedItem("url").getTextContent(),
               mapAttr.getNamedItem("logo").getTextContent(),
               mapAttr.getNamedItem("image").getTextContent(),
               mapAttr.getNamedItem("compatible").getTextContent(),
               mapAttr.getNamedItem("mcversion").getTextContent(),
               mapAttr.getNamedItem("mapname").getTextContent(),
               mapAttr.getNamedItem("description") == null
                   ? null
                   : mapAttr.getNamedItem("description").getTextContent().replace("\\n", "\n"),
               i));
     }
   } catch (Exception e) {
     Logger.logError("Error while updating map info", e);
   } finally {
     MapUtils.loaded = true;
     Benchmark.logBenchAs("MapLoader", "MapLoader run ");
     LaunchFrame.checkDoneLoading();
   }
 }