mirror of
https://e.coding.net/circlecloud/YumCore.git
synced 2024-11-22 01:48:50 +00:00
feat: 兼容 1.17
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
f130cfed60
commit
834f3d7d58
4
pom.xml
4
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>pw.yumc</groupId>
|
<groupId>pw.yumc</groupId>
|
||||||
<artifactId>YumCore</artifactId>
|
<artifactId>YumCore</artifactId>
|
||||||
<version>1.9.1</version>
|
<version>1.9.2</version>
|
||||||
<build>
|
<build>
|
||||||
<finalName>${project.artifactId}</finalName>
|
<finalName>${project.artifactId}</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
@ -92,7 +92,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.clip</groupId>
|
<groupId>me.clip</groupId>
|
||||||
<artifactId>placeholderapi</artifactId>
|
<artifactId>placeholderapi</artifactId>
|
||||||
<version>2.9.2</version>
|
<version>2.10.9</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
|
@ -38,11 +38,18 @@ public class C {
|
|||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
version = getNMSVersion();
|
version = getNMSVersion();
|
||||||
newversion = Integer.parseInt(version.split("_")[1]) > 7;
|
Integer subVersion = Integer.parseInt(version.split("_")[1]);
|
||||||
Class<?> nmsChatSerializer = Class.forName(a(newversion ? "IChatBaseComponent$ChatSerializer" : "ChatSerializer"));
|
newversion = subVersion > 7;
|
||||||
|
Class<?> nmsChatSerializer = subVersion < 17 ?
|
||||||
|
Class.forName(a(newversion ? "IChatBaseComponent$ChatSerializer" : "ChatSerializer")) :
|
||||||
|
Class.forName("net.minecraft.network.chat.IChatBaseComponent$ChatSerializer");
|
||||||
chatSerializer = nmsChatSerializer.getMethod("a", String.class);
|
chatSerializer = nmsChatSerializer.getMethod("a", String.class);
|
||||||
nmsIChatBaseComponent = Class.forName(a("IChatBaseComponent"));
|
nmsIChatBaseComponent = subVersion < 17 ?
|
||||||
Class<?> packetType = Class.forName(a("PacketPlayOutChat"));
|
Class.forName(a("IChatBaseComponent")) :
|
||||||
|
Class.forName("net.minecraft.network.chat.IChatBaseComponent");
|
||||||
|
Class<?> packetType = subVersion < 17 ?
|
||||||
|
Class.forName(a("PacketPlayOutChat")) :
|
||||||
|
Class.forName("net.minecraft.network.protocol.game.PacketPlayOutChat");
|
||||||
Arrays.stream(packetType.getConstructors()).forEach(c -> {
|
Arrays.stream(packetType.getConstructors()).forEach(c -> {
|
||||||
if (c.getParameterTypes().length == 2) {
|
if (c.getParameterTypes().length == 2) {
|
||||||
packetTypeConstructor = c;
|
packetTypeConstructor = c;
|
||||||
@ -67,11 +74,13 @@ public class C {
|
|||||||
nmsChatMessageTypeClassValueOf = nmsChatMessageTypeClass.getDeclaredMethod("valueOf", String.class);
|
nmsChatMessageTypeClassValueOf = nmsChatMessageTypeClass.getDeclaredMethod("valueOf", String.class);
|
||||||
}
|
}
|
||||||
Class<?> typeCraftPlayer = Class.forName(b("entity.CraftPlayer"));
|
Class<?> typeCraftPlayer = Class.forName(b("entity.CraftPlayer"));
|
||||||
Class<?> typeNMSPlayer = Class.forName(a("EntityPlayer"));
|
Class<?> typeNMSPlayer = subVersion < 17 ? Class.forName(a("EntityPlayer")) : Class.forName("net.minecraft.server.level.EntityPlayer");
|
||||||
Class<?> typePlayerConnection = Class.forName(a("PlayerConnection"));
|
Class<?> typePlayerConnection = subVersion < 17 ? Class.forName(a("PlayerConnection")) : Class.forName("net.minecraft.server.network.PlayerConnection");
|
||||||
getHandle = typeCraftPlayer.getMethod("getHandle");
|
getHandle = typeCraftPlayer.getMethod("getHandle");
|
||||||
playerConnection = typeNMSPlayer.getField("playerConnection");
|
playerConnection = subVersion < 17 ? typeNMSPlayer.getField("playerConnection") : typeNMSPlayer.getField("b");
|
||||||
sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName(a("Packet")));
|
sendPacket = typePlayerConnection.getMethod("sendPacket", subVersion < 17 ?
|
||||||
|
Class.forName(a("Packet")) :
|
||||||
|
Class.forName("net.minecraft.network.protocol.Packet"));
|
||||||
init = true;
|
init = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.w("C 兼容性工具初始化失败 可能造成部分功能不可用!");
|
Log.w("C 兼容性工具初始化失败 可能造成部分功能不可用!");
|
||||||
|
Loading…
Reference in New Issue
Block a user