3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 19:10:09 +01:00
Paper/patches/api/0300-List-all-missing-hard-depends-not-just-first.patch

92 Zeilen
5.2 KiB
Diff

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
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
2022-07-21 21:53:04 +02:00
index 7937e240949bbaeb680098a674d27087e3f6acf8..60988665eb358d5566e9de61aec841db3f79722c 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
2022-07-21 21:53:04 +02:00
@@ -258,6 +258,7 @@ public final class SimplePluginManager implements PluginManager {
2021-06-11 14:02:28 +02:00
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();
2022-07-21 21:53:04 +02:00
@@ -268,6 +269,12 @@ public final class SimplePluginManager implements PluginManager {
2021-06-11 14:02:28 +02:00
// 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);
2022-07-21 21:53:04 +02:00
@@ -276,9 +283,7 @@ public final class SimplePluginManager implements PluginManager {
2021-06-11 14:02:28 +02:00
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
2022-06-07 19:20:30 +02:00
index 4b54af83ef8fd18696d2d21ed52b61f13bff7988..8ff78fad47f6086aa289e32590f4fbec24b3d500 100644
2021-06-11 14:02:28 +02:00
--- 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);