From 1d1303b31c74d51b7f081360ea27cfd8400395dd Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Mon, 6 Dec 2021 14:57:28 +0000 Subject: [PATCH] feat: compatible 1.18 Signed-off-by: MiaoWoo --- pom.xml | 2 +- src/main/java/pw/yumc/YumCore/bukkit/compatible/C.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 26e23a1..dfb4b9e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 pw.yumc YumCore - 1.9.2 + 1.9.3 ${project.artifactId} diff --git a/src/main/java/pw/yumc/YumCore/bukkit/compatible/C.java b/src/main/java/pw/yumc/YumCore/bukkit/compatible/C.java index 5acf1cb..4b2ca6f 100644 --- a/src/main/java/pw/yumc/YumCore/bukkit/compatible/C.java +++ b/src/main/java/pw/yumc/YumCore/bukkit/compatible/C.java @@ -78,9 +78,13 @@ public class C { Class typePlayerConnection = subVersion < 17 ? Class.forName(a("PlayerConnection")) : Class.forName("net.minecraft.server.network.PlayerConnection"); getHandle = typeCraftPlayer.getMethod("getHandle"); playerConnection = subVersion < 17 ? typeNMSPlayer.getField("playerConnection") : typeNMSPlayer.getField("b"); - sendPacket = typePlayerConnection.getMethod("sendPacket", subVersion < 17 ? - Class.forName(a("Packet")) : - Class.forName("net.minecraft.network.protocol.Packet")); + if (subVersion < 17) { + sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName(a("Packet"))); + } else if (subVersion == 17) { + sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName("net.minecraft.network.protocol.Packet")); + } else { + sendPacket = typePlayerConnection.getMethod("a", Class.forName("net.minecraft.network.protocol.Packet")); + } init = true; } catch (Exception e) { Log.w("C 兼容性工具初始化失败 可能造成部分功能不可用!");