-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
timerB (i think works) and remove stuff in groundspoof
- Loading branch information
Showing
3 changed files
with
80 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 38 additions & 85 deletions
123
src/main/java/com/justdoom/flappyanticheat/checks/movement/groundspoof/GroundSpoofA.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,125 +1,78 @@ | ||
package com.justdoom.flappyanticheat.checks.movement.groundspoof; | ||
|
||
import com.justdoom.flappyanticheat.FlappyAnticheat; | ||
import com.justdoom.flappyanticheat.checks.Check; | ||
import com.justdoom.flappyanticheat.utils.PlayerUtil; | ||
import com.justdoom.flappyanticheat.utils.ServerUtil; | ||
import io.github.retrooper.packetevents.event.impl.PacketPlayReceiveEvent; | ||
import io.github.retrooper.packetevents.packettype.PacketType; | ||
import io.github.retrooper.packetevents.packetwrappers.play.in.flying.WrappedPacketInFlying; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.Material; | ||
import org.bukkit.Tag; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerMoveEvent; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
public class GroundSpoofA extends Check { | ||
public class GroundSpoofA extends Check implements Listener { | ||
|
||
private int buffer = 0; | ||
|
||
private Map<UUID, Boolean> lastInAir = new HashMap<>(); | ||
private Map<UUID, Boolean> lastOnGround = new HashMap<>(); | ||
|
||
public GroundSpoofA(){ | ||
private boolean isLastOnGround; | ||
|
||
public GroundSpoofA() { | ||
super("GroundSpoof", "A", false); | ||
} | ||
|
||
@Override | ||
public void onPacketPlayReceive(PacketPlayReceiveEvent e) { | ||
@EventHandler | ||
public void check(PlayerMoveEvent e) { | ||
Player player = e.getPlayer(); | ||
|
||
if (e.getPacketId() == PacketType.Play.Client.POSITION || e.getPacketId() == PacketType.Play.Client.POSITION_LOOK) { | ||
|
||
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 (player.getLocation().getY() < 1 | ||
|| player.isDead() | ||
|| player.isInsideVehicle()) { | ||
return; | ||
} | ||
|
||
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); | ||
} | ||
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; | ||
} | ||
} else if (buffer > 0) buffer-=0.5; | ||
|
||
boolean inAir = 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; | ||
if (entity.getType() == EntityType.SHULKER) { | ||
shulker = true; | ||
break; | ||
} | ||
} | ||
|
||
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); | ||
|
||
if (!boat && !shulker && !pistonHead && ++buffer > 1) { | ||
Bukkit.getScheduler().runTaskAsynchronously(FlappyAnticheat.getInstance(), () -> fail("mod=" + e.getTo().getY() % groundY + " &7Client: &2" + client + " &7Server: &2" + server, player)); | ||
} | ||
|
||
this.lastOnGround.put(player.getUniqueId(), packet.isOnGround()); | ||
this.lastInAir.put(player.getUniqueId(), inAir); | ||
} | ||
} else if (buffer > 0) | ||
buffer -= 0.5; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/justdoom/flappyanticheat/checks/player/timer/TimerB.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.justdoom.flappyanticheat.checks.player.timer; | ||
|
||
import com.justdoom.flappyanticheat.checks.Check; | ||
import io.github.retrooper.packetevents.event.impl.PacketPlayReceiveEvent; | ||
import io.github.retrooper.packetevents.event.impl.PacketPlaySendEvent; | ||
import io.github.retrooper.packetevents.packettype.PacketType; | ||
|
||
public class TimerB extends Check { | ||
|
||
private long lastFlyingTime = 0L; | ||
private long balance = 0L; | ||
|
||
public TimerB() { | ||
super("Timer", "B", true); | ||
} | ||
|
||
@Override | ||
public void onPacketPlayReceive(PacketPlayReceiveEvent event) { | ||
if (event.getPacketId() == PacketType.Play.Client.POSITION) { | ||
if (lastFlyingTime != 0L) { | ||
final long now = System.currentTimeMillis(); | ||
balance += 50L; | ||
balance -= now - lastFlyingTime; | ||
if (balance > 0) { | ||
fail("balance=" + balance, event.getPlayer()); | ||
balance = -50; | ||
} | ||
} | ||
lastFlyingTime = System.currentTimeMillis(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onPacketPlaySend(PacketPlaySendEvent event){ | ||
if (event.getPacketId() == PacketType.Play.Server.POSITION) { | ||
balance -= 50; | ||
} | ||
} | ||
} |