diff --git a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java index 8682f341b4..dbcbacb1b5 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -796,11 +796,11 @@ public final class SimplePluginManager implements PluginManager { return new HashSet(permissions.values()); } - public boolean isTransitiveDepend(@NotNull PluginDescriptionFile plugin, @NotNull Plugin depend) { + public boolean isTransitiveDepend(@NotNull PluginDescriptionFile plugin, @NotNull PluginDescriptionFile depend) { Preconditions.checkArgument(plugin != null, "plugin"); Preconditions.checkArgument(depend != null, "depend"); - return Graphs.reachableNodes(dependencyGraph, plugin.getName()).contains(depend.getName()); + return dependencyGraph.nodes().contains(plugin.getName()) && Graphs.reachableNodes(dependencyGraph, plugin.getName()).contains(depend.getName()); } @Override 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 bd10ca723f..5830e8b9b7 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 @@ -1,6 +1,5 @@ package org.bukkit.plugin.java; -import com.google.common.base.Preconditions; import com.google.common.io.ByteStreams; import java.io.File; import java.io.IOException; @@ -108,20 +107,18 @@ final class PluginClassLoader extends URLClassLoader { result = loader.getClassByName(name); if (result != null) { - JavaPlugin provider = ((PluginClassLoader) result.getClassLoader()).plugin; - Preconditions.checkState(provider != null, "Globally provided class %s has no plugin. Perhaps broken reflection is in use.", name); - String providerName = provider.getName(); + PluginDescriptionFile provider = ((PluginClassLoader) result.getClassLoader()).description; - if (provider != plugin - && !seenIllegalAccess.contains(providerName) + if (provider != description + && !seenIllegalAccess.contains(provider.getName()) && !((SimplePluginManager) loader.server.getPluginManager()).isTransitiveDepend(description, provider)) { - seenIllegalAccess.add(providerName); + seenIllegalAccess.add(provider.getName()); if (plugin != null) { - plugin.getLogger().log(Level.WARNING, "Loaded class {0} from {1} which is not a depend, softdepend or loadbefore of this plugin.", new Object[]{name, provider.getDescription().getFullName()}); + plugin.getLogger().log(Level.WARNING, "Loaded class {0} from {1} which is not a depend, softdepend or loadbefore of this plugin.", new Object[]{name, provider.getFullName()}); } else { // In case the bad access occurs on construction - loader.server.getLogger().log(Level.WARNING, "[{0}] Loaded class {1} from {2} which is not a depend, softdepend or loadbefore of this plugin.", new Object[]{description.getName(), name, provider.getDescription().getFullName()}); + loader.server.getLogger().log(Level.WARNING, "[{0}] Loaded class {1} from {2} which is not a depend, softdepend or loadbefore of this plugin.", new Object[]{description.getName(), name, provider.getFullName()}); } } }