Skip to content

Commit

Permalink
fixes #118
Browse files Browse the repository at this point in the history
  • Loading branch information
C10udburst committed May 22, 2022
1 parent 2d2c282 commit f0b1896
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/main/java/anticope/rejects/modules/AntiBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,23 @@ public AntiBot() {

@EventHandler
public void onTick(TickEvent.Post tickEvent) {
for (Entity entity : mc.world.getEntities())
{
for (Entity entity : mc.world.getEntities()) {
if (entity == null || !(entity instanceof PlayerEntity playerEntity)) continue;
if (removeInvisible.get() && !entity.isInvisible()) continue;

if (isBot(entity)) entity.remove(Entity.RemovalReason.DISCARDED);
if (isBot(playerEntity)) entity.remove(Entity.RemovalReason.DISCARDED);
}
}

private boolean isBot(Entity entity) {
if (entity == null) return false;
if (!(entity instanceof PlayerEntity)) return false;

PlayerEntity player = (PlayerEntity)entity;
private boolean isBot(PlayerEntity entity) {
try {
if (gameMode.get() && EntityUtils.getGameMode(player) == null) return true;
if (gameMode.get() && EntityUtils.getGameMode(entity) == null) return true;
if (api.get() &&
mc.getNetworkHandler().getPlayerListEntry(player.getUuid()) == null) return true;
mc.getNetworkHandler().getPlayerListEntry(entity.getUuid()) == null) return true;
if (profile.get() &&
mc.getNetworkHandler().getPlayerListEntry(player.getUuid()).getProfile() == null) return true;
mc.getNetworkHandler().getPlayerListEntry(entity.getUuid()).getProfile() == null) return true;
if (latency.get() &&
mc.getNetworkHandler().getPlayerListEntry(player.getUuid()).getLatency() > 1) return true;
mc.getNetworkHandler().getPlayerListEntry(entity.getUuid()).getLatency() > 1) return true;
} catch (NullPointerException e) {
if (nullException.get()) return true;
}
Expand Down

0 comments on commit f0b1896

Please sign in to comment.