diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java index 45d0ce95..f08b1fc5 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java @@ -228,6 +228,7 @@ private static void launch(ClientProfile profile, ClientLauncherProcess.ClientPa System.setProperty("minecraft.applet.TargetDirectory", params.clientDir); } Collections.addAll(args, profile.getClientArgs()); + profile.pushOptionalClientArgs(args); List copy = new ArrayList<>(args); for (int i = 0, l = copy.size(); i < l; i++) { String s = copy.get(i); diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java index 5c3bc532..1a7bb5ba 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java @@ -70,6 +70,7 @@ private void applyClientProfile() { this.systemClassPath.add(IOHelper.getCodeSource(ClientLauncherEntryPoint.class).toAbsolutePath().toString()); Collections.addAll(this.jvmArgs, this.params.profile.getJvmArgs()); + this.params.profile.pushOptionalJvmArgs(this.jvmArgs); this.systemEnv.put("JAVA_HOME", javaDir.toString()); Collections.addAll(this.systemClassPath, this.params.profile.getAlternativeClassPath()); if (params.ram > 0) { 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 94a1d0d1..c24186d0 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java @@ -248,20 +248,11 @@ public Collection getShared() { } - public void markOptional(String name, OptionalType type) { - OptionalFile file = getOptionalFile(name, type); - if (file == null) { - throw new SecurityException(String.format("Optional %s not found in optionalList", name)); - } - markOptional(file); - } - - public void markOptional(OptionalFile file) { if (file.mark) return; file.mark = true; - file.notifyObservers(true); + file.watchEvent(true); if (file.dependencies != null) { for (OptionalFile dep : file.dependencies) { if (dep.dependenciesCount == null) dep.dependenciesCount = new HashSet<>(); @@ -277,19 +268,10 @@ public void markOptional(OptionalFile file) { } - public void unmarkOptional(String name, OptionalType type) { - OptionalFile file = getOptionalFile(name, type); - if (file == null) { - throw new SecurityException(String.format("Optional %s not found in optionalList", name)); - } - unmarkOptional(file); - } - - public void unmarkOptional(OptionalFile file) { if (!file.mark) return; file.mark = false; - file.notifyObservers(false); + file.watchEvent(false); if (file.dependenciesCount != null) { for (OptionalFile f : file.dependenciesCount) { if (f.isPreset) continue; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalFile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalFile.java index 668ec186..0f73ec9f 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalFile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalFile.java @@ -6,11 +6,11 @@ import pro.gravit.utils.helper.LogHelper; import java.io.IOException; -import java.util.Objects; -import java.util.Observable; -import java.util.Set; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.BiConsumer; -public class OptionalFile extends Observable { +public class OptionalFile { @LauncherNetworkAPI public String[] list; @LauncherNetworkAPI @@ -18,7 +18,7 @@ public class OptionalFile extends Observable { @LauncherNetworkAPI public boolean mark; @LauncherNetworkAPI - public final boolean visible = true; + public boolean visible = true; @LauncherNetworkAPI public String name; @LauncherNetworkAPI @@ -125,4 +125,27 @@ public static OptionalType readType(HInput input) throws IOException { } return type; } + private volatile transient Collection> watchList = null; + public void registerWatcher(BiConsumer watcher) + { + if(watchList == null) watchList = ConcurrentHashMap.newKeySet(); + watchList.add(watcher); + } + public void removeWatcher(BiConsumer watcher) + { + if(watchList == null) return; + watchList.remove(watcher); + } + public void clearAllWatchers() + { + if(watchList == null) return; + watchList.clear(); + } + public void watchEvent(boolean isMark) + { + if(watchList == null) return; + watchList.forEach((e) -> { + e.accept(this, isMark); + }); + } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalTrigger.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalTrigger.java index 0603aef4..8e94ce09 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalTrigger.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalTrigger.java @@ -11,7 +11,7 @@ public enum TriggerType public boolean need = true; public long value; public long compareMode = 0; - boolean isTriggered() + public boolean isTriggered() { long test; switch (type)