funkemunky

Untitled

Apr 16th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.50 KB | None | 0 0
  1. package cc.funkemunky.anticheat.impl.checks.combat.killaura;
  2.  
  3. import cc.funkemunky.anticheat.api.checks.CancelType;
  4. import cc.funkemunky.anticheat.api.checks.Check;
  5. import cc.funkemunky.anticheat.api.checks.CheckInfo;
  6. import cc.funkemunky.anticheat.api.checks.CheckType;
  7. import cc.funkemunky.anticheat.api.utils.Packets;
  8. import cc.funkemunky.anticheat.api.utils.TickTimer;
  9. import cc.funkemunky.api.tinyprotocol.api.Packet;
  10. import cc.funkemunky.api.tinyprotocol.packet.in.WrappedInUseEntityPacket;
  11. import cc.funkemunky.api.utils.MathUtils;
  12. import org.bukkit.event.Event;
  13.  
  14. @Packets(packets = {
  15.         Packet.Client.USE_ENTITY,
  16.         Packet.Client.FLYING,
  17.         Packet.Client.POSITION,
  18.         Packet.Client.POSITION_LOOK,
  19.         Packet.Client.LOOK,
  20.         Packet.Client.LEGACY_POSITION,
  21.         Packet.Client.LEGACY_POSITION_LOOK,
  22.         Packet.Client.LEGACY_LOOK})
  23. @cc.funkemunky.api.utils.Init
  24. @CheckInfo(name = "Killaura (Type A)", description = "Checks the intervalTime between certain packets and attacks.", type = CheckType.KILLAURA, cancelType = CancelType.COMBAT, maxVL = 150)
  25. public class KillauraA extends Check {
  26.  
  27.     private long lastFlying = 0;
  28.     private int verbose;
  29.     private TickTimer lastLag = new TickTimer(4);
  30.  
  31.     public KillauraA() {
  32.  
  33.     }
  34.  
  35.     @Override
  36.     public void onPacket(Object packet, String packetType, long timeStamp) {
  37.         if (packetType.equals(Packet.Client.USE_ENTITY)) {
  38.             WrappedInUseEntityPacket use = new WrappedInUseEntityPacket(packet, getData().getPlayer());
  39.  
  40.             if (!use.getAction().equals(WrappedInUseEntityPacket.EnumEntityUseAction.ATTACK)) return;
  41.  
  42.             /*Checks the intervalTime difference between a flying packet and a use packet. If legit, it should normally be around 50ms.
  43.             KillauraA modules tend to be made using a motion event, and client developers usually forget to make sure that the motion
  44.             and the attack packets are being sent in separate ticks */
  45.             long elapsed = MathUtils.elapsed(lastFlying);
  46.             if (elapsed < 20) {
  47.                 if (lastLag.hasPassed() && verbose++ > 12) {
  48.                     flag("t: post; " + elapsed + "<-10", true, true);
  49.                 }
  50.             } else {
  51.                 verbose = 0;
  52.             }
  53.  
  54.         } else {
  55.             if (MathUtils.getDelta(timeStamp, lastFlying) < 5) lastLag.reset();
  56.             lastFlying = timeStamp;
  57.         }
  58.     }
  59.  
  60.     @Override
  61.     public void onBukkitEvent(Event event) {
  62.  
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment