diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/SaveProfilesCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/SaveProfilesCommand.java index adc9bcf5..3c253ec7 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/SaveProfilesCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/SaveProfilesCommand.java @@ -2,6 +2,8 @@ import pro.gravit.launcher.Launcher; import pro.gravit.launcher.profiles.ClientProfile; +import pro.gravit.launcher.profiles.optional.OptionalFile; +import pro.gravit.launcher.profiles.optional.actions.*; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.command.Command; import pro.gravit.utils.helper.IOHelper; @@ -12,6 +14,9 @@ import java.io.Writer; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; import java.util.UUID; public class SaveProfilesCommand extends Command { @@ -31,6 +36,37 @@ public static void saveProfile(ClientProfile profile, Path path) throws IOExcept serverProfile.serverPort = profile.getServerPort(); profile.getServers().add(serverProfile); } + for(OptionalFile file : profile.getOptional()) + { + if(file.list != null) + { + String[] list = file.list; + file.list = null; + if(file.actions == null) file.actions = new ArrayList<>(2); + OptionalAction action; + switch (file.type) + { + case FILE: + OptionalActionFile result = new OptionalActionFile(new HashMap<>()); + for(String s : list) result.files.put(s, ""); + action = result; + break; + case CLASSPATH: + action = new OptionalActionClassPath(list); + break; + case JVMARGS: + action = new OptionalActionJvmArgs(Arrays.asList(list)); + break; + case CLIENTARGS: + action = new OptionalActionClientArgs(Arrays.asList(list)); + break; + default: + LogHelper.warning("Not converted optional %s with type %s. Type unknown", file.name, file.type.toString()); + continue; + } + file.actions.add(action); + } + } try (Writer w = IOHelper.newWriter(path)) { Launcher.gsonManager.configGson.toJson(profile, w); } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java index 286e8cc1..e00c837f 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java @@ -184,16 +184,23 @@ public void updateOptionalGraph() { } } } - + @Deprecated public OptionalFile getOptionalFile(String file, OptionalType type) { for (OptionalFile f : updateOptional) if (f.type.equals(type) && f.name.equals(file)) return f; return null; } + public OptionalFile getOptionalFile(String file) { + for (OptionalFile f : updateOptional) + if (f.name.equals(file)) return f; + return null; + } + public Collection getShared() { return updateShared; } + @Deprecated public void markOptional(OptionalFile file) { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalView.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalView.java index 071bf9d9..7fa1cf3c 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalView.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalView.java @@ -4,8 +4,6 @@ import pro.gravit.launcher.profiles.optional.actions.OptionalAction; import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; import java.util.Set; public class OptionalView { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionClassPath.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionClassPath.java index b3d592cd..a9093ff2 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionClassPath.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionClassPath.java @@ -1,8 +1,18 @@ package pro.gravit.launcher.profiles.optional.actions; -import java.util.List; - public class OptionalActionClassPath extends OptionalAction { public String[] args; public boolean useAltClasspath = false; + + public OptionalActionClassPath() { + } + + public OptionalActionClassPath(String[] args) { + this.args = args; + } + + public OptionalActionClassPath(String[] args, boolean useAltClasspath) { + this.args = args; + this.useAltClasspath = useAltClasspath; + } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionClientArgs.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionClientArgs.java index 32d907ee..90bf980d 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionClientArgs.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionClientArgs.java @@ -4,4 +4,11 @@ public class OptionalActionClientArgs extends OptionalAction { public List args; + + public OptionalActionClientArgs() { + } + + public OptionalActionClientArgs(List args) { + this.args = args; + } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionFile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionFile.java index 7551c82b..1d58b053 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionFile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionFile.java @@ -29,4 +29,11 @@ public void disableInHashedDir(HashedDir dir) firstPath.parent.remove(firstPath.name); }); } + + public OptionalActionFile() { + } + + public OptionalActionFile(Map files) { + this.files = files; + } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionJvmArgs.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionJvmArgs.java index a5e5150e..328a224c 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionJvmArgs.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionJvmArgs.java @@ -4,4 +4,11 @@ public class OptionalActionJvmArgs extends OptionalAction { public List args; + + public OptionalActionJvmArgs() { + } + + public OptionalActionJvmArgs(List args) { + this.args = args; + } }