3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-20 06:50:09 +01:00

Move command reader into standalone module

Dieser Commit ist enthalten in:
RednedEpic 2019-12-01 18:28:36 -06:00
Ursprung c76c39f3f5
Commit 3e7e34dfb9
6 geänderte Dateien mit 45 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -17,6 +17,31 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </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> </dependencies>
<build> <build>
<finalName>${outputName}</finalName> <finalName>${outputName}</finalName>

Datei anzeigen

@ -29,6 +29,8 @@ import org.fusesource.jansi.AnsiConsole;
import org.geysermc.common.bootstrap.IGeyserBootstrap; import org.geysermc.common.bootstrap.IGeyserBootstrap;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.utils.FileUtils; 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.File;
import java.io.IOException; import java.io.IOException;
@ -60,7 +62,10 @@ public class GeyserBootstrap implements IGeyserBootstrap {
System.exit(0); System.exit(0);
} }
GeyserConnector.start(this, false); GeyserConnector connector = GeyserConnector.start(this, false);
ConsoleCommandReader consoleReader = new ConsoleCommandReader(connector);
consoleReader.startConsole();
} }
@Override @Override

Datei anzeigen

@ -23,12 +23,12 @@
* @link https://github.com/GeyserMC/Geyser * @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.api.command.ConsoleCommandSender;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.GeyserConsoleCommandSender; import org.geysermc.connector.command.GeyserConsoleCommandSender;
import net.minecrell.terminalconsole.TerminalConsoleAppender;
import org.jline.reader.EndOfFileException; import org.jline.reader.EndOfFileException;
import org.jline.reader.LineReader; import org.jline.reader.LineReader;
import org.jline.reader.LineReaderBuilder; import org.jline.reader.LineReaderBuilder;
@ -45,7 +45,6 @@ public class ConsoleCommandReader {
private GeyserConnector connector; private GeyserConnector connector;
private Terminal terminal; private Terminal terminal;
private Thread thread;
public ConsoleCommandReader(GeyserConnector connector) { public ConsoleCommandReader(GeyserConnector connector) {
this.connector = connector; this.connector = connector;
@ -53,7 +52,7 @@ public class ConsoleCommandReader {
} }
public void startConsole() { public void startConsole() {
thread = new Thread(() -> { Thread thread = new Thread(() -> {
if (terminal != null) { if (terminal != null) {
LineReader lineReader = LineReaderBuilder.builder() LineReader lineReader = LineReaderBuilder.builder()
.appName("Geyser") .appName("Geyser")
@ -74,8 +73,8 @@ public class ConsoleCommandReader {
if (line == null) if (line == null)
break; break;
} }
} catch (UserInterruptException e /* do nothing */) { } catch (UserInterruptException ignore) {
// /* do nothing */
} finally { } finally {
TerminalConsoleAppender.setReader(null); TerminalConsoleAppender.setReader(null);
} }
@ -93,6 +92,5 @@ public class ConsoleCommandReader {
}); });
thread.setName("ConsoleCommandThread"); thread.setName("ConsoleCommandThread");
connector.getGeneralThreadPool().execute(thread);
} }
} }

Datei anzeigen

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.platform.standalone; package org.geysermc.platform.standalone.console;
import io.sentry.Sentry; import io.sentry.Sentry;
import org.geysermc.api.ChatColor; import org.geysermc.api.ChatColor;

Datei anzeigen

@ -36,25 +36,6 @@
<version>1.7.0</version> <version>1.7.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </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> <dependency>
<groupId>com.nukkitx.protocol</groupId> <groupId>com.nukkitx.protocol</groupId>
<artifactId>bedrock-v388</artifactId> <artifactId>bedrock-v388</artifactId>
@ -111,6 +92,12 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.4</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>${project.artifactId}-${project.version}-noshade</finalName> <finalName>${project.artifactId}-${project.version}-noshade</finalName>

Datei anzeigen

@ -38,7 +38,6 @@ import org.geysermc.api.logger.Logger;
import org.geysermc.api.plugin.Plugin; import org.geysermc.api.plugin.Plugin;
import org.geysermc.common.bootstrap.IGeyserBootstrap; import org.geysermc.common.bootstrap.IGeyserBootstrap;
import org.geysermc.connector.command.GeyserCommandMap; import org.geysermc.connector.command.GeyserCommandMap;
import org.geysermc.connector.console.ConsoleCommandReader;
import org.geysermc.connector.console.GeyserLogger; import org.geysermc.connector.console.GeyserLogger;
import org.geysermc.connector.metrics.Metrics; import org.geysermc.connector.metrics.Metrics;
import org.geysermc.connector.network.ConnectorServerEventHandler; import org.geysermc.connector.network.ConnectorServerEventHandler;
@ -105,8 +104,6 @@ public class GeyserConnector implements Connector {
this.config = config; this.config = config;
this.generalThreadPool = Executors.newScheduledThreadPool(config.getGeneralThreadPool()); this.generalThreadPool = Executors.newScheduledThreadPool(config.getGeneralThreadPool());
ConsoleCommandReader consoleReader = new ConsoleCommandReader(this);
consoleReader.startConsole();
logger.setDebug(config.isDebugMode()); logger.setDebug(config.isDebugMode());
@ -177,8 +174,8 @@ public class GeyserConnector implements Connector {
players.remove(player.getSocketAddress()); players.remove(player.getSocketAddress());
} }
public static void start(IGeyserBootstrap bootstrap, boolean loadPlugins) { public static GeyserConnector start(IGeyserBootstrap bootstrap, boolean loadPlugins) {
instance = new GeyserConnector(bootstrap.getGeyserConfig(), bootstrap.getGeyserLogger(), loadPlugins); return new GeyserConnector(bootstrap.getGeyserConfig(), bootstrap.getGeyserLogger(), loadPlugins);
} }
public static void stop() { public static void stop() {