use of net.kodehawa.mantarobot.utils.banner.BannerPrinter in project MantaroBot by Mantaro.
the class MantaroCore method startMainComponents.
public MantaroCore startMainComponents(boolean single) throws Exception {
if (config == null)
throw new IllegalArgumentException("Config cannot be null!");
if (useSentry)
Sentry.init(config.sentryDSN);
if (useBanner)
new BannerPrinter(1).printBanner();
if (commandsPackage == null)
throw new IllegalArgumentException("Cannot look for commands if you don't specify where!");
if (optsPackage == null)
throw new IllegalArgumentException("Cannot look for options if you don't specify where!");
Future<Set<Class<?>>> commands = lookForAnnotatedOn(commandsPackage, Module.class);
Future<Set<Class<?>>> options = lookForAnnotatedOn(optsPackage, Option.class);
if (single) {
startSingleShardInstance();
} else {
startShardedInstance();
}
shardEventBus = new EventBus();
for (Class<?> aClass : commands.get()) {
try {
shardEventBus.register(aClass.newInstance());
} catch (Exception e) {
log.error("Invalid module: no zero arg public constructor found for " + aClass);
}
}
for (Class<?> clazz : options.get()) {
try {
shardEventBus.register(clazz.newInstance());
} catch (Exception e) {
log.error("Invalid module: no zero arg public constructor found for " + clazz);
}
}
Async.thread("Mantaro EventBus-Post", () -> {
// For now, only used by AsyncInfoMonitor startup and Anime Login Task.
shardEventBus.post(new PreLoadEvent());
// Registers all commands
shardEventBus.post(DefaultCommandProcessor.REGISTRY);
// Registers all options
shardEventBus.post(new OptionRegistryEvent());
});
return this;
}
Aggregations