From 0ca7a20cb70eb1d52b13bf8bd97db48f6fd2466a Mon Sep 17 00:00:00 2001 From: JustDoom <61824552+JustDoom@users.noreply.github.com> Date: Tue, 18 May 2021 16:32:19 +1000 Subject: [PATCH] fixed some falses, added PlayerUtil and removed checks from last pr --- .../flappyanticheat/checks/Check.java | 10 +--- .../flappyanticheat/checks/CheckManager.java | 10 +--- .../combat/autoclicker/AutoClickerA.java | 43 ------------- .../checks/combat/killaura/KillAuraA.java | 44 -------------- .../checks/movement/fly/FlyA.java | 17 +++--- .../movement/groundspoof/GroundSpoofA.java | 25 +++----- .../checks/movement/noslow/NoSlowA.java | 6 ++ .../checks/movement/speed/SpeedA.java | 8 +++ .../checks/player/badpackets/BadPacketsA.java | 3 + .../checks/player/badpackets/BadPacketsB.java | 9 +++ .../checks/player/blockplace/BlockPlaceA.java | 7 +++ .../checks/player/blockplace/BlockPlaceB.java | 8 +++ .../checks/player/inventory/InventoryA.java | 8 +++ .../player/skinblinker/SkinBlinkerA.java | 8 +++ .../justdoom/flappyanticheat/utils/Ping.java | 27 --------- .../flappyanticheat/utils/PlayerUtil.java | 60 +++++++++++++++++++ src/main/resources/config.yml | 26 +++++++- update-log.txt | 4 +- 18 files changed, 168 insertions(+), 155 deletions(-) delete mode 100644 src/main/java/com/justdoom/flappyanticheat/checks/combat/autoclicker/AutoClickerA.java delete mode 100644 src/main/java/com/justdoom/flappyanticheat/checks/combat/killaura/KillAuraA.java delete mode 100644 src/main/java/com/justdoom/flappyanticheat/utils/Ping.java create mode 100644 src/main/java/com/justdoom/flappyanticheat/utils/PlayerUtil.java diff --git a/src/main/java/com/justdoom/flappyanticheat/checks/Check.java b/src/main/java/com/justdoom/flappyanticheat/checks/Check.java index acb200d..fbcdf1b 100644 --- a/src/main/java/com/justdoom/flappyanticheat/checks/Check.java +++ b/src/main/java/com/justdoom/flappyanticheat/checks/Check.java @@ -3,14 +3,10 @@ import com.justdoom.flappyanticheat.FlappyAnticheat; import com.justdoom.flappyanticheat.customevents.FlagEvent; import com.justdoom.flappyanticheat.customevents.PunishEvent; -import com.justdoom.flappyanticheat.data.PlayerData; import com.justdoom.flappyanticheat.utils.Color; -import com.justdoom.flappyanticheat.utils.Ping; +import com.justdoom.flappyanticheat.utils.PlayerUtil; import io.github.retrooper.packetevents.PacketEvents; -import io.github.retrooper.packetevents.event.PacketEvent; import io.github.retrooper.packetevents.event.PacketListenerAbstract; -import io.github.retrooper.packetevents.utils.server.ServerUtils; -import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; @@ -19,8 +15,6 @@ import org.bukkit.GameMode; import org.bukkit.entity.Player; -import java.util.HashMap; -import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; public class Check extends PacketListenerAbstract { @@ -49,7 +43,7 @@ public void fail(String debug, Player player) { String flagmsg = FlappyAnticheat.getInstance().getConfig().getString("prefix") + FlappyAnticheat.getInstance().getConfig().getString("messages.failed-check"); flagmsg = flagmsg.replace("{player}", player.getName()).replace("{check}", this.check + " " + checkType).replace("{vl}", String.valueOf(FlappyAnticheat.getInstance().violationHandler.getViolations(this, player))); - String hover = FlappyAnticheat.getInstance().getConfig().getString("messages.hover").replace("{ping}", String.valueOf(Ping.getPing(player))).replace("{debug}", debug).replace("{tps}", String.valueOf(PacketEvents.get().getServerUtils().getTPS())); + String hover = FlappyAnticheat.getInstance().getConfig().getString("messages.hover").replace("{ping}", String.valueOf(PlayerUtil.getPing(player))).replace("{debug}", debug).replace("{tps}", String.valueOf(PacketEvents.get().getServerUtils().getTPS())); if(experimental){ flagmsg = flagmsg+"&r*"; diff --git a/src/main/java/com/justdoom/flappyanticheat/checks/CheckManager.java b/src/main/java/com/justdoom/flappyanticheat/checks/CheckManager.java index 3a32ffd..9014d96 100644 --- a/src/main/java/com/justdoom/flappyanticheat/checks/CheckManager.java +++ b/src/main/java/com/justdoom/flappyanticheat/checks/CheckManager.java @@ -3,13 +3,11 @@ 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.movement.noslow.NoSlowA; import com.justdoom.flappyanticheat.checks.movement.speed.SpeedA; import com.justdoom.flappyanticheat.checks.player.blockplace.BlockPlaceA; import com.justdoom.flappyanticheat.checks.player.badpackets.BadPacketsA; import com.justdoom.flappyanticheat.checks.player.badpackets.BadPacketsB; -import com.justdoom.flappyanticheat.checks.combat.killaura.KillAuraA; -import com.justdoom.flappyanticheat.checks.combat.autoclicker.AutoClickerA; -import com.justdoom.flappyanticheat.data.PlayerData; import com.justdoom.flappyanticheat.checks.player.blockplace.BlockPlaceB; import com.justdoom.flappyanticheat.checks.player.skinblinker.SkinBlinkerA; import io.github.retrooper.packetevents.PacketEvents; @@ -28,13 +26,11 @@ public void loadChecks(){ PacketEvents.get().registerListener(new FlyA()); PacketEvents.get().registerListener(new BadPacketsA()); PacketEvents.get().registerListener(new BadPacketsB()); - PacketEvents.get().registerListener(new NoSlowA()); - PacketEvents.get().registerListener(new AutoClickerA()); - PacketEvents.get().registerListener(new KillAuraA()); + //PacketEvents.get().registerListener(new NoSlowA()); PacketEvents.get().registerListener(new SkinBlinkerA()); PacketEvents.get().registerListener(new SpeedA()); Bukkit.getPluginManager().registerEvents(new BlockPlaceA(), plugin); Bukkit.getPluginManager().registerEvents(new BlockPlaceB(), plugin); } -} +} \ No newline at end of file diff --git a/src/main/java/com/justdoom/flappyanticheat/checks/combat/autoclicker/AutoClickerA.java b/src/main/java/com/justdoom/flappyanticheat/checks/combat/autoclicker/AutoClickerA.java deleted file mode 100644 index 9ed8097..0000000 --- a/src/main/java/com/justdoom/flappyanticheat/checks/combat/autoclicker/AutoClickerA.java +++ /dev/null @@ -1,43 +0,0 @@ - -package com.justdoom.flappyanticheat.checks.combat.killaura; - -import com.justdoom.flappyanticheat.checks.Check; -import com.justdoom.flappyanticheat.data.PlayerData; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation; -import net.minecraft.server.v1_8_R3.PacketPlayInFlying; -import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; -import org.bukkit.entity.Player; - -/** - * ported by pixchure - * - */ - -public class AutoClickerA extends Check { - - private int swings; - private int movements; - - public AutoClickerA(PlayerData playerData) { - super("AutoClicker", "A", true); - } - - @Override - public void handleCheck(Player player, Packet packet) { - //double vl = playerData.getCheckVl(this); - - if (packet instanceof PacketPlayInArmAnimation - && !playerData.isDigging() && !playerData.isPlacing() && !playerData.isFakeDigging() - && (System.currentTimeMillis() - playerData.getLastDelayedMovePacket()) > 220L - && (System.currentTimeMillis() - playerData.getLastMovePacket().getTimestamp()) < 110L) { - ++swings; - } else if (packet instanceof PacketPlayInFlying && ++movements == 20) { - if (swings > 35) { - fail("", player); - } - movements = swings = 0; - } - } - -} diff --git a/src/main/java/com/justdoom/flappyanticheat/checks/combat/killaura/KillAuraA.java b/src/main/java/com/justdoom/flappyanticheat/checks/combat/killaura/KillAuraA.java deleted file mode 100644 index 18b4e22..0000000 --- a/src/main/java/com/justdoom/flappyanticheat/checks/combat/killaura/KillAuraA.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.justdoom.flappyanticheat.checks.combat.killaura; - -import com.justdoom.flappyanticheat.checks.Check; -import com.justdoom.flappyanticheat.data.PlayerData; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation; -import net.minecraft.server.v1_8_R3.PacketPlayInFlying; -import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; -import org.bukkit.entity.Player; - -/** - * ported by Pixchure - * not even sure if this works - */ - -public class KillAuraA extends Check { - private boolean sent; - public KillAuraA(){ - super("KillAura", "A", false); - } - - @Override - public void handleCheck(Player player, Packet packet) { - //double vl = playerData.getCheckVl(this); - - if (playerData.getPing() > 70) { - return; - } - - if (packet instanceof PacketPlayInUseEntity && ((PacketPlayInUseEntity) packet).a() == PacketPlayInUseEntity - .EnumEntityUseAction.ATTACK) { - if (!sent) { - fail("", player) - } else { - sent = false; - } - } else if (packet instanceof PacketPlayInArmAnimation) { - sent = true; - } else if (packet instanceof PacketPlayInFlying) { - sent = false; - } - //playerData.setCheckVl(vl, this); - } -} 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 02e232c..7004162 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 @@ -1,8 +1,11 @@ package com.justdoom.flappyanticheat.checks.movement.fly; +import com.justdoom.flappyanticheat.FlappyAnticheat; import com.justdoom.flappyanticheat.checks.Check; import com.justdoom.flappyanticheat.checks.CheckData; import com.justdoom.flappyanticheat.data.PlayerData; +import com.justdoom.flappyanticheat.utils.PlayerUtil; +import io.github.retrooper.packetevents.PacketEvents; 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; @@ -28,6 +31,11 @@ public FlyA(){ public void onPacketPlayReceive(PacketPlayReceiveEvent event) { if (event.getPacketId() == PacketType.Play.Client.POSITION || event.getPacketId() == PacketType.Play.Client.POSITION_LOOK) { + String path = ("checks." + check + "." + checkType).toLowerCase(); + if(PacketEvents.get().getServerUtils().getTPS() <= FlappyAnticheat.getInstance().getConfig().getDouble(path + ".min-tps")){ + return; + } + WrappedPacketInFlying packet = new WrappedPacketInFlying(event.getNMSPacket()); Player player = event.getPlayer(); @@ -40,7 +48,7 @@ public void onPacketPlayReceive(PacketPlayReceiveEvent event) { this.lastOnGround = onGround; boolean lastLastOnGround = this.lastLastOnGround; this.lastLastOnGround = lastOnGround; - if (!lastLastOnGround && !lastOnGround && !onGround && !isInLiquid(player)) { + if (!lastLastOnGround && !lastOnGround && !onGround && !PlayerUtil.isInLiquid(player) && !PlayerUtil.isOnClimbable(player)) { double deltaY = (currentLoc.getY() - lastLocation.getY()); double lastDeltaY = this.lastDeltaY; this.lastDeltaY = deltaY; @@ -59,13 +67,6 @@ public void onPacketPlayReceive(PacketPlayReceiveEvent event) { } } - public boolean isInLiquid(Player player) { - if(player.isInWater() || player.getLocation().getBlock().getType() == Material.LAVA){ - return true; - } - return false; - } - //Not at all taken from Juaga Anticheat, ignore this message ;) //Got stuck with a bug, had most of this code myself anyway } diff --git a/src/main/java/com/justdoom/flappyanticheat/checks/movement/groundspoof/GroundSpoofA.java b/src/main/java/com/justdoom/flappyanticheat/checks/movement/groundspoof/GroundSpoofA.java index 94bc0e6..921a605 100644 --- a/src/main/java/com/justdoom/flappyanticheat/checks/movement/groundspoof/GroundSpoofA.java +++ b/src/main/java/com/justdoom/flappyanticheat/checks/movement/groundspoof/GroundSpoofA.java @@ -4,6 +4,8 @@ import com.justdoom.flappyanticheat.checks.Check; import com.justdoom.flappyanticheat.checks.CheckData; import com.justdoom.flappyanticheat.data.PlayerData; +import com.justdoom.flappyanticheat.utils.PlayerUtil; +import io.github.retrooper.packetevents.PacketEvents; 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; @@ -40,10 +42,15 @@ public void onPacketPlayReceive(PacketPlayReceiveEvent e) { WrappedPacketInFlying packet = new WrappedPacketInFlying(e.getNMSPacket()); + String path = ("checks." + check + "." + checkType).toLowerCase(); + if(PacketEvents.get().getServerUtils().getTPS() <= FlappyAnticheat.getInstance().getConfig().getDouble(path + ".min-tps")){ + return; + } + double groundY = 0.015625; boolean client = packet.isOnGround(), server = packet.getY() % groundY < 0.0001; - if (client != server) { + if (client != server && !PlayerUtil.isOnClimbable(player)) { if (++buffer > 1) { if(player.getLocation().getY() < 1){ @@ -67,7 +74,7 @@ public void onPacketPlayReceive(PacketPlayReceiveEvent e) { } } - for (Block block : getNearbyBlocks(new Location(player.getWorld(), packet.getX(), packet.getY(), packet.getZ()), 2)) { + 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; @@ -88,18 +95,4 @@ public void onPacketPlayReceive(PacketPlayReceiveEvent e) { } else if (buffer > 0) buffer--; } } - - public Set getNearbyBlocks(Location location, int radius) { - Set blocks = new HashSet<>(); - - for(int x = location.getBlockX() - radius; x <= location.getBlockX() + radius; x++) { - for(int y = location.getBlockY() - radius; y <= location.getBlockY() + radius; y++) { - for(int z = location.getBlockZ() - radius; z <= location.getBlockZ() + radius; z++) { - blocks.add(location.getWorld().getBlockAt(x, y, z)); - } - } - } - - return blocks; - } } \ No newline at end of file diff --git a/src/main/java/com/justdoom/flappyanticheat/checks/movement/noslow/NoSlowA.java b/src/main/java/com/justdoom/flappyanticheat/checks/movement/noslow/NoSlowA.java index fd1a4db..9a29d6d 100644 --- a/src/main/java/com/justdoom/flappyanticheat/checks/movement/noslow/NoSlowA.java +++ b/src/main/java/com/justdoom/flappyanticheat/checks/movement/noslow/NoSlowA.java @@ -1,5 +1,6 @@ package com.justdoom.flappyanticheat.checks.movement.noslow; +import com.justdoom.flappyanticheat.FlappyAnticheat; import com.justdoom.flappyanticheat.checks.Check; import com.justdoom.flappyanticheat.checks.CheckData; import com.justdoom.flappyanticheat.data.PlayerData; @@ -31,6 +32,11 @@ public void onPacketPlayReceive(PacketPlayReceiveEvent event) { if(event.getPacketId() == PacketType.Play.Client.POSITION){ WrappedPacketInFlying packet = new WrappedPacketInFlying(event.getNMSPacket()); + String path = ("checks." + check + "." + checkType).toLowerCase(); + if(PacketEvents.get().getServerUtils().getTPS() <= FlappyAnticheat.getInstance().getConfig().getDouble(path + ".min-tps")){ + return; + } + Location currentLoc = new Location(event.getPlayer().getWorld(), packet.getX(), packet.getY(), packet.getZ()); Location lastLocation = this.lastLocation; this.lastLocation = currentLoc; diff --git a/src/main/java/com/justdoom/flappyanticheat/checks/movement/speed/SpeedA.java b/src/main/java/com/justdoom/flappyanticheat/checks/movement/speed/SpeedA.java index 06b61e8..cee33f6 100644 --- a/src/main/java/com/justdoom/flappyanticheat/checks/movement/speed/SpeedA.java +++ b/src/main/java/com/justdoom/flappyanticheat/checks/movement/speed/SpeedA.java @@ -1,6 +1,8 @@ package com.justdoom.flappyanticheat.checks.movement.speed; +import com.justdoom.flappyanticheat.FlappyAnticheat; import com.justdoom.flappyanticheat.checks.Check; +import io.github.retrooper.packetevents.PacketEvents; 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; @@ -19,10 +21,16 @@ public SpeedA(){ @Override public void onPacketPlayReceive(PacketPlayReceiveEvent event) { + if(event.getPacketId() == PacketType.Play.Client.POSITION){ WrappedPacketInFlying packet = new WrappedPacketInFlying(event.getNMSPacket()); Player player = event.getPlayer(); + String path = ("checks." + check + "." + checkType).toLowerCase(); + if(PacketEvents.get().getServerUtils().getTPS() <= FlappyAnticheat.getInstance().getConfig().getDouble(path + ".min-tps")){ + return; + } + double deltaX = packet.getX() - player.getLocation().getX(); double deltaZ = packet.getZ() - player.getLocation().getZ(); 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 index f268173..f0316a7 100644 --- a/src/main/java/com/justdoom/flappyanticheat/checks/player/badpackets/BadPacketsA.java +++ b/src/main/java/com/justdoom/flappyanticheat/checks/player/badpackets/BadPacketsA.java @@ -4,6 +4,7 @@ import com.justdoom.flappyanticheat.checks.Check; import com.justdoom.flappyanticheat.checks.CheckData; import com.justdoom.flappyanticheat.data.PlayerData; +import io.github.retrooper.packetevents.PacketEvents; 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; @@ -16,7 +17,9 @@ public BadPacketsA(){ @Override public void onPacketPlayReceive(PacketPlayReceiveEvent event) { + if (event.getPacketId() == PacketType.Play.Client.POSITION || event.getPacketId() == PacketType.Play.Client.POSITION_LOOK) { + float pitch = event.getPlayer().getLocation().getPitch(); if(Math.abs(pitch) > 90F || Math.abs(pitch) < -90F){ String suspectedHack = "Old/Bad KillAura (This cannot false)"; 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 index 7294723..2eb581b 100644 --- a/src/main/java/com/justdoom/flappyanticheat/checks/player/badpackets/BadPacketsB.java +++ b/src/main/java/com/justdoom/flappyanticheat/checks/player/badpackets/BadPacketsB.java @@ -1,8 +1,10 @@ package com.justdoom.flappyanticheat.checks.player.badpackets; +import com.justdoom.flappyanticheat.FlappyAnticheat; import com.justdoom.flappyanticheat.checks.Check; import com.justdoom.flappyanticheat.checks.CheckData; import com.justdoom.flappyanticheat.data.PlayerData; +import io.github.retrooper.packetevents.PacketEvents; import io.github.retrooper.packetevents.event.impl.PacketPlayReceiveEvent; import io.github.retrooper.packetevents.packettype.PacketType; @@ -16,7 +18,14 @@ public BadPacketsB(){ @Override public void onPacketPlayReceive(PacketPlayReceiveEvent event) { + if (event.getPacketId() == PacketType.Play.Client.USE_ENTITY){ + + String path = ("checks." + check + "." + checkType).toLowerCase(); + if(PacketEvents.get().getServerUtils().getTPS() <= FlappyAnticheat.getInstance().getConfig().getDouble(path + ".min-tps")){ + return; + } + if(!wasLastArmAnimation){ fail("&7ArmAnimation=&2false", event.getPlayer()); } diff --git a/src/main/java/com/justdoom/flappyanticheat/checks/player/blockplace/BlockPlaceA.java b/src/main/java/com/justdoom/flappyanticheat/checks/player/blockplace/BlockPlaceA.java index 136bd99..07ab8ec 100644 --- a/src/main/java/com/justdoom/flappyanticheat/checks/player/blockplace/BlockPlaceA.java +++ b/src/main/java/com/justdoom/flappyanticheat/checks/player/blockplace/BlockPlaceA.java @@ -2,6 +2,7 @@ import com.justdoom.flappyanticheat.FlappyAnticheat; import com.justdoom.flappyanticheat.checks.Check; +import io.github.retrooper.packetevents.PacketEvents; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; @@ -22,6 +23,12 @@ public BlockPlaceA() { @EventHandler public void onBlockPlace(BlockPlaceEvent event) { + + String path = ("checks." + check + "." + checkType).toLowerCase(); + if(PacketEvents.get().getServerUtils().getTPS() <= FlappyAnticheat.getInstance().getConfig().getDouble(path + ".min-tps")){ + return; + } + Player player = event.getPlayer(); Block block = event.getBlock(); diff --git a/src/main/java/com/justdoom/flappyanticheat/checks/player/blockplace/BlockPlaceB.java b/src/main/java/com/justdoom/flappyanticheat/checks/player/blockplace/BlockPlaceB.java index b6f1a29..fbdcdcf 100644 --- a/src/main/java/com/justdoom/flappyanticheat/checks/player/blockplace/BlockPlaceB.java +++ b/src/main/java/com/justdoom/flappyanticheat/checks/player/blockplace/BlockPlaceB.java @@ -2,6 +2,7 @@ import com.justdoom.flappyanticheat.FlappyAnticheat; import com.justdoom.flappyanticheat.checks.Check; +import io.github.retrooper.packetevents.PacketEvents; import org.bukkit.Bukkit; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -18,13 +19,20 @@ public BlockPlaceB() { @EventHandler public void onBlockPlace(BlockPlaceEvent event) { + Player player = event.getPlayer(); Block block = event.getBlock(); ItemStack hand = player.getItemInHand(); + String path = ("checks." + check + "." + checkType).toLowerCase(); + if(PacketEvents.get().getServerUtils().getTPS() <= FlappyAnticheat.getInstance().getConfig().getDouble(path + ".min-tps")){ + return; + } + if (block.getType() != hand.getType()) { + Bukkit.getScheduler().runTaskAsynchronously(FlappyAnticheat.getInstance(), () -> fail("hand=" + hand.getType() + " placed=" + block.getType(), player)); } } 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 index e714b72..2c83f3d 100644 --- a/src/main/java/com/justdoom/flappyanticheat/checks/player/inventory/InventoryA.java +++ b/src/main/java/com/justdoom/flappyanticheat/checks/player/inventory/InventoryA.java @@ -1,6 +1,8 @@ package com.justdoom.flappyanticheat.checks.player.inventory; +import com.justdoom.flappyanticheat.FlappyAnticheat; import com.justdoom.flappyanticheat.checks.Check; +import io.github.retrooper.packetevents.PacketEvents; import io.github.retrooper.packetevents.event.impl.PacketPlayReceiveEvent; import io.github.retrooper.packetevents.packettype.PacketType; @@ -12,8 +14,14 @@ public InventoryA(){ @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()); + + String path = ("checks." + check + "." + checkType).toLowerCase(); + if(PacketEvents.get().getServerUtils().getTPS() <= FlappyAnticheat.getInstance().getConfig().getDouble(path + ".min-tps")){ + return; + } } } } diff --git a/src/main/java/com/justdoom/flappyanticheat/checks/player/skinblinker/SkinBlinkerA.java b/src/main/java/com/justdoom/flappyanticheat/checks/player/skinblinker/SkinBlinkerA.java index 07281d0..60917db 100644 --- a/src/main/java/com/justdoom/flappyanticheat/checks/player/skinblinker/SkinBlinkerA.java +++ b/src/main/java/com/justdoom/flappyanticheat/checks/player/skinblinker/SkinBlinkerA.java @@ -1,6 +1,8 @@ package com.justdoom.flappyanticheat.checks.player.skinblinker; +import com.justdoom.flappyanticheat.FlappyAnticheat; import com.justdoom.flappyanticheat.checks.Check; +import io.github.retrooper.packetevents.PacketEvents; import io.github.retrooper.packetevents.event.impl.PacketPlayReceiveEvent; import io.github.retrooper.packetevents.packettype.PacketType; import io.github.retrooper.packetevents.packetwrappers.play.in.setcreativeslot.WrappedPacketInSetCreativeSlot; @@ -17,10 +19,16 @@ public SkinBlinkerA(){ @Override public void onPacketPlayReceive(PacketPlayReceiveEvent event) { + if (event.getPacketId() == PacketType.Play.Client.SETTINGS){ WrappedPacketInSettings packet = new WrappedPacketInSettings(event.getNMSPacket()); Player player = event.getPlayer(); + String path = ("checks." + check + "." + checkType).toLowerCase(); + if(PacketEvents.get().getServerUtils().getTPS() <= FlappyAnticheat.getInstance().getConfig().getDouble(path + ".min-tps")){ + return; + } + if (lastSkin == -1) { lastSkin = packet.getDisplaySkinPartsMask(); return; diff --git a/src/main/java/com/justdoom/flappyanticheat/utils/Ping.java b/src/main/java/com/justdoom/flappyanticheat/utils/Ping.java deleted file mode 100644 index e56bba4..0000000 --- a/src/main/java/com/justdoom/flappyanticheat/utils/Ping.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.justdoom.flappyanticheat.utils; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.logging.Level; - -public class Ping { - - public static int getPing(Player player) { - try { - Method handle = player.getClass().getMethod("getHandle"); - Object nmsHandle = handle.invoke(player); - Field pingField = nmsHandle.getClass().getField("ping"); - return pingField.getInt(nmsHandle); - } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException - | NoSuchFieldException e) { - Bukkit.getLogger().log(Level.SEVERE, "Exception while trying to get player ping.", e); - } - - return -1; - } -} diff --git a/src/main/java/com/justdoom/flappyanticheat/utils/PlayerUtil.java b/src/main/java/com/justdoom/flappyanticheat/utils/PlayerUtil.java new file mode 100644 index 0000000..0cc687a --- /dev/null +++ b/src/main/java/com/justdoom/flappyanticheat/utils/PlayerUtil.java @@ -0,0 +1,60 @@ +package com.justdoom.flappyanticheat.utils; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashSet; +import java.util.Set; +import java.util.logging.Level; + +public class PlayerUtil { + + public static int getPing(Player player) { + try { + Method handle = player.getClass().getMethod("getHandle"); + Object nmsHandle = handle.invoke(player); + Field pingField = nmsHandle.getClass().getField("ping"); + return pingField.getInt(nmsHandle); + } + catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException + | NoSuchFieldException e) { + Bukkit.getLogger().log(Level.SEVERE, "Exception while trying to get player ping.", e); + } + + return -1; + } + + public static boolean isInLiquid(Player player) { + if(player.isInWater() || player.getLocation().getBlock().getType() == Material.LAVA){ + return true; + } + return false; + } + + public static boolean isOnClimbable(Player player) { + if(player.getLocation().getBlock().getType() == Material.LADDER || player.getLocation().getBlock().getType() == Material.VINE ){ + return true; + } + return false; + } + + public static Set getNearbyBlocks(Location location, int radius) { + Set blocks = new HashSet<>(); + + for(int x = location.getBlockX() - radius; x <= location.getBlockX() + radius; x++) { + for(int y = location.getBlockY() - radius; y <= location.getBlockY() + radius; y++) { + for(int z = location.getBlockZ() - radius; z <= location.getBlockZ() + radius; z++) { + blocks.add(location.getWorld().getBlockAt(x, y, z)); + } + } + } + + return blocks; + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 6968ef1..1db6930 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -32,6 +32,7 @@ checks: groundspoof: a: enabled: true + min-tps: 17.0 punishable: true broadcast-punishment: true punish-vl: 200 @@ -41,6 +42,7 @@ checks: fly: a: enabled: true + min-tps: 17.0 punishable: false broadcast-punishment: true punish-vl: 200 @@ -50,6 +52,7 @@ checks: badpackets: a: enabled: true + min-tps: 17.0 punishable: true broadcast-punishment: true punish-vl: 10 @@ -58,6 +61,7 @@ checks: vl: 10 b: enabled: true + min-tps: 17.0 punishable: true broadcast-punishment: true punish-vl: 200 @@ -67,9 +71,29 @@ checks: skinblinker: a: enabled: true + min-tps: 17.0 punishable: true broadcast-punishment: true punish-vl: 100 punish-commands: - - "kick {player} SkinBlinker A" + - "kick {player} FlappyAC > Suspicious Activity" + vl: 10 + blockplace: + a: + enabled: true + min-tps: 17.0 + punishable: true + broadcast-punishment: true + punish-vl: 100 + punish-commands: + - "kick {player} FlappyAC > Suspicious Activity" vl: 10 + b: + enabled: true + min-tps: 17.0 + punishable: true + broadcast-punishment: true + punish-vl: 100 + punish-commands: + - "kick {player} FlappyAC > Suspicious Activity" + vl: 10 \ No newline at end of file diff --git a/update-log.txt b/update-log.txt index 825faa2..ea7fab2 100644 --- a/update-log.txt +++ b/update-log.txt @@ -63,6 +63,7 @@ added a skinblinker check experimanetal checks have a * after the flag added broadcast punishment option added blockplace a-b checks +fixed fly and groundspoof A false with vines/ladders Todo @@ -78,7 +79,7 @@ Todo - lag back feature??? Could be an extension - proper 1.8 - 1.16 support possibly - alert interval -- max ping/min tps option +- max ping - possibly customizable buffer - discord integration - include ban config for easy switch, could be on discord or with download @@ -95,3 +96,4 @@ api todo false todo groundspoof/fly A piston elevator false (believe its when your glitched inside piston head) groundspoof A on join false +groundspoof/fly a https://www.youtube.com/watch?v=YTmjY9Dbk30&ab_channel=Spiriten ladders/trap doors \ No newline at end of file