use of io.github.nucleuspowered.nucleus.internal.command.ICommandInterceptor in project Nucleus by NucleusPowered.
the class StandardModule method registerCommandInterceptors.
private void registerCommandInterceptors() throws Exception {
RegisterCommandInterceptors annotation = getClass().getAnnotation(RegisterCommandInterceptors.class);
if (annotation != null) {
// for each annotation, attempt to register the service.
for (Class<? extends ICommandInterceptor> service : annotation.value()) {
// create the impl
ICommandInterceptor impl;
try {
impl = service.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
String error = "ERROR: Cannot instantiate ICommandInterceptor " + service.getName();
Nucleus.getNucleus().getLogger().error(error);
throw new IllegalStateException(error, e);
}
if (impl instanceof Reloadable) {
Reloadable reloadable = (Reloadable) impl;
Nucleus.getNucleus().registerReloadable(reloadable);
reloadable.onReload();
}
AbstractCommand.registerInterceptor(impl);
}
}
}
Aggregations