mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-04 14:38:47 +00:00
A bit more fastbreak detection, this wont catch everything though.
This commit is contained in:
1 parent
5f9c8a0fd1
commit
1c685488f6
4 files changed
+57
-8
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package net.h31ix.anticheat.checks;
|
||||
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.PlayerTracker;
|
||||
import net.h31ix.anticheat.manage.AnimationManager;
|
||||
import net.h31ix.anticheat.manage.BlockManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
public class FastbreakCheck implements Runnable
|
||||
{
|
||||
private Player player;
|
||||
private AnimationManager am;
|
||||
private BlockBreakEvent event;
|
||||
private PlayerTracker tracker;
|
||||
private Anticheat plugin;
|
||||
|
||||
Thread thread = new Thread(this);
|
||||
|
||||
public FastbreakCheck(Player player, BlockBreakEvent event, Anticheat plugin)
|
||||
{
|
||||
this.player = player;
|
||||
this.am = plugin.am;
|
||||
this.event = event;
|
||||
this.tracker = plugin.getPlayerTracker();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void start()
|
||||
{
|
||||
thread.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if(!am.swungArm(player))
|
||||
{
|
||||
tracker.increaseLevel(player,2);
|
||||
plugin.log(player.getName()+" didn't finish breaking a block!");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.PlayerTracker;
|
||||
import net.h31ix.anticheat.checks.*;
|
||||
import net.h31ix.anticheat.manage.*;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@@ -20,7 +19,7 @@ public class BlockListener implements Listener {
|
||||
private PlayerTracker tracker;
|
||||
private static final EyeCheck e = new EyeCheck();
|
||||
private BlockManager blm;
|
||||
private static final double BLOCK_MAX_DISTANCE = 6.0;
|
||||
private static final double BLOCK_MAX_DISTANCE = 5.0;
|
||||
|
||||
public BlockListener(Anticheat plugin)
|
||||
{
|
||||
@@ -66,7 +65,7 @@ public class BlockListener implements Listener {
|
||||
tracker.decreaseLevel(player);
|
||||
}
|
||||
}
|
||||
if (!player.hasPermission("anticheat.fastbreak") && player.getGameMode() != GameMode.CREATIVE)
|
||||
if (!player.hasPermission("anticheat.fastbreak"))
|
||||
{
|
||||
if(!player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED))
|
||||
{
|
||||
@@ -89,7 +88,6 @@ public class BlockListener implements Listener {
|
||||
&& block.getType() != Material.DIODE_BLOCK_ON
|
||||
&& block.getType() != Material.SAPLING
|
||||
&& block.getType() != Material.TORCH
|
||||
&& block.getType() != Material.TNT
|
||||
&& block.getType() != Material.SNOW)
|
||||
{
|
||||
if (!blm.justBroke(player))
|
||||
@@ -98,7 +96,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.log(player.getName() + " tried to break a block too fast! Block: "+block.getType().name());
|
||||
plugin.log(player.getName() + " tried to break a block too fast!");
|
||||
tracker.increaseLevel(player, 2);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@@ -106,8 +104,12 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
am.reset(player);
|
||||
if(!player.hasPermission("anticheat.fastbreak"))
|
||||
{
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new FastbreakCheck(player,event,plugin), 2L);
|
||||
}
|
||||
}
|
||||
am.reset(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +125,7 @@ public class BlockListener implements Listener {
|
||||
if(block.getType() != Material.LADDER && !e.canSee(player, block) && !player.getWorld().getBlockAt(player.getLocation()).isLiquid())
|
||||
{
|
||||
plugin.log(player.getName()+" tried to place a block that they couldn't see!");
|
||||
//event.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if(!player.hasPermission("anticheat.longreach"))
|
||||
{
|
||||
@@ -148,7 +150,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.log(player.getName() + " tried to place a block too fast! Block: "+block.getType().name());
|
||||
plugin.log(player.getName() + " tried to place a block too fast!");
|
||||
tracker.increaseLevel(player, 2);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public class PlayerListener implements Listener {
|
||||
private FlyManager fm;
|
||||
private BowManager bm;
|
||||
private FoodManager fom;
|
||||
private BlockManager blm;
|
||||
|
||||
public PlayerListener(Anticheat plugin)
|
||||
{
|
||||
@@ -51,6 +52,7 @@ public class PlayerListener implements Listener {
|
||||
this.fm = plugin.fm;
|
||||
this.bm = plugin.bm;
|
||||
this.fom = plugin.fom;
|
||||
this.blm = plugin.blm;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.h31ix.anticheat.manage;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BlockManager
|
||||
|
||||
Reference in new issue
Block a user