mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 06:28:52 +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
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user