use of com.voxelgameslib.voxelgameslib.internal.log.LoggingHandler 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;
}
use of com.voxelgameslib.voxelgameslib.internal.log.LoggingHandler in project VoxelGamesLibv2 by VoxelGamesLib.
the class VoxelGamesLibModule method configure.
@Override
protected void configure() {
bind(Plugin.class).toInstance(voxelGamesLib);
bind(VoxelGamesLib.class).toInstance(voxelGamesLib);
bind(TimingManager.class).toInstance(timingManager);
bind(BukkitCommandManager.class).toInstance(commandManager);
bind(LoggingHandler.class).toInstance(loggingHandler);
bind(ErrorHandler.class).toInstance(errorHandler);
bind(String.class).annotatedWith(Names.named("PluginVersion")).toInstance(pluginVersion);
bind(File.class).annotatedWith(Names.named("ConfigFolder")).toInstance(dataFolder);
bind(File.class).annotatedWith(Names.named("LangFolder")).toInstance(new File(dataFolder.getAbsoluteFile(), "lang"));
bind(File.class).annotatedWith(Names.named("WorldsFolder")).toInstance(new File(Bukkit.getWorldContainer().getAbsoluteFile(), "worlds"));
bind(File.class).annotatedWith(Names.named("WorldContainer")).toInstance(Bukkit.getWorldContainer().getAbsoluteFile());
bind(File.class).annotatedWith(Names.named("GameDefinitionFolder")).toInstance(new File(dataFolder.getAbsoluteFile(), "games"));
bind(File.class).annotatedWith(Names.named("DataFolder")).toInstance(new File(dataFolder.getAbsoluteFile(), "data"));
bind(File.class).annotatedWith(Names.named("KitsFolder")).toInstance(new File(dataFolder.getAbsoluteFile(), "kits"));
bind(File.class).annotatedWith(Names.named("SkinsFolder")).toInstance(new File(dataFolder.getAbsoluteFile(), "skins"));
bind(WorldConfig.class).toProvider(WorldHandler.class);
bind(GlobalConfig.class).toProvider(ConfigHandler.class);
requestStaticInjection(Lang.class);
requestStaticInjection(Permission.class);
offeredModules.forEach((key, value) -> bind(key).toInstance(value));
}
Aggregations