From ac57ecb939463174fccbc18ce049c39345551b25 Mon Sep 17 00:00:00 2001 From: Kyle873 Date: Sun, 26 May 2024 20:10:08 -0400 Subject: [PATCH] Scuffy console command input, good enough for now --- Elisa/Commands/TestCommand.cs | 2 +- Elisa/Controllers/CommandController.cs | 18 ------------------ Elisa/InputSystem.cs | 19 +++++++++++++++++++ Elisa/Program.cs | 1 + 4 files changed, 21 insertions(+), 19 deletions(-) delete mode 100644 Elisa/Controllers/CommandController.cs create mode 100644 Elisa/InputSystem.cs diff --git a/Elisa/Commands/TestCommand.cs b/Elisa/Commands/TestCommand.cs index db93416..5d9442e 100644 --- a/Elisa/Commands/TestCommand.cs +++ b/Elisa/Commands/TestCommand.cs @@ -18,7 +18,7 @@ public class tESTcOMMAND : Command string output = string.Empty; - switch (Type.ToLower()) + switch (Type?.ToLower()) { case "encrypt": output = Crypto.Encrypt(Value, "test"); diff --git a/Elisa/Controllers/CommandController.cs b/Elisa/Controllers/CommandController.cs deleted file mode 100644 index 5cd3434..0000000 --- a/Elisa/Controllers/CommandController.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Elisa.Commands; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; - -namespace Elisa.Controllers; - -[ApiController] -[Route("/")] -public class CommandController : ControllerBase -{ - [HttpGet("command")] - public async Task Command([FromQuery] string command) - { - CommandHandlerFactory.HandleCommand(command); - - return Results.Text("Command executed"); - } -} diff --git a/Elisa/InputSystem.cs b/Elisa/InputSystem.cs new file mode 100644 index 0000000..e4b9a14 --- /dev/null +++ b/Elisa/InputSystem.cs @@ -0,0 +1,19 @@ +using Elisa.Commands; + +namespace Elisa; + +public static class InputSystem +{ + public static void Start() + { + while (true) + { + string? command = Console.ReadLine(); + + if (string.IsNullOrEmpty(command)) + continue; + + CommandHandlerFactory.HandleCommand(command); + } + } +} diff --git a/Elisa/Program.cs b/Elisa/Program.cs index 7c5f97b..538c744 100644 --- a/Elisa/Program.cs +++ b/Elisa/Program.cs @@ -36,6 +36,7 @@ internal static class Program stopwatch.Stop(); Log.Information($"Done! Loaded in {stopwatch.ElapsedMilliseconds}ms"); + Task.Run(InputSystem.Start); Task.Run(Proxy.Start); Task.Run(GameServer.Start).Wait(); }