From b19cf16345c30d03aeed4f96fe3cd249566486e3 Mon Sep 17 00:00:00 2001 From: "Five (Xer)" Date: Thu, 18 Feb 2021 22:02:26 +0100 Subject: [PATCH] Snapshot 21w07a --- .../api/network/ProtocolVersion.java | 2 +- .../client/ClientSettingsWrapper.java | 2 +- .../proxy/protocol/packet/ClientSettings.java | 20 ++++++++++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java index e09ac5519..8637d76b0 100644 --- a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java +++ b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java @@ -54,7 +54,7 @@ public enum ProtocolVersion { MINECRAFT_1_16_2(751, "1.16.2"), MINECRAFT_1_16_3(753, "1.16.3"), MINECRAFT_1_16_4(754, "1.16.4", "1.16.5"), - MINECRAFT_1_17(-1, 14, "1.17"); // Snapshot: 21w06a, future protocol: 755 + MINECRAFT_1_17(-1, 15, "1.17"); // Snapshot: 21w07a, future protocol: 755 private static final int SNAPSHOT_BIT = 30; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientSettingsWrapper.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientSettingsWrapper.java index b268ee19c..38942fa16 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientSettingsWrapper.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientSettingsWrapper.java @@ -26,7 +26,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; public class ClientSettingsWrapper implements PlayerSettings { static final PlayerSettings DEFAULT = new ClientSettingsWrapper( - new ClientSettings("en_US", (byte) 10, 0, true, (short) 127, 1)); + new ClientSettings("en_US", (byte) 10, 0, true, (short) 127, 1, true)); private final ClientSettings settings; private final SkinParts parts; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ClientSettings.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ClientSettings.java index a2d7e32bc..ef3818c99 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ClientSettings.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ClientSettings.java @@ -33,12 +33,13 @@ public class ClientSettings implements MinecraftPacket { private byte difficulty; // 1.7 Protocol private short skinParts; private int mainHand; + private boolean chatFilteringEnabled; // Added in 1.17 public ClientSettings() { } public ClientSettings(String locale, byte viewDistance, int chatVisibility, boolean chatColors, - short skinParts, int mainHand) { + short skinParts, int mainHand, boolean chatFilteringEnabled) { this.locale = locale; this.viewDistance = viewDistance; this.chatVisibility = chatVisibility; @@ -98,6 +99,14 @@ public class ClientSettings implements MinecraftPacket { this.mainHand = mainHand; } + public boolean isChatFilteringEnabled() { + return chatFilteringEnabled; + } + + public void setChatFilteringEnabled(boolean chatFilteringEnabled) { + this.chatFilteringEnabled = chatFilteringEnabled; + } + @Override public String toString() { return "ClientSettings{" @@ -107,6 +116,7 @@ public class ClientSettings implements MinecraftPacket { + ", chatColors=" + chatColors + ", skinParts=" + skinParts + ", mainHand=" + mainHand + + ", chatFilteringEnabled=" + chatFilteringEnabled + '}'; } @@ -125,6 +135,10 @@ public class ClientSettings implements MinecraftPacket { if (version.compareTo(ProtocolVersion.MINECRAFT_1_9) >= 0) { this.mainHand = ProtocolUtils.readVarInt(buf); + + if (version.compareTo(ProtocolVersion.MINECRAFT_1_17) >= 0) { + this.chatFilteringEnabled = buf.readBoolean(); + } } } @@ -146,6 +160,10 @@ public class ClientSettings implements MinecraftPacket { if (version.compareTo(ProtocolVersion.MINECRAFT_1_9) >= 0) { ProtocolUtils.writeVarInt(buf, mainHand); + + if (version.compareTo(ProtocolVersion.MINECRAFT_1_17) >= 0) { + buf.writeBoolean(chatFilteringEnabled); + } } }