Exemplo n.º 1
0
 @Override
 protected String doInBackground() {
   Benchmark.start("LoginWorker");
   try {
     if (Main.isAuthlibReadyToUse()) {
       try {
         LoginResponse resp =
             AuthlibHelper.authenticateWithAuthlib(
                 username, password, mojangData, selectedProfile);
         this.resp = resp;
         Benchmark.logBenchAs("LoginWorker", "Login Worker Run");
         if (resp != null && resp.getUsername() != null && !resp.getUsername().isEmpty()) {
           if (resp.getSessionID() != null) {
             return "good";
           } else {
             return "offline";
           }
         }
         if (resp == null) return "nullResponse";
         if (resp.getUsername() == null) return "NullUsername";
         return "bad";
       } catch (Exception e) {
         Logger.logError("Error using authlib", e);
       }
     } else {
       ErrorUtils.tossError("Authlib Unavaible. Please check your log for errors");
     }
   } catch (Exception e) {
     ErrorUtils.tossError(
         "Exception occurred, minecraft servers might be down. Check @ help.mojang.com");
   }
   return "";
 }
Exemplo n.º 2
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();
   }
 }