diff --git a/libs/ProtocolSupport.jar b/libs/ProtocolSupport.jar deleted file mode 100644 index 1b779c2..0000000 Binary files a/libs/ProtocolSupport.jar and /dev/null differ diff --git a/pom.xml b/pom.xml index c6c7762..b60cf00 100644 --- a/pom.xml +++ b/pom.xml @@ -106,13 +106,6 @@ bungeecord-event 1.19-R0.1-SNAPSHOT - - protocolsupport - protocolsupport - 1.0 - system - ${basedir}/libs/ProtocolSupport.jar - diff --git a/src/me/asofold/bpl/cncp/ClientVersion/ClientVersionListener.java b/src/me/asofold/bpl/cncp/ClientVersion/ClientVersionListener.java index 3026dc4..3b0ffb1 100644 --- a/src/me/asofold/bpl/cncp/ClientVersion/ClientVersionListener.java +++ b/src/me/asofold/bpl/cncp/ClientVersion/ClientVersionListener.java @@ -1,5 +1,7 @@ package me.asofold.bpl.cncp.ClientVersion; +import java.lang.reflect.Method; + import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -9,17 +11,19 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.Plugin; import com.viaversion.viaversion.api.Via; -import protocolsupport.api.ProtocolSupportAPI; import fr.neatmonster.nocheatplus.compat.Folia; import fr.neatmonster.nocheatplus.players.DataManager; import fr.neatmonster.nocheatplus.players.IPlayerData; +import fr.neatmonster.nocheatplus.utilities.ReflectionUtil; import me.asofold.bpl.cncp.CompatNoCheatPlus; -import me.asofold.bpl.cncp.config.Settings; public class ClientVersionListener implements Listener { private Plugin ViaVersion = Bukkit.getPluginManager().getPlugin("ViaVersion"); 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); @SuppressWarnings("unchecked") @EventHandler(priority = EventPriority.MONITOR) @@ -34,7 +38,10 @@ public class ClientVersionListener implements Listener { } else if (ProtocolSupport != null && ProtocolSupport.isEnabled()) { // Fallback to PS - pData.setClientVersionID(ProtocolSupportAPI.getProtocolVersion(player).getId()); + Object protocolVersion = ReflectionUtil.invokeMethod(getProtocolVersion, null, player); + Method getId = ReflectionUtil.getMethodNoArgs(ProtocolVersionClass, "getId", int.class); + int version = (int) ReflectionUtil.invokeMethodNoArgs(getId, protocolVersion); + pData.setClientVersionID(version); } // (Client version stays unknown (-1)) }