예제 #1
0
 static void modified() {
   try (FileWriter writer = new FileWriter(getFile())) {
     JsonObject obj = deepCopy(INSTANCE.everythingElse);
     obj.addProperty("clientToken", INSTANCE.clientToken);
     obj.add("authenticationDatabase", GSON.toJsonTree(INSTANCE.authenticationDatabase.profiles));
     GSON.toJson(obj, writer);
     System.out.println("Profiles saved");
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
예제 #2
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();
   }
 }