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 a7dd0c97d..8a6ebb722 100644 --- a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java +++ b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java @@ -56,7 +56,7 @@ public enum ProtocolVersion { MINECRAFT_1_16_4(754, "1.16.4", "1.16.5"), MINECRAFT_1_17(755, "1.17"), MINECRAFT_1_17_1(756, "1.17.1"), - MINECRAFT_1_18(-1, 47, "1.18"); // Snapshot: 21w43a, future protocol: 757 + MINECRAFT_1_18(-1, 48, "1.18"); // Snapshot: 21w44a, future protocol: 757 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 38942fa16..b9cbed7a4 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, true)); + new ClientSettings("en_US", (byte) 10, 0, true, (short) 127, 1, true, false)); 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 ef3818c99..f1e7d038a 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 @@ -34,18 +34,20 @@ public class ClientSettings implements MinecraftPacket { private short skinParts; private int mainHand; private boolean chatFilteringEnabled; // Added in 1.17 + private boolean clientListingAllowed; // Added in 1.18, overwrites server-list "anonymous" mode public ClientSettings() { } public ClientSettings(String locale, byte viewDistance, int chatVisibility, boolean chatColors, - short skinParts, int mainHand, boolean chatFilteringEnabled) { + short skinParts, int mainHand, boolean chatFilteringEnabled, boolean clientListingAllowed) { this.locale = locale; this.viewDistance = viewDistance; this.chatVisibility = chatVisibility; this.chatColors = chatColors; this.skinParts = skinParts; this.mainHand = mainHand; + this.clientListingAllowed = clientListingAllowed; } public String getLocale() { @@ -107,6 +109,14 @@ public class ClientSettings implements MinecraftPacket { this.chatFilteringEnabled = chatFilteringEnabled; } + public boolean isClientListingAllowed() { + return clientListingAllowed; + } + + public void setClientListingAllowed(boolean clientListingAllowed) { + this.clientListingAllowed = clientListingAllowed; + } + @Override public String toString() { return "ClientSettings{" @@ -117,6 +127,7 @@ public class ClientSettings implements MinecraftPacket { + ", skinParts=" + skinParts + ", mainHand=" + mainHand + ", chatFilteringEnabled=" + chatFilteringEnabled + + ", clientListingAllowed=" + clientListingAllowed + '}'; } @@ -138,6 +149,10 @@ public class ClientSettings implements MinecraftPacket { if (version.compareTo(ProtocolVersion.MINECRAFT_1_17) >= 0) { this.chatFilteringEnabled = buf.readBoolean(); + + if (version.compareTo(ProtocolVersion.MINECRAFT_1_18) >= 0) { + this.clientListingAllowed = buf.readBoolean(); + } } } } @@ -163,6 +178,10 @@ public class ClientSettings implements MinecraftPacket { if (version.compareTo(ProtocolVersion.MINECRAFT_1_17) >= 0) { buf.writeBoolean(chatFilteringEnabled); + + if (version.compareTo(ProtocolVersion.MINECRAFT_1_18) >= 0) { + buf.writeBoolean(clientListingAllowed); + } } } }