mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-01-09 00:59:44 +03:00
[FEATURE] SaveProfilesCommand поддержка ServerProfile
This commit is contained in:
parent
4bea6bb16b
commit
b92e9a1d29
1 changed files with 10 additions and 0 deletions
|
@ -19,8 +19,18 @@ public SaveProfilesCommand(LaunchServer server) {
|
||||||
super(server);
|
super(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecated")
|
||||||
public static void saveProfile(ClientProfile profile, Path path) throws IOException {
|
public static void saveProfile(ClientProfile profile, Path path) throws IOException {
|
||||||
if (profile.getUUID() == null) profile.setUUID(UUID.randomUUID());
|
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)) {
|
try (Writer w = IOHelper.newWriter(path)) {
|
||||||
Launcher.gsonManager.configGson.toJson(profile, w);
|
Launcher.gsonManager.configGson.toJson(profile, w);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue