77import com .comphenix .protocol .reflect .accessors .ConstructorAccessor ;
88import com .comphenix .protocol .reflect .accessors .FieldAccessor ;
99import com .comphenix .protocol .reflect .accessors .MethodAccessor ;
10+ import com .comphenix .protocol .reflect .instances .DefaultInstances ;
11+ import com .comphenix .protocol .reflect .instances .MinecraftGenerator ;
1012import com .comphenix .protocol .utility .MinecraftProtocolVersion ;
1113import com .comphenix .protocol .utility .MinecraftReflection ;
1214import com .comphenix .protocol .utility .MinecraftVersion ;
@@ -23,6 +25,7 @@ public final class ServerPingRecord implements ServerPingImpl {
2325 private static Class <?> SERVER_PING ;
2426 private static Class <?> PLAYER_SAMPLE_CLASS ;
2527 private static Class <?> SERVER_DATA_CLASS ;
28+ private static Class <?> NAME_AND_ID_CLASS ;
2629
2730 private static Class <?> GSON_CLASS ;
2831 private static MethodAccessor GSON_TO_JSON ;
@@ -62,7 +65,31 @@ private static void initialize() {
6265 SAMPLE_WRAPPER = AutoWrapper .wrap (PlayerSample .class , PLAYER_SAMPLE_CLASS );
6366 FAVICON_WRAPPER = AutoWrapper .wrap (Favicon .class , MinecraftReflection .getMinecraftClass ("network.protocol.status.ServerPing$a" , "network.protocol.status.ServerStatus$Favicon" ));
6467
65- PROFILE_LIST_CONVERTER = BukkitConverters .getListConverter (BukkitConverters .getWrappedGameProfileConverter ());
68+ if (MinecraftVersion .v1_21_10 .atOrAbove ()) {
69+ NAME_AND_ID_CLASS = MinecraftReflection .getMinecraftClass ("server.players.NameAndId" );
70+ NAME_AND_ID_WRAPPER = AutoWrapper .wrap (NameAndId .class , NAME_AND_ID_CLASS );
71+
72+ PROFILE_LIST_CONVERTER = BukkitConverters .getListConverter (new EquivalentConverter <>() {
73+ @ Override
74+ public Object getGeneric (WrappedGameProfile specific ) {
75+ NameAndId wrapper = new NameAndId (specific .getUUID (), specific .getName ());
76+ return NAME_AND_ID_WRAPPER .getGeneric (wrapper );
77+ }
78+
79+ @ Override
80+ public WrappedGameProfile getSpecific (Object generic ) {
81+ NameAndId wrapper = NAME_AND_ID_WRAPPER .getSpecific (generic );
82+ return new WrappedGameProfile (wrapper .id , wrapper .name );
83+ }
84+
85+ @ Override
86+ public Class <WrappedGameProfile > getSpecificType () {
87+ return WrappedGameProfile .class ;
88+ }
89+ });
90+ } else {
91+ PROFILE_LIST_CONVERTER = BukkitConverters .getListConverter (BukkitConverters .getWrappedGameProfileConverter ());
92+ }
6693
6794 DEFAULT_DESCRIPTION = WrappedChatComponent .fromLegacyText ("A Minecraft Server" );
6895
@@ -124,11 +151,24 @@ public Favicon() {
124151 }
125152 }
126153
127- private static AutoWrapper <PlayerSample > SAMPLE_WRAPPER ;
154+ public static final class NameAndId {
155+ public UUID id ;
156+ public String name ;
128157
129- private static AutoWrapper <ServerData > DATA_WRAPPER ;
158+ public NameAndId (UUID id , String name ) {
159+ this .id = id ;
160+ this .name = name ;
161+ }
130162
163+ public NameAndId () {
164+ this (MinecraftGenerator .SYS_UUID , "" );
165+ }
166+ }
167+
168+ private static AutoWrapper <PlayerSample > SAMPLE_WRAPPER ;
169+ private static AutoWrapper <ServerData > DATA_WRAPPER ;
131170 private static AutoWrapper <Favicon > FAVICON_WRAPPER ;
171+ private static AutoWrapper <NameAndId > NAME_AND_ID_WRAPPER ;
132172
133173 private WrappedChatComponent description ;
134174 private PlayerSample playerSample ;
0 commit comments