mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 20:07:41 +01:00
Validate providers when populating load order tree (#8890)
This commit is contained in:
parent
ee1dffb8d5
commit
75e61d5bf2
@ -1590,6 +1590,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+import java.util.function.Predicate;
|
||||
+
|
||||
+@SuppressWarnings("UnstableApiUsage")
|
||||
+public class DependencyUtil {
|
||||
@ -1614,14 +1615,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static MutableGraph<String> buildLoadGraph(@NotNull MutableGraph<String> dependencyGraph, @NotNull LoadOrderConfiguration configuration) {
|
||||
+ public static MutableGraph<String> buildLoadGraph(@NotNull MutableGraph<String> dependencyGraph, @NotNull LoadOrderConfiguration configuration, Predicate<String> validator) {
|
||||
+ String identifier = configuration.getMeta().getName();
|
||||
+ for (String dependency : configuration.getLoadAfter()) {
|
||||
+ dependencyGraph.putEdge(identifier, dependency);
|
||||
+ if (validator.test(dependency)) {
|
||||
+ dependencyGraph.putEdge(identifier, dependency);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for (String loadBeforeTarget : configuration.getLoadBefore()) {
|
||||
+ dependencyGraph.putEdge(loadBeforeTarget, identifier);
|
||||
+ if (validator.test(loadBeforeTarget)) {
|
||||
+ dependencyGraph.putEdge(loadBeforeTarget, identifier);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ dependencyGraph.addNode(identifier); // Make sure dependencies at least have a node
|
||||
@ -2422,7 +2427,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ LoadOrderConfiguration loadOrderConfiguration = validated.createConfiguration(providerMapMirror);
|
||||
+
|
||||
+ // Build a validated provider's load order changes
|
||||
+ DependencyUtil.buildLoadGraph(loadOrderGraph, loadOrderConfiguration);
|
||||
+ DependencyUtil.buildLoadGraph(loadOrderGraph, loadOrderConfiguration, providerMap::containsKey);
|
||||
+
|
||||
+ // Build a validated provider's dependencies into the graph
|
||||
+ DependencyUtil.buildDependencyGraph(dependencyGraph, configuration);
|
||||
|
Loading…
Reference in New Issue
Block a user