mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Added Blink check
This commit is contained in:
1 parent
2d14475a20
commit
ebd46db8a2
10 files changed
+77
-6
No files matched your search
@@ -32,6 +32,7 @@ import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
|
||||
import net.gravitydevelopment.anticheat.check.combat.KillAuraCheck;
|
||||
import net.gravitydevelopment.anticheat.check.movement.BlinkCheck;
|
||||
import net.gravitydevelopment.anticheat.command.CommandHandler;
|
||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||
import net.gravitydevelopment.anticheat.event.BlockListener;
|
||||
@@ -96,6 +97,9 @@ public class AntiCheat extends JavaPlugin {
|
||||
// Enable packetlisteners
|
||||
if (VersionUtil.getVersion().equals("v1_8_R3"))
|
||||
KillAuraCheck.listenPackets();
|
||||
|
||||
BlinkCheck.startTimer();
|
||||
BlinkCheck.listenPackets();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||
import net.gravitydevelopment.anticheat.check.combat.KillAuraCheck;
|
||||
import net.gravitydevelopment.anticheat.check.movement.BlinkCheck;
|
||||
import net.gravitydevelopment.anticheat.check.movement.FlightCheck;
|
||||
import net.gravitydevelopment.anticheat.check.movement.GlideCheck;
|
||||
import net.gravitydevelopment.anticheat.check.movement.WaterWalkCheck;
|
||||
@@ -118,6 +119,7 @@ public class Backend {
|
||||
String pN = player.getName();
|
||||
|
||||
KillAuraCheck.cleanPlayer(player);
|
||||
BlinkCheck.MOVE_COUNT.remove(player.getUniqueId());
|
||||
blocksDropped.remove(pN);
|
||||
blockTime.remove(pN);
|
||||
FlightCheck.movingExempt.remove(pN);
|
||||
|
||||
@@ -58,7 +58,8 @@ public enum CheckType {
|
||||
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
||||
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
||||
AUTOTOOL(Permission.CHECK_AUTOTOOL),
|
||||
KILLAURA(Permission.CHECK_KILLAURA);
|
||||
KILLAURA(Permission.CHECK_KILLAURA),
|
||||
BLINK(Permission.CHECK_BLINK);
|
||||
|
||||
private final Permission permission;
|
||||
private final Map<String, Integer> level = new HashMap<String, Integer>();
|
||||
|
||||
@@ -22,8 +22,7 @@ import net.gravitydevelopment.anticheat.util.CheckerNPCS;
|
||||
import net.gravitydevelopment.anticheat.util.VersionUtil;
|
||||
|
||||
/**
|
||||
* @author Marco
|
||||
* STILL IN HEAVY DEVELOPMENT!
|
||||
* @author Rammelkast
|
||||
*/
|
||||
public class KillAuraCheck {
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package net.gravitydevelopment.anticheat.check.movement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
|
||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
||||
import net.gravitydevelopment.anticheat.event.EventListener;
|
||||
|
||||
/**
|
||||
* @author Rammelkast
|
||||
*/
|
||||
public class BlinkCheck {
|
||||
|
||||
public static final Map<UUID, Integer> MOVE_COUNT = new HashMap<UUID, Integer>();
|
||||
|
||||
public static void startTimer() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (AntiCheat.getManager().getCheckManager().checkInWorld(p) && !AntiCheat.getManager().getCheckManager().isOpExempt(p) && AntiCheat.getManager().getCheckManager().isExempt(p, CheckType.BLINK))
|
||||
if (MOVE_COUNT.containsKey(p.getUniqueId()))
|
||||
if (MOVE_COUNT.get(p.getUniqueId()) > AntiCheat.getManager().getBackend().getMagic().BLINK_PACKET()) {
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed Blink, sent " + MOVE_COUNT.get(p.getUniqueId()) + "packets in one second (max=" + AntiCheat.getManager().getBackend().getMagic().BLINK_PACKET() + ")").getMessage(), p, CheckType.KILLAURA);
|
||||
}
|
||||
MOVE_COUNT.remove(p.getUniqueId());
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(AntiCheat.getPlugin(), 0, 20);
|
||||
}
|
||||
|
||||
public static void listenPackets() {
|
||||
AntiCheat.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheat.getPlugin(), ListenerPriority.NORMAL, new PacketType[] {PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK}) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (!MOVE_COUNT.containsKey(p.getUniqueId()))
|
||||
MOVE_COUNT.put(p.getUniqueId(), 1);
|
||||
else {
|
||||
MOVE_COUNT.put(p.getUniqueId(), MOVE_COUNT.get(p.getUniqueId()) + 1);
|
||||
if (MOVE_COUNT.get(p.getUniqueId()) > AntiCheat.getManager().getBackend().getMagic().BLINK_PACKET())
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -377,4 +377,8 @@ public interface Magic {
|
||||
* Maximum amount of times a player can hit a killaura bot; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int KILLAURA_BOTHITS();
|
||||
/**
|
||||
* Maximum amount of packets a player can send in a second; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int BLINK_PACKET();
|
||||
}
|
||||
@@ -452,7 +452,7 @@ public class PlayerListener extends EventListener {
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
public void onDeath(PlayerDeathEvent e) {
|
||||
KillAuraCheck.cleanPlayer(e.getEntity());
|
||||
KillAuraCheck.cleanPlayer(e.getEntity()); // Remove bots on death to reduce lag
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
|
||||
@@ -61,7 +61,7 @@ public enum Permission {
|
||||
SYSTEM_CALIBRATE,
|
||||
SYSTEM_CHECK,
|
||||
SYSTEM_DEBUG,
|
||||
SYSTEM_RELOAD, CHECK_KILLAURA;
|
||||
SYSTEM_RELOAD, CHECK_KILLAURA, CHECK_BLINK;
|
||||
|
||||
private static final String PERMISSION_ALL = "anticheat.*";
|
||||
private static final String PERMISSION_SPAM = "anticheat.check.spam";
|
||||
|
||||
Reference in new issue
Block a user