mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-28 18:52:03 -07:00
Add allow server listing & text filtering client options (#7595)
This commit is contained in:
@@ -26,6 +26,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ public static final ClientOption<String> LOCALE = new ClientOption<>(String.class);
|
||||
+ public static final ClientOption<MainHand> MAIN_HAND = new ClientOption<>(MainHand.class);
|
||||
+ public static final ClientOption<Integer> VIEW_DISTANCE = new ClientOption<>(Integer.class);
|
||||
+ public static final ClientOption<Boolean> ALLOW_SERVER_LISTINGS = new ClientOption<>(Boolean.class);
|
||||
+ public static final ClientOption<Boolean> TEXT_FILTERING_ENABLED = new ClientOption<>(Boolean.class);
|
||||
+
|
||||
+ private final Class<T> type;
|
||||
+
|
||||
@@ -97,16 +99,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import com.destroystokyo.paper.ClientOption;
|
||||
+import com.destroystokyo.paper.ClientOption.ChatVisibility;
|
||||
+import com.destroystokyo.paper.SkinParts;
|
||||
+
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.player.PlayerEvent;
|
||||
+import org.bukkit.inventory.MainHand;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.Map;
|
||||
+
|
||||
+/**
|
||||
+ * Called when the player changes his client settings
|
||||
+ * Called when the player changes their client settings
|
||||
+ */
|
||||
+public class PlayerClientOptionsChangeEvent extends PlayerEvent {
|
||||
+
|
||||
@@ -118,7 +120,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ private final boolean chatColors;
|
||||
+ private final SkinParts skinparts;
|
||||
+ private final MainHand mainHand;
|
||||
+ private final boolean allowsServerListings;
|
||||
+ private final boolean textFilteringEnabled;
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public PlayerClientOptionsChangeEvent(@NotNull Player player, @NotNull String locale, int viewDistance, @NotNull ChatVisibility chatVisibility, boolean chatColors, @NotNull SkinParts skinParts, @NotNull MainHand mainHand) {
|
||||
+ super(player);
|
||||
+ this.locale = locale;
|
||||
@@ -127,6 +132,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ this.chatColors = chatColors;
|
||||
+ this.skinparts = skinParts;
|
||||
+ this.mainHand = mainHand;
|
||||
+ this.allowsServerListings = false;
|
||||
+ this.textFilteringEnabled = false;
|
||||
+ }
|
||||
+
|
||||
+ public PlayerClientOptionsChangeEvent(@NotNull Player player, @NotNull Map<ClientOption<?>, ?> options) {
|
||||
+ super(player);
|
||||
+
|
||||
+ this.locale = (String) options.get(ClientOption.LOCALE);
|
||||
+ this.viewDistance = (int) options.get(ClientOption.VIEW_DISTANCE);
|
||||
+ this.chatVisibility = (ChatVisibility) options.get(ClientOption.CHAT_VISIBILITY);
|
||||
+ this.chatColors = (boolean) options.get(ClientOption.CHAT_COLORS_ENABLED);
|
||||
+ this.skinparts = (SkinParts) options.get(ClientOption.SKIN_PARTS);
|
||||
+ this.mainHand = (MainHand) options.get(ClientOption.MAIN_HAND);
|
||||
+ this.allowsServerListings = (boolean) options.get(ClientOption.ALLOW_SERVER_LISTINGS);
|
||||
+ this.textFilteringEnabled = (boolean) options.get(ClientOption.TEXT_FILTERING_ENABLED);
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
@@ -181,6 +201,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ return mainHand != player.getClientOption(ClientOption.MAIN_HAND);
|
||||
+ }
|
||||
+
|
||||
+ public boolean allowsServerListings() {
|
||||
+ return allowsServerListings;
|
||||
+ }
|
||||
+
|
||||
+ public boolean hasAllowServerListingsChanged() {
|
||||
+ return allowsServerListings != player.getClientOption(ClientOption.ALLOW_SERVER_LISTINGS);
|
||||
+ }
|
||||
+
|
||||
+ public boolean hasTextFilteringEnabled() {
|
||||
+ return textFilteringEnabled;
|
||||
+ }
|
||||
+
|
||||
+ public boolean hasTextFilteringChanged() {
|
||||
+ return textFilteringEnabled != player.getClientOption(ClientOption.TEXT_FILTERING_ENABLED);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public HandlerList getHandlers() {
|
||||
|
Reference in New Issue
Block a user