Move command reader into standalone module

This commit is contained in:
RednedEpic 2019-12-01 18:28:36 -06:00
parent c76c39f3f5
commit 3e7e34dfb9
6 changed files with 45 additions and 33 deletions

View file

@ -17,6 +17,31 @@
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.minecrell</groupId>
<artifactId>terminalconsoleappender</artifactId>
<version>1.0.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>1.18</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>${outputName}</finalName>

View file

@ -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

View file

@ -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);
}
}

View file

@ -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;

View file

@ -36,25 +36,6 @@
<version>1.7.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.minecrell</groupId>
<artifactId>terminalconsoleappender</artifactId>
<version>1.0.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>1.18</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nukkitx.protocol</groupId>
<artifactId>bedrock-v388</artifactId>
@ -111,6 +92,12 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}-noshade</finalName>

View file

@ -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() {