Inline PluginManager#loadPlugins() call to catch load errors (bungee)
This commit is contained in:
parent
c1a6fe269e
commit
870e2bcae5
2 changed files with 31 additions and 2 deletions
|
|
@ -12,6 +12,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.Stack;
|
||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
@ -82,7 +83,17 @@ public class BungeePluginManager extends AbstractPluginManager<Plugin, BungeePlu
|
||||||
}
|
}
|
||||||
|
|
||||||
RPluginManager.setToLoad(proxyPluginManager, toLoad);
|
RPluginManager.setToLoad(proxyPluginManager, toLoad);
|
||||||
proxyPluginManager.loadPlugins();
|
|
||||||
|
Map<PluginDescription, Boolean> pluginStatuses = new HashMap<>();
|
||||||
|
for (Map.Entry<String, PluginDescription> entry : toLoad.entrySet()) {
|
||||||
|
// Yeah... loadPlugins() calls enablePlugin()
|
||||||
|
if (!RPluginManager.enablePlugin(proxyPluginManager, pluginStatuses, new Stack<>(), entry.getValue())) {
|
||||||
|
return loadResults.addResult(entry.getKey(), Result.ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toLoad.clear();
|
||||||
|
RPluginManager.setToLoad(proxyPluginManager, null);
|
||||||
|
|
||||||
for (BungeePluginDescription description : descriptions) {
|
for (BungeePluginDescription description : descriptions) {
|
||||||
Optional<Plugin> pluginOptional = getPlugin(description.getId());
|
Optional<Plugin> pluginOptional = getPlugin(description.getId());
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
package net.frankheijden.serverutils.bungee.reflection;
|
package net.frankheijden.serverutils.bungee.reflection;
|
||||||
|
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import java.util.Map;
|
import dev.frankheijden.minecraftreflection.ClassObject;
|
||||||
import dev.frankheijden.minecraftreflection.MinecraftReflection;
|
import dev.frankheijden.minecraftreflection.MinecraftReflection;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Stack;
|
||||||
import net.frankheijden.serverutils.common.utils.MapUtils;
|
import net.frankheijden.serverutils.common.utils.MapUtils;
|
||||||
import net.md_5.bungee.api.plugin.Command;
|
import net.md_5.bungee.api.plugin.Command;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
|
|
@ -43,6 +45,22 @@ public class RPluginManager {
|
||||||
reflection.set(pluginManager, "toLoad", toLoad);
|
reflection.set(pluginManager, "toLoad", toLoad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables a plugin.
|
||||||
|
*/
|
||||||
|
public static boolean enablePlugin(
|
||||||
|
Object pluginManager,
|
||||||
|
Map<PluginDescription, Boolean> pluginStatuses,
|
||||||
|
Stack<PluginDescription> dependStack,
|
||||||
|
PluginDescription plugin
|
||||||
|
) {
|
||||||
|
return reflection.invoke(pluginManager, "enablePlugin",
|
||||||
|
ClassObject.of(Map.class, pluginStatuses),
|
||||||
|
ClassObject.of(Stack.class, dependStack),
|
||||||
|
ClassObject.of(PluginDescription.class, plugin)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the registered plugin of the command.
|
* Retrieves the registered plugin of the command.
|
||||||
* @param instance The PluginManager instance.
|
* @param instance The PluginManager instance.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue