Skip to content

Commit

Permalink
Major cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Coccocoahelper authored May 17, 2024
1 parent 1abe4d0 commit 2c6a1e0
Show file tree
Hide file tree
Showing 136 changed files with 887 additions and 889 deletions.
2 changes: 1 addition & 1 deletion API/src/main/java/dev/brighten/api/KauriAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void unregisterEvents(Plugin plugin) {

public void registerEvent(Plugin plugin, KauriEvent event) {
registeredEvents.compute(plugin.getName(), (key, list) -> {
if(list == null) {
if (list == null) {
list = new ArrayList<>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public AtomicBoolean addExemption(UUID uuid, long timeLater, TimeUnit unitLater,

@Deprecated
public boolean isExempt(UUID uuid, KauriCheck... checks) {
if(!exemptions.containsKey(uuid)) return false;
if (!exemptions.containsKey(uuid)) return false;

return isExempt(uuid, Arrays.stream(checks).map(KauriCheck::getCheckType).toArray(CheckType[]::new));
}
Expand All @@ -72,7 +72,7 @@ public Exemption getExemption(UUID uuid) {
}

public Optional<Exemption> getPlayerExemption(UUID uuid) {
if(!exemptions.containsKey(uuid)) return Optional.empty();
if (!exemptions.containsKey(uuid)) return Optional.empty();

return Optional.of(exemptions.get(uuid));
}
Expand Down
4 changes: 2 additions & 2 deletions API/src/main/java/dev/brighten/api/wrappers/Wrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public <T> T fetchField(String fieldName) {
assert object != null;

return cachedFields.compute(wrappedClass.getParent().getName() + ";;;" + fieldName, (key, field) -> {
if(field != null) return field;
if (field != null) return field;

return wrappedClass.getFieldByName(fieldName);
}).get(object);
Expand All @@ -42,7 +42,7 @@ public <T> T fetchMethod(String methodName, Object... parameters) {
return cachedMethods.compute(wrappedClass.getParent().getName() + ";;;" + methodName + ";;;"
+ Arrays.stream(parameters).map(ob -> ob.getClass().getSimpleName())
.collect(Collectors.joining(",")), (key, field) -> {
if(field != null) return field;
if (field != null) return field;

return wrappedClass.getMethod(methodName);
}).invoke(object, parameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
public class AimA extends Check {
@Packet
public void onFlying(WrappedInFlyingPacket packet) {
if(packet.isLook()) {
if (packet.isLook()) {
float yawAccel = MathUtils.getDelta(data.playerInfo.lDeltaYaw, data.playerInfo.deltaYaw);
float pitchAccel = MathUtils.getDelta(data.playerInfo.lDeltaPitch, data.playerInfo.deltaPitch);

if(yawAccel < 1E-3 && pitchAccel < 1E-4
if (yawAccel < 1E-3 && pitchAccel < 1E-4
&& (data.playerInfo.deltaPitch > 0 || yawAccel > 0)
&& (data.moveProcessor.deltaX > 2 || data.moveProcessor.deltaY > 2)) {
if(vl++ > 20) {
if (vl++ > 20) {
flag("yawAccel=%s pitchAccel=%s", yawAccel, pitchAccel);
}
} else vl-= vl > 0 ? 2 : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import cc.funkemunky.api.tinyprotocol.packet.in.WrappedInFlyingPacket;
import cc.funkemunky.api.utils.Color;
import cc.funkemunky.api.utils.MathUtils;
import dev.brighten.anticheat.check.api.Check;
import dev.brighten.anticheat.check.api.CheckInfo;
import dev.brighten.anticheat.check.api.Packet;
Expand All @@ -24,13 +23,12 @@ public class AimB extends Check {
public void process(WrappedInFlyingPacket packet) {
if (!packet.isLook()) return;

float sensitivity = data.moveProcessor.sensitivityMcp;
final float deltaYaw = Math.abs(data.playerInfo.deltaYaw),
deltaPitch = Math.abs(data.playerInfo.deltaPitch);
final float deltaX = deltaYaw / data.moveProcessor.yawMode,
deltaY = deltaPitch / data.moveProcessor.pitchMode;

if(data.moveProcessor.yawGcdList.size() < 40)
if (data.moveProcessor.yawGcdList.size() < 40)
return;

final double gridX = getGrid(data.moveProcessor.yawGcdList),
Expand All @@ -43,7 +41,7 @@ public void process(WrappedInFlyingPacket packet) {
debug("sensitivity instability: mcp=%.4f, cx=%.4f, cy=%.4f, dx=%.1f, dy=%.1f",
data.moveProcessor.sensitivityMcp, data.moveProcessor.currentSensX,
data.moveProcessor.currentSensY, deltaX, deltaY);
if(buffer > 0) buffer--;
if (buffer > 0) buffer--;
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
public class AimC extends Check {
@Packet
public void onFlying(WrappedInFlyingPacket packet) {
if(packet.isLook() && data.moveProcessor.deltaX > 0) {
if (packet.isLook() && data.moveProcessor.deltaX > 0) {
float deltaYaw = MathUtils.getAngleDelta(data.playerInfo.to.yaw, data.playerInfo.from.yaw);
if(deltaYaw > 320
if (deltaYaw > 320
&& data.playerInfo.lDeltaYaw > 0
&& data.moveProcessor.sensitivityX < 0.65
&& data.playerInfo.lDeltaYaw < 30
&& data.playerInfo.lastTeleportTimer.isPassed(1)
&& !data.playerInfo.doingTeleport) {
vl++;
if(vl > 1) {
if (vl > 1) {
flag("yaw=%.3f", deltaYaw);
}
} else vl-= vl > 0 ? 0.005 : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public class AimD extends Check {

@Packet
public void onFlying(WrappedInFlyingPacket packet) {
if(packet.isLook() && Math.abs(data.playerInfo.deltaPitch) >= 0.5f) {
if (packet.isLook() && Math.abs(data.playerInfo.deltaPitch) >= 0.5f) {

float shit1 = data.playerInfo.deltaPitch % 0.1f, shit2 = data.playerInfo.deltaPitch % 0.05f;
if(data.playerInfo.deltaPitch > 0 && Math.abs(data.playerInfo.deltaPitch) < 100
if (data.playerInfo.deltaPitch > 0 && Math.abs(data.playerInfo.deltaPitch) < 100
&& (shit1 == 0 || shit2 == 0 || data.playerInfo.deltaPitch % 1f == 0)) {
if(verbose.add(1) > 10) {
if (verbose.add(1) > 10) {
vl++;
flag("deltaPitch=%s trimmed=%s vb=%s", data.playerInfo.deltaPitch,
data.playerInfo.deltaPitch, verbose.value());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.List;
import java.util.Optional;

@CheckInfo(name = "Aim (G)", description = "Statistical aim analysis",
@CheckInfo(name = "Aim (E)", description = "Statistical aim analysis",
checkType = CheckType.AIM, punishVL = 20, executable = true)
public class AimE extends Check {

Expand All @@ -23,12 +23,12 @@ public class AimE extends Check {

@Packet
public void onUse(WrappedInUseEntityPacket packet) {
if(packet.getAction() != WrappedInUseEntityPacket.EnumEntityUseAction.ATTACK
if (packet.getAction() != WrappedInUseEntityPacket.EnumEntityUseAction.ATTACK
|| data.target == null) return;

Optional<EntityLocation> opLoc = data.entityLocationProcessor.getEntityLocation(data.target);

if(!opLoc.isPresent()) return;
if (!opLoc.isPresent()) return;

final EntityLocation eloc = opLoc.get();

Expand All @@ -41,8 +41,8 @@ public void onUse(WrappedInUseEntityPacket packet) {
targetLocation.toLocation(data.getPlayer().getWorld()));

// Running the TypeG detection itself
if(offset[0] == 0D) {
if(data.playerInfo.deltaYaw > 0.2 && ++abuffer > 5) {
if (offset[0] == 0D) {
if (data.playerInfo.deltaYaw > 0.2 && ++abuffer > 5) {
vl++;
abuffer = 5;
flag("t=a y=%.2f dy=%.3f", offset[1], data.playerInfo.deltaYaw);
Expand All @@ -53,7 +53,7 @@ public void onUse(WrappedInUseEntityPacket packet) {
yawOffsets.add(offset[0]);
pitchOffsets.add(offset[1]);

if(yawOffsets.size() < 8 || pitchOffsets.size() < 8) return;
if (yawOffsets.size() < 8 || pitchOffsets.size() < 8) return;

debug("po=%.1f yo=%.1f", offset[1], offset[0]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import dev.brighten.api.check.CheckType;
import dev.brighten.api.check.DevStage;

@CheckInfo(name = "Aim (H)", description = "checks for large headsnaps.",
@CheckInfo(name = "Aim (F)", description = "checks for large headsnaps.",
devStage = DevStage.BETA, checkType = CheckType.AIM, vlToFlag = 9)
public class AimF extends Check {
private double lastHorizontalDistance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
import dev.brighten.anticheat.check.api.Packet;
import dev.brighten.api.check.CheckType;

@CheckInfo(name = "Aim (I)", description = "Checks for weird pitch values that are near impossible to accomplish",
@CheckInfo(name = "Aim (G)", description = "Checks for weird pitch values that are near impossible to accomplish",
checkType = CheckType.AIM, executable = true,
punishVL = 12)
public class AimG extends Check {

private int buffer;
@Packet
public void onFlying(WrappedInFlyingPacket packet) {
if(!packet.isLook()) return;
if (!packet.isLook()) return;

final double pitch = data.playerInfo.to.pitch, lpitch = data.playerInfo.from.pitch;

if(pitch == lpitch && pitch == 0 && !data.playerInfo.inVehicle
if (pitch == lpitch && pitch == 0 && !data.playerInfo.inVehicle
&& data.playerInfo.lastTeleportTimer.isPassed(1) && data.moveProcessor.deltaX > 12) {
if(++buffer > 3) {
if (++buffer > 3) {
vl++;
flag("deltaX=%s buffer=%s", data.moveProcessor.deltaX, buffer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public class AutoclickerA extends Check {
@Packet
public void onFlying(WrappedInFlyingPacket packet, long timeStamp) {
flyingTicks++;
if(flyingTicks >= 20) {
if(cps > cpsToFlag) {
if(cps > cpsToBan) vl++;
if (flyingTicks >= 20) {
if (cps > cpsToFlag) {
if (cps > cpsToBan) vl++;
flag("cps=%s", cps);
}
debug("cps=%s", cps);
Expand All @@ -36,7 +36,7 @@ public void onFlying(WrappedInFlyingPacket packet, long timeStamp) {

@Packet
public void onArmAnimation(WrappedInArmAnimationPacket packet) {
if(!data.playerInfo.breakingBlock
if (!data.playerInfo.breakingBlock
&& data.playerInfo.lastBrokenBlock.isPassed(5)
&& data.playerInfo.lastBlockDigPacket.isPassed(1)
&& data.playerInfo.lastBlockPlacePacket.isPassed(1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public class AutoclickerB extends Check {

@Packet
public void onBlockPlace(WrappedInBlockPlacePacket packet, int currentTick) {
if(data.playerInfo.breakingBlock || data.getPlayer().getItemInHand().getType().isBlock()) return;
if (data.playerInfo.breakingBlock || data.getPlayer().getItemInHand().getType().isBlock()) return;
int deltaPlace = currentTick - lastPlace;

tickDeltas.add(deltaPlace);
if(tickDeltas.size() > 8) {
if (tickDeltas.size() > 8) {
int max = -10000000, min = Integer.MAX_VALUE;
double average = 0;
int range, total = 0;
Expand All @@ -43,12 +43,12 @@ public void onBlockPlace(WrappedInBlockPlacePacket packet, int currentTick) {
average/= total;
range = max - min;

if(average < 3 && range <= 1) {
if(++buffer > 12) {
if (average < 3 && range <= 1) {
if (++buffer > 12) {
vl++;
flag("range=%s", range);
}
} else if(vl > 0) buffer-= 0.5f;
} else if (vl > 0) buffer-= 0.5f;

debug("range=%s average=%.1f vl=%.1f", range, average, vl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ public class AutoclickerC extends Check {

@Packet
public void onArm(WrappedInArmAnimationPacket packet, long timeStamp) {
if(data.playerInfo.breakingBlock || data.playerInfo.lookingAtBlock) return;
if (data.playerInfo.breakingBlock || data.playerInfo.lookingAtBlock) return;
cps = 1000D / (timeStamp - lastArm);
lastArm = timeStamp;
armTicks++;
}

@Packet
public void onFlying(WrappedInFlyingPacket packet) {
if(blocked) {
if(armTicks > 0) {
if(armTicks == 1 && cps > 3) {
if(cps > 7) verbose.add();
if(verbose.value() > 15) {
if (blocked) {
if (armTicks > 0) {
if (armTicks == 1 && cps > 3) {
if (cps > 7) verbose.add();
if (verbose.value() > 15) {
flag("arm=%s cps=%.3f lagging=%s", armTicks,
cps, data.lagInfo.lagging);
}
Expand All @@ -52,7 +52,7 @@ public void onFlying(WrappedInFlyingPacket packet) {

@Packet
public void onPlace(WrappedInBlockPlacePacket packet) {
if(packet.getItemStack() == null || !packet.getItemStack().getType().name().contains("SWORD")) return;
if (packet.getItemStack() == null || !packet.getItemStack().getType().name().contains("SWORD")) return;
blocked = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class AutoclickerD extends Check {

@Packet
public void onClick(WrappedInArmAnimationPacket packet, long timeStamp) {
if(!data.playerInfo.breakingBlock
if (!data.playerInfo.breakingBlock
&& !data.playerInfo.lookingAtBlock
&& data.playerInfo.lastBrokenBlock.isPassed(5)
&& data.playerInfo.lastBlockDigPacket.isPassed(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class AutoclickerE extends Check {
private float buffer;
@Packet
public void onClick(WrappedInArmAnimationPacket packet) {
if(data.playerInfo.breakingBlock
if (data.playerInfo.breakingBlock
|| data.playerInfo.lookingAtBlock
|| data.clickProcessor.isNotReady()
|| data.playerInfo.lastBrokenBlock.isNotPassed(5)
Expand All @@ -28,38 +28,38 @@ public void onClick(WrappedInArmAnimationPacket packet) {

TagsBuilder tags = new TagsBuilder();

if(data.clickProcessor.getOutliers() == 0
if (data.clickProcessor.getOutliers() == 0
&& data.clickProcessor.getMean() < 2.5) {
tags.addTag("outliers");
buffer++;
}

if(data.clickProcessor.getStd() < 0.5 && data.clickProcessor.getOutliers() <= 1) {
if (data.clickProcessor.getStd() < 0.5 && data.clickProcessor.getOutliers() <= 1) {
buffer+= 0.75;
tags.addTag("deviation");
}

if(data.clickProcessor.getKurtosis() < 0
if (data.clickProcessor.getKurtosis() < 0
&& (data.clickProcessor.getOutliers() <= 1 || skewness < 0.1)
&& data.clickProcessor.getMean() < 2.5) {
buffer+= 0.45f;
tags.addTag("kurtosis");
}

if(skewness < 0.15 && data.clickProcessor.getMean() < 2.5) {
if (skewness < 0.15 && data.clickProcessor.getMean() < 2.5) {
buffer+= 0.45f;
tags.addTag("skew");
}

if(tags.getSize() > 0) {
if(buffer > 30) {
if (tags.getSize() > 0) {
if (buffer > 30) {
vl++;
buffer = 28;
flag("tags=%s k=%.2f o=%s sk=%.2f a=%.1f", tags.build(), data.clickProcessor.getKurtosis(),
data.clickProcessor.getOutliers(), data.clickProcessor.getSkewness(),
data.clickProcessor.getMean());
}
} else if(buffer > 0) buffer-= 0.75f;
} else if (buffer > 0) buffer-= 0.75f;

debug("tags=%s mean=%.2f skew=%.2f kurt=%.2f std=%.3f outliers=%s buffer=%.1f",
(tags.getSize() > 0 ? Color.Green : "") +tags.build() + Color.Gray, data.clickProcessor.getMean(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class AutoclickerF extends Check {
public void onFlying(WrappedInTransactionPacket packet) {
val optional = Kauri.INSTANCE.keepaliveProcessor.getKeepById(packet.getAction());

if(optional.isPresent()) {
if (optional.isPresent()) {
flying++;
}
}
Expand All @@ -43,7 +43,7 @@ public void onUse(WrappedInUseEntityPacket packet, int current) {

@Packet
public void onArm(WrappedInArmAnimationPacket packet, int current) {
if(data.playerInfo.breakingBlock
if (data.playerInfo.breakingBlock
|| data.playerInfo.lookingAtBlock
|| data.playerInfo.lastBrokenBlock.isNotPassed(5)
|| data.playerInfo.lastBlockDigPacket.isNotPassed(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class AutoclickerG extends Check {
float buffer;
@Packet
public void check(WrappedInArmAnimationPacket packet) {
if(data.playerInfo.breakingBlock
if (data.playerInfo.breakingBlock
|| data.playerInfo.lookingAtBlock
|| data.clickProcessor.isNotReady()
|| data.playerInfo.lastBrokenBlock.isNotPassed(5)
Expand All @@ -26,8 +26,8 @@ public void check(WrappedInArmAnimationPacket packet) {

int low = data.clickProcessor.getLowOutliers(), high = data.clickProcessor.getHighOutliers();
double cpsAvg = 20L / Math.max(0.0001, data.clickProcessor.getMean()); //I used long for 1000 since long is 64 bit with double.
if((low + high) == 0 && data.clickProcessor.getMean() < 2.52) {
if((buffer < 20 ? ++buffer : buffer) > 6) {
if ((low + high) == 0 && data.clickProcessor.getMean() < 2.52) {
if ((buffer < 20 ? ++buffer : buffer) > 6) {
vl++;
flag(20 * 30,
"buffer=%.1f avgCps=%.1f std=%.2f low=%s high=%s", buffer, cpsAvg,
Expand Down
Loading

0 comments on commit 2c6a1e0

Please sign in to comment.