From d8099a9643cdd5664e380f9c9f9523c8f086ed95 Mon Sep 17 00:00:00 2001 From: kuroppoi <68156848+kuroppoi@users.noreply.github.com> Date: Fri, 23 Apr 2021 18:05:39 +0200 Subject: [PATCH] Console commands are now handled on main thread --- .../java/brainwine/gameserver/ConsoleThread.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gameserver/src/main/java/brainwine/gameserver/ConsoleThread.java b/gameserver/src/main/java/brainwine/gameserver/ConsoleThread.java index d8ed27a..84a815c 100644 --- a/gameserver/src/main/java/brainwine/gameserver/ConsoleThread.java +++ b/gameserver/src/main/java/brainwine/gameserver/ConsoleThread.java @@ -26,11 +26,19 @@ public class ConsoleThread extends Thread { try { while((line = reader.readLine()) != null) { - // TODO run these on main thread lol - CommandManager.executeCommand(server, line); + queueConsoleCommand(line); } } catch(IOException e) { logger.info("Could not read console input", e); } } + + private void queueConsoleCommand(String commandLine) { + server.queueSynchronousTask(new Runnable() { + @Override + public void run() { + CommandManager.executeCommand(server, commandLine); + } + }); + } }