Missing unregister

keep-around/d31701866686f66088b78de2e29736ae36e55a68
Pingex aka Raphaël 9 years ago
parent 279d8aae13
commit a4e493e577

@ -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());
});
}
}
}

@ -2,7 +2,6 @@ package net.pingex.dcf.commands;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.*;
/**