mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FEATURE] OptionalTrigger
This commit is contained in:
parent
459f305f13
commit
9351cc1de5
2 changed files with 55 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue