mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-01-05 15:28:18 +03:00
[FIX] Bug with missing forgotten dependency/conflict
This commit is contained in:
parent
ca87e0c726
commit
aed383b1fb
2 changed files with 34 additions and 3 deletions
|
@ -375,9 +375,10 @@ public void verify() {
|
|||
if (s == null)
|
||||
throw new IllegalArgumentException(String.format("Found null entry in updateOptional.%s.dependenciesFile", f.name));
|
||||
}
|
||||
if(f.xorConflictFile != null) for (OptionalDepend s : f.xorConflictFile) {
|
||||
if (s == null)
|
||||
throw new IllegalArgumentException(String.format("Found null entry in updateOptional.%s.xorConflictFile", f.name));
|
||||
if(f.xorConflictFile != null)
|
||||
for (OptionalDepend s : f.xorConflictFile) {
|
||||
if (s == null)
|
||||
throw new IllegalArgumentException(String.format("Found null entry in updateOptional.%s.xorConflictFile", f.name));
|
||||
}
|
||||
if (f.triggersList != null) {
|
||||
for (OptionalTrigger trigger : f.triggersList) {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import java.util.Set;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class OptionalView {
|
||||
public Set<OptionalFile> enabled = new HashSet<>();
|
||||
|
@ -26,6 +27,7 @@ public OptionalView(OptionalView view) {
|
|||
this.enabled = new HashSet<>(view.enabled);
|
||||
this.installInfo = new HashMap<>(view.installInfo);
|
||||
this.all = view.all;
|
||||
fixDependencies();
|
||||
}
|
||||
|
||||
public OptionalView(ClientProfile profile, OptionalView old) {
|
||||
|
@ -41,6 +43,7 @@ public OptionalView(ClientProfile profile, OptionalView old) {
|
|||
disable(newFile, (file, status) -> {});
|
||||
}
|
||||
}
|
||||
fixDependencies();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -81,6 +84,33 @@ public Set<OptionalAction> getEnabledActions() {
|
|||
return results;
|
||||
}
|
||||
|
||||
//Needed if dependency/conflict was added after mod declaring it and clients have their profiles with this mod enabled
|
||||
public void fixDependencies() {
|
||||
Set<OptionalFile> disabled = all.stream().filter(t -> !isEnabled(t)).collect(Collectors.toSet());
|
||||
for (OptionalFile file : disabled) {
|
||||
if (file.xorConflict != null && Arrays.stream(file.xorConflict).noneMatch(this::isEnabled)) {
|
||||
enable(file.xorConflict[0], false, null);
|
||||
}
|
||||
}
|
||||
for (OptionalFile file : enabled) {
|
||||
if (file.dependencies != null) {
|
||||
for (OptionalFile dep : file.dependencies) {
|
||||
enable(dep, false, null);
|
||||
}
|
||||
}
|
||||
if (file.conflict != null) {
|
||||
for (OptionalFile conflict : file.conflict) {
|
||||
disable(conflict, null);
|
||||
}
|
||||
}
|
||||
if (file.xorConflict != null) {
|
||||
for (OptionalFile xorConflict : file.xorConflict) {
|
||||
disable(xorConflict, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Set<OptionalAction> getDisabledActions() {
|
||||
Set<OptionalAction> results = new HashSet<>();
|
||||
for (OptionalFile e : all) {
|
||||
|
|
Loading…
Reference in a new issue