use of com.voxelgameslib.voxelgameslib.api.event.events.VoxelGamesLibEnableEvent in project VoxelGamesLibv2 by VoxelGamesLib.
the class VoxelGamesLib method onEnable.
@Override
public void onEnable() {
try {
// logging first, only changes prefixes anyways
loggingHandler = new LoggingHandler();
loggingHandler.setErrorHandler(errorHandler);
loggingHandler.enable();
// enable by enabling external stuff. they don't require any VGL stuff
// timings
timingManager = TimingManager.of(this);
// commands
commandManager = new BukkitCommandManager(this);
commandManager.setDefaultExceptionHandler((scope, registeredCommand, sender, args, t) -> {
errorHandler.handle(sender, args, t);
return false;
});
// living on the edge!
commandManager.enableUnstableAPI("help");
// task chain
taskChainFactory = BukkitTaskChainFactory.create(this);
taskChainFactory.setDefaultErrorHandler((e, t) -> {
log.severe("Task " + t.hashCode() + " generated an exception:");
e.printStackTrace();
});
// chat menu api
ChatMenuAPI.init(this);
// menu builder (excuse the hack, but we want to shade you)
MenuBuilderPlugin menuBuilderPluginFake = new ObjenesisStd().getInstantiatorOf(MenuBuilderPlugin.class).newInstance();
menuBuilderPluginFake.inventoryListener = new InventoryListener(menuBuilderPluginFake);
MenuBuilderPlugin.instance = menuBuilderPluginFake;
Bukkit.getPluginManager().registerEvents(menuBuilderPluginFake.inventoryListener, this);
// guice
VoxelGamesLibModule module = new VoxelGamesLibModule(this, loggingHandler, timingManager, commandManager, getVersion(), getDataFolder(), ModuleHandler.getOfferedModules(), errorHandler);
injector = module.createInjector();
injector.injectMembers(this);
// startup handler
startupHandler.registerService("onEnable");
Bukkit.getPluginManager().registerEvents(injector.getInstance(StartupListener.class), this);
// then enable all VGL stuff
try (final Timing timing = new Timing("EnableAllHandlers")) {
eventHandler.enable();
configHandler.enable();
persistenceHandler.enable();
langHandler.enable();
tickHandler.enable();
chatHandler.enable();
userHandler.enable();
roleHandler.enable();
mapHandler.enable();
worldHandler.enable();
teamHandler.enable();
eloHandler.enable();
matchmakingHandler.enable();
signHandler.enable();
metricHandler.enable();
pointHandler.enable();
kitHandler.enable();
commandHandler.enable();
textureHandler.enable();
statsHandler.enable();
gameHandler.enable();
}
registerListeners();
} catch (Exception ex) {
errorHandler.handle(ex, Severity.ERROR, true);
startupHandler.interrupt();
return;
}
// register commands
registerCommandContexts();
registerCommandReplacements();
registerCommands();
registerCommandCompletions();
moduleHandler.enable();
gameHandler.startDefaultGame();
getServer().getPluginManager().callEvent(new VoxelGamesLibEnableEvent());
testStuff.test();
startupHandler.unregisterService("onEnable");
enabledCleanly = true;
}
Aggregations