geforkt von Mirrors/Velocity
Add TerminalConsoleAppender for console prompts
Dieser Commit ist enthalten in:
Ursprung
a7a227ed05
Commit
a044ed72de
@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'com.github.johnrengelman.shadow' version '2.0.4'
|
id 'com.github.johnrengelman.shadow' version '2.0.4'
|
||||||
|
id 'de.sebastianboegl.shadow.transformer.log4j' version '2.1.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava {
|
compileJava {
|
||||||
@ -21,17 +22,24 @@ jar {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile project(':velocity-api')
|
compile project(':velocity-api')
|
||||||
compile project(':velocity-native')
|
compile project(':velocity-native')
|
||||||
|
|
||||||
compile "io.netty:netty-codec:${nettyVersion}"
|
compile "io.netty:netty-codec:${nettyVersion}"
|
||||||
compile "io.netty:netty-codec-http:${nettyVersion}"
|
compile "io.netty:netty-codec-http:${nettyVersion}"
|
||||||
compile "io.netty:netty-handler:${nettyVersion}"
|
compile "io.netty:netty-handler:${nettyVersion}"
|
||||||
compile "io.netty:netty-transport-native-epoll:${nettyVersion}"
|
compile "io.netty:netty-transport-native-epoll:${nettyVersion}"
|
||||||
compile "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-x86_64"
|
compile "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-x86_64"
|
||||||
|
|
||||||
compile "org.apache.logging.log4j:log4j-api:${log4jVersion}"
|
compile "org.apache.logging.log4j:log4j-api:${log4jVersion}"
|
||||||
compile "org.apache.logging.log4j:log4j-core:${log4jVersion}"
|
compile "org.apache.logging.log4j:log4j-core:${log4jVersion}"
|
||||||
|
|
||||||
|
compile 'net.minecrell:terminalconsoleappender:1.1.1'
|
||||||
|
runtime 'net.java.dev.jna:jna:4.5.2' // Needed for JLine
|
||||||
|
runtime 'com.lmax:disruptor:3.4.2' // Async loggers
|
||||||
|
|
||||||
testCompile "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
|
testCompile "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
|
||||||
testCompile "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
|
testCompile "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
|
||||||
}
|
}
|
||||||
|
|
||||||
artifacts {
|
artifacts {
|
||||||
archives shadowJar
|
archives shadowJar
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package com.velocitypowered.proxy;
|
package com.velocitypowered.proxy;
|
||||||
|
|
||||||
|
import com.velocitypowered.proxy.console.VelocityConsole;
|
||||||
|
|
||||||
public class Velocity {
|
public class Velocity {
|
||||||
public static void main(String... args) throws InterruptedException {
|
public static void main(String... args) {
|
||||||
final VelocityServer server = VelocityServer.getServer();
|
final VelocityServer server = VelocityServer.getServer();
|
||||||
server.start();
|
server.start();
|
||||||
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(server::shutdown, "Shutdown thread"));
|
Runtime.getRuntime().addShutdownHook(new Thread(server::shutdown, "Shutdown thread"));
|
||||||
|
new VelocityConsole(server).start();
|
||||||
Thread.currentThread().join();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,7 @@ public class VelocityServer implements ProxyServer {
|
|||||||
private final CommandInvoker consoleCommandInvoker = new CommandInvoker() {
|
private final CommandInvoker consoleCommandInvoker = new CommandInvoker() {
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(@Nonnull Component component) {
|
public void sendMessage(@Nonnull Component component) {
|
||||||
// TODO: TerminalConsoleAppender
|
logger.info(ComponentSerializers.LEGACY.serialize(component));
|
||||||
logger.info(ComponentSerializers.PLAIN.serialize(component));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.velocitypowered.proxy.console;
|
||||||
|
|
||||||
|
import com.velocitypowered.proxy.VelocityServer;
|
||||||
|
import net.minecrell.terminalconsole.SimpleTerminalConsole;
|
||||||
|
import org.jline.reader.LineReader;
|
||||||
|
import org.jline.reader.LineReaderBuilder;
|
||||||
|
|
||||||
|
public final class VelocityConsole extends SimpleTerminalConsole {
|
||||||
|
|
||||||
|
private final VelocityServer server;
|
||||||
|
|
||||||
|
public VelocityConsole(VelocityServer server) {
|
||||||
|
this.server = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected LineReader buildReader(LineReaderBuilder builder) {
|
||||||
|
return super.buildReader(builder
|
||||||
|
.appName("Velocity")
|
||||||
|
// TODO: Command completion
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isRunning() {
|
||||||
|
return !this.server.isShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void runCommand(String command) {
|
||||||
|
this.server.getCommandManager().execute(this.server.getConsoleCommandInvoker(), command);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void shutdown() {
|
||||||
|
this.server.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
1
proxy/src/main/resources/log4j2.component.properties
Normale Datei
1
proxy/src/main/resources/log4j2.component.properties
Normale Datei
@ -0,0 +1 @@
|
|||||||
|
log4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
|
@ -1,12 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Configuration status="warn">
|
<Configuration status="warn">
|
||||||
<Appenders>
|
<Appenders>
|
||||||
<Console name="Console" target="SYSTEM_OUT">
|
<TerminalConsole name="TerminalConsole">
|
||||||
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n"/>
|
<PatternLayout pattern="%highlightError{[%d{HH:mm:ss} %level]: %minecraftFormatting{%msg}%n%xEx}"/>
|
||||||
</Console>
|
</TerminalConsole>
|
||||||
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz"
|
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz"
|
||||||
immediateFlush="false">
|
immediateFlush="false">
|
||||||
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n"/>
|
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %minecraftFormatting{%msg}{strip}%n"/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<TimeBasedTriggeringPolicy/>
|
<TimeBasedTriggeringPolicy/>
|
||||||
<OnStartupTriggeringPolicy/>
|
<OnStartupTriggeringPolicy/>
|
||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<Loggers>
|
<Loggers>
|
||||||
<Root level="info">
|
<Root level="info">
|
||||||
<AppenderRef ref="Console"/>
|
<AppenderRef ref="TerminalConsole"/>
|
||||||
<AppenderRef ref="File"/>
|
<AppenderRef ref="File"/>
|
||||||
</Root>
|
</Root>
|
||||||
</Loggers>
|
</Loggers>
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren