/// <inheritdoc /> public void Register(IDependencyContainer container, IDependencyResolver resolver) { container.RegisterSingletonType <IHost, EcoHost>(null, "eco", "game"); container.RegisterSingletonType <IEcoSettingsProvider, EcoSettingsProvider>(); IEcoSettingsProvider settingsProvider = container.Resolve <IEcoSettingsProvider>(); settingsProvider.Load(); container.RegisterSingletonType <ICommandProvider, EcoCommandProvider>("eco_commands"); container.RegisterSingletonInstance <ICommandProvider>(new EcoNativeCommandProvider(container, settingsProvider), "eco_vanilla_commands"); container.RegisterSingletonType <IPermissionProvider, EcoPermissionProvider>("eco_vanilla_permissions"); container.RegisterSingletonType <ITaskScheduler, EcoTaskScheduler>(null, "eco", "game"); IPlayerManager playerManager = new EcoPlayerManager(container); container.RegisterSingletonInstance(playerManager, null, "eco", "game"); container.RegisterSingletonInstance <IUserManager>(playerManager, "eco", "game"); container.RegisterSingletonType <IUserManager, StdConsoleUserManager>("stdconsole"); #if DEBUG container.RegisterSingletonType <IGovernment, EcoGovernment>(null, "eco", "game"); container.RegisterSingletonType <IEconomyProvider, EcoEconomyProvider>(null, "eco", "game"); #endif }
/// <inheritdoc /> public void Init(IRuntime runtime) { if (Assembly.GetCallingAssembly().GetName().Name != "Rocket.Runtime") { throw new MethodAccessException(); } this.runtime = runtime; logger = runtime.Container.Resolve <ILogger>(); eventManager = runtime.Container.Resolve <IEventBus>(); pluginManager = runtime.Container.Resolve <IPluginManager>(); commandHandler = runtime.Container.Resolve <ICommandHandler>(); taskScheduler = runtime.Container.Resolve <ITaskScheduler>(); permissionProvider = (ConfigurationPermissionProvider)runtime.Container.Resolve <IPermissionProvider>("default_permissions"); playerManager = (EcoPlayerManager)runtime.Container.Resolve <IPlayerManager>("eco"); CheckConfig(); Func <object, bool> prePlayerJoin = _EmitPlayerPreJoin; Action <object> playerJoin = _EmitPlayerJoin; Action <object> playerLeave = _EmitPlayerLeave; Func <object, string, bool> playerChat = _EmitPlayerChat; Type userType = typeof(User); Type chatManagerType = typeof(ChatManager); userType.GetField("OnUserPreLogin").SetValue(null, prePlayerJoin); userType.GetField("OnUserLogin").SetValue(null, playerJoin); userType.GetField("OnUserLogout").SetValue(null, playerLeave); chatManagerType.GetField("OnUserChat").SetValue(null, playerChat); pluginManager.Init(); eventManager.Emit(this, new ImplementationReadyEvent(this)); logger.LogInformation($"Rocket has initialized under the server name {ServerName}!"); while (true) { string input = System.Console.ReadLine(); if (input == null) { continue; } taskScheduler .ScheduleNextFrame(this, () => { if (input.StartsWith("/", StringComparison.InvariantCulture)) { input = input.Remove(0, 1); } bool wasHandled = commandHandler.HandleCommand(Console, input, string.Empty); if (!wasHandled) { logger.LogError("That command could not be found!"); } }, "Console Command"); } }