use of net.runelite.client.events.PluginChanged in project runelite by runelite.
the class PluginManager method startPlugin.
public synchronized boolean startPlugin(Plugin plugin) throws PluginInstantiationException {
if (activePlugins.contains(plugin) || !isPluginEnabled(plugin)) {
return false;
}
activePlugins.add(plugin);
try {
// plugins always start in the event thread
SwingUtilities.invokeAndWait(() -> {
try {
plugin.startUp();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
});
log.debug("Plugin {} is now running", plugin.getClass().getSimpleName());
regionTileManager.simulateObjectSpawns(plugin);
eventBus.register(plugin);
schedule(plugin);
eventBus.post(new PluginChanged(plugin, true));
} catch (InterruptedException | InvocationTargetException ex) {
throw new PluginInstantiationException(ex);
}
return true;
}
use of net.runelite.client.events.PluginChanged in project runelite by runelite.
the class PluginManager method stopPlugin.
public synchronized boolean stopPlugin(Plugin plugin) throws PluginInstantiationException {
if (!activePlugins.contains(plugin) || isPluginEnabled(plugin)) {
return false;
}
activePlugins.remove(plugin);
try {
unschedule(plugin);
eventBus.unregister(plugin);
// plugins always stop in the event thread
SwingUtilities.invokeAndWait(() -> {
try {
plugin.shutDown();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
});
log.debug("Plugin {} is now stopped", plugin.getClass().getSimpleName());
eventBus.post(new PluginChanged(plugin, false));
} catch (InterruptedException | InvocationTargetException ex) {
throw new PluginInstantiationException(ex);
}
return true;
}
Aggregations