try
{
+ moo.stopPlugins();
Plugin p = pluginManager.loadPlugin(pinfo[0], pinfo[1], pinfo[2]);
- moo.rebuildInjector();
+ moo.buildInjector();
source.reply("Plugin " + p.getName() + " loaded");
}
- catch (Throwable ex)
+ catch (Exception ex)
{
source.reply("Unable to load plugin " + params[2] + ": " + ex.getMessage());
else
{
pluginManager.remove(p);
- moo.rebuildInjector();
+ moo.stopPlugins();
+ moo.buildInjector();
source.reply("Plugin " + p.getName() + " removed");
}
}
if (p == null)
{
source.reply("Plugin " + params[2] + " is not loaded");
+ return;
}
- else
+
+ Artifact a = p.getArtifact();
+ pluginManager.remove(p);
+ moo.stopPlugins();
+ moo.buildInjector();
+
+ try
+ {
+ moo.stopPlugins();
+ p = pluginManager.loadPlugin(a.getGroupId(), a.getArtifactId(), a.getVersion());
+ moo.buildInjector();
+ source.reply("Plugin " + p.getName() + " reloaded");
+ }
+ catch (Exception ex)
{
- Artifact a = p.getArtifact();
- p.remove();
- moo.rebuildInjector();
+ source.reply("Unable to load plugin " + params[2] + ": " + ex.getMessage());
- try
- {
- p = pluginManager.loadPlugin(a.getGroupId(), a.getArtifactId(), a.getVersion());
- moo.rebuildInjector();
- source.reply("Plugin " + p.getName() + " reloaded");
- }
- catch (Throwable ex)
- {
- source.reply("Unable to load plugin " + params[2] + ": " + ex.getMessage());
-
- logger.warn("Unable to reload plugin " + params[2], ex);
- }
+ logger.warn("Unable to reload plugin " + params[2], ex);
}
}
}
return moo.group.schedule(r, t, unit);
}
- private void buildInjector()
+ public void buildInjector()
{
List<Module> modules = new ArrayList<>();
}
}
- public void rebuildInjector()
+ public void stopPlugins()
{
for (Plugin p : pluginManager.getPlugins())
p.stop();
-
- buildInjector();
}
}