|
|
|
@ -80,5 +80,24 @@ public class CommandHandler
|
|
|
|
|
public static void unregisterPlugin(PluginWrapper pluginWrapper)
|
|
|
|
|
{
|
|
|
|
|
LOGGER.debug("Removing commands for plugin {}.", pluginWrapper.getId());
|
|
|
|
|
|
|
|
|
|
// Raw commands
|
|
|
|
|
if(IWithCommands.class.isAssignableFrom(pluginWrapper.getInstance().getClass()))
|
|
|
|
|
{
|
|
|
|
|
LOGGER.debug("Plugin has commands (raw commands).");
|
|
|
|
|
((IWithCommands) pluginWrapper.getInstance()).getCommands().forEach(CommandRegistry::unregisterCommand);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Annotated commands
|
|
|
|
|
if(IWithAnnotatedCommands.class.isAssignableFrom(pluginWrapper.getInstance().getClass()))
|
|
|
|
|
{
|
|
|
|
|
LOGGER.debug("Plugin has commands (annotated commands).");
|
|
|
|
|
((IWithAnnotatedCommands) pluginWrapper.getInstance()).getAnnotatedObjects().forEach(e ->
|
|
|
|
|
{
|
|
|
|
|
for(Method i : e.getClass().getMethods())
|
|
|
|
|
if(i.isAnnotationPresent(AnnotatedCommand.class))
|
|
|
|
|
CommandRegistry.unregisterCommandByName(i.getAnnotation(AnnotatedCommand.class).name());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|