aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0300-List-all-missing-hard-depends-not-just-first.patch
diff options
context:
space:
mode:
authorJake Potrebic <[email protected]>2022-03-04 00:09:43 -0800
committerGitHub <[email protected]>2022-03-04 09:09:43 +0100
commit15b6b3db2cf24c98afbfb0849e694875d18fc021 (patch)
tree03e884d0c7fe2ce292825b5b51ec4c9a6ce2e8cc /patches/api/0300-List-all-missing-hard-depends-not-just-first.patch
parent753bf2c1034c5f35cc0839001d12363a44f936fc (diff)
downloadPaper-15b6b3db2cf24c98afbfb0849e694875d18fc021.tar.gz
Paper-15b6b3db2cf24c98afbfb0849e694875d18fc021.zip
Add StructuresLocateEvent as replacement for StructureLocateEvent (#7524)
Diffstat (limited to 'patches/api/0300-List-all-missing-hard-depends-not-just-first.patch')
-rw-r--r--patches/api/0300-List-all-missing-hard-depends-not-just-first.patch91
1 files changed, 91 insertions, 0 deletions
diff --git a/patches/api/0300-List-all-missing-hard-depends-not-just-first.patch b/patches/api/0300-List-all-missing-hard-depends-not-just-first.patch
new file mode 100644
index 0000000000..995528e860
--- /dev/null
+++ b/patches/api/0300-List-all-missing-hard-depends-not-just-first.patch
@@ -0,0 +1,91 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+Date: Tue, 18 May 2021 10:38:10 -0700
+Subject: [PATCH] List all missing hard depends not just first
+
+
+diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
+index 0d9d729a18b5388b06ab0a3749e55f91f838be88..c57a59d337a41c083e88e36637d839db027b9289 100644
+--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
++++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
+@@ -262,6 +262,7 @@ public final class SimplePluginManager implements PluginManager {
+
+ if (dependencies.containsKey(plugin)) {
+ Iterator<String> dependencyIterator = dependencies.get(plugin).iterator();
++ final Set<String> missingHardDependencies = new HashSet<>(dependencies.get(plugin).size()); // Paper - list all missing hard depends
+
+ while (dependencyIterator.hasNext()) {
+ String dependency = dependencyIterator.next();
+@@ -272,6 +273,12 @@ public final class SimplePluginManager implements PluginManager {
+
+ // We have a dependency not found
+ } else if (!plugins.containsKey(dependency) && !pluginsProvided.containsKey(dependency)) {
++ // Paper start
++ missingHardDependencies.add(dependency);
++ }
++ }
++ if (!missingHardDependencies.isEmpty()) {
++ // Paper end
+ missingDependency = false;
+ pluginIterator.remove();
+ softDependencies.remove(plugin);
+@@ -280,9 +287,7 @@ public final class SimplePluginManager implements PluginManager {
+ server.getLogger().log(
+ Level.SEVERE,
+ "Could not load '" + entry.getValue().getPath() + "' in folder '" + entry.getValue().getParentFile().getPath() + "'", // Paper
+- new UnknownDependencyException("Unknown dependency " + dependency + ". Please download and install " + dependency + " to run this plugin."));
+- break;
+- }
++ new UnknownDependencyException(missingHardDependencies, plugin)); // Paper
+ }
+
+ if (dependencies.containsKey(plugin) && dependencies.get(plugin).isEmpty()) {
+diff --git a/src/main/java/org/bukkit/plugin/UnknownDependencyException.java b/src/main/java/org/bukkit/plugin/UnknownDependencyException.java
+index a80251eff75430863b37db1c131e22593f3fcd5e..7b2e607a21f1173d98ee84581881411176380625 100644
+--- a/src/main/java/org/bukkit/plugin/UnknownDependencyException.java
++++ b/src/main/java/org/bukkit/plugin/UnknownDependencyException.java
+@@ -26,6 +26,19 @@ public class UnknownDependencyException extends RuntimeException {
+ super(message);
+ }
+
++ // Paper start
++ /**
++ * Create a new {@link UnknownDependencyException} with a message informing
++ * about which dependencies are missing for what plugin.
++ *
++ * @param missingDependencies missing dependencies
++ * @param pluginName plugin which is missing said dependencies
++ */
++ public UnknownDependencyException(final @org.jetbrains.annotations.NotNull java.util.Collection<String> missingDependencies, final @org.jetbrains.annotations.NotNull String pluginName) {
++ this("Unknown/missing dependency plugins: [" + String.join(", ", missingDependencies) + "]. Please download and install these plugins to run '" + pluginName + "'.");
++ }
++ // Paper end
++
+ /**
+ * Constructs a new UnknownDependencyException based on the given
+ * Exception
+diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
+index d2712f45dbcf26fabe8463d99f378bf422c66970..c8b11793c6a3baabc1c9566e0463ab1d6e293827 100644
+--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
++++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
+@@ -132,13 +132,19 @@ public final class JavaPluginLoader implements PluginLoader {
+ ));
+ }
+
++ Set<String> missingHardDependencies = new HashSet<>(description.getDepend().size()); // Paper - list all missing hard depends
+ for (final String pluginName : description.getDepend()) {
+ Plugin current = server.getPluginManager().getPlugin(pluginName);
+
+ if (current == null) {
+- throw new UnknownDependencyException("Unknown dependency " + pluginName + ". Please download and install " + pluginName + " to run this plugin.");
++ missingHardDependencies.add(pluginName); // Paper - list all missing hard depends
+ }
+ }
++ // Paper start - list all missing hard depends
++ if (!missingHardDependencies.isEmpty()) {
++ throw new UnknownDependencyException(missingHardDependencies, description.getFullName());
++ }
++ // Paper end
+
+ server.getUnsafe().checkSupported(description);
+