From 2a6c9ddd4f2e2cb2339f60ba9b05fbf93450e58a Mon Sep 17 00:00:00 2001 From: Xaw3ep Date: Tue, 25 Apr 2023 00:06:34 +0700 Subject: [PATCH] Fix null pointer --- .../asofold/bpl/cncp/ClientVersion/ClientVersionListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/me/asofold/bpl/cncp/ClientVersion/ClientVersionListener.java b/src/me/asofold/bpl/cncp/ClientVersion/ClientVersionListener.java index 3b0ffb1..47984fc 100644 --- a/src/me/asofold/bpl/cncp/ClientVersion/ClientVersionListener.java +++ b/src/me/asofold/bpl/cncp/ClientVersion/ClientVersionListener.java @@ -23,7 +23,7 @@ public class ClientVersionListener implements Listener { private Plugin ProtocolSupport = Bukkit.getPluginManager().getPlugin("ProtocolSupport"); private final Class ProtocolSupportAPIClass = ReflectionUtil.getClass("protocolsupport.api.ProtocolSupportAPI"); private final Class ProtocolVersionClass = ReflectionUtil.getClass("protocolsupport.api.ProtocolVersion"); - private final Method getProtocolVersion = ReflectionUtil.getMethod(ProtocolSupportAPIClass, "getProtocolVersion", Player.class); + private final Method getProtocolVersion = ProtocolSupportAPIClass == null ? null : ReflectionUtil.getMethod(ProtocolSupportAPIClass, "getProtocolVersion", Player.class); @SuppressWarnings("unchecked") @EventHandler(priority = EventPriority.MONITOR) @@ -36,7 +36,7 @@ public class ClientVersionListener implements Listener { // Give precedence to ViaVersion pData.setClientVersionID(Via.getAPI().getPlayerVersion(player)); } - else if (ProtocolSupport != null && ProtocolSupport.isEnabled()) { + else if (ProtocolSupport != null && getProtocolVersion != null && ProtocolSupport.isEnabled()) { // Fallback to PS Object protocolVersion = ReflectionUtil.invokeMethod(getProtocolVersion, null, player); Method getId = ReflectionUtil.getMethodNoArgs(ProtocolVersionClass, "getId", int.class);