mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FEATURE][EXPERIMENTAL] Потенциальная проблема с зависимостями в опциональных модах
This commit is contained in:
parent
72a8325a15
commit
8b8ef665ef
2 changed files with 14 additions and 10 deletions
|
@ -47,6 +47,7 @@ public class OptionalFile {
|
|||
public int subTreeLevel = 1;
|
||||
@LauncherNetworkAPI
|
||||
public boolean isPreset;
|
||||
@Deprecated
|
||||
public transient Set<OptionalFile> dependenciesCount;
|
||||
private volatile transient Collection<BiConsumer<OptionalFile, Boolean>> watchList = null;
|
||||
|
||||
|
|
|
@ -3,11 +3,14 @@
|
|||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.launcher.profiles.optional.actions.OptionalAction;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class OptionalView {
|
||||
public Set<OptionalFile> enabled = new HashSet<>();
|
||||
public Map<OptionalFile, Set<OptionalFile>> dependenciesCountMap = new HashMap<>();
|
||||
public Set<OptionalFile> all;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -64,8 +67,8 @@ public void enable(OptionalFile file)
|
|||
file.watchEvent(true);
|
||||
if (file.dependencies != null) {
|
||||
for (OptionalFile dep : file.dependencies) {
|
||||
if (dep.dependenciesCount == null) dep.dependenciesCount = new HashSet<>();
|
||||
dep.dependenciesCount.add(file);
|
||||
Set<OptionalFile> dependenciesCount = dependenciesCountMap.computeIfAbsent(dep, k -> new HashSet<>());
|
||||
dependenciesCount.add(file);
|
||||
enable(dep);
|
||||
}
|
||||
}
|
||||
|
@ -79,22 +82,22 @@ public void disable(OptionalFile file)
|
|||
{
|
||||
if(!enabled.remove(file)) return;
|
||||
file.watchEvent(false);
|
||||
if (file.dependenciesCount != null) {
|
||||
for (OptionalFile f : file.dependenciesCount) {
|
||||
Set<OptionalFile> dependenciesCount = dependenciesCountMap.get(file);
|
||||
if (dependenciesCount != null) {
|
||||
for (OptionalFile f : dependenciesCount) {
|
||||
if (f.isPreset) continue;
|
||||
disable(f);
|
||||
}
|
||||
file.dependenciesCount.clear();
|
||||
file.dependenciesCount = null;
|
||||
dependenciesCount.clear();
|
||||
}
|
||||
if (file.dependencies != null) {
|
||||
for (OptionalFile f : file.dependencies) {
|
||||
if (!enabled.contains(f)) continue;
|
||||
if (f.dependenciesCount == null) {
|
||||
dependenciesCount = dependenciesCountMap.get(f);
|
||||
if (dependenciesCount == null) {
|
||||
disable(f);
|
||||
} else if (f.dependenciesCount.size() <= 1) {
|
||||
f.dependenciesCount.clear();
|
||||
f.dependenciesCount = null;
|
||||
} else if (dependenciesCount.size() <= 1) {
|
||||
dependenciesCount.clear();
|
||||
disable(f);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue