diff --git a/BUILDS/net6.0/PluginManager.dll b/BUILDS/net6.0/PluginManager.dll
index 3442573..90dfd5a 100644
Binary files a/BUILDS/net6.0/PluginManager.dll and b/BUILDS/net6.0/PluginManager.dll differ
diff --git a/BUILDS/net6.0/Plugins/Commands/CMD_LevelingSystem.dll b/BUILDS/net6.0/Plugins/Commands/CMD_LevelingSystem.dll
index c1c7ecf..665a62d 100644
Binary files a/BUILDS/net6.0/Plugins/Commands/CMD_LevelingSystem.dll and b/BUILDS/net6.0/Plugins/Commands/CMD_LevelingSystem.dll differ
diff --git a/BUILDS/net6.0/Plugins/Events/EVE_LevelingSystem.dll b/BUILDS/net6.0/Plugins/Events/EVE_LevelingSystem.dll
index efc3f15..0a08495 100644
Binary files a/BUILDS/net6.0/Plugins/Events/EVE_LevelingSystem.dll and b/BUILDS/net6.0/Plugins/Events/EVE_LevelingSystem.dll differ
diff --git a/DiscordBot/Program.cs b/DiscordBot/Program.cs
index 712828f..8836669 100644
--- a/DiscordBot/Program.cs
+++ b/DiscordBot/Program.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using DiscordBot.Discord.Core;
using PluginManager;
@@ -66,7 +67,7 @@ public class Program
/// The main loop for the discord bot
///
/// The discord booter used to start the application
- private static Task NoGUI(Boot discordbooter)
+ private static void NoGUI(Boot discordbooter)
{
var consoleCommandsHandler = new ConsoleCommandsHandler(discordbooter.client);
if (loadPluginsOnStartup) consoleCommandsHandler.HandleCommand("lp");
@@ -77,9 +78,18 @@ public class Program
while (true)
{
Console.ForegroundColor = ConsoleColor.White;
+
+#if DEBUG
+ Console_Utilities.WriteColorText("&rSethBot (&yDEBUG&r) &c> ", false);
var cmd = Console.ReadLine();
- if (!consoleCommandsHandler.HandleCommand(cmd))
+ if (!consoleCommandsHandler.HandleCommand(cmd!, false) && cmd.Length > 0)
Console.WriteLine("Failed to run command " + cmd);
+#else
+ Console_Utilities.WriteColorText("&rSethBot &c> ", false);
+ var cmd = Console.ReadLine();
+ if (!consoleCommandsHandler.HandleCommand(cmd!) && cmd.Length > 0)
+ Console.WriteLine("Failed to run command " + cmd);
+#endif
}
}
@@ -177,8 +187,9 @@ public class Program
if (len == 0 || (args[0] != "--exec" && args[0] != "--execute"))
{
- var b = await StartNoGUI();
- await NoGUI(b);
+ var b = await StartNoGUI();
+ Thread mainThread = new Thread(() => NoGUI(b));
+ mainThread.Start();
return;
}
@@ -204,15 +215,7 @@ public class Program
case "--help":
case "-help":
Console.ForegroundColor = ConsoleColor.DarkYellow;
- Console.WriteLine(
- "\tCommand name\t\t\t\tDescription\n" +
- "-- help | -help\t\t ------ \tDisplay the help message\n" +
- "--reset-full\t\t ------ \tReset all files (clear files)\n" +
- "--reset-settings\t ------ \tReset only bot settings\n" +
- "--reset-logs\t\t ------ \tClear up the output folder\n" +
- "--start\t\t ------ \tStart the bot\n" +
- "exit\t\t\t ------ \tClose the application"
- );
+ Console.WriteLine("\tCommand name\t\t\t\tDescription\n" + "-- help | -help\t\t ------ \tDisplay the help message\n" + "--reset-full\t\t ------ \tReset all files (clear files)\n" + "--reset-settings\t ------ \tReset only bot settings\n" + "--reset-logs\t\t ------ \tClear up the output folder\n" + "--start\t\t ------ \tStart the bot\n" + "exit\t\t\t ------ \tClose the application");
break;
case "--reset-full":
await ClearFolder("./Data/Resources/");
@@ -232,10 +235,6 @@ public class Program
case "exit":
Environment.Exit(0);
break;
- case "--start":
- var booter = await StartNoGUI();
- await NoGUI(booter);
- return;
default:
Console.WriteLine("Failed to execute command " + message[0]);
@@ -321,6 +320,7 @@ public class Program
}
}
+ Console_Utilities.Initialize();
Config.SaveConfig();
}
diff --git a/EVE_LevelingSystem/Level.cs b/EVE_LevelingSystem/Level.cs
index f4a9c6b..9afa612 100644
--- a/EVE_LevelingSystem/Level.cs
+++ b/EVE_LevelingSystem/Level.cs
@@ -11,15 +11,18 @@ namespace EVE_LevelingSystem
{
public string name => "Leveling System Event Handler";
public string description => "The Leveling System Event Handler";
+
internal static Settings globalSettings = new();
public async void Start(DiscordSocketClient client)
{
Directory.CreateDirectory("./Data/Resources/LevelingSystem");
- Config.AddValueToVariables("LevelingSystemPath", "./Data/Resources/LevelingSystem", true);
- Config.AddValueToVariables("LevelingSystemSettingsFile", "./Data/Resources/LevelingSystemSettings.txt", true);
-
+ if (!Config.ContainsKey("LevelingSystemPath"))
+ Config.AddValueToVariables("LevelingSystemPath", "./Data/Resources/LevelingSystem", true);
+ if (!Config.ContainsKey("LevelingSystemSettingsFile"))
+ Config.AddValueToVariables("LevelingSystemSettingsFile", "./Data/Resources/LevelingSystemSettings.txt", true);
+ //PluginManager.Config.AddValueToVariables
if (!File.Exists(Config.GetValue("LevelingSystemSettingsFile")))
{
globalSettings = new Settings { TimeToWaitBetweenMessages = 5 };
diff --git a/PluginManager/Items/Command.cs b/PluginManager/Items/Command.cs
index 6634b59..22cd36a 100644
--- a/PluginManager/Items/Command.cs
+++ b/PluginManager/Items/Command.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Threading.Tasks;
using Discord.WebSocket;
using PluginManager.Others;
diff --git a/PluginManager/Items/ConsoleCommandsHandler.cs b/PluginManager/Items/ConsoleCommandsHandler.cs
index 07e90f2..351d295 100644
--- a/PluginManager/Items/ConsoleCommandsHandler.cs
+++ b/PluginManager/Items/ConsoleCommandsHandler.cs
@@ -97,7 +97,7 @@ public class ConsoleCommandsHandler
}
);
- AddCommand("listplugs", "list available plugins", async () => { await manager.ListAvailablePlugins(); });
+ AddCommand("listplugs", "list available plugins", () => { manager.ListAvailablePlugins().Wait(); });
AddCommand("dwplug", "download plugin", "dwplug [name]", async args =>
{
@@ -233,20 +233,6 @@ public class ConsoleCommandsHandler
}
);
- AddCommand("vars", "Display all variables", () =>
- {
- var d = Config.GetAllVariables();
- var data = new List();
- data.Add(new[] { "-", "-" });
- data.Add(new[] { "Key", "Value" });
- data.Add(new[] { "-", "-" });
- foreach (var kvp in d)
- data.Add(new[] { kvp.Key, kvp.Value.ToString()! });
- data.Add(new[] { "-", "-" });
- Console_Utilities.FormatAndAlignTable(data);
- }
- );
-
AddCommand("sd", "Shuts down the discord bot", async () =>
{
if (client is null)
@@ -299,7 +285,7 @@ public class ConsoleCommandsHandler
if (removeCommandExecution)
{
Console.SetCursorPosition(0, Console.CursorTop - 1);
- for (int i = 0; i < command.Length; i++)
+ for (int i = 0; i < command.Length + 30; i++)
Console.Write(" ");
Console.SetCursorPosition(0, Console.CursorTop);
}
diff --git a/PluginManager/Loaders/PluginLoader.cs b/PluginManager/Loaders/PluginLoader.cs
index 6fdaf74..c506eaf 100644
--- a/PluginManager/Loaders/PluginLoader.cs
+++ b/PluginManager/Loaders/PluginLoader.cs
@@ -85,9 +85,20 @@ public class PluginLoader
private void OnEventLoaded(LoaderArgs e)
{
- if (e.IsLoaded) ((DBEvent)e.Plugin!).Start(_client);
+ try
+ {
+ if (e.IsLoaded)
+ ((DBEvent)e.Plugin!).Start(_client);
- onEVELoad?.Invoke(((DBEvent)e.Plugin!).name, e.TypeName!, e.IsLoaded, e.Exception);
+ onEVELoad?.Invoke(((DBEvent)e.Plugin!).name, e.TypeName!, e.IsLoaded, e.Exception);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.ToString());
+ Console.WriteLine("Plugin: " + e.PluginName);
+ Console.WriteLine("Type: " + e.TypeName);
+ Console.WriteLine("IsLoaded: " + e.IsLoaded);
+ }
}
private void OnCommandLoaded(LoaderArgs e)
diff --git a/PluginManager/Others/Console Utilities.cs b/PluginManager/Others/Console Utilities.cs
index 15b902e..44a8a42 100644
--- a/PluginManager/Others/Console Utilities.cs
+++ b/PluginManager/Others/Console Utilities.cs
@@ -7,6 +7,26 @@ namespace PluginManager.Others
{
public static class Console_Utilities
{
+ public static void Initialize()
+ {
+ if (!Config.ContainsKey("TableVariables"))
+ Config.AddValueToVariables("TableVariables", new Dictionary { { "DefaultSpace", "3" } }, false);
+ if (!Config.ContainsKey("ColorDataBase"))
+ Config.AddValueToVariables("ColorDataBase", new Dictionary()
+ {
+ { 'g', ConsoleColor.Green },
+ { 'b', ConsoleColor.Blue },
+ { 'r', ConsoleColor.Red },
+ { 'm', ConsoleColor.Magenta },
+ { 'y', ConsoleColor.Yellow },
+ }, false
+ );
+
+ if (!Config.ContainsKey("ColorPrefix"))
+ Config.AddValueToVariables("ColorPrefix", '&', false);
+ }
+
+
///
/// Progress bar object
///
@@ -177,7 +197,7 @@ namespace PluginManager.Others
if (format == TableFormat.DEFAULT)
{
int[] widths = new int[data[0].Length];
- int space_between_columns = 5;
+ int space_between_columns = int.Parse(Config.GetValue>("TableVariables")?["DefaultSpace"]!);
for (int i = 0; i < data.Count; i++)
{
for (int j = 0; j < data[i].Length; j++)
@@ -210,26 +230,21 @@ namespace PluginManager.Others
public static void WriteColorText(string text, bool appendNewLineAtEnd = true)
{
ConsoleColor initialForeGround = Console.ForegroundColor;
- Dictionary colors = new()
- {
- { 'g', ConsoleColor.Green },
- { 'b', ConsoleColor.Blue },
- { 'r', ConsoleColor.Red },
- { 'm', ConsoleColor.Magenta },
- { 'y', ConsoleColor.Yellow },
- { 'c', initialForeGround }
- };
-
- char[] input = text.ToCharArray();
+ char[] input = text.ToCharArray();
for (int i = 0; i < input.Length; i++)
{
- if (input[i] == '&')
+ if (input[i] == Config.GetValue("ColorPrefix"))
{
if (i + 1 < input.Length)
{
- if (colors.ContainsKey(input[i + 1]))
+ if (Config.GetValue>("ColorDataBase")!.ContainsKey(input[i + 1]))
{
- Console.ForegroundColor = colors[input[i + 1]];
+ Console.ForegroundColor = Config.GetValue>("ColorDataBase")![input[i + 1]];
+ i++;
+ }
+ else if (input[i + 1] == 'c')
+ {
+ Console.ForegroundColor = initialForeGround;
i++;
}
}
diff --git a/PluginManager/Others/Functions.cs b/PluginManager/Others/Functions.cs
index 638b6f1..360b7c8 100644
--- a/PluginManager/Others/Functions.cs
+++ b/PluginManager/Others/Functions.cs
@@ -50,31 +50,15 @@ namespace PluginManager.Others
/// The file name that is inside the archive or its full path
/// The archive location from the PAKs folder
/// A string that represents the content of the file or null if the file does not exists or it has no content
- public static async Task ReadFromPakAsync(string FileName, string archFile)
+ public static Stream? ReadFromPakAsync(string FileName, string archFile)
{
archFile = pakFolder + archFile;
Directory.CreateDirectory(pakFolder);
if (!File.Exists(archFile)) throw new FileNotFoundException("Failed to load file !");
- Stream? textValue = null;
- var fs = new FileStream(archFile, FileMode.Open);
- var zip = new ZipArchive(fs, ZipArchiveMode.Read);
- foreach (var entry in zip.Entries)
- {
- if (entry.Name == FileName || entry.FullName == FileName)
- {
- Stream s = entry.Open();
- StreamReader reader = new StreamReader(s);
- textValue = reader.BaseStream;
- textValue.Position = 0;
- reader.Close();
- s.Close();
- fs.Close();
- break;
- }
- }
-
- return textValue;
+ using ZipArchive archive = ZipFile.OpenRead(archFile);
+ ZipArchiveEntry? entry = archive.GetEntry(FileName);
+ return entry?.Open();
}
///