From 7ed4f4c03a56caccb7d953d92271b2ed22202264 Mon Sep 17 00:00:00 2001 From: FivePB Date: Thu, 25 Nov 2021 17:04:10 +0100 Subject: [PATCH] Add new ClientSettings API Add the new API introducted with the ClientSettings packet changes in 1.18 --- .../api/proxy/player/PlayerSettings.java | 10 ++++++++++ .../proxy/connection/client/ClientSettingsWrapper.java | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/api/src/main/java/com/velocitypowered/api/proxy/player/PlayerSettings.java b/api/src/main/java/com/velocitypowered/api/proxy/player/PlayerSettings.java index 61faae34b..0f70e4aac 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/player/PlayerSettings.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/player/PlayerSettings.java @@ -57,6 +57,16 @@ public interface PlayerSettings { */ MainHand getMainHand(); + /** + * Returns whether the client explicitly allows listing on the + * {@link com.velocitypowered.api.proxy.player.TabList} or not in + * anonymous TabList mode. + * This feature was introduced in 1.18. + * + * @return whether or not the client explicitly allows listing. Always false on older clients. + */ + boolean isClientListingAllowed(); + enum ChatMode { SHOWN, COMMANDS_ONLY, 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 b9cbed7a4..402ef78d2 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 @@ -74,5 +74,9 @@ public class ClientSettingsWrapper implements PlayerSettings { return settings.getMainHand() == 1 ? MainHand.RIGHT : MainHand.LEFT; } + @Override + public boolean isClientListingAllowed() { + return settings.isClientListingAllowed(); + } }