[FEATURE] OptionalTrigger

This commit is contained in:
Gravit 2020-01-04 22:13:04 +07:00
parent 459f305f13
commit 9351cc1de5
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
2 changed files with 55 additions and 0 deletions

View file

@ -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;

View file

@ -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;
}
}