[FEATURE] Update OptionalView

This commit is contained in:
Gravita 2023-02-25 18:42:17 +07:00
parent ebf25a65f7
commit b4331819cb
4 changed files with 33 additions and 5 deletions

View file

@ -27,6 +27,21 @@ public OptionalView(OptionalView view) {
this.all = view.all;
}
public OptionalView(ClientProfile profile, OptionalView old) {
this(profile);
for(OptionalFile oldFile : old.all) {
OptionalFile newFile = findByName(oldFile.name);
if(newFile == null) {
continue;
}
if(old.isEnabled(oldFile)) {
enable(newFile, old.installInfo.get(oldFile).isManual, (file, status) -> {});
} else {
disable(newFile, (file, status) -> {});
}
}
}
@SuppressWarnings("unchecked")
public <T extends OptionalAction> Set<T> getActionsByClass(Class<T> clazz) {
Set<T> results = new HashSet<>();
@ -42,6 +57,19 @@ public <T extends OptionalAction> Set<T> getActionsByClass(Class<T> clazz) {
return results;
}
public OptionalFile findByName(String name) {
for(OptionalFile file : all) {
if(name.equals(file.name)) {
return file;
}
}
return null;
}
public boolean isEnabled(OptionalFile file) {
return enabled.contains(file);
}
public Set<OptionalAction> getEnabledActions() {
Set<OptionalAction> results = new HashSet<>();
for (OptionalFile e : enabled) {

View file

@ -6,9 +6,9 @@ public final class Version implements Comparable<Version> {
public static final int MAJOR = 5;
public static final int MINOR = 3;
public static final int PATCH = 5;
public static final int PATCH = 6;
public static final int BUILD = 1;
public static final Version.Type RELEASE = Type.STABLE;
public static final Version.Type RELEASE = Type.DEV;
public final int major;
public final int minor;
public final int patch;

View file

@ -64,7 +64,7 @@ pack project(':LauncherAPI')
shadowJar {
duplicatesStrategy = 'EXCLUDE'
classifier = null
archiveClassifier = null
relocate 'io.netty', 'pro.gravit.repackage.io.netty'
configurations = [project.configurations.pack]
exclude 'module-info.class'

View file

@ -1,11 +1,11 @@
plugins {
id 'com.github.johnrengelman.shadow' version '5.2.0' apply false
id 'com.github.johnrengelman.shadow' version '7.1.2' apply false
id 'maven-publish'
id 'signing'
id 'org.openjfx.javafxplugin' version '0.0.10' apply false
}
group = 'pro.gravit.launcher'
version = '5.3.5'
version = '5.3.6-SNAPSHOT'
apply from: 'props.gradle'