From 0c705ef59da2fcf43409331c6b87af30ac83afbc Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Fri, 27 Nov 2015 17:02:41 -0500 Subject: [PATCH] Restore backwards compatibility with server pings I don't know why people are using 1.8.1, but whatever --- .../protocol/utility/MinecraftReflection.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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 6bab797b..695c9fe6 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java @@ -1652,16 +1652,22 @@ public class MinecraftReflection { return getMinecraftClass("TileEntity"); } + private static Class gsonClass = null; + /** * Retrieve the Gson class used by Minecraft. - * @return The GSON class. + * @return The Gson class. */ public static Class getMinecraftGsonClass() { - try { - return getClass("com.google.gson.Gson"); - } catch (RuntimeException e) { - return getClass("org.bukkit.craftbukkit.libs.com.google.gson.Gson"); + if (gsonClass == null) { + try { + return gsonClass = getClass("org.bukkit.craftbukkit.libs.com.google.gson.Gson"); + } catch (RuntimeException e) { + return gsonClass = getClass("com.google.gson.Gson"); + } } + + return gsonClass; } /**