mirror of
https://github.com/asofold/CompatNoCheatPlus.git
synced 2025-02-21 02:12:24 +01:00
Fix complilation error
Also add folia support and exempt all check on bedrock player Upcoming: support Velocity, Sponge?
This commit is contained in:
parent
eaf1b2280e
commit
347423c60b
BIN
libs/mcMMO-2.1.158.jar
Normal file
BIN
libs/mcMMO-2.1.158.jar
Normal file
Binary file not shown.
@ -3,6 +3,7 @@ main: me.asofold.bpl.cncp.CompatNoCheatPlus
|
||||
version: ${project.version}-${buildDescription}
|
||||
dev-url: http://dev.bukkit.org/server-mods/compatnocheatplus-cncp/
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
|
||||
loadbefore:
|
||||
- NoCheatPlus
|
||||
|
22
pom.xml
22
pom.xml
@ -34,8 +34,8 @@
|
||||
<url>https://repo.viaversion.com</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>repo-public</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
<id>bungeecord-repo</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
@ -51,7 +51,8 @@
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.1.158</version>
|
||||
<scope>provided</scope>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/libs/mcMMO-2.1.158.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.citizensnpcs</groupId>
|
||||
@ -76,7 +77,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.updated-nocheatplus.nocheatplus</groupId>
|
||||
<artifactId>nocheatplus</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
<version>-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
@ -93,7 +94,7 @@
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.18-R0.1-20220408.230221-26</version>
|
||||
<version>1.19-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.viaversion</groupId>
|
||||
@ -103,7 +104,7 @@
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-event</artifactId>
|
||||
<version>1.18-R0.1-20220408.230147-26</version>
|
||||
<version>1.19-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>protocolsupport</groupId>
|
||||
@ -184,15 +185,6 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<!--
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
-->
|
||||
|
||||
<!-- Properties -->
|
||||
<properties>
|
||||
|
@ -10,7 +10,7 @@ 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 me.asofold.bpl.cncp.CompatNoCheatPlus;
|
||||
@ -25,23 +25,19 @@ public class ClientVersionListener implements Listener {
|
||||
@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))
|
||||
}
|
||||
Folia.runSyncDelayedTask(CompatNoCheatPlus.getInstance(), (arg) -> {
|
||||
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());
|
||||
}
|
||||
}, 20); // Wait 20 ticks before setting client data
|
||||
// (Client version stays unknown (-1))
|
||||
}
|
||||
}, 20); // Wait 20 ticks before setting client data
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import fr.neatmonster.nocheatplus.NCPAPIProvider;
|
||||
import fr.neatmonster.nocheatplus.compat.Folia;
|
||||
import fr.neatmonster.nocheatplus.components.registry.feature.IDisableListener;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPHook;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPHookManager;
|
||||
@ -272,7 +273,7 @@ public class CompatNoCheatPlus extends JavaPlugin implements Listener {
|
||||
}
|
||||
|
||||
// Start ticktask 2
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new TickTask2(), 1, 1);
|
||||
Folia.runSyncRepatingTask(this, (arg) -> new TickTask2().run(), 1, 1);
|
||||
|
||||
// Check for the NoCheatPlus plugin.
|
||||
Plugin plugin = pm.getPlugin("NoCheatPlus");
|
||||
|
@ -13,79 +13,80 @@ import me.asofold.bpl.cncp.config.compatlayer.ConfigUtil;
|
||||
import me.asofold.bpl.cncp.config.compatlayer.NewConfig;
|
||||
|
||||
public class Settings {
|
||||
public static final int configVersion = 2;
|
||||
|
||||
public Set<String> forceEnableLater = new LinkedHashSet<String>();
|
||||
public Set<String> loadPlugins = new LinkedHashSet<String>();
|
||||
public Set<CheckType> extemptChecks = new LinkedHashSet<CheckType>();
|
||||
|
||||
public static Set<String> preventAddHooks = new HashSet<String>();
|
||||
|
||||
public static CompatConfig getDefaultConfig(){
|
||||
CompatConfig cfg = new NewConfig(null);
|
||||
cfg.set("plugins.force-enable-later", new LinkedList<String>()); // ConfigUtil.asList(new String[]{ "NoCheatPlus" }));
|
||||
cfg.set("plugins.ensure-enable", new LinkedList<String>()); // ConfigUtil.asList(new String[]{ "WorldGuard" }));
|
||||
cfg.set("plugins.bedrock-extempt-checks", ConfigUtil.asList(new String[]{
|
||||
"BLOCKINTERACT_VISIBLE",
|
||||
"BLOCKINTERACT_DIRECTION",
|
||||
"BLOCKINTERACT_REACH",
|
||||
"BLOCKBREAK_DIRECTION",
|
||||
"BLOCKBREAK_NOSWING",
|
||||
"BLOCKBREAK_REACH",
|
||||
"BLOCKPLACE_NOSWING",
|
||||
"BLOCKPLACE_DIRECTION",
|
||||
"BLOCKPLACE_REACH",
|
||||
"BLOCKPLACE_SCAFFOLD",
|
||||
"FIGHT_DIRECTION",
|
||||
}));
|
||||
cfg.set("hooks.prevent-add", new LinkedList<String>());
|
||||
cfg.set("configversion", configVersion);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
public static boolean addDefaults(CompatConfig cfg){
|
||||
boolean changed = false;
|
||||
if (cfg.getInt("configversion", 0) == 0){
|
||||
cfg.remove("plugins");
|
||||
cfg.set("configversion", configVersion);
|
||||
changed = true;
|
||||
}
|
||||
if (cfg.getInt("configversion", 0) <= 1){
|
||||
if (cfg.getDouble("hooks.set-speed.fly-speed", 0.1) != 0.1){
|
||||
changed = true;
|
||||
cfg.set("hooks.set-speed.fly-speed", 0.1);
|
||||
Bukkit.getLogger().warning("[cncp] Reset fly-speed for the set-speed hook to 0.1 (default) as a safety measure.");
|
||||
}
|
||||
if (cfg.getDouble("hooks.set-speed.walk-speed", 0.2) != 0.2){
|
||||
changed = true;
|
||||
cfg.set("hooks.set-speed.walk-speed", 0.2);
|
||||
Bukkit.getLogger().warning("[cncp] Reset walk-speed for the set-speed hook to 0.2 (default) as a safety measure.");
|
||||
}
|
||||
}
|
||||
if (ConfigUtil.forceDefaults(getDefaultConfig(), cfg)) changed = true;
|
||||
if (cfg.getInt("configversion", 0) != configVersion){
|
||||
cfg.set("configversion", configVersion);
|
||||
changed = true;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
public boolean fromConfig(CompatConfig cfg){
|
||||
// Settings ref = new Settings();
|
||||
|
||||
// plugins to force enabling after this plugin.
|
||||
ConfigUtil.readStringSetFromList(cfg, "plugins.force-enable-later", forceEnableLater, true, true, false);
|
||||
ConfigUtil.readStringSetFromList(cfg, "plugins.ensure-enable", loadPlugins, true, true, false);
|
||||
public static final int configVersion = 2;
|
||||
|
||||
public Set<String> forceEnableLater = new LinkedHashSet<String>();
|
||||
public Set<String> loadPlugins = new LinkedHashSet<String>();
|
||||
public Set<CheckType> extemptChecks = new LinkedHashSet<CheckType>();
|
||||
|
||||
public static Set<String> preventAddHooks = new HashSet<String>();
|
||||
|
||||
public static CompatConfig getDefaultConfig(){
|
||||
CompatConfig cfg = new NewConfig(null);
|
||||
cfg.set("plugins.force-enable-later", new LinkedList<String>()); // ConfigUtil.asList(new String[]{ "NoCheatPlus" }));
|
||||
cfg.set("plugins.ensure-enable", new LinkedList<String>()); // ConfigUtil.asList(new String[]{ "WorldGuard" }));
|
||||
cfg.set("plugins.bedrock-extempt-checks", ConfigUtil.asList(new String[]{
|
||||
"ALL",
|
||||
"BLOCKINTERACT_VISIBLE",
|
||||
"BLOCKINTERACT_DIRECTION",
|
||||
"BLOCKINTERACT_REACH",
|
||||
"BLOCKBREAK_DIRECTION",
|
||||
"BLOCKBREAK_NOSWING",
|
||||
"BLOCKBREAK_REACH",
|
||||
"BLOCKPLACE_NOSWING",
|
||||
"BLOCKPLACE_DIRECTION",
|
||||
"BLOCKPLACE_REACH",
|
||||
"BLOCKPLACE_SCAFFOLD",
|
||||
"FIGHT_DIRECTION",
|
||||
}));
|
||||
cfg.set("hooks.prevent-add", new LinkedList<String>());
|
||||
cfg.set("configversion", configVersion);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
public static boolean addDefaults(CompatConfig cfg){
|
||||
boolean changed = false;
|
||||
if (cfg.getInt("configversion", 0) == 0){
|
||||
cfg.remove("plugins");
|
||||
cfg.set("configversion", configVersion);
|
||||
changed = true;
|
||||
}
|
||||
if (cfg.getInt("configversion", 0) <= 1){
|
||||
if (cfg.getDouble("hooks.set-speed.fly-speed", 0.1) != 0.1){
|
||||
changed = true;
|
||||
cfg.set("hooks.set-speed.fly-speed", 0.1);
|
||||
Bukkit.getLogger().warning("[cncp] Reset fly-speed for the set-speed hook to 0.1 (default) as a safety measure.");
|
||||
}
|
||||
if (cfg.getDouble("hooks.set-speed.walk-speed", 0.2) != 0.2){
|
||||
changed = true;
|
||||
cfg.set("hooks.set-speed.walk-speed", 0.2);
|
||||
Bukkit.getLogger().warning("[cncp] Reset walk-speed for the set-speed hook to 0.2 (default) as a safety measure.");
|
||||
}
|
||||
}
|
||||
if (ConfigUtil.forceDefaults(getDefaultConfig(), cfg)) changed = true;
|
||||
if (cfg.getInt("configversion", 0) != configVersion){
|
||||
cfg.set("configversion", configVersion);
|
||||
changed = true;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
public boolean fromConfig(CompatConfig cfg){
|
||||
// Settings ref = new Settings();
|
||||
|
||||
// plugins to force enabling after this plugin.
|
||||
ConfigUtil.readStringSetFromList(cfg, "plugins.force-enable-later", forceEnableLater, true, true, false);
|
||||
ConfigUtil.readStringSetFromList(cfg, "plugins.ensure-enable", loadPlugins, true, true, false);
|
||||
|
||||
ConfigUtil.readCheckTypeSetFromList(cfg, "plugins.bedrock-extempt-checks", extemptChecks, true, true, true);
|
||||
ConfigUtil.readCheckTypeSetFromList(cfg, "plugins.bedrock-extempt-checks", extemptChecks, true, true, true);
|
||||
|
||||
// General
|
||||
ConfigUtil.readStringSetFromList(cfg, "hooks.prevent-add", preventAddHooks, true, true, false);
|
||||
return true;
|
||||
}
|
||||
// General
|
||||
ConfigUtil.readStringSetFromList(cfg, "hooks.prevent-add", preventAddHooks, true, true, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
forceEnableLater.clear();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
forceEnableLater.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.checks.access.IViolationInfo;
|
||||
import fr.neatmonster.nocheatplus.compat.Bridge1_9;
|
||||
import fr.neatmonster.nocheatplus.compat.Folia;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPHook;
|
||||
import fr.neatmonster.nocheatplus.players.DataManager;
|
||||
import fr.neatmonster.nocheatplus.utilities.map.BlockProperties;
|
||||
@ -160,14 +162,14 @@ public class HookFacadeImpl implements HookFacade, NCPHook {
|
||||
public final void blockDamageLowest(final Player player) {
|
||||
// System.out.println("block damage lowest");
|
||||
// setPlayer(player, cancelChecksBlockDamage);
|
||||
if (getToolProps(player.getItemInHand()).toolType == ToolType.AXE) addExemption(player, exemptBreakMany);
|
||||
if (getToolProps(Bridge1_9.getItemInMainHand(player)).toolType == ToolType.AXE) addExemption(player, exemptBreakMany);
|
||||
else addExemption(player, exemptBreakNormal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean blockBreakLowest(final Player player) {
|
||||
// System.out.println("block break lowest");
|
||||
final boolean isAxe = getToolProps(player.getItemInHand()).toolType == ToolType.AXE;
|
||||
final boolean isAxe = getToolProps(Bridge1_9.getItemInMainHand(player)).toolType == ToolType.AXE;
|
||||
if (breakCancel > 0){
|
||||
breakCancel ++;
|
||||
return true;
|
||||
@ -200,12 +202,7 @@ public class HookFacadeImpl implements HookFacade, NCPHook {
|
||||
}
|
||||
else if (!isAxe){
|
||||
setPlayer(player, cancelChecksBlockBreak);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CompatNoCheatPlus.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DataManager.removeData(player.getName(), CheckType.BLOCKBREAK_FASTBREAK);
|
||||
}
|
||||
});
|
||||
Folia.runSyncTask(CompatNoCheatPlus.getInstance(), (arg) -> DataManager.removeData(player.getName(), CheckType.BLOCKBREAK_FASTBREAK));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user