Skip to content

Commit 664550e

Browse files
committed
修复 LightInjector 在高版本的 NoSuchMethodError 导致玩家无法进入服务器的问题
1 parent 9e947e4 commit 664550e

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

module/bukkit-nms/src/main/java/taboolib/module/nms/LightInjector.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public abstract class LightInjector implements Closeable {
8787

8888
private static final Method GET_PLAYER_HANDLE = getMethod(getCBClass("entity.CraftPlayer"), "getHandle");
8989

90+
private static final Method GAME_PROFILE_ID = getMethod(GameProfile.class, MinecraftVersion.INSTANCE.getVersionId() > 12108 ? "id" : "getId");
91+
9092
// Used to make identifiers unique if multiple instances are created. This doesn't need to be atomic
9193
// since it is called only from the constructor, which is assured to run on the main thread
9294
// 如果创建了多个实例,用于使标识符唯一。由于它仅在构造函数中调用,并确保在主线程上运行,因此不需要是原子的
@@ -589,7 +591,7 @@ public void write(ChannelHandlerContext ctx, Object packet, ChannelPromise promi
589591
// Player object should be in cache. If it's not, then it'll be PlayerJoinEvent to set the player
590592
// 玩家对象应该在缓存中。如果不在缓存中,则将在 PlayerJoinEvent 中设置玩家
591593
try {
592-
@Nullable Player player = playerCache.remove(((GameProfile) GAME_PROFILE_FROM_PACKET.get(packet)).getId());
594+
@Nullable Player player = playerCache.remove((UUID) GAME_PROFILE_ID.invoke(((GameProfile) GAME_PROFILE_FROM_PACKET.get(packet))));
593595
// Set the player only if it was contained in the cache
594596
// 仅在缓存中包含玩家时才设置玩家
595597
if (player != null) {

module/bukkit-nms/src/main/resources/mapping.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
"file": "bukkit-1.21.5-cl.csrg",
226226
"hash": "c4152823729ffa2ce3427b6534836150cbfa12b2"
227227
},
228-
"fields":{
228+
"fields": {
229229
"file": "bukkit-956575d9-members.csrg",
230230
"hash": "2d4dbd77eafcd301418cc442cf6f93f60ebd2484"
231231
}
@@ -236,7 +236,7 @@
236236
"file": "bukkit-1.21.6-cl.csrg",
237237
"hash": "ec1e68d42e761dd448721473cf36801e1064c976"
238238
},
239-
"fields":{
239+
"fields": {
240240
"file": "bukkit-380678f7-members.csrg",
241241
"hash": "ca84c12a6533f52754813e8ef02f20449009402a"
242242
}
@@ -247,7 +247,7 @@
247247
"file": "bukkit-1.21.7-cl.csrg",
248248
"hash": "ec1e68d42e761dd448721473cf36801e1064c976"
249249
},
250-
"fields":{
250+
"fields": {
251251
"file": "bukkit-541d8131-members.csrg",
252252
"hash": "0555763ae246fa29d22b11096e9021f850136a3c"
253253
}
@@ -258,7 +258,7 @@
258258
"file": "bukkit-1.21.8-cl.csrg",
259259
"hash": "ec1e68d42e761dd448721473cf36801e1064c976"
260260
},
261-
"fields":{
261+
"fields": {
262262
"file": "bukkit-7d8f8942-members.csrg",
263263
"hash": "0555763ae246fa29d22b11096e9021f850136a3c"
264264
}
@@ -269,7 +269,7 @@
269269
"file": "bukkit-1.21.9-cl.csrg",
270270
"hash": "d4e560891e7bd6c782ee541d70253f04c5e7a7f9"
271271
},
272-
"fields":{
272+
"fields": {
273273
"file": "bukkit-a2426d28-members.csrg",
274274
"hash": "862fd6e1c27ad26e616a8717b8f60e3c25aedd4a"
275275
}
@@ -280,7 +280,7 @@
280280
"file": "bukkit-1.21.10-cl.csrg",
281281
"hash": "d4e560891e7bd6c782ee541d70253f04c5e7a7f9"
282282
},
283-
"fields":{
283+
"fields": {
284284
"file": "bukkit-75645fa6-members.csrg",
285285
"hash": "be0c1d15fd28220c024c4599025304773b4af45b"
286286
}

0 commit comments

Comments
 (0)