From fe8b567ad1abfb686511fa90771c133385dd1342 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sun, 26 Jan 2020 12:40:56 +1100 Subject: [PATCH] Print warning when loading classes from depends that have not been specified By: md_5 --- .../org/bukkit/plugin/java/PluginClassLoader.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java index 1d91015780..1ae00aa0c0 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java @@ -16,6 +16,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.Manifest; +import java.util.logging.Level; import org.apache.commons.lang.Validate; import org.bukkit.plugin.InvalidPluginException; import org.bukkit.plugin.PluginDescriptionFile; @@ -101,6 +102,17 @@ final class PluginClassLoader extends URLClassLoader { if (result == null) { if (checkGlobal) { result = loader.getClassByName(name); + + if (result != null) { + JavaPlugin provider = ((PluginClassLoader) result.getClassLoader()).plugin; + + if (!description.getDepend().contains(provider.getName()) + && !description.getSoftDepend().contains(provider.getName()) + && !provider.getDescription().getLoadBefore().contains(description.getName())) { + + plugin.getLogger().log(Level.WARNING, "Loaded class {0} from {1} which is not a depend, softdepend or loadbefore of this plugin.", new Object[]{name, description.getFullName()}); + } + } } if (result == null) {