use of dev.rosewood.rosegarden.command.framework.RoseCommandWrapper in project RoseGarden by Rosewood-Development.
the class AbstractCommandManager method reload.
@Override
public final void reload() {
if (this.commandWrappers == null) {
this.commandWrappers = new ArrayList<>();
for (Class<? extends RoseCommandWrapper> commandWrapperClass : this.getRootCommands()) {
try {
Constructor<? extends RoseCommandWrapper> constructor = commandWrapperClass.getConstructor(RosePlugin.class);
RoseCommandWrapper commandWrapper = constructor.newInstance(this.rosePlugin);
this.commandWrappers.add(commandWrapper);
} catch (ReflectiveOperationException e) {
e.printStackTrace();
}
}
}
try {
// Load argument handlers
List<Class<RoseCommandArgumentHandler>> argumentHandlerClasses = new ArrayList<>(ClassUtils.getClassesOf(this.rosePlugin, ARGUMENT_PACKAGE, RoseCommandArgumentHandler.class));
this.getArgumentHandlerPackages().stream().map(x -> ClassUtils.getClassesOf(this.rosePlugin, x, RoseCommandArgumentHandler.class)).forEach(argumentHandlerClasses::addAll);
for (Class<RoseCommandArgumentHandler> argumentHandlerClass : argumentHandlerClasses) {
// Ignore abstract/interface classes
if (Modifier.isAbstract(argumentHandlerClass.getModifiers()) || Modifier.isInterface(argumentHandlerClass.getModifiers()))
continue;
RoseCommandArgumentHandler<?> argumentHandler = argumentHandlerClass.getConstructor(RosePlugin.class).newInstance(this.rosePlugin);
this.argumentHandlers.put(argumentHandlerClass, argumentHandler);
}
} catch (Exception e) {
this.rosePlugin.getLogger().severe("Fatal error initializing command argument handlers");
e.printStackTrace();
}
this.commandWrappers.forEach(RoseCommandWrapper::register);
Bukkit.getOnlinePlayers().forEach(Player::updateCommands);
}
Aggregations