1
0
mirror of https://e.coding.net/circlecloud/YumCore.git synced 2024-11-21 01:38:51 +00:00

fix: 修复兼容工具载入错误

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-08-09 17:33:36 +08:00
parent a567e2eb03
commit 192245c22c

View File

@ -37,24 +37,24 @@ public class C {
private static String version;
private static Field playerConnection;
private static Method sendPacket;
static {
try {
version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
version = getNMSVersion();
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"));
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"));
final Class<?> typeCraftPlayer = Class.forName(a("CraftPlayer"));
final Class<?> typeCraftPlayer = Class.forName(b("entity.CraftPlayer"));
final Class<?> typeNMSPlayer = Class.forName(a("EntityPlayer"));
final Class<?> typePlayerConnection = Class.forName(a("PlayerConnection"));
getHandle = typeCraftPlayer.getMethod("getHandle");
playerConnection = typeNMSPlayer.getField("playerConnection");
sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName(a("Packet")));
} 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;
}
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 {
/**
* 公告发送ActionBar