diff --git a/SecretAdmin/API/Features/Module.cs b/SecretAdmin/API/Features/Module.cs index 3986454..bfd4dc2 100644 --- a/SecretAdmin/API/Features/Module.cs +++ b/SecretAdmin/API/Features/Module.cs @@ -1,6 +1,7 @@ using System; using System.Reflection; using SecretAdmin.Features.Console; +using Spectre.Console; namespace SecretAdmin.API.Features { @@ -23,12 +24,12 @@ protected Module() public virtual void OnEnabled() { - Log.SpectreRaw($"The module {Name} [{Version}] by {Author} has been enabled.", "lightcyan1"); + Log.SpectreRaw($"The module {Name} [{Version}] by {Author} has been enabled.".EscapeMarkup(), "lightcyan1"); } public virtual void OnDisabled() { - Log.SpectreRaw($"The module {Name} [{Version}] by {Author} has been disabled.", "lightcyan1"); + Log.SpectreRaw($"The module {Name} [{Version}] by {Author} has been disabled.".EscapeMarkup(), "lightcyan1"); } public virtual void OnRegisteringCommands() diff --git a/SecretAdmin/API/ModuleManager.cs b/SecretAdmin/API/ModuleManager.cs index 1d0e792..ae36648 100644 --- a/SecretAdmin/API/ModuleManager.cs +++ b/SecretAdmin/API/ModuleManager.cs @@ -27,11 +27,11 @@ public static void LoadAll(uint port) { var assembly = Assembly.UnsafeLoadFrom(file); count++; - Log.SpectreRaw($"Dependency {assembly.GetName().Name} ({assembly.GetName().Version}) has been loaded!", "lightcyan1"); + Log.SpectreRaw($"Dependency {assembly.GetName().Name} ({assembly.GetName().Version}) has been loaded!".EscapeMarkup(), "lightcyan1"); } catch (Exception e) { - Log.SpectreRaw($"Couldn't load the dependency in the path {file}", "deeppink2"); + Log.SpectreRaw($"Couldn't load the dependency in the path {file}".EscapeMarkup(), "deeppink2"); AnsiConsole.WriteException(e); } } @@ -73,7 +73,7 @@ public static void LoadAll(uint port) } catch (Exception e) { - Log.SpectreRaw($"Couldn't load the module in the path {file}", "deeppink2"); + Log.SpectreRaw($"Couldn't load the module in the path {file}".EscapeMarkup(), "deeppink2"); AnsiConsole.WriteException(e); } } diff --git a/SecretAdmin/Features/Server/SocketServer.cs b/SecretAdmin/Features/Server/SocketServer.cs index 58f37b8..58f41cb 100644 --- a/SecretAdmin/Features/Server/SocketServer.cs +++ b/SecretAdmin/Features/Server/SocketServer.cs @@ -87,7 +87,7 @@ private async void ListenRequests() Log.HandleMessage(message, codeType); } } - catch (OperationCanceledException) + catch (Exception) { Log.Alert("Socket cancelled."); } diff --git a/SecretAdmin/Program.cs b/SecretAdmin/Program.cs index 7ffa75c..9e01d30 100644 --- a/SecretAdmin/Program.cs +++ b/SecretAdmin/Program.cs @@ -12,11 +12,13 @@ namespace SecretAdmin { class Program { - public static Version Version { get; } = new (0, 0, 0,2); + public static Version Version { get; } = new (0, 0, 0,3); public static ScpServer Server { get; private set; } public static ConfigManager ConfigManager { get; private set; } public static CommandHandler CommandHandler { get; private set; } + private static bool _exceptionalExit = true; + static void Main(string[] args) { Console.Title = $"SecretAdmin [v{Version}]"; @@ -57,14 +59,12 @@ private static void Start(string[] args) private static void OnError(object obj, UnhandledExceptionEventArgs ev) { + _exceptionalExit = false; AnsiConsole.WriteException((Exception)ev.ExceptionObject); File.WriteAllText(Path.Combine(Paths.ProgramLogsFolder, $"{DateTime.Now:MM.dd.yyyy-hh.mm.ss}-exception.log"), AnsiConsole.ExportText()); - Exit(false); } - private static void OnExit(object obj, EventArgs ev) => Exit(); - - private static void Exit(bool saveLogs = true) + private static void OnExit(object obj, EventArgs ev) { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("\nExit Detected. Killing game process."); @@ -78,7 +78,7 @@ private static void Exit(bool saveLogs = true) Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Everything seems good to go! Bye :)"); - if(saveLogs) + if(!_exceptionalExit) File.WriteAllText(Path.Combine(Paths.ProgramLogsFolder, $"{DateTime.Now:MM.dd.yyyy-hh.mm.ss}.log"), AnsiConsole.ExportText()); } } diff --git a/SecretAdmin/SecretAdmin.csproj b/SecretAdmin/SecretAdmin.csproj index d863a9f..fcfa27b 100644 --- a/SecretAdmin/SecretAdmin.csproj +++ b/SecretAdmin/SecretAdmin.csproj @@ -5,13 +5,13 @@ net5.0 SecretAdmin.ico true - 0.0.0.1 + 0.0.0.3 SecretAdmin Jesus-QC, SecretAdmin Server client for SCP:SL - - https://github.com/Jesus-QC/SecretAdmin + 0.0.0.3 + en