From 46da2553fb2215cc9558cd416757d917c662a7dd Mon Sep 17 00:00:00 2001 From: A248 Date: Sat, 7 Nov 2020 14:53:09 -0500 Subject: [PATCH] Permit passing PluginContainer to PluginManager#addToClasspath --- .../proxy/plugin/VelocityPluginManager.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java b/proxy/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java index 232e8c254..bd84db592 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java @@ -175,9 +175,12 @@ public class VelocityPluginManager implements PluginManager { public void addToClasspath(Object plugin, Path path) { checkNotNull(plugin, "instance"); checkNotNull(path, "path"); - checkArgument(pluginInstances.containsKey(plugin), "plugin is not loaded"); + Optional optContainer = fromInstance(plugin); + checkArgument(optContainer.isPresent(), "plugin is not loaded"); + Optional optInstance = optContainer.get().getInstance(); + checkArgument(optInstance.isPresent(), "plugin has no instance"); - ClassLoader pluginClassloader = plugin.getClass().getClassLoader(); + ClassLoader pluginClassloader = optInstance.get().getClass().getClassLoader(); if (pluginClassloader instanceof PluginClassLoader) { ((PluginClassLoader) pluginClassloader).addPath(path); } else {