Skip to content

Commit

Permalink
Add an option for setting Bedrock compression level (#2128)
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy authored Apr 20, 2021
1 parent 852d5b0 commit bb41c0f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ interface IBedrockConfiguration {

String getServerName();

int getCompressionLevel();

boolean isEnableProxyProtocol();

List<String> getProxyProtocolWhitelistedIPs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ public static class BedrockConfiguration implements IBedrockConfiguration {
@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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
@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);
Expand Down
3 changes: 3 additions & 0 deletions connector/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bb41c0f

Please sign in to comment.