diff --git a/credits.txt b/credits.txt index 2291227..aaec450 100644 --- a/credits.txt +++ b/credits.txt @@ -2,5 +2,5 @@ I have *borrowed* some code from some peoples anticheats so I will list them off Anticheat | Developer | For Juaga | Salers | Main Fly A check Tutorial Series | funkemonkey | Bit of check code here and there -Tutorial Series | Jonhan | Little bit of check code here and there +Tutorial Series | Jonhan | Little bit of check code here and there and some badpacket checks Optimus | notOM3GA | Main GroundSpoof A Check \ No newline at end of file diff --git a/src/main/java/com/justdoom/flappyanticheat/checks/CheckManager.java b/src/main/java/com/justdoom/flappyanticheat/checks/CheckManager.java index 4cdd226..42ea8f8 100644 --- a/src/main/java/com/justdoom/flappyanticheat/checks/CheckManager.java +++ b/src/main/java/com/justdoom/flappyanticheat/checks/CheckManager.java @@ -3,6 +3,8 @@ import com.justdoom.flappyanticheat.FlappyAnticheat; import com.justdoom.flappyanticheat.checks.movement.fly.FlyA; import com.justdoom.flappyanticheat.checks.movement.groundspoof.GroundSpoofA; +import com.justdoom.flappyanticheat.checks.player.badpackets.BadPacketsA; +import com.justdoom.flappyanticheat.checks.player.badpackets.BadPacketsB; import com.justdoom.flappyanticheat.data.PlayerData; import io.github.retrooper.packetevents.PacketEvents; import org.bukkit.Bukkit; @@ -21,5 +23,7 @@ public CheckManager(FlappyAnticheat plugin, PlayerData data) { public void loadChecks(){ PacketEvents.get().registerListener(new GroundSpoofA(data)); PacketEvents.get().registerListener(new FlyA(data)); + PacketEvents.get().registerListener(new BadPacketsA(data)); + PacketEvents.get().registerListener(new BadPacketsB(data)); } } \ No newline at end of file diff --git a/src/main/java/com/justdoom/flappyanticheat/checks/movement/fly/FlyA.java b/src/main/java/com/justdoom/flappyanticheat/checks/movement/fly/FlyA.java index fa57d94..3fda74e 100644 --- a/src/main/java/com/justdoom/flappyanticheat/checks/movement/fly/FlyA.java +++ b/src/main/java/com/justdoom/flappyanticheat/checks/movement/fly/FlyA.java @@ -13,7 +13,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerMoveEvent; -@CheckData(name = "Fly", type = "A") +@CheckData(name = "Fly", type = "A", experimental = false) public class FlyA extends Check { private float buffer; @@ -36,12 +36,12 @@ public void onPacketPlayReceive(PacketPlayReceiveEvent event) { Location lastLocation = this.lastLocation; this.lastLocation = currentLoc; - boolean onGround = packet.isOnGround(); + boolean onGround = packet.getY() % 0.015625 < 0.0001; boolean lastOnGround = this.lastOnGround; this.lastOnGround = onGround; boolean lastLastOnGround = this.lastLastOnGround; this.lastLastOnGround = lastOnGround; - if (!lastLastOnGround && !lastOnGround && !onGround && !player.isInWater()) { + if (!lastLastOnGround && !lastOnGround && !onGround && !isInLiquid(player)) { double deltaY = (currentLoc.getY() - lastLocation.getY()); double lastDeltaY = this.lastDeltaY; this.lastDeltaY = deltaY; @@ -60,13 +60,9 @@ public void onPacketPlayReceive(PacketPlayReceiveEvent event) { } } - public boolean isNearGround(Location location) { - double expand = 0.3; - for (double x = -expand; x <= expand; x += expand) { - for (double z = -expand; z <= expand; z += expand) { - if (location.clone().add(x, -0.5001, z).getBlock().getType() != Material.AIR) - return true; - } + public boolean isInLiquid(Player player) { + if(player.isInWater() || player.getLocation().getBlock().getType() == Material.LAVA){ + return true; } return false; } diff --git a/src/main/java/com/justdoom/flappyanticheat/checks/player/badpackets/BadPacketsA.java b/src/main/java/com/justdoom/flappyanticheat/checks/player/badpackets/BadPacketsA.java new file mode 100644 index 0000000..fa1ba84 --- /dev/null +++ b/src/main/java/com/justdoom/flappyanticheat/checks/player/badpackets/BadPacketsA.java @@ -0,0 +1,26 @@ +package com.justdoom.flappyanticheat.checks.player.badpackets; + +import com.justdoom.flappyanticheat.checks.Check; +import com.justdoom.flappyanticheat.checks.CheckData; +import com.justdoom.flappyanticheat.data.PlayerData; +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; + +@CheckData(name = "BadPackets", type = "A") +public class BadPacketsA extends Check { + + public BadPacketsA(PlayerData data) { + super(data); + } + + @Override + public void onPacketPlayReceive(PacketPlayReceiveEvent event) { + if (event.getPacketId() == PacketType.Play.Client.POSITION || event.getPacketId() == PacketType.Play.Client.POSITION_LOOK) { + WrappedPacketInFlying packet = new WrappedPacketInFlying(event.getNMSPacket()); + if(Math.abs(packet.getPitch()) > 90.0){ + fail("pitch=" + packet.getPitch(), event.getPlayer()); + } + } + } +} diff --git a/src/main/java/com/justdoom/flappyanticheat/checks/player/badpackets/BadPacketsB.java b/src/main/java/com/justdoom/flappyanticheat/checks/player/badpackets/BadPacketsB.java new file mode 100644 index 0000000..9184f5b --- /dev/null +++ b/src/main/java/com/justdoom/flappyanticheat/checks/player/badpackets/BadPacketsB.java @@ -0,0 +1,32 @@ +package com.justdoom.flappyanticheat.checks.player.badpackets; + +import com.justdoom.flappyanticheat.checks.Check; +import com.justdoom.flappyanticheat.checks.CheckData; +import com.justdoom.flappyanticheat.data.PlayerData; +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 io.github.retrooper.packetevents.packetwrappers.play.in.useentity.WrappedPacketInUseEntity; + +@CheckData(name = "BadPackets", type = "B") +public class BadPacketsB extends Check { + + private boolean wasLastArmAnimation; + + public BadPacketsB(PlayerData data) { + super(data); + } + + @Override + public void onPacketPlayReceive(PacketPlayReceiveEvent event) { + if (event.getPacketId() == PacketType.Play.Client.USE_ENTITY){ + if(!wasLastArmAnimation){ + fail("ArmAnimation=false", event.getPlayer()); + } + } else if (event.getPacketId() == PacketType.Play.Client.ARM_ANIMATION){ + wasLastArmAnimation = true; + } else if (event.getPacketId() == PacketType.Play.Client.FLYING){ + wasLastArmAnimation = false; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/justdoom/flappyanticheat/checks/player/inventory/InventoryA.java b/src/main/java/com/justdoom/flappyanticheat/checks/player/inventory/InventoryA.java new file mode 100644 index 0000000..1f28afc --- /dev/null +++ b/src/main/java/com/justdoom/flappyanticheat/checks/player/inventory/InventoryA.java @@ -0,0 +1,23 @@ +package com.justdoom.flappyanticheat.checks.player.inventory; + +import com.justdoom.flappyanticheat.checks.Check; +import com.justdoom.flappyanticheat.checks.CheckData; +import com.justdoom.flappyanticheat.data.PlayerData; +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; + +@CheckData(name = "Inventory", type = "A") +public class InventoryA extends Check { + + public InventoryA(PlayerData data) { + super(data); + } + + @Override + public void onPacketPlayReceive(PacketPlayReceiveEvent event) { + if (event.getPacketId() == PacketType.Play.Client.POSITION || event.getPacketId() == PacketType.Play.Client.POSITION_LOOK) { + //WrappedPacketIn packet = new WrappedPacketInFlying(e.getNMSPacket()); + } + } +} diff --git a/src/main/java/com/justdoom/flappyanticheat/violations/ViolationHandler.java b/src/main/java/com/justdoom/flappyanticheat/violations/ViolationHandler.java index 2ad35b3..c37cfc7 100644 --- a/src/main/java/com/justdoom/flappyanticheat/violations/ViolationHandler.java +++ b/src/main/java/com/justdoom/flappyanticheat/violations/ViolationHandler.java @@ -56,8 +56,10 @@ public void addViolation(Check check, Player p){ } this.violations.put(p.getUniqueId(), vl); if(getViolations(check, p) >= FlappyAnticheat.getInstance().getConfig().getInt(path + ".punish-vl")){ - punish(p, path); - FlappyAnticheat.getInstance().fileData.addToFile("punishments.txt", "\n" + p.getName() + " has been punished for " + check.check.toLowerCase() + " " + check.checkType.toLowerCase()); + if(FlappyAnticheat.getInstance().getConfig().getBoolean(path + ".punishable")){ + punish(p, path); + FlappyAnticheat.getInstance().fileData.addToFile("punishments.txt", "\n" + p.getName() + " has been punished for " + check.check.toLowerCase() + " " + check.checkType.toLowerCase()); + } } } @@ -71,9 +73,6 @@ public Integer getViolations(Check check, Player p) { } public void punish(Player player, String path){ - if(!FlappyAnticheat.getInstance().getConfig().getBoolean(path + ".punishable")){ - return; - } for(String command: FlappyAnticheat.getInstance().getConfig().getStringList(path + ".punish-commands")) { command = command.replace("{player}", player.getName()); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 1bd8dc8..a56e3aa 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -44,4 +44,19 @@ checks: punish-vl: 200 punish-commands: - "kick {player} Fly A" - vl: 15 \ No newline at end of file + vl: 15 + badpackets: + a: + enabled: true + punishable: true + punish-vl: 10 + punish-commands: + - "kick {player} BadPackets A" + vl: 10 + b: + enabled: true + punishable: true + punish-vl: 200 + punish-commands: + - "kick {player} BadPackets A" + vl: 10 \ No newline at end of file diff --git a/update-log.txt b/update-log.txt index 875adf8..3ba57b2 100644 --- a/update-log.txt +++ b/update-log.txt @@ -44,6 +44,7 @@ Added a violation and punishment log Added an update checker Changed to packets fixed tps placeholder +Added BadPackets A-B check Todo @@ -67,3 +68,4 @@ next checks false todo groundspoof/fly A piston elevator false +groundspoof A on join false