Add an option for setting Bedrock compression level (#2128)

This commit is contained in:
Camotoy 2021-04-19 22:18:18 -04:00 committed by GitHub
parent 852d5b050d
commit bb41c0f9ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 0 deletions

View File

@ -111,6 +111,8 @@ public interface GeyserConfiguration {
String getServerName();
int getCompressionLevel();
boolean isEnableProxyProtocol();
List<String> getProxyProtocolWhitelistedIPs();

View File

@ -147,6 +147,13 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
@JsonProperty("server-name")
private String serverName = GeyserConnector.NAME;
@JsonProperty("compression-level")
private int compressionLevel = 6;
public int getCompressionLevel() {
return Math.max(-1, Math.min(compressionLevel, 9));
}
@JsonProperty("enable-proxy-protocol")
private boolean enableProxyProtocol = false;

View File

@ -159,6 +159,7 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
@Override
public void onSessionCreation(BedrockServerSession bedrockServerSession) {
bedrockServerSession.setLogging(true);
bedrockServerSession.setCompressionLevel(connector.getConfig().getBedrock().getCompressionLevel());
bedrockServerSession.setPacketHandler(new UpstreamPacketHandler(connector, new GeyserSession(connector, bedrockServerSession)));
// Set the packet codec to default just in case we need to send disconnect packets.
bedrockServerSession.setPacketCodec(BedrockProtocol.DEFAULT_BEDROCK_CODEC);

View File

@ -23,6 +23,9 @@ bedrock:
motd2: "Another Geyser server."
# The Server Name that will be sent to Minecraft: Bedrock Edition clients. This is visible in both the pause menu and the settings menu.
server-name: "Geyser"
# How much to compress network traffic to the Bedrock client. The higher the number, the more CPU usage used, but
# the smaller the bandwidth used. Does not have any effect below -1 or above 9. Set to -1 to disable.
compression-level: 6
# Whether to enable PROXY protocol or not for clients. You DO NOT WANT this feature unless you run UDP reverse proxy
# in front of your Geyser instance.
enable-proxy-protocol: false