use of io.xol.chunkstories.api.exceptions.plugins.PluginCreationException in project chunkstories by Hugobros3.
the class DefaultPluginManager method enablePlugins.
private void enablePlugins(LinkedList<PluginInformationImplementation> pluginsToInitialize) {
logger().info(pluginsToInitialize.size() + " plugins to initialize");
Deque<PluginInformationImplementation> order = new LinkedBlockingDeque<PluginInformationImplementation>();
// TODO sort plugins requirements (requires/before)
for (PluginInformationImplementation pluginInformation : pluginsToInitialize) {
order.add(pluginInformation);
}
// Loads each provided plugin
for (PluginInformationImplementation pluginInformation : order) {
try {
// Add commands support
for (Command command : pluginInformation.getCommands()) {
// Checks the command isn't already defined
if (commands.contains(command)) {
logger().warn("Plugin " + pluginInformation.getName() + " can't define the command " + command.getName() + " as it's already defined by another plugin.");
continue;
}
commands.add(command);
for (String alias : command.aliases()) if (commandsAliases.put(alias, command) != null)
logger().warn("Plugin " + pluginInformation + " tried to register alias " + alias + " for command " + command + ".");
}
// Instanciate the plugin after all
ChunkStoriesPlugin pluginInstance = pluginInformation.createInstance(pluginExecutionContext);
activePlugins.add(pluginInstance);
pluginInstance.onEnable();
} catch (PluginCreationException pce) {
logger().error("Couldn't create plugin " + pluginInformation + " : " + pce.getMessage());
pce.printStackTrace();
}
}
}
Aggregations