Skip to content

Commit

Permalink
Revert "Revert "Push""
Browse files Browse the repository at this point in the history
This reverts commit b6bacad.
  • Loading branch information
funkemunky committed Sep 18, 2020
1 parent b6bacad commit e799b7d
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public void registerChecks() {
Check.register(new BadPacketsK());
Check.register(new BadPacketsL());
Check.register(new BadPacketsM());
Check.register(new Timer());
//Check.register(new BadPacketsN())
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.brighten.anticheat.check.impl.packets;
package dev.brighten.anticheat.check.impl.packets.badpackets;

import cc.funkemunky.api.tinyprotocol.packet.in.WrappedInFlyingPacket;
import cc.funkemunky.api.tinyprotocol.packet.in.WrappedInTransactionPacket;
Expand All @@ -12,7 +12,7 @@
import dev.brighten.api.check.CheckType;
import lombok.val;

@CheckInfo(name = "Timer", description = "Checks the rate of packets coming in.",
@CheckInfo(name = "Timer (A)", description = "Checks the rate of packets coming in.",
checkType = CheckType.BADPACKETS, vlToFlag = 4, developer = true)
@Cancellable
public class Timer extends Check {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package dev.brighten.anticheat.utils;

public class ExponentialMovingAverage {
private double alpha;
private Double oldValue;
public ExponentialMovingAverage(double alpha) {
this.alpha = alpha;
}

public double average(double value) {
if (oldValue == null) {
oldValue = value;
return value;
}
double newValue = oldValue + alpha * (value - oldValue);
oldValue = newValue;
return newValue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ public class VelocityB extends Check {

@Packet
public void velocity(WrappedOutVelocityPacket packet) {
pvX = packet.getX();
pvY = packet.getY();
pvZ = packet.getZ();
if(packet.getId() == data.getPlayer().getEntityId()) {
pvX = packet.getX();
pvY = packet.getY();
pvZ = packet.getZ();
}
}

@Packet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import dev.brighten.anticheat.check.impl.movement.speed.SpeedC;
import dev.brighten.anticheat.check.impl.movement.velocity.VelocityA;
import dev.brighten.anticheat.check.impl.movement.velocity.VelocityC;
import dev.brighten.anticheat.check.impl.packets.Timer;
import dev.brighten.anticheat.check.impl.packets.TimerB;
import dev.brighten.anticheat.check.impl.packets.exploits.*;

@Init(priority = Priority.LOWEST)
Expand Down Expand Up @@ -57,7 +57,7 @@ public void registerChecks() {
Check.register(new KillauraE());
Check.register(new KillauraF());
Check.register(new OmniSprint());
Check.register(new Timer());
Check.register(new TimerB());
Check.register(new VelocityA());
Check.register(new VelocityC());
Check.register(new HandA());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ public class VelocityC extends Check {

@Packet
public void velocity(WrappedOutVelocityPacket packet) {
pvX = packet.getX();
pvY = packet.getY();
pvZ = packet.getZ();
if(packet.getId() == data.getPlayer().getEntityId()) {
pvX = packet.getX();
pvY = packet.getY();
pvZ = packet.getZ();
}
}

@Packet
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package dev.brighten.anticheat.check.impl.packets;

import cc.funkemunky.api.tinyprotocol.packet.in.WrappedInFlyingPacket;
import cc.funkemunky.api.tinyprotocol.packet.in.WrappedInTransactionPacket;
import cc.funkemunky.api.tinyprotocol.packet.out.WrappedOutPositionPacket;
import cc.funkemunky.api.utils.MathUtils;
import cc.funkemunky.api.utils.math.RollingAverage;
import cc.funkemunky.api.utils.objects.evicting.EvictingList;
import dev.brighten.anticheat.Kauri;
import dev.brighten.anticheat.check.api.Cancellable;
import dev.brighten.anticheat.check.api.Check;
import dev.brighten.anticheat.check.api.CheckInfo;
import dev.brighten.anticheat.check.api.Packet;
import dev.brighten.anticheat.utils.ExponentialMovingAverage;
import dev.brighten.anticheat.utils.MiscUtils;
import dev.brighten.api.check.CheckType;
import lombok.val;

@CheckInfo(name = "Timer (B)", description = "Checks the rate of packets coming in.",
checkType = CheckType.BADPACKETS, vlToFlag = 4, developer = true)
@Cancellable
public class TimerB extends Check {

private int ticks, buffer;
private ExponentialMovingAverage average = new ExponentialMovingAverage(50);
private long lastFlying = System.currentTimeMillis();

@Packet
public void onPacket(WrappedInFlyingPacket packet, long current) {

double avg = average.average(current - lastFlying);

debug("std=%v.5", avg);
lastFlying = current;
}
}

0 comments on commit e799b7d

Please sign in to comment.