From 3e7e34dfb98abad8e3ac3b725f1f86caf50294b9 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Sun, 1 Dec 2019 18:28:36 -0600 Subject: [PATCH] Move command reader into standalone module --- bootstrap/standalone/pom.xml | 25 +++++++++++++++++++ .../platform/standalone/GeyserBootstrap.java | 7 +++++- .../console/ConsoleCommandReader.java | 12 ++++----- .../{ => console}/GeyserLogger.java | 2 +- connector/pom.xml | 25 +++++-------------- .../geysermc/connector/GeyserConnector.java | 7 ++---- 6 files changed, 45 insertions(+), 33 deletions(-) rename {connector/src/main/java/org/geysermc/connector => bootstrap/standalone/src/main/java/org/geysermc/platform/standalone}/console/ConsoleCommandReader.java (93%) rename bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/{ => console}/GeyserLogger.java (98%) diff --git a/bootstrap/standalone/pom.xml b/bootstrap/standalone/pom.xml index 03e17895..7f0aef55 100644 --- a/bootstrap/standalone/pom.xml +++ b/bootstrap/standalone/pom.xml @@ -17,6 +17,31 @@ 1.0-SNAPSHOT compile + + net.minecrell + terminalconsoleappender + 1.0.0 + jar + compile + + + org.slf4j + slf4j-api + 1.7.5 + compile + + + org.slf4j + slf4j-simple + 1.6.4 + compile + + + org.fusesource.jansi + jansi + 1.18 + compile + ${outputName} diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserBootstrap.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserBootstrap.java index f769c52f..8424fd63 100644 --- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserBootstrap.java +++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserBootstrap.java @@ -29,6 +29,8 @@ import org.fusesource.jansi.AnsiConsole; import org.geysermc.common.bootstrap.IGeyserBootstrap; import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.utils.FileUtils; +import org.geysermc.platform.standalone.console.ConsoleCommandReader; +import org.geysermc.platform.standalone.console.GeyserLogger; import java.io.File; import java.io.IOException; @@ -60,7 +62,10 @@ public class GeyserBootstrap implements IGeyserBootstrap { System.exit(0); } - GeyserConnector.start(this, false); + GeyserConnector connector = GeyserConnector.start(this, false); + + ConsoleCommandReader consoleReader = new ConsoleCommandReader(connector); + consoleReader.startConsole(); } @Override diff --git a/connector/src/main/java/org/geysermc/connector/console/ConsoleCommandReader.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/console/ConsoleCommandReader.java similarity index 93% rename from connector/src/main/java/org/geysermc/connector/console/ConsoleCommandReader.java rename to bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/console/ConsoleCommandReader.java index f2c6af7f..8396228c 100644 --- a/connector/src/main/java/org/geysermc/connector/console/ConsoleCommandReader.java +++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/console/ConsoleCommandReader.java @@ -23,12 +23,12 @@ * @link https://github.com/GeyserMC/Geyser */ -package org.geysermc.connector.console; +package org.geysermc.platform.standalone.console; +import net.minecrell.terminalconsole.TerminalConsoleAppender; import org.geysermc.api.command.ConsoleCommandSender; import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.command.GeyserConsoleCommandSender; -import net.minecrell.terminalconsole.TerminalConsoleAppender; import org.jline.reader.EndOfFileException; import org.jline.reader.LineReader; import org.jline.reader.LineReaderBuilder; @@ -45,7 +45,6 @@ public class ConsoleCommandReader { private GeyserConnector connector; private Terminal terminal; - private Thread thread; public ConsoleCommandReader(GeyserConnector connector) { this.connector = connector; @@ -53,7 +52,7 @@ public class ConsoleCommandReader { } public void startConsole() { - thread = new Thread(() -> { + Thread thread = new Thread(() -> { if (terminal != null) { LineReader lineReader = LineReaderBuilder.builder() .appName("Geyser") @@ -74,8 +73,8 @@ public class ConsoleCommandReader { if (line == null) break; } - } catch (UserInterruptException e /* do nothing */) { - // + } catch (UserInterruptException ignore) { + /* do nothing */ } finally { TerminalConsoleAppender.setReader(null); } @@ -93,6 +92,5 @@ public class ConsoleCommandReader { }); thread.setName("ConsoleCommandThread"); - connector.getGeneralThreadPool().execute(thread); } } diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserLogger.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/console/GeyserLogger.java similarity index 98% rename from bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserLogger.java rename to bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/console/GeyserLogger.java index 0df4f1f1..0e7af429 100644 --- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserLogger.java +++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/console/GeyserLogger.java @@ -23,7 +23,7 @@ * @link https://github.com/GeyserMC/Geyser */ -package org.geysermc.platform.standalone; +package org.geysermc.platform.standalone.console; import io.sentry.Sentry; import org.geysermc.api.ChatColor; diff --git a/connector/pom.xml b/connector/pom.xml index 30ada454..fe01a370 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -36,25 +36,6 @@ 1.7.0 compile - - net.minecrell - terminalconsoleappender - 1.0.0 - jar - compile - - - org.projectlombok - lombok - 1.18.4 - provided - - - org.fusesource.jansi - jansi - 1.18 - compile - com.nukkitx.protocol bedrock-v388 @@ -111,6 +92,12 @@ + + org.projectlombok + lombok + 1.18.4 + provided + ${project.artifactId}-${project.version}-noshade diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java index 215769a2..b25b640a 100644 --- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java +++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java @@ -38,7 +38,6 @@ import org.geysermc.api.logger.Logger; import org.geysermc.api.plugin.Plugin; import org.geysermc.common.bootstrap.IGeyserBootstrap; import org.geysermc.connector.command.GeyserCommandMap; -import org.geysermc.connector.console.ConsoleCommandReader; import org.geysermc.connector.console.GeyserLogger; import org.geysermc.connector.metrics.Metrics; import org.geysermc.connector.network.ConnectorServerEventHandler; @@ -105,8 +104,6 @@ public class GeyserConnector implements Connector { this.config = config; this.generalThreadPool = Executors.newScheduledThreadPool(config.getGeneralThreadPool()); - ConsoleCommandReader consoleReader = new ConsoleCommandReader(this); - consoleReader.startConsole(); logger.setDebug(config.isDebugMode()); @@ -177,8 +174,8 @@ public class GeyserConnector implements Connector { players.remove(player.getSocketAddress()); } - public static void start(IGeyserBootstrap bootstrap, boolean loadPlugins) { - instance = new GeyserConnector(bootstrap.getGeyserConfig(), bootstrap.getGeyserLogger(), loadPlugins); + public static GeyserConnector start(IGeyserBootstrap bootstrap, boolean loadPlugins) { + return new GeyserConnector(bootstrap.getGeyserConfig(), bootstrap.getGeyserLogger(), loadPlugins); } public static void stop() {