@@ -40,7 +40,7 @@ public class PlayerInfoData {
40
40
41
41
private final UUID profileId ;
42
42
private final int latency ;
43
- private final int listOrder = 0 ;
43
+ private final int listOrder ;
44
44
private final boolean listed ;
45
45
private final boolean showHat ;
46
46
private final NativeGameMode gameMode ;
@@ -113,6 +113,23 @@ public PlayerInfoData(UUID profileId, int latency, boolean listed, NativeGameMod
113
113
this .profileKeyData = profileKeyData ;
114
114
this .remoteChatSessionData = null ;
115
115
this .showHat = false ;
116
+ this .listOrder = 0 ;
117
+ }
118
+
119
+ /**
120
+ * Constructs a new PlayerInfoData for Minecraft 1.21.2 or later.
121
+ *
122
+ * @param profileId the id of the profile (has to be non-null)
123
+ * @param latency the latency in milliseconds
124
+ * @param listed whether the player is listed in the tab list
125
+ * @param gameMode the game mode
126
+ * @param profile the game profile
127
+ * @param displayName display name in tab list (optional)
128
+ * @param listOrder the priority of this entry in the tab list
129
+ * @param remoteChatSession the remote chat session for this profile or null
130
+ */
131
+ public PlayerInfoData (UUID profileId , int latency , boolean listed , NativeGameMode gameMode , WrappedGameProfile profile , WrappedChatComponent displayName , int listOrder , @ Nullable WrappedRemoteChatSessionData remoteChatSession ) {
132
+ this (profileId , latency , listed , gameMode , profile , displayName , false , listOrder , remoteChatSession );
116
133
}
117
134
118
135
/**
@@ -128,6 +145,23 @@ public PlayerInfoData(UUID profileId, int latency, boolean listed, NativeGameMod
128
145
* @param remoteChatSession the remote chat session for this profile or null
129
146
*/
130
147
public PlayerInfoData (UUID profileId , int latency , boolean listed , NativeGameMode gameMode , WrappedGameProfile profile , WrappedChatComponent displayName , boolean showHat , @ Nullable WrappedRemoteChatSessionData remoteChatSession ) {
148
+ this (profileId , latency , listed , gameMode , profile , displayName , showHat , 0 , remoteChatSession );
149
+ }
150
+
151
+ /**
152
+ * Constructs a new PlayerInfoData for Minecraft 1.21.4 or later.
153
+ *
154
+ * @param profileId the id of the profile (has to be non-null)
155
+ * @param latency the latency in milliseconds
156
+ * @param listed whether the player is listed in the tab list
157
+ * @param gameMode the game mode
158
+ * @param profile the game profile
159
+ * @param displayName display name in tab list (optional)
160
+ * @param showHat whether a hat should be shown
161
+ * @param listOrder the priority of this entry in the tab list
162
+ * @param remoteChatSession the remote chat session for this profile or null
163
+ */
164
+ public PlayerInfoData (UUID profileId , int latency , boolean listed , NativeGameMode gameMode , WrappedGameProfile profile , WrappedChatComponent displayName , boolean showHat , int listOrder , @ Nullable WrappedRemoteChatSessionData remoteChatSession ) {
131
165
this .profileId = profileId ;
132
166
this .latency = latency ;
133
167
this .listed = listed ;
@@ -137,6 +171,7 @@ public PlayerInfoData(UUID profileId, int latency, boolean listed, NativeGameMod
137
171
this .profileKeyData = null ;
138
172
this .remoteChatSessionData = remoteChatSession ;
139
173
this .showHat = showHat ;
174
+ this .listOrder = listOrder ;
140
175
}
141
176
142
177
/**
@@ -203,8 +238,16 @@ public WrappedChatComponent getDisplayName() {
203
238
* @return if the hat is shown
204
239
*/
205
240
public boolean isShowHat () {
206
- return showHat ;
207
- }
241
+ return showHat ;
242
+ }
243
+
244
+ /**
245
+ * Gets the priority of this entry in the tab list (since 1.21.2)
246
+ * @return the priority of this entry in the tab list
247
+ */
248
+ public int getListOrder () {
249
+ return listOrder ;
250
+ }
208
251
209
252
/**
210
253
* Returns the public key of the profile (since 1.19). Returns the public key of the remote chat session since 1.19.3
@@ -255,7 +298,7 @@ public Object getGeneric(PlayerInfoData specific) {
255
298
args .add (MinecraftReflection .getIChatBaseComponentClass ());
256
299
257
300
if (MinecraftVersion .v1_21_4 .atOrAbove ()) {
258
- args .add (boolean .class );
301
+ args .add (boolean .class );
259
302
}
260
303
if (MinecraftVersion .v1_21_2 .atOrAbove ()) {
261
304
args .add (int .class );
@@ -376,6 +419,18 @@ public PlayerInfoData getSpecific(Object generic) {
376
419
gameProfile ,
377
420
displayName ,
378
421
modifier .<Boolean >withType (boolean .class ).read (1 ),
422
+ ints .read (1 ),
423
+ modifier .withType (MinecraftReflection .getRemoteChatSessionDataClass (), BukkitConverters .getWrappedRemoteChatSessionDataConverter ()).read (0 )
424
+ );
425
+ }
426
+ if (MinecraftVersion .v1_21_2 .atOrAbove ()) {
427
+ return new PlayerInfoData (modifier .<UUID >withType (UUID .class ).read (0 ),
428
+ latency ,
429
+ modifier .<Boolean >withType (boolean .class ).read (0 ),
430
+ gameMode ,
431
+ gameProfile ,
432
+ displayName ,
433
+ ints .read (1 ),
379
434
modifier .withType (MinecraftReflection .getRemoteChatSessionDataClass (), BukkitConverters .getWrappedRemoteChatSessionDataConverter ()).read (0 )
380
435
);
381
436
}
0 commit comments