mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Aura/knockback hack blocker
This commit is contained in:
1 parent
aa3796438e
commit
891ca4eb4e
4 files changed
+69
-4
No files matched your search
@@ -23,6 +23,7 @@ public class Anticheat extends JavaPlugin {
|
||||
public FoodManager fom = new FoodManager(this);
|
||||
public FlyManager fm = new FlyManager();
|
||||
public BlockManager blm = new BlockManager(this);
|
||||
public SprintManager sp = new SprintManager(this);
|
||||
//End Managers
|
||||
|
||||
private Configuration config;
|
||||
|
||||
@@ -22,6 +22,7 @@ public class EntityListener implements Listener {
|
||||
private PlayerTracker tracker;
|
||||
private HealthManager hm;
|
||||
private FoodManager fom;
|
||||
private SprintManager sp;
|
||||
private static final double ENTITY_MAX_DISTANCE_XZ = 5.0;
|
||||
private static final double ENTITY_MAX_DISTANCE_Y = 4.3;
|
||||
|
||||
@@ -33,6 +34,7 @@ public class EntityListener implements Listener {
|
||||
this.ex = plugin.ex;
|
||||
this.hm = plugin.hm;
|
||||
this.fom = plugin.fom;
|
||||
this.sp = plugin.sp;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -124,7 +126,17 @@ public class EntityListener implements Listener {
|
||||
{
|
||||
if (event instanceof EntityDamageByEntityEvent)
|
||||
{
|
||||
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
||||
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
||||
if(e.getDamager() instanceof Player)
|
||||
{
|
||||
Player player = (Player) e.getDamager();
|
||||
if(sp.justSprinted(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
tracker.increaseLevel(player,2);
|
||||
plugin.log(player.getName()+" tried to sprint and damage too fast!");
|
||||
}
|
||||
}
|
||||
if(event.getEntity() instanceof Player)
|
||||
{
|
||||
Player player = (Player)event.getEntity();
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@@ -38,7 +39,7 @@ public class PlayerListener implements Listener {
|
||||
private FlyManager fm;
|
||||
private BowManager bm;
|
||||
private FoodManager fom;
|
||||
private BlockManager blm;
|
||||
private SprintManager sp;
|
||||
|
||||
public PlayerListener(Anticheat plugin)
|
||||
{
|
||||
@@ -52,7 +53,7 @@ public class PlayerListener implements Listener {
|
||||
this.fm = plugin.fm;
|
||||
this.bm = plugin.bm;
|
||||
this.fom = plugin.fom;
|
||||
this.blm = plugin.blm;
|
||||
this.sp = plugin.sp;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -180,6 +181,15 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerToggleSprint(PlayerToggleSprintEvent event)
|
||||
{
|
||||
if(event.isSprinting())
|
||||
{
|
||||
sp.logSprint(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
@@ -261,7 +271,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
else
|
||||
{
|
||||
if(player.getFoodLevel() <= 6)
|
||||
if(player.getFoodLevel() <= 6 && player.getGameMode() != GameMode.CREATIVE)
|
||||
{
|
||||
player.setSprinting(false);
|
||||
tracker.increaseLevel(player,2);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SprintManager {
|
||||
private Map<Player,Boolean> sprint = new HashMap<Player,Boolean>();
|
||||
private Anticheat plugin;
|
||||
|
||||
public SprintManager(Anticheat plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void logSprint(final Player player)
|
||||
{
|
||||
sprint.put(player, true);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
sprint.put(player, false);
|
||||
}
|
||||
}, 2L);
|
||||
}
|
||||
|
||||
public boolean justSprinted(Player player)
|
||||
{
|
||||
if(sprint.get(player) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return sprint.get(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user