From f167c6b6cd25a9e9621c5a6e6792eb552ba437e8 Mon Sep 17 00:00:00 2001 From: duckietm Date: Thu, 9 Dec 2021 07:41:10 +0000 Subject: [PATCH] Adding TTY setting in the emulator --- src/main/java/com/eu/habbo/Emulator.java | 28 ++++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 97fe313a..affec180 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -175,26 +175,30 @@ public final class Emulator { Runtime.getRuntime().availableProcessors() * 2); } - Emulator.getThreading().run(() -> { }, 1500); - BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); + // Check if console mode is true or false, default is true + if (Emulator.getConfig().getBoolean("console.mode", true)) { - while (!isShuttingDown && isReady) { - try { - String line = reader.readLine(); + BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); - if (line != null) { - ConsoleCommand.handle(line); - } - System.out.println("Waiting for command: "); - } catch (Exception e) { - if (!(e instanceof IOException && e.getMessage().equals("Bad file descriptor"))) { - LOGGER.error("Error while reading command", e); + while (!isShuttingDown && isReady) { + try { + String line = reader.readLine(); + + if (line != null) { + ConsoleCommand.handle(line); + } + System.out.println("Waiting for command: "); + } catch (Exception e) { + if (!(e instanceof IOException && e.getMessage().equals("Bad file descriptor"))) { + LOGGER.error("Error while reading command", e); + } } } } + } catch (Exception e) { e.printStackTrace(); }