mirror of
https://e.coding.net/circlecloud/YumCore.git
synced 2024-11-24 02:08:48 +00:00
fix: 修复兼容工具载入错误
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
a567e2eb03
commit
192245c22c
@ -37,24 +37,24 @@ public class C {
|
|||||||
private static String version;
|
private static String version;
|
||||||
private static Field playerConnection;
|
private static Field playerConnection;
|
||||||
private static Method sendPacket;
|
private static Method sendPacket;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
version = getNMSVersion();
|
||||||
final boolean newversion = Integer.parseInt(version.split("_")[1]) > 7;
|
final boolean newversion = Integer.parseInt(version.split("_")[1]) > 7;
|
||||||
nmsChatSerializer = Class.forName(a(newversion ? "ChatSerializer" : "IChatBaseComponent$ChatSerializer"));
|
nmsChatSerializer = Class.forName(a(newversion ? "IChatBaseComponent$ChatSerializer" : "ChatSerializer"));
|
||||||
nmsIChatBaseComponent = Class.forName(a("IChatBaseComponent"));
|
nmsIChatBaseComponent = Class.forName(a("IChatBaseComponent"));
|
||||||
packetType = Class.forName(a("PacketPlayOutChat"));
|
packetType = Class.forName(a("PacketPlayOutChat"));
|
||||||
packetActions = Class.forName(a(newversion ? "EnumTitleAction" : "PacketPlayOutTitle$EnumTitleAction"));
|
packetActions = Class.forName(a(newversion ? "PacketPlayOutTitle$EnumTitleAction" : "EnumTitleAction"));
|
||||||
packetTitle = Class.forName(a("PacketPlayOutTitle"));
|
packetTitle = Class.forName(a("PacketPlayOutTitle"));
|
||||||
final Class<?> typeCraftPlayer = Class.forName(a("CraftPlayer"));
|
final Class<?> typeCraftPlayer = Class.forName(b("entity.CraftPlayer"));
|
||||||
final Class<?> typeNMSPlayer = Class.forName(a("EntityPlayer"));
|
final Class<?> typeNMSPlayer = Class.forName(a("EntityPlayer"));
|
||||||
final Class<?> typePlayerConnection = Class.forName(a("PlayerConnection"));
|
final Class<?> typePlayerConnection = Class.forName(a("PlayerConnection"));
|
||||||
getHandle = typeCraftPlayer.getMethod("getHandle");
|
getHandle = typeCraftPlayer.getMethod("getHandle");
|
||||||
playerConnection = typeNMSPlayer.getField("playerConnection");
|
playerConnection = typeNMSPlayer.getField("playerConnection");
|
||||||
sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName(a("Packet")));
|
sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName(a("Packet")));
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
Log.warning(Player.class.getSimpleName() + "兼容性工具初始化失败 可能造成部分功能不可用!");
|
Log.warning(C.class.getSimpleName() + " 兼容性工具初始化失败 可能造成部分功能不可用!");
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,6 +62,19 @@ public class C {
|
|||||||
return "net.minecraft.server." + version + "." + str;
|
return "net.minecraft.server." + version + "." + str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String b(final String str) {
|
||||||
|
return "org.bukkit.craftbukkit." + version + "." + str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得NMS版本号
|
||||||
|
*
|
||||||
|
* @return NMS版本号
|
||||||
|
*/
|
||||||
|
public static String getNMSVersion() {
|
||||||
|
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||||
|
}
|
||||||
|
|
||||||
public static class ActionBar {
|
public static class ActionBar {
|
||||||
/**
|
/**
|
||||||
* 公告发送ActionBar
|
* 公告发送ActionBar
|
||||||
|
Loading…
Reference in New Issue
Block a user