13
0
geforkt von Mirrors/Velocity

Added logPlayerConnections configuration option (#673)

Dieser Commit ist enthalten in:
4drian3d 2022-04-03 14:30:47 -05:00 committet von GitHub
Ursprung 8214fe30fe
Commit b8223686ea
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
5 geänderte Dateien mit 27 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -378,6 +378,10 @@ public class VelocityConfiguration implements ProxyConfig {
return advanced.isLogCommandExecutions();
}
public boolean isLogPlayerConnections() {
return advanced.isLogPlayerConnections();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
@ -640,6 +644,7 @@ public class VelocityConfiguration implements ProxyConfig {
@Expose private boolean failoverOnUnexpectedServerDisconnect = true;
@Expose private boolean announceProxyCommands = true;
@Expose private boolean logCommandExecutions = false;
@Expose private boolean logPlayerConnections = true;
private Advanced() {
}
@ -663,6 +668,7 @@ public class VelocityConfiguration implements ProxyConfig {
.getOrElse("failover-on-unexpected-server-disconnect", true);
this.announceProxyCommands = config.getOrElse("announce-proxy-commands", true);
this.logCommandExecutions = config.getOrElse("log-command-executions", false);
this.logPlayerConnections = config.getOrElse("log-player-connections", true);
}
}
@ -714,6 +720,10 @@ public class VelocityConfiguration implements ProxyConfig {
return logCommandExecutions;
}
public boolean isLogPlayerConnections() {
return logPlayerConnections;
}
@Override
public String toString() {
return "Advanced{"
@ -729,6 +739,7 @@ public class VelocityConfiguration implements ProxyConfig {
+ ", failoverOnUnexpectedServerDisconnect=" + failoverOnUnexpectedServerDisconnect
+ ", announceProxyCommands=" + announceProxyCommands
+ ", logCommandExecutions=" + logCommandExecutions
+ ", logPlayerConnections=" + logPlayerConnections
+ '}';
}
}

Datei anzeigen

@ -82,7 +82,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
private @Nullable MinecraftSessionHandler sessionHandler;
private ProtocolVersion protocolVersion;
private @Nullable MinecraftConnectionAssociation association;
private final VelocityServer server;
public final VelocityServer server;
private ConnectionType connectionType = ConnectionTypes.UNDETERMINED;
private boolean knownDisconnect = false;
@ -104,7 +104,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
sessionHandler.connected();
}
if (association != null) {
if (association != null && server.getConfiguration().isLogPlayerConnections()) {
logger.info("{} has connected", association);
}
}
@ -116,7 +116,8 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
}
if (association != null && !knownDisconnect
&& !(sessionHandler instanceof StatusSessionHandler)) {
&& !(sessionHandler instanceof StatusSessionHandler)
&& server.getConfiguration().isLogPlayerConnections()) {
logger.info("{} has disconnected", association);
}
}

Datei anzeigen

@ -520,8 +520,10 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
public void disconnect0(Component reason, boolean duringLogin) {
Component translated = this.translateMessage(reason);
if (server.getConfiguration().isLogPlayerConnections()) {
logger.info("{} has disconnected: {}", this,
LegacyComponentSerializer.legacySection().serialize(translated));
}
connection.closeWith(Disconnect.create(translated, this.getProtocolVersion()));
}

Datei anzeigen

@ -85,9 +85,10 @@ public final class InitialInboundConnection implements InboundConnection,
public void disconnect(Component reason) {
Component translated = GlobalTranslator.render(reason, ClosestLocaleMatcher.INSTANCE
.lookupClosest(Locale.getDefault()));
if (connection.server.getConfiguration().isLogPlayerConnections()) {
logger.info("{} has disconnected: {}", this,
LegacyComponentSerializer.legacySection().serialize(translated));
}
connection.closeWith(Disconnect.create(translated, getProtocolVersion()));
}

Datei anzeigen

@ -133,6 +133,10 @@ announce-proxy-commands = true
# Enables the logging of commands
log-command-executions = false
# Enables logging of player connections when connecting to the proxy, switching servers
# and disconnecting from the proxy.
log-player-connections = true
[query]
# Whether to enable responding to GameSpy 4 query responses or not.
enabled = false