From d643690eef77b20263f615eaadab7c1a1df712e4 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Thu, 21 Mar 2013 02:10:30 +0100 Subject: [PATCH] Added a small patch for Libigot. --- .../protocol/utility/MinecraftReflection.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java index 399082d1..d5bf2329 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java @@ -129,6 +129,9 @@ public class MinecraftReflection { Class craftClass = craftServer.getClass(); CRAFTBUKKIT_PACKAGE = getPackage(craftClass.getCanonicalName()); + // Libigot patch + handleLibigot(); + // Next, do the same for CraftEntity.getHandle() in order to get the correct Minecraft package Class craftEntity = getCraftEntityClass(); Method getHandle = craftEntity.getMethod("getHandle"); @@ -165,6 +168,20 @@ public class MinecraftReflection { throw new IllegalStateException("Could not find Bukkit. Is it running?"); } } + + // Patch for Libigot + private static void handleLibigot() { + try { + getCraftEntityClass(); + } catch (RuntimeException e) { + // Try reverting the package to the old format + craftbukkitPackage = null; + CRAFTBUKKIT_PACKAGE = "org.bukkit.craftbukkit"; + + // This might fail too + getCraftEntityClass(); + } + } /** * Used during debugging and testing.