Esempio n. 1
0
 public static LauncherProfiles load() throws IOException {
   System.out.println("Loading Minecraft profiles from " + DevLauncher.workingDirectory);
   try (FileReader reader = new FileReader(getFile())) {
     LauncherProfiles profiles = new LauncherProfiles();
     JsonObject e = new JsonParser().parse(reader).getAsJsonObject();
     for (Map.Entry<String, JsonElement> entry : e.entrySet()) {
       if (entry.getKey().equals("clientToken")) {
         profiles.clientToken = entry.getValue().getAsString();
       } else if (entry.getKey().equals("authenticationDatabase")) {
         JsonObject o = entry.getValue().getAsJsonObject();
         for (Map.Entry<String, JsonElement> entry1 : o.entrySet()) {
           profiles.authenticationDatabase.profiles.put(
               UUIDTypeAdapter.fromString(entry1.getKey()),
               GSON.fromJson(entry1.getValue(), OnlineProfile.class));
         }
       } else {
         profiles.everythingElse.add(entry.getKey(), entry.getValue());
       }
     }
     INSTANCE = profiles;
     return INSTANCE;
   } finally {
     if (INSTANCE == null) {
       INSTANCE = new LauncherProfiles();
     }
     INSTANCE.markLoaded();
   }
 }
Esempio n. 2
0
 private static JsonObject deepCopyObj(JsonObject from) {
   JsonObject result = new JsonObject();
   for (Map.Entry<String, JsonElement> entry : from.entrySet()) {
     result.add(entry.getKey(), deepCopy(entry.getValue()));
   }
   return result;
 }