Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #508 from antihack3r/patch-1
Browse files Browse the repository at this point in the history
antobot code cleanery
  • Loading branch information
Pan4ur authored Sep 16, 2024
2 parents ef44257 + 096be2e commit 7a10695
Showing 1 changed file with 29 additions and 33 deletions.
62 changes: 29 additions & 33 deletions src/main/java/thunder/hack/features/modules/combat/AntiBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,34 @@ public final class AntiBot extends Module {
public Setting<Boolean> onlyAura = new Setting<>("OnlyAura", true);
private final Setting<Mode> mode = new Setting("Mode", Mode.UUIDCheck);
public Setting<Integer> checkticks = new Setting("checkTicks", 3, 0, 10, v -> mode.getValue() == Mode.MotionCheck);
private final Timer timer = new Timer();
private int botsNumber = 0;
private final Timer clearTimer = new Timer();
private int ticks = 0;


public AntiBot() {
super("AntiBot", Category.COMBAT);
}

@EventHandler
public void onSync(EventSync e) {
if (!onlyAura.getValue()) mc.world.getPlayers().forEach(this::isABot);
else if (Aura.target instanceof PlayerEntity ent) isABot(ent);
if (!onlyAura.getValue()) mc.world.getPlayers().forEach(this::markAsBot);
else if (Aura.target instanceof PlayerEntity ent) this.markAsBot(ent);

bots.forEach(b -> {
if (remove.getValue())
try {
mc.world.removeEntity(b.getId(), Entity.RemovalReason.KILLED);
} catch (Exception ignored) {
}
});
if (remove.getValue())
bots.forEach(b -> {
try {
mc.world.removeEntity(b.getId(), Entity.RemovalReason.KILLED);
} catch (Exception ignored) {
}
});

if (timer.passedMs(10000)) {
if (clearTimer.passedMs(10000)) {
bots.clear();
botsNumber = 0;
ticks = 0;
timer.reset();
clearTimer.reset();
}
}

private void isABot(PlayerEntity ent) {
private void markAsBot(PlayerEntity ent) {
if (bots.contains(ent))
return;

Expand All @@ -60,38 +57,37 @@ private void isABot(PlayerEntity ent) {
if (!ent.getUuid().equals(UUID.nameUUIDFromBytes(("OfflinePlayer:" + ent.getName().getString()).getBytes(StandardCharsets.UTF_8))) && ent instanceof OtherClientPlayerEntity
&& (FakePlayer.fakePlayer == null || ent.getId() != FakePlayer.fakePlayer.getId())
&& !ent.getName().getString().contains("-")) {
sendMessage(ent.getName().getString() + " is a bot!");
++botsNumber;
bots.add(ent);
this.addBot(ent);
}
}
case MotionCheck -> {
double speed = (ent.getX() - ent.prevX) * (ent.getX() - ent.prevX) + (ent.getZ() - ent.prevZ) * (ent.getZ() - ent.prevZ);
if (speed > 0.5 && !bots.contains(ent)) {
if (ticks >= checkticks.getValue()) {
sendMessage(ent.getName().getString() + " is a bot!");
++botsNumber;
bots.add(ent);
}
double diffX = ent.getX() - ent.prevX;
double diffZ = ent.getZ() - ent.prevZ;

if ((diffX * diffX) + (diffZ * diffZ) > 0.5D) {
if (ticks >= checkticks.getValue())
this.addBot(ent);
ticks++;
}
}
case ZeroPing -> {
if (NameTags.getEntityPing(ent) <= 0) {
sendMessage(ent.getName().getString() + " is a bot!");
++botsNumber;
bots.add(ent);
}
if (NameTags.getEntityPing(ent) <= 0)
this.addBot(ent);
}
}
}

private void addBot(PlayerEntity entity) {
this.sendMessage(entity.getName().getString() + " is a bot!");
bots.add(entity);
}

@Override
public String getDisplayInfo() {
return String.valueOf(botsNumber);
return String.valueOf(bots.size());
}

public enum Mode {
UUIDCheck, MotionCheck, ZeroPing
}
}
}

1 comment on commit 7a10695

@lolasaman
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

урооо харощ, теперь я отменяю событие ронни макнатта

Please sign in to comment.