Skip to content

Commit

Permalink
1.5.0 BETA
Browse files Browse the repository at this point in the history
  • Loading branch information
JustDoom committed May 15, 2021
1 parent 1717b34 commit f1dfeef
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 17 deletions.
2 changes: 1 addition & 1 deletion credits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
@@ -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());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

Expand All @@ -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);
Expand Down
17 changes: 16 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,19 @@ checks:
punish-vl: 200
punish-commands:
- "kick {player} Fly A"
vl: 15
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
2 changes: 2 additions & 0 deletions update-log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -67,3 +68,4 @@ next checks

false todo
groundspoof/fly A piston elevator false
groundspoof A on join false

0 comments on commit f1dfeef

Please sign in to comment.