mirror of
https://github.com/asofold/CompatNoCheatPlus.git
synced 2025-02-21 02:12:24 +01:00
Attempt to retrieve the client's protocol ID through ProtocolSupport/ViaVersion.
This commit is contained in:
parent
d12cf777f4
commit
eaf1b2280e
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/target/
|
||||
.classpath
|
||||
.DS_Store
|
||||
.project
|
||||
.settings/org.eclipse.core.resources.prefs
|
||||
*.prefs
|
BIN
libs/ProtocolSupport.jar
Normal file
BIN
libs/ProtocolSupport.jar
Normal file
Binary file not shown.
35
pom.xml
35
pom.xml
@ -25,14 +25,18 @@
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>repo-public</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>viaversion-repo</id>
|
||||
<url>https://repo.viaversion.com</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>repo-public</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<!-- Dependencies -->
|
||||
@ -91,11 +95,23 @@
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.18-R0.1-20220408.230221-26</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.viaversion</groupId>
|
||||
<artifactId>viaversion-api</artifactId>
|
||||
<version>LATEST</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-event</artifactId>
|
||||
<version>1.18-R0.1-20220408.230147-26</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 -->
|
||||
@ -168,8 +184,15 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
-->
|
||||
|
||||
<!-- Properties -->
|
||||
<properties>
|
||||
|
@ -0,0 +1,47 @@
|
||||
package me.asofold.bpl.cncp.ClientVersion;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
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.players.DataManager;
|
||||
import fr.neatmonster.nocheatplus.players.IPlayerData;
|
||||
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");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
Bukkit.getScheduler()
|
||||
.runTaskLater(CompatNoCheatPlus.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final IPlayerData pData = DataManager.getPlayerData(player);
|
||||
if (pData != null) {
|
||||
if (ViaVersion != null && ViaVersion.isEnabled()) {
|
||||
// Give precedence to ViaVersion
|
||||
pData.setClientVersionID(Via.getAPI().getPlayerVersion(player));
|
||||
}
|
||||
else if (ProtocolSupport != null && ProtocolSupport.isEnabled()) {
|
||||
// Fallback to PS
|
||||
pData.setClientVersionID(ProtocolSupportAPI.getProtocolVersion(player).getId());
|
||||
}
|
||||
// (Client version stays unknown (-1))
|
||||
}
|
||||
}
|
||||
}, 20); // Wait 20 ticks before setting client data
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ import fr.neatmonster.nocheatplus.components.registry.feature.IDisableListener;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPHook;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPHookManager;
|
||||
import me.asofold.bpl.cncp.bedrock.BedrockPlayerListener;
|
||||
import me.asofold.bpl.cncp.ClientVersion.ClientVersionListener;
|
||||
import me.asofold.bpl.cncp.config.Settings;
|
||||
import me.asofold.bpl.cncp.config.compatlayer.CompatConfig;
|
||||
import me.asofold.bpl.cncp.config.compatlayer.NewConfig;
|
||||
@ -171,25 +172,25 @@ public class CompatNoCheatPlus extends JavaPlugin implements Listener {
|
||||
builtinHooks.clear();
|
||||
// Might-fail hooks:
|
||||
// Set speed
|
||||
try{
|
||||
try {
|
||||
builtinHooks.add(new me.asofold.bpl.cncp.hooks.generic.HookSetSpeed());
|
||||
}
|
||||
catch (Throwable t){}
|
||||
catch (Throwable t) {}
|
||||
// Citizens 2
|
||||
try{
|
||||
try {
|
||||
builtinHooks.add(new me.asofold.bpl.cncp.hooks.citizens2.HookCitizens2());
|
||||
}
|
||||
catch (Throwable t){}
|
||||
catch (Throwable t) {}
|
||||
// mcMMO
|
||||
try{
|
||||
try {
|
||||
builtinHooks.add(new me.asofold.bpl.cncp.hooks.mcmmo.HookmcMMO());
|
||||
}
|
||||
catch (Throwable t){}
|
||||
catch (Throwable t) {}
|
||||
// GravityTubes
|
||||
try {
|
||||
builtinHooks.add(new me.asofold.bpl.cncp.hooks.GravityTubes.HookGravityTubes());
|
||||
}
|
||||
catch(Throwable t){}
|
||||
catch (Throwable t) {}
|
||||
// CMI
|
||||
try {
|
||||
builtinHooks.add(new me.asofold.bpl.cncp.hooks.CMI.HookCMI());
|
||||
@ -247,6 +248,7 @@ public class CompatNoCheatPlus extends JavaPlugin implements Listener {
|
||||
final PluginManager pm = getServer().getPluginManager();
|
||||
pm.registerEvents(this, this);
|
||||
pm.registerEvents(new BedrockPlayerListener(), this);
|
||||
pm.registerEvents(new ClientVersionListener(), this);
|
||||
getServer().getMessenger().registerIncomingPluginChannel(this, "cncp:geyser", new BedrockPlayerListener());
|
||||
try {
|
||||
bungee = getServer().spigot().getConfig().getBoolean("settings.bungeecord");
|
||||
|
Loading…
Reference in New Issue
Block a user