private void _checkForUpdates(object parameter) { GithubUpdater Updater = new GithubUpdater(); if (Updater.LaunchUpdater() == 0) { ToastViewModel.Show("No update available"); } }
static void Main() { bool bUpdatePending = GithubUpdater.FindAndApplyUpdates(); if (bUpdatePending) { return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
public ShellViewModel() { SelectedProfile = null; _mainWindow = new ShellView(); _mainWindow.Topmost = Configuration.Instance.AlwaysOnTop; _mainWindow.DataContext = this; _mainWindow.Show(); if (Configuration.Instance.LaunchProfileId != 0) { SelectedProfile = Configuration.ProfileById(Configuration.Instance.LaunchProfileId); _launchAndMove(null); } if (Configuration.Instance.LastOpenProfileId != 0) { SelectedProfile = Configuration.ProfileById(Configuration.Instance.LastOpenProfileId); } GithubUpdater updater = new GithubUpdater(); if (Configuration.Instance.CheckForUpdates) { updater.LaunchUpdaterAsync(); } }
protected override void Load() { try { var stopwatch = Stopwatch.StartNew(); Instance = this; try { var essPermProvider = new EssentialsPermissionsProvider(); R.Permissions = essPermProvider; } catch (Exception ex) { Console.Error.WriteLine(ex); } R.Plugins.OnPluginsLoaded += OverrideCommands; TaskExecutor = new EssentialsTaskExecutor(); SteamGameServer.SetKeyValue("essversion", PLUGIN_VERSION); Logger = new ConsoleLogger("[uEssentials] "); ConnectedPlayers = new Dictionary <ulong, UPlayer>(); Debug.Listeners.Add(new EssentialsConsoleTraceListener()); Provider.onServerDisconnected += PlayerDisconnectCallback; Provider.onServerConnected += PlayerConnectCallback; Logger.LogInfo("Enabling uEssentials..."); if (Provider.clients.Count > 0) { Provider.clients.ForEach(p => { ConnectedPlayers.Add(p.playerID.steamID.m_SteamID, new UPlayer(UnturnedPlayer.FromSteamPlayer(p))); }); } _folder = Rocket.Core.Environment.PluginsDirectory + "/uEssentials/"; _translationFolder = Folder + "translations/"; _dataFolder = Folder + "data/"; _modulesFolder = Folder + "modules/"; WebResources = new WebResources(); Config = new EssConfig(); var webResourcesPath = Path.Combine(Folder, WebResources.FileName); var configPath = Path.Combine(Folder, Config.FileName); WebResources.Load(webResourcesPath); // Sync web config with local config.json if (WebResources.Loaded.ContainsKey("Config")) { File.WriteAllText(configPath, WebResources.Loaded["Config"]); } Config.Load(configPath); CommandOptions = new CommandOptions(); CommandOptions.Load(Path.Combine(Folder, CommandOptions.FileName)); Updater = new GithubUpdater(); EventManager = new EventManager(); CommandManager = new CommandManager(); ModuleManager = new ModuleManager(); HookManager = new HookManager(); EssLang.Load(); new [] { "Plugin version: ~white~" + PLUGIN_VERSION + BUILD_INFO, "Recommended Rocket version: ~white~" + ROCKET_VERSION, "Recommended Unturned version: ~white~" + UNTURNED_VERSION, "Author: ~white~leonardosnt", "Wiki: ~white~uessentials.github.io", }.ForEach(text => Logger.LogInfo(text, true)); EventManager.RegisterAll(GetType().Assembly); if (!Config.EnableJoinLeaveMessage) { EventManager.Unregister <EssentialsEventHandler>("JoinMessage"); EventManager.Unregister <EssentialsEventHandler>("LeaveMessage"); } // Register all commands from namespace Essentials.Commands CommandManager.RegisterAll("Essentials.Commands"); HookManager.RegisterAll(); HookManager.LoadAll(); if (Config.Economy.UseXp) { EconomyProvider = Optional <IEconomyProvider> .Of(new ExpEconomyProvider()); } else if (HookManager.GetActiveByType <AviEconomyHook>().IsPresent) { EconomyProvider = Optional <IEconomyProvider> .Of(HookManager.GetActiveByType <AviEconomyHook>().Value); } else if (HookManager.GetActiveByType <UconomyHook>().IsPresent) { EconomyProvider = Optional <IEconomyProvider> .Of(HookManager.GetActiveByType <UconomyHook>().Value); } else { EconomyProvider = Optional <IEconomyProvider> .Empty(); } LoadNativeModules(); Logger.LogInfo($"Loaded {CommandManager.Commands.Count()} commands"); Logger.LogInfo("Loading modules..."); ModuleManager.LoadAll(ModulesFolder); Logger.LogInfo($"Loaded {ModuleManager.RunningModules.Count(t => !(t is NativeModule))} modules"); if (Config.AutoAnnouncer.Enabled) { Config.AutoAnnouncer.Start(); } if (Config.AutoCommands.Enabled) { Config.AutoCommands.Start(); } if (!Config.Updater.AlertOnJoin) { EventManager.Unregister <EssentialsEventHandler>("UpdateAlert"); } if (Config.ServerFrameRate != -1) { var frameRate = Config.ServerFrameRate; if (Config.ServerFrameRate < -1) { frameRate = -1; // Set to default } UnityEngine.Application.targetFrameRate = frameRate; } if (Config.DisabledCommands.Count != 0) { Config.DisabledCommands.ForEach(cmdName => { var command = CommandManager.GetByName(cmdName); if (command == null || command is CommandEssentials) { Logger.LogWarning($"There is no command named '{cmdName}' to disable."); } else { CommandManager.Unregister(command); Logger.LogInfo($"Disabled command: '{command.Name}'"); } }); } if (Config.EnableTextCommands) { TextCommands = new TextCommands(); var textCommandsFile = Path.Combine(Folder, TextCommands.FileName); TextCommands.Load(textCommandsFile); TextCommands.Commands.ForEach(txtCommand => { CommandManager.Register(new TextCommand(txtCommand)); }); } if (!Config.EnableDeathMessages) { EventManager.Unregister <EssentialsEventHandler>("DeathMessages"); } #if EXPERIMENTAL Logger.LogWarning("THIS IS AN EXPERIMENTAL BUILD, CAN BE BUGGY."); Logger.LogWarning("THIS IS AN EXPERIMENTAL BUILD, CAN BE BUGGY."); #endif // Delete useless files generated by Rocket Task.Create() .Id("Delete Xml Files") .Delay(TimeSpan.FromSeconds(1)) .Async() .Action(() => { File.Delete($"{Folder}uEssentials.en.translation.xml"); File.Delete($"{Folder}uEssentials.configuration.xml"); }) .Submit(); CommandWindow.input.onInputText += ReloadCallback; Logger.LogInfo($"Enabled ({stopwatch.ElapsedMilliseconds} ms)"); } catch (Exception e) { var msg = new List <string>() { "An error occurred while enabling uEssentials.", "If this error is not related with wrong configuration please report", "immediatly here https://github.com/uEssentials/uEssentials/issues", "Error: " + e }; if (!Provider.APP_VERSION.EqualsIgnoreCase(UNTURNED_VERSION)) { msg.Add("I detected that you are using a different version of the recommended, " + "please update your uEssentials/Unturned."); msg.Add("If you are using the latest uEssentials release, please wait for update."); } if (Logger == null) { Console.BackgroundColor = ConsoleColor.Red; msg.ForEach(Console.WriteLine); Console.BackgroundColor = ConsoleColor.White; } else { msg.ForEach(Logger.LogError); } } #if !DEV Analytics.SendEvent($"ServerInit"); #endif #if DEV Console.Title = "Unturned Server"; #else CheckUpdates(); #endif }
private void Application_Startup(object sender, StartupEventArgs e) { Logger.Initialize(e.Args); bool canStart = false; bool updatePending = GithubUpdater.FindAndApplyUpdates(); if (!updatePending) { bool hasAssets = LoadAssets(); if (hasAssets) { canStart = true; } else { string appName = Assembly.GetEntryAssembly().GetName().Name; MessageBox.Show("Failed to initialize resources!", appName, MessageBoxButton.OK, MessageBoxImage.Stop); } } #if DEBUG if (Array.Find(e.Args, x => x == "-runTests") != null) { TestManager.RunTests(); canStart = false; } else if (Array.Find(e.Args, x => x == "-dataConvert") != null) { var converter = new DataConverter(); converter.Run(); canStart = false; } #endif // DEBUG if (canStart) { DialogWindowService.Initialize(); OverlayWindowService.Initialize(); AppWindowService.Initialize(); canSaveSettings = true; var window = new MainWindow(); var settingsDB = PlayerSettingsDB.Get(); window.FontSize = settingsDB.fontSize; window.Topmost = settingsDB.alwaysOnTop; if (settingsDB.lastHeight > window.MinHeight) { window.Height = settingsDB.lastHeight; } if (settingsDB.lastWidth > window.MinWidth) { window.Width = settingsDB.lastWidth; } window.Show(); } else { Shutdown(); } }
protected override void Load() { try { var stopwatch = Stopwatch.StartNew(); Instance = this; R.Permissions = new EssentialsPermissionsProvider(); Provider.onServerDisconnected += PlayerDisconnectCallback; Provider.onServerConnected += PlayerConnectCallback; Logger = new EssLogger("[uEssentials] "); ConnectedPlayers = new Dictionary <ulong, UPlayer>(); Logger.Log("Enabling uEssentials.", ConsoleColor.Green); if (Provider.Players.Count > 0) { Provider.Players.ForEach(p => { ConnectedPlayers.Add(p.SteamPlayerID.CSteamID.m_SteamID, new UPlayer(UnturnedPlayer.FromSteamPlayer(p))); }); } _folder = Rocket.Core.Environment.PluginsDirectory + "/uEssentials/"; _translationFolder = Folder + "translations/"; _dataFolder = Folder + "data/"; _modulesFolder = Folder + "modules/"; var configPath = $"{Folder}config.json"; Config = new EssConfig(); Config.Load(configPath); if (Config.WebConfig.Enabled) { var conf = new EssWebConfig(); conf.Load(configPath); Config = conf; } CommandsConfig = new CommandsConfig(); CommandsConfig.Load($"{Folder}commands.json"); Updater = new GithubUpdater(); EventManager = new EventManager(); CommandManager = new CommandManager(); ModuleManager = new ModuleManager(); HookManager = new HookManager(); EssLang.Load(); Logger.Log("Plugin version: ", ConsoleColor.Green, suffix: ""); #if EXPERIMENTAL const string label = "experimental" #if EXPERIMENTAL_HASH + "-commit-$COMMIT_HASH$" #endif ; Logger.Log($"{PLUGIN_VERSION} {label}", ConsoleColor.White, ""); #else Logger.Log(PLUGIN_VERSION, ConsoleColor.White, ""); #endif Logger.Log("Recommended Rocket version: ", ConsoleColor.Green, suffix: ""); Logger.Log(ROCKET_VERSION, ConsoleColor.White, ""); Logger.Log("Recommended Unturned version: ", ConsoleColor.Green, suffix: ""); Logger.Log(UNTURNED_VERSION, ConsoleColor.White, ""); Logger.Log("Author: ", ConsoleColor.Green, suffix: ""); Logger.Log("leonardosc", ConsoleColor.White, ""); Logger.Log("Wiki: ", ConsoleColor.Green, suffix: ""); Logger.Log("uessentials.github.io", ConsoleColor.White, ""); EventManager.RegisterAll(GetType().Assembly); if (!Config.EnableJoinLeaveMessage) { EventManager.Unregister <EssentialsEventHandler>("JoinMessage"); EventManager.Unregister <EssentialsEventHandler>("LeaveMessage"); } CommandManager.RegisterAll("Essentials.Commands"); HookManager.RegisterAll(); HookManager.LoadAll(); if (Config.Economy.UseXp) { EconomyProvider = Optional <IEconomyProvider> .Of(new ExpEconomyProvider()); } else if (HookManager.GetActiveByType <UconomyHook>().IsPresent) { EconomyProvider = Optional <IEconomyProvider> .Of( HookManager.GetActiveByType <UconomyHook>().Value); } else { EconomyProvider = Optional <IEconomyProvider> .Empty(); } /* * Load native modules */ ( from type in Assembly.GetTypes() where typeof(NativeModule).IsAssignableFrom(type) where !type.IsAbstract let mAttr = (ModuleInfo)type.GetCustomAttributes(typeof(ModuleInfo), false)[0] where Config.EnabledSystems.Any(s => s.Equals(mAttr.Name, StringComparison.OrdinalIgnoreCase)) select type ).ForEach(type => { ModuleManager.LoadModule((NativeModule)Activator.CreateInstance(type)); }); Logger.LogInfo($"Loaded {CommandManager.Commands.Count()} commands"); Logger.LogInfo("Loading modules..."); ModuleManager.LoadAll(ModulesFolder); Logger.LogInfo($"Loaded {ModuleManager.RunningModules.Count(t => !(t is NativeModule))} modules"); if (Config.AutoAnnouncer.Enabled) { Config.AutoAnnouncer.Start(); } if (Config.AutoCommands.Enabled) { Config.AutoCommands.Start(); } if (!Config.Updater.AlertOnJoin) { EventManager.Unregister <EssentialsEventHandler>("UpdateAlert"); } if (Config.ServerFrameRate != -1) { var frameRate = Config.ServerFrameRate; if (Config.ServerFrameRate < -1) { frameRate = -1; // Set to default } UnityEngine.Application.targetFrameRate = frameRate; } if (Config.DisabledCommands.Count != 0) { Config.DisabledCommands.ForEach(cmdName => { var command = CommandManager.GetByName(cmdName); if (command == null || command is CommandEssentials) { Logger.LogWarning($"There is no command named '{cmdName}' to disable."); } else { CommandManager.Unregister(command); Logger.LogInfo($"Disabled command: '{command.Name}'"); } }); } if (Config.EnableTextCommands) { var textCommandsFile = $"{Folder}textcommands.json"; TextCommands = new TextCommands(); TextCommands.Load(textCommandsFile); TextCommands.Commands.ForEach(txtCommand => { CommandManager.Register(new TextCommand(txtCommand)); }); } if (!Config.EnableDeathMessages) { EventManager.Unregister <EssentialsEventHandler>("DeathMessages"); } #if EXPERIMENTAL Logger.LogWarning("THIS IS AN EXPERIMENTAL BUILD, CAN BE BUGGY."); Logger.LogWarning("THIS IS AN EXPERIMENTAL BUILD, CAN BE BUGGY."); #endif TryAddComponent <Tasks.TaskExecutor>(); Tasks.New(t => { File.Delete($"{Folder}uEssentials.en.translation.xml"); File.Delete($"{Folder}uEssentials.configuration.xml"); }).Delay(100).Go(); Tasks.New(t => { UnregisterRocketCommands(true); // Second check, silently. }).Delay(3000).Go(); CommandWindow.ConsoleInput.onInputText += ReloadCallback; UnregisterRocketCommands(); // First check. Logger.Log($"Enabled ({stopwatch.ElapsedMilliseconds} ms)", ConsoleColor.Green); } catch (Exception e) { var msg = new List <string>() { "An error occurred while enabling uEssentials.", "If this error is not related with wrong configuration please report", "immediatly here https://github.com/uEssentials/uEssentials/issues", "Error: " + e }; if (!Provider.Version.EqualsIgnoreCase(UNTURNED_VERSION)) { msg.Add("I detected that you are using an different version of the recommended, " + "please update your uEssentials/Unturned."); msg.Add("If you are using the latest uEssentials release, please wait for update."); } if (Logger == null) { Console.BackgroundColor = ConsoleColor.Red; msg.ForEach(Console.WriteLine); Console.BackgroundColor = ConsoleColor.White; } else { msg.ForEach(Logger.LogError); } } #if DEV CommandWindow.ConsoleOutput.title = "Unturned Server"; #else CheckUpdates(); #endif #if DUMP_COMMANDS DumpCommands(); #endif }
protected override void Load() { try { var stopwatch = Stopwatch.StartNew(); Instance = this; R.Plugins.OnPluginsLoaded += OverrideCommands; TaskExecutor = new EssentialsTaskExecutor(); SteamGameServer.SetKeyValue("essversion", PLUGIN_VERSION); Logger = new ConsoleLogger("[uEssentials] "); _consoleTraceListener = new EssentialsConsoleTraceListener(); Debug.Listeners.Add(_consoleTraceListener); Provider.onServerDisconnected += PlayerDisconnectCallback; Provider.onServerConnected += PlayerConnectCallback; Logger.LogInfo("Enabling uEssentials..."); new[] { "Plugin version: ~white~" + PLUGIN_VERSION + BUILD_INFO, "Recommended Rocket version: ~white~" + ROCKET_VERSION, "Recommended Unturned version: ~white~" + UNTURNED_VERSION, "Author: ~white~leonardosnt", "Wiki: ~white~uessentials.github.io", }.ForEach(text => Logger.LogInfo(text, true)); if (Provider.clients.Count > 0) { Provider.clients.ForEach(p => { ConnectedPlayers.Add(p.playerID.steamID.m_SteamID, new UPlayer(UnturnedPlayer.FromSteamPlayer(p))); }); } _folder = Rocket.Core.Environment.PluginsDirectory + "/uEssentials/"; _translationFolder = Folder + "translations/"; _dataFolder = Folder + "data/"; _modulesFolder = Folder + "modules/"; CommandOptions = new CommandOptions(); Updater = new GithubUpdater(); EventManager = new EventManager(); CommandManager = new CommandManager(); ModuleManager = new ModuleManager(); HookManager = new HookManager(); WebResources = new WebResources(); Config = new EssConfig(); var webResourcesPath = Path.Combine(Folder, WebResources.FileName); var configPath = Path.Combine(Folder, Config.FileName); WebResources.Load(webResourcesPath); // Sync web config with local config.json if (WebResources.Loaded.ContainsKey("Config")) { File.WriteAllText(configPath, WebResources.Loaded["Config"]); } Config.Load(configPath); CommandOptions.Load(Path.Combine(Folder, CommandOptions.FileName)); EssLang.Load(); EventManager.RegisterAll(GetType().Assembly); // Register all commands from namespace Essentials.Commands CommandManager.RegisterAll("Essentials.Commands"); HookManager.RegisterAll(); HookManager.LoadAll(); // Load after EventManager because we relies on it inside this routine. ConfigPostLoad(); LoadNativeModules(); Logger.LogInfo("Loading modules..."); ModuleManager.LoadAll(ModulesFolder); Logger.LogInfo($"Loaded {ModuleManager.RunningModules.Count(t => !(t is NativeModule))} modules"); // We log it here because the modules being loaded above can // register commands. Logger.LogInfo($"Loaded {CommandManager.Commands.Count()} commands"); #if EXPERIMENTAL Logger.LogWarning("THIS IS AN EXPERIMENTAL BUILD, IT CAN BE BUGGY."); Logger.LogWarning("THIS IS AN EXPERIMENTAL BUILD, IT CAN BE BUGGY."); #endif // Delete useless files generated by Rocket Task.Create() .Id("Delete Xml Files") .Delay(TimeSpan.FromSeconds(1)) .Async() .Action(() => { File.Delete($"{Folder}uEssentials.en.translation.xml"); File.Delete($"{Folder}uEssentials.configuration.xml"); }) .Submit(); // If _wasLoadedBefore, then it means that uEssentials is // being reloaded, and it also means that R.Plugins.OnPluginsLoaded will not be called, // consequently OverrideCommands will not be called too // so we need to call it here. if (_wasLoadedBefore) { OverrideCommands(); } _wasLoadedBefore = true; CommandWindow.input.onInputText += ReloadCallback; Logger.LogInfo($"Enabled ({stopwatch.ElapsedMilliseconds} ms)"); } catch (Exception e) { string[] messages = { "An error occurred while enabling uEssentials.", "If this error is not related with wrong configuration, please report", "it here https://github.com/uEssentials/uEssentials/issues", "Error: " + e }; if (Logger == null) { Console.BackgroundColor = ConsoleColor.Red; messages.ForEach(Console.WriteLine); Console.BackgroundColor = ConsoleColor.White; } else { messages.ForEach(m => Logger.LogError(m)); } } #if !DEV Analytics.SendEvent($"ServerInit"); #endif #if DEV Console.Title = "Unturned Server"; #else CheckUpdates(); #endif }
protected override void Load() { try { var stopwatch = Stopwatch.StartNew(); Instance = this; try { var essPermProvider = new EssentialsPermissionsProvider(); R.Permissions = essPermProvider; } catch (Exception ex) { Console.Error.WriteLine(ex); } TaskExecutor = new EssentialsTaskExecutor(); Logger = new ConsoleLogger("[uEssentials] "); ConnectedPlayers = new Dictionary <ulong, UPlayer>(); Debug.Listeners.Add(new EssentialsConsoleTraceListener()); Provider.onServerDisconnected += PlayerDisconnectCallback; Provider.onServerConnected += PlayerConnectCallback; Logger.LogInfo("Enabling uEssentials..."); if (Provider.Players.Count > 0) { Provider.Players.ForEach(p => { ConnectedPlayers.Add(p.SteamPlayerID.CSteamID.m_SteamID, new UPlayer(UnturnedPlayer.FromSteamPlayer(p))); }); } _folder = Rocket.Core.Environment.PluginsDirectory + "/uEssentials/"; _translationFolder = Folder + "translations/"; _dataFolder = Folder + "data/"; _modulesFolder = Folder + "modules/"; WebResources = new WebResources(); Config = new EssConfig(); var webRscPath = Path.Combine(Folder, WebResources.FileName); var configPath = Path.Combine(Folder, Config.FileName); WebResources.Load(webRscPath); // TODO: Remove // Load old webkit/webconfig try { if (File.Exists(configPath) && !WebResources.Enabled) { var json = JObject.Parse(File.ReadAllText(configPath)); var save = false; foreach (var opt in new[] { "Config", "Kits" }) { JToken val; if (json.TryGetValue($"Web{opt}", out val)) { if (val.Value <bool>("Enabled")) { WebResources.Enabled = true; WebResources.URLs[opt] = val.Value <string>("Url"); save = true; } } } if (save) { WebResources.Save(webRscPath); WebResources.Load(webRscPath); } } } catch (Exception ex) { Debug.Print(ex.ToString()); } // Sync web config with local config.json if (WebResources.Loaded.ContainsKey("Config")) { File.WriteAllText(configPath, WebResources.Loaded["Config"]); } Config.Load(configPath); CommandOptions = new CommandOptions(); CommandOptions.Load(Path.Combine(Folder, CommandOptions.FileName)); Updater = new GithubUpdater(); EventManager = new EventManager(); CommandManager = new CommandManager(); ModuleManager = new ModuleManager(); HookManager = new HookManager(); EssLang.Load(); new [] { "Plugin version: ~white~" + PLUGIN_VERSION + BUILD_INFO, "Recommended Rocket version: ~white~" + ROCKET_VERSION, "Recommended Unturned version: ~white~" + UNTURNED_VERSION, "Author: ~white~leonardosnt", "Wiki: ~white~uessentials.github.io", }.ForEach(text => Logger.LogInfo(text, true)); EventManager.RegisterAll(GetType().Assembly); if (!Config.EnableJoinLeaveMessage) { EventManager.Unregister <EssentialsEventHandler>("JoinMessage"); EventManager.Unregister <EssentialsEventHandler>("LeaveMessage"); } CommandManager.RegisterAll("Essentials.Commands"); HookManager.RegisterAll(); HookManager.LoadAll(); if (Config.Economy.UseXp) { EconomyProvider = Optional <IEconomyProvider> .Of(new ExpEconomyProvider()); } else if (HookManager.GetActiveByType <UconomyHook>().IsPresent) { EconomyProvider = Optional <IEconomyProvider> .Of(HookManager.GetActiveByType <UconomyHook>().Value); } else { EconomyProvider = Optional <IEconomyProvider> .Empty(); } /* * Load native modules */ Assembly.GetTypes() .Where(t => typeof(NativeModule).IsAssignableFrom(t)) .WhereNot(t => t.IsAbstract) .Where(t => { var moduleInfo = (ModuleInfo)t.GetCustomAttributes(typeof(ModuleInfo), false)[0]; return(Config.EnabledSystems.Any(s => s.Equals(moduleInfo.Name, StringComparison.OrdinalIgnoreCase))); }) .ForEach(t => { ModuleManager.LoadModule((NativeModule)Activator.CreateInstance(t)); }); Logger.LogInfo($"Loaded {CommandManager.Commands.Count()} commands"); Logger.LogInfo("Loading modules..."); ModuleManager.LoadAll(ModulesFolder); Logger.LogInfo($"Loaded {ModuleManager.RunningModules.Count(t => !(t is NativeModule))} modules"); if (Config.AutoAnnouncer.Enabled) { Config.AutoAnnouncer.Start(); } if (Config.AutoCommands.Enabled) { Config.AutoCommands.Start(); } if (!Config.Updater.AlertOnJoin) { EventManager.Unregister <EssentialsEventHandler>("UpdateAlert"); } if (Config.ServerFrameRate != -1) { var frameRate = Config.ServerFrameRate; if (Config.ServerFrameRate < -1) { frameRate = -1; // Set to default } UnityEngine.Application.targetFrameRate = frameRate; } if (Config.DisabledCommands.Count != 0) { Config.DisabledCommands.ForEach(cmdName => { var command = CommandManager.GetByName(cmdName); if (command == null || command is CommandEssentials) { Logger.LogWarning($"There is no command named '{cmdName}' to disable."); } else { CommandManager.Unregister(command); Logger.LogInfo($"Disabled command: '{command.Name}'"); } }); } if (Config.EnableTextCommands) { TextCommands = new TextCommands(); var textCommandsFile = Path.Combine(Folder, TextCommands.FileName); TextCommands.Load(textCommandsFile); TextCommands.Commands.ForEach(txtCommand => { CommandManager.Register(new TextCommand(txtCommand)); }); } if (!Config.EnableDeathMessages) { EventManager.Unregister <EssentialsEventHandler>("DeathMessages"); } #if EXPERIMENTAL Logger.LogWarning("THIS IS AN EXPERIMENTAL BUILD, CAN BE BUGGY."); Logger.LogWarning("THIS IS AN EXPERIMENTAL BUILD, CAN BE BUGGY."); #endif Task.Create() .Id("Delete Xml Files") .Delay(TimeSpan.FromSeconds(1)) .Async() .Action(() => { File.Delete($"{Folder}uEssentials.en.translation.xml"); File.Delete($"{Folder}uEssentials.configuration.xml"); }) .Submit(); Task.Create() .Id("Unregister Rocket Commands") .Delay(TimeSpan.FromSeconds(3)) .Action(() => UnregisterRocketCommands(true)) // Second check, silently. .Submit(); CommandWindow.ConsoleInput.onInputText += ReloadCallback; UnregisterRocketCommands(); // First check. Logger.LogInfo($"Enabled ({stopwatch.ElapsedMilliseconds} ms)"); } catch (Exception e) { var msg = new List <string>() { "An error occurred while enabling uEssentials.", "If this error is not related with wrong configuration please report", "immediatly here https://github.com/uEssentials/uEssentials/issues", "Error: " + e }; if (!Provider.APP_VERSION.EqualsIgnoreCase(UNTURNED_VERSION)) { msg.Add("I detected that you are using a different version of the recommended, " + "please update your uEssentials/Unturned."); msg.Add("If you are using the latest uEssentials release, please wait for update."); } if (Logger == null) { Console.BackgroundColor = ConsoleColor.Red; msg.ForEach(Console.WriteLine); Console.BackgroundColor = ConsoleColor.White; } else { msg.ForEach(Logger.LogError); } } #if !DEV TriggerGaData($"Server/{Parser.getIPFromUInt32(Provider.ip)}"); #endif #if DEV CommandWindow.ConsoleOutput.title = "Unturned Server"; #else CheckUpdates(); #endif }