From 75e61d5bf2ac1d8ffed59ffa8e0bb9c06e3f2183 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Wed, 22 Feb 2023 10:59:12 -0500 Subject: [PATCH] Validate providers when populating load order tree (#8890) --- patches/server/Paper-Plugins.patch | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/patches/server/Paper-Plugins.patch b/patches/server/Paper-Plugins.patch index 91d4cf6608..8792d587e0 100644 --- a/patches/server/Paper-Plugins.patch +++ b/patches/server/Paper-Plugins.patch @@ -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 buildLoadGraph(@NotNull MutableGraph dependencyGraph, @NotNull LoadOrderConfiguration configuration) { ++ public static MutableGraph buildLoadGraph(@NotNull MutableGraph dependencyGraph, @NotNull LoadOrderConfiguration configuration, Predicate 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);