mirror of
https://github.com/asofold/CompatNoCheatPlus.git
synced 2024-11-12 10:24:13 +01:00
Oops
This commit is contained in:
parent
347423c60b
commit
e29dfcb42a
Binary file not shown.
7
pom.xml
7
pom.xml
@ -106,13 +106,6 @@
|
||||
<artifactId>bungeecord-event</artifactId>
|
||||
<version>1.19-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>protocolsupport</groupId>
|
||||
<artifactId>protocolsupport</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/libs/ProtocolSupport.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- Build Description Profiles -->
|
||||
|
@ -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))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user