[FEATURE] SaveProfilesCommand поддержка ServerProfile

This commit is contained in:
Gravit 2020-07-03 07:38:01 +07:00
parent 4bea6bb16b
commit b92e9a1d29
No known key found for this signature in database
GPG key ID: 98A079490768CCE5

View file

@ -19,8 +19,18 @@ public SaveProfilesCommand(LaunchServer server) {
super(server);
}
@SuppressWarnings("deprecated")
public static void saveProfile(ClientProfile profile, Path path) throws IOException {
if (profile.getUUID() == null) profile.setUUID(UUID.randomUUID());
if(profile.getServers().size() == 0)
{
ClientProfile.ServerProfile serverProfile = new ClientProfile.ServerProfile();
serverProfile.isDefault = true;
serverProfile.name = profile.getTitle();
serverProfile.serverAddress = profile.getServerAddress();
serverProfile.serverPort = profile.getServerPort();
profile.getServers().add(serverProfile);
}
try (Writer w = IOHelper.newWriter(path)) {
Launcher.gsonManager.configGson.toJson(profile, w);
}