From 9351cc1de53e9d3294bdb73215fb4a2e15476bd3 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 4 Jan 2020 22:13:04 +0700 Subject: [PATCH] [FEATURE] OptionalTrigger --- .../profiles/optional/OptionalFile.java | 2 + .../profiles/optional/OptionalTrigger.java | 53 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalTrigger.java 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 237deb22..668ec186 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 @@ -24,6 +24,8 @@ public class OptionalFile extends Observable { @LauncherNetworkAPI public String info; @LauncherNetworkAPI + public OptionalTrigger[] triggers; + @LauncherNetworkAPI public OptionalDepend[] dependenciesFile; @LauncherNetworkAPI public OptionalDepend[] conflictFile; 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 new file mode 100644 index 00000000..0603aef4 --- /dev/null +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalTrigger.java @@ -0,0 +1,53 @@ +package pro.gravit.launcher.profiles.optional; + +import pro.gravit.utils.helper.JVMHelper; + +public class OptionalTrigger { + public enum TriggerType + { + JAVA_VERSION, JAVA_BITS, OS_BITS, OS_TYPE + } + public TriggerType type; + public boolean need = true; + public long value; + public long compareMode = 0; + boolean isTriggered() + { + long test; + switch (type) + { + + case JAVA_VERSION: + test = JVMHelper.JVM_VERSION; + break; + case JAVA_BITS: + test = JVMHelper.JVM_BITS; + break; + case OS_BITS: + test = JVMHelper.OS_BITS; + break; + case OS_TYPE: + switch (JVMHelper.OS_TYPE) + { + + case MUSTDIE: + test = 0; + break; + case LINUX: + test = 1; + break; + case MACOSX: + test = 2; + break; + default: + return false; + } + break; + default: + return false; + } + if(compareMode == 0) return test == value; + else if(compareMode < 0) return test < value; + else return test > value; + } +}