From 08289514158e4a1760fe51765897c57c6c00d92d Mon Sep 17 00:00:00 2001 From: hyper Date: Wed, 8 May 2024 17:07:09 -0400 Subject: [PATCH 1/5] New client_options tag --- .../properties/PaperPlayerExtensions.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java b/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java index fba2df72d6..4647519125 100644 --- a/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java +++ b/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java @@ -6,8 +6,12 @@ import com.denizenscript.denizen.objects.PlayerTag; import com.denizenscript.denizencore.objects.core.ElementTag; import com.denizenscript.denizencore.objects.core.ListTag; +import com.denizenscript.denizencore.objects.core.MapTag; +import com.destroystokyo.paper.ClientOption; +import com.destroystokyo.paper.SkinParts; import net.kyori.adventure.util.TriState; import org.bukkit.Material; +import org.bukkit.entity.Player; public class PaperPlayerExtensions { @@ -26,6 +30,42 @@ public static void register() { return new ElementTag(object.getPlayerEntity().getAffectsSpawning()); }); + // <--[tag] + // @attribute + // @returns MapTag + // @group paper + // @Plugin Paper + // @description + // Returns the player's client options as a MapTag. + // The allow_server_listings & text_filtering_enabled options are only available in MC 1.19+. + // --> + PlayerTag.registerOnlineOnlyTag(MapTag.class, "client_options", (attribute, object) -> { + MapTag map = new MapTag(); + Player player = object.getPlayerEntity(); + if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) { + map.putObject("allow_server_listings", new ElementTag(player.getClientOption(ClientOption.ALLOW_SERVER_LISTINGS))); + } + map.putObject("chat_colors_enabled", new ElementTag(player.getClientOption(ClientOption.CHAT_COLORS_ENABLED))); + map.putObject("chat_visibility", new ElementTag(player.getClientOption(ClientOption.CHAT_VISIBILITY))); + map.putObject("locale", new ElementTag(player.getClientOption(ClientOption.LOCALE))); + map.putObject("main_hand", new ElementTag(player.getClientOption(ClientOption.MAIN_HAND))); + MapTag skinParts = new MapTag(); + SkinParts parts = player.getClientOption(ClientOption.SKIN_PARTS); + skinParts.putObject("cape", new ElementTag(parts.hasCapeEnabled())); + skinParts.putObject("hat", new ElementTag(parts.hasHatsEnabled())); + skinParts.putObject("jacket", new ElementTag(parts.hasJacketEnabled())); + skinParts.putObject("left_sleeve", new ElementTag(parts.hasLeftSleeveEnabled())); + skinParts.putObject("right_sleeve", new ElementTag(parts.hasRightSleeveEnabled())); + skinParts.putObject("left_pants", new ElementTag(parts.hasLeftPantsEnabled())); + skinParts.putObject("right_pants", new ElementTag(parts.hasRightPantsEnabled())); + map.putObject("skin_parts", skinParts); + if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) { + map.putObject("text_filtering_enabled", new ElementTag(player.getClientOption(ClientOption.TEXT_FILTERING_ENABLED))); + } + map.putObject("view_distance", new ElementTag(player.getClientOption(ClientOption.VIEW_DISTANCE))); + return map; + }); + // <--[mechanism] // @object PlayerTag // @name affects_monster_spawning From 3b24e66fb39e1ac49db0708c4d51c7a00549a25f Mon Sep 17 00:00:00 2001 From: hyper Date: Wed, 8 May 2024 17:09:37 -0400 Subject: [PATCH 2/5] Update meta --- .../denizen/paper/properties/PaperPlayerExtensions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java b/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java index 4647519125..d17ca55d9d 100644 --- a/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java +++ b/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java @@ -36,7 +36,7 @@ public static void register() { // @group paper // @Plugin Paper // @description - // Returns the player's client options as a MapTag. + // Returns the player's client options. // The allow_server_listings & text_filtering_enabled options are only available in MC 1.19+. // --> PlayerTag.registerOnlineOnlyTag(MapTag.class, "client_options", (attribute, object) -> { From 43d9aacfaeeab2793ec98ec09767251ab88c2e1e Mon Sep 17 00:00:00 2001 From: hyper Date: Fri, 10 May 2024 09:53:05 -0400 Subject: [PATCH 3/5] Update meta --- .../paper/properties/PaperPlayerExtensions.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java b/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java index d17ca55d9d..b9da4affec 100644 --- a/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java +++ b/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java @@ -37,7 +37,22 @@ public static void register() { // @Plugin Paper // @description // Returns the player's client options. - // The allow_server_listings & text_filtering_enabled options are only available in MC 1.19+. + // The output map contains the following keys: + // - 'allow_server_listings' (ElementTag(Boolean)): whether the player allows server listings. Available only on MC 1.19+. + // - 'chat_colors_enabled' (ElementTag(Boolean)): whether the player has chat colors enabled. + // - 'chat_visibility' (ElementTag(String)): the player's current chat visibility option. Possible output values are: FULL, SYSTEM, HIDDEN, and UNKNOWN. + // - 'locale' (ElementTag(String)): the player's current locale. + // - 'main_hand' (ElementTag(String)): the player's main hand, either LEFT or RIGHT. + // - 'skin_parts' (MapTag): which skin parts the player has enabled. The output map contains the following keys: + // - 'cape' (ElementTag(Boolean)): whether the player's cape is enabled. + // - 'hat' (ElementTag(Boolean)): whether the player's hat is enabled. + // - 'jacket' (ElementTag(Boolean)): whether the player's jacket is enabled. + // - 'left_sleeve' (ElementTag(Boolean)): whether the player's left sleeve is enabled. + // - 'right_sleeve' (ElementTag(Boolean)): whether the player's right sleeve is enabled. + // - 'left_pants' (ElementTag(Boolean)): whether the player's left pants is enabled. + // - 'right_pants' (ElementTag(Boolean)): whether the player's right pants is enabled. + // - 'text_filtering_enabled' (ElementTag(Boolean)): whether the player has text filtering enabled. Available only on MC 1.19+. + // - 'view_distance' (ElementTag(Number)): the player's current view distance. // --> PlayerTag.registerOnlineOnlyTag(MapTag.class, "client_options", (attribute, object) -> { MapTag map = new MapTag(); From a2618660eeee7163d77de0ed21497bc3fd5ee42f Mon Sep 17 00:00:00 2001 From: hyper Date: Mon, 13 May 2024 08:57:23 -0400 Subject: [PATCH 4/5] Removed nonexistent ElementTag in meta --- .../denizen/paper/properties/PaperPlayerExtensions.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java b/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java index b9da4affec..bf303025e5 100644 --- a/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java +++ b/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java @@ -40,9 +40,9 @@ public static void register() { // The output map contains the following keys: // - 'allow_server_listings' (ElementTag(Boolean)): whether the player allows server listings. Available only on MC 1.19+. // - 'chat_colors_enabled' (ElementTag(Boolean)): whether the player has chat colors enabled. - // - 'chat_visibility' (ElementTag(String)): the player's current chat visibility option. Possible output values are: FULL, SYSTEM, HIDDEN, and UNKNOWN. - // - 'locale' (ElementTag(String)): the player's current locale. - // - 'main_hand' (ElementTag(String)): the player's main hand, either LEFT or RIGHT. + // - 'chat_visibility' (ElementTag): the player's current chat visibility option. Possible output values are: FULL, SYSTEM, HIDDEN, and UNKNOWN. + // - 'locale' (ElementTag): the player's current locale. + // - 'main_hand' (ElementTag): the player's main hand, either LEFT or RIGHT. // - 'skin_parts' (MapTag): which skin parts the player has enabled. The output map contains the following keys: // - 'cape' (ElementTag(Boolean)): whether the player's cape is enabled. // - 'hat' (ElementTag(Boolean)): whether the player's hat is enabled. From 6233fc95bd299ea891717f91d2e3d04f19661f15 Mon Sep 17 00:00:00 2001 From: hyper Date: Fri, 31 May 2024 18:31:08 -0400 Subject: [PATCH 5/5] Merged with other version check --- .../denizen/paper/properties/PaperPlayerExtensions.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java b/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java index bf303025e5..be56152901 100644 --- a/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java +++ b/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperPlayerExtensions.java @@ -59,6 +59,7 @@ public static void register() { Player player = object.getPlayerEntity(); if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) { map.putObject("allow_server_listings", new ElementTag(player.getClientOption(ClientOption.ALLOW_SERVER_LISTINGS))); + map.putObject("text_filtering_enabled", new ElementTag(player.getClientOption(ClientOption.TEXT_FILTERING_ENABLED))); } map.putObject("chat_colors_enabled", new ElementTag(player.getClientOption(ClientOption.CHAT_COLORS_ENABLED))); map.putObject("chat_visibility", new ElementTag(player.getClientOption(ClientOption.CHAT_VISIBILITY))); @@ -74,9 +75,6 @@ public static void register() { skinParts.putObject("left_pants", new ElementTag(parts.hasLeftPantsEnabled())); skinParts.putObject("right_pants", new ElementTag(parts.hasRightPantsEnabled())); map.putObject("skin_parts", skinParts); - if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) { - map.putObject("text_filtering_enabled", new ElementTag(player.getClientOption(ClientOption.TEXT_FILTERING_ENABLED))); - } map.putObject("view_distance", new ElementTag(player.getClientOption(ClientOption.VIEW_DISTANCE))); return map; });