Skip to content

Commit

Permalink
groundspoof check back to packets
Browse files Browse the repository at this point in the history
  • Loading branch information
JustDoom committed Jul 20, 2021
1 parent 2055144 commit 36f9979
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 32 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.justdoom</groupId>
<artifactId>FlappyAnticheat</artifactId>
<version>1.7.2-BETA</version>
<version>1.7.3-BETA</version>
<packaging>jar</packaging>

<name>FlappyAnticheat</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,50 +29,102 @@ public class GroundSpoofA extends Check implements Listener {

private int buffer = 0;

private boolean isLastOnGround;

public GroundSpoofA() {
super("GroundSpoof", "A", false);
}

@EventHandler
public void check(PlayerMoveEvent e) {
private Map<UUID, Boolean> lastInAir = new HashMap<>();
private Map<UUID, Boolean> lastOnGround = new HashMap<>();

@Override
public void onPacketPlayReceive(PacketPlayReceiveEvent e) {
Player player = e.getPlayer();

if (player.getLocation().getY() < 1
|| player.isDead()
|| player.isInsideVehicle()) {
return;
}
if (e.getPacketId() == PacketType.Play.Client.POSITION || e.getPacketId() == PacketType.Play.Client.POSITION_LOOK) {

double groundY = 0.015625;
boolean client = player.isOnGround(), server = e.getTo().getY() % groundY < 0.0001;

if (client && !server && !e.getFrom().getBlock().getType().name().contains("LADDER")
&& !e.getTo().getBlock().getType().name().contains("LADDER")
&& !e.getFrom().getBlock().getType().name().contains("VINE")
&& !e.getTo().getBlock().getType().name().contains("VINE")) {

boolean boat = false;
boolean shulker = false;
boolean pistonHead = false;
// TODO Implement better pistons
for (Entity entity : player.getNearbyEntities(1.5, 2, 1.5)) {
if (entity.getType() == EntityType.BOAT && player.getLocation().getY() > entity.getLocation().getY()) {
boat = true;
break;
WrappedPacketInFlying packet = new WrappedPacketInFlying(e.getNMSPacket());

if(ServerUtil.lowTPS(("checks." + check + "." + checkType).toLowerCase()) || player.getLocation().getY() < 1 || player.isDead()){
return;
}

if (player.isInsideVehicle()){
return;
}

double groundY = 0.015625;
boolean client = packet.isOnGround(), server = packet.getY() % groundY < 0.0001;

if (client && !server && !PlayerUtil.isOnClimbable(player)) {
if (++buffer > 1) {

boolean boat = false;
boolean shulker = false;
boolean pistonHead = false;

AtomicReference<List<Entity>> nearby = new AtomicReference<>();
sync(() -> nearby.set(player.getNearbyEntities(1.5, 10, 1.5)));

for (Entity entity : nearby.get()) {
if (entity.getType() == EntityType.BOAT && player.getLocation().getY() > entity.getLocation().getY()) {
boat = true;
break;
}

if (entity.getType() == EntityType.SHULKER && player.getLocation().getY() > entity.getBoundingBox().getMinY()) {
shulker = true;
break;
}
}

for (Block block : PlayerUtil.getNearbyBlocks(new Location(player.getWorld(), packet.getX(), packet.getY(), packet.getZ()), 2)) {

if (Tag.SHULKER_BOXES.isTagged(block.getType())) {
shulker = true;
break;
}

if (block.getType() == Material.PISTON_HEAD) {
pistonHead = true;
break;
}
}

if (!boat && !shulker && !pistonHead) {
String suspectedHack;
if(packet.getY() % groundY == 0.0){
suspectedHack = "Criticals/Anti Hunger";
} else {
suspectedHack = "NoFall";
}
fail("mod=" + packet.getY() % groundY + " &7Client: &2" + client + " &7Server: &2" + server + " &7Suspected Hack: &2" + suspectedHack, player);
}
}
} else if (buffer > 0) buffer-=0.5;

boolean inAir = true;

if (entity.getType() == EntityType.SHULKER) {
shulker = true;
boolean lastInAir = this.lastInAir.getOrDefault(player.getUniqueId(), false);

for (Block block : PlayerUtil.getNearbyBlocksConfigurable(new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY() -1, player.getLocation().getZ()), 1, 0, 1)) {
if (block.getType() != Material.AIR) {
inAir = false;
break;
}
}

if (!boat && !shulker && !pistonHead && ++buffer > 1) {
Bukkit.getScheduler().runTaskAsynchronously(FlappyAnticheat.getInstance(), () -> fail("mod=" + e.getTo().getY() % groundY + " &7Client: &2" + client + " &7Server: &2" + server, player));
boolean lastOnGround = this.lastOnGround.getOrDefault(player.getUniqueId(), true);

//check if they have packet on ground, are in the air, and were last in the air.
if (packet.isOnGround() && lastOnGround && inAir && lastInAir) {
String suspectedHack = "NoFall";

fail("mod=" + packet.getY() % groundY + " &7Client: &2" + client + " &7Server: &2" + server + " &7Suspected Hack: &2" + suspectedHack, player);

}
} else if (buffer > 0)
buffer -= 0.5;

this.lastOnGround.put(player.getUniqueId(), packet.isOnGround());
this.lastInAir.put(player.getUniqueId(), inAir);
}
}
}
18 changes: 18 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ checks:
punish-commands:
- "kick {player} FlappyAC > Suspicious Activity"
vl: 20
b:
enabled: true
min-tps: 17.0
punishable: true
broadcast-punishment: true
punish-vl: 200
punish-commands:
- "kick {player} FlappyAC > Suspicious Activity"
vl: 20
badpackets:
a:
enabled: true
Expand Down Expand Up @@ -109,6 +118,15 @@ checks:
punish-commands:
- "kick {player} FlappyAC > Suspicious Activity"
vl: 10
b:
enabled: true
min-tps: 17.0
punishable: true
broadcast-punishment: true
punish-vl: 200
punish-commands:
- "kick {player} FlappyAC > Suspicious Activity"
vl: 10
speed:
a:
enabled: true
Expand Down
4 changes: 4 additions & 0 deletions update-log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ Added Fly B
Fixed a groundspoof A bypass
Fixed issue with 1.17.1 servers

1.7.3 BETA
Added Timer B
Added Fly B to config - oops


Todo
- More checks
Expand Down

0 comments on commit 36f9979

Please sign in to comment.