mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 22:16:03 +00:00
Updated to 1.15, fixed issues and made changes to some checks
This commit is contained in:
1 parent
0428c4796a
commit
0963458be5
18 files changed
+275
-501
No files matched your search
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.rammelkast.anticheatreloaded.check;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -262,7 +263,7 @@ public class Backend {
|
||||
}
|
||||
|
||||
public CheckResult checkYSpeed(Player player, double y) {
|
||||
if (!isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping() && (y > (VersionUtil.isNewYSpeed() ? magic.Y_SPEED_MAX() + 0.05 : magic.Y_SPEED_MAX())) && !isDoing(player, velocitized, magic.VELOCITY_TIME()) && !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)) {
|
||||
if (!isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping() && (y > magic.Y_SPEED_MAX()) && !isDoing(player, velocitized, magic.VELOCITY_TIME()) && !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + "'s y speed was too high (speed=" + y + ", max=" + magic.Y_SPEED_MAX() + ")");
|
||||
} else {
|
||||
return PASS;
|
||||
@@ -432,7 +433,7 @@ public class Backend {
|
||||
public CheckResult checkSwing(Player player, Block block) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (!isInstantBreakExempt(player)) {
|
||||
if (!VersionUtil.getItemInHand(player).containsEnchantment(Enchantment.DIG_SPEED) && !(VersionUtil.getItemInHand(player).getType() == Material.SHEARS && block.getType() == Material.LEAVES)) {
|
||||
if (!VersionUtil.getItemInHand(player).containsEnchantment(Enchantment.DIG_SPEED) && !(VersionUtil.getItemInHand(player).getType() == Material.SHEARS && block.getType().name().endsWith("LEAVES"))) {
|
||||
if (blockPunches.get(uuid) != null && player.getGameMode() != GameMode.CREATIVE) {
|
||||
int i = blockPunches.get(uuid);
|
||||
if (i < magic.BLOCK_PUNCH_MIN()) {
|
||||
@@ -584,7 +585,21 @@ public class Backend {
|
||||
user.addMessage(msg);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public CheckResult checkChatUnicode(Player player, String msg) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
User user = manager.getUserManager().getUser(uuid);
|
||||
if (!isPureAscii(msg)) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "Unicode chat is not allowed.");
|
||||
}
|
||||
user.addMessage(msg);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private boolean isPureAscii(String v) {
|
||||
return StandardCharsets.US_ASCII.newEncoder().canEncode(v.replaceAll("¡", "!").replaceAll("¿", "?"));
|
||||
}
|
||||
|
||||
public CheckResult checkCommandSpam(Player player, String cmd) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
User user = manager.getUserManager().getUser(uuid);
|
||||
|
||||
@@ -64,8 +64,9 @@ public enum CheckType {
|
||||
AUTOTOOL(Permission.CHECK_AUTOTOOL),
|
||||
KILLAURA(Permission.CHECK_KILLAURA),
|
||||
BLINK(Permission.CHECK_BLINK),
|
||||
VELOCITY(Permission.VELOCITY),
|
||||
CRITICALS(Permission.CRITICALS);
|
||||
VELOCITY(Permission.CHECK_VELOCITY),
|
||||
CRITICALS(Permission.CHECK_CRITICALS),
|
||||
CHAT_UNICODE(Permission.CHECK_UNICODE);
|
||||
|
||||
private final Permission permission;
|
||||
private final Map<UUID, Integer> level = new HashMap<UUID, Integer>();
|
||||
|
||||
@@ -19,42 +19,28 @@
|
||||
|
||||
package com.rammelkast.anticheatreloaded.check.combat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
import com.rammelkast.anticheatreloaded.util.NPC_1_12;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
/**
|
||||
* @author Rammelkast
|
||||
*/
|
||||
@Deprecated
|
||||
public class KillAuraCheck {
|
||||
|
||||
private static final Map<UUID, NPC_1_12> NPC_LIST = new HashMap<UUID, NPC_1_12>();
|
||||
private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>();
|
||||
//private static final Map<UUID, NPC_1_12> NPC_LIST = new HashMap<UUID, NPC_1_12>();
|
||||
//private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>();
|
||||
|
||||
public static void cleanPlayer(Player p) {
|
||||
if (!VersionUtil.getVersion().equals("v1_12_R1")) {
|
||||
/*if (!VersionUtil.getVersion().equals("v1_12_R1")) {
|
||||
return;
|
||||
}
|
||||
NPC_LIST.remove(p.getUniqueId());
|
||||
NPC_LIST.remove(p.getUniqueId());*/
|
||||
}
|
||||
|
||||
public static void listenPackets() {
|
||||
if (!VersionUtil.getVersion().equals("v1_12_R1")) {
|
||||
/*if (!VersionUtil.getVersion().equals("v1_12_R1")) {
|
||||
return;
|
||||
}
|
||||
AntiCheatReloaded.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(),
|
||||
@@ -86,11 +72,11 @@ public class KillAuraCheck {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});*/
|
||||
}
|
||||
|
||||
public static void doDamageEvent(EntityDamageByEntityEvent e, Player p) {
|
||||
if (!VersionUtil.getVersion().equals("v1_12_R1")) {
|
||||
/*if (!VersionUtil.getVersion().equals("v1_12_R1")) {
|
||||
return;
|
||||
}
|
||||
if (NPC_LIST.containsKey(p.getUniqueId()))
|
||||
@@ -99,16 +85,16 @@ public class KillAuraCheck {
|
||||
NPC_1_12 npc = new NPC_1_12(p);
|
||||
NPC_LIST.put(p.getUniqueId(), npc);
|
||||
npc.spawn();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public static void doMove(PlayerMoveEvent e) {
|
||||
if (!VersionUtil.getVersion().equals("v1_12_R1")) {
|
||||
/*if (!VersionUtil.getVersion().equals("v1_12_R1")) {
|
||||
return;
|
||||
}
|
||||
if (NPC_LIST.containsKey(e.getPlayer().getUniqueId())) {
|
||||
NPC_LIST.get(e.getPlayer().getUniqueId()).move(e);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@@ -35,6 +36,7 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
/**
|
||||
* @author Rammelkast
|
||||
@@ -49,7 +51,7 @@ public class BlinkCheck {
|
||||
public void run() {
|
||||
MOVE_COUNT.clear();
|
||||
}
|
||||
}.runTaskTimer(AntiCheatReloaded.getPlugin(), 20, 20);
|
||||
}.runTaskTimer(AntiCheatReloaded.getPlugin(), 100, 20);
|
||||
}
|
||||
|
||||
public static void listenPackets() {
|
||||
@@ -67,18 +69,35 @@ public class BlinkCheck {
|
||||
if (AntiCheatReloaded.getManager().getCheckManager().checkInWorld(p)
|
||||
&& !AntiCheatReloaded.getManager().getCheckManager().isOpExempt(p)
|
||||
&& !AntiCheatReloaded.getManager().getCheckManager().isExempt(p, CheckType.BLINK)) {
|
||||
if (MOVE_COUNT.get(p.getUniqueId()) > AntiCheatReloaded.getManager().getBackend()
|
||||
.getMagic().BLINK_PACKET()) {
|
||||
EventListener.log(
|
||||
new CheckResult(CheckResult.Result.FAILED, p.getName()
|
||||
+ " failed Blink, sent " + MOVE_COUNT.get(p.getUniqueId())
|
||||
+ " packets in one second (max=" + AntiCheatReloaded.getManager()
|
||||
.getBackend().getMagic().BLINK_PACKET()
|
||||
+ ")").getMessage(),
|
||||
p, CheckType.BLINK);
|
||||
MOVE_COUNT.remove(p.getUniqueId());
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().teleport(cur);
|
||||
int ping = VersionUtil.getPlayerPing(p);
|
||||
int blinkMagic = AntiCheatReloaded.getManager().getBackend()
|
||||
.getMagic().BLINK_PACKET();
|
||||
float pingLeniency = (float) ((ping / 150));
|
||||
if (pingLeniency < 1) pingLeniency = 1;
|
||||
if (pingLeniency > 3) pingLeniency = 3;
|
||||
blinkMagic = Math.round(pingLeniency * blinkMagic);
|
||||
final float finalPingLeniency = pingLeniency;
|
||||
try {
|
||||
if (MOVE_COUNT.get(p.getUniqueId()) > blinkMagic) {
|
||||
final int packets = MOVE_COUNT.get(p.getUniqueId());
|
||||
MOVE_COUNT.remove(p.getUniqueId());
|
||||
AntiCheatReloaded.sendToMainThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EventListener.log(
|
||||
new CheckResult(CheckResult.Result.FAILED, p.getName()
|
||||
+ " failed Blink, sent " + packets
|
||||
+ " packets in one second (max=" + AntiCheatReloaded.getManager()
|
||||
.getBackend().getMagic().BLINK_PACKET()
|
||||
+ ", leniency=" + finalPingLeniency + ", ping=" + ping + ")").getMessage(),
|
||||
p, CheckType.BLINK);
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().teleport(cur);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (NullPointerException nullPointer) {
|
||||
// TODO this is thrown sometimes, might have something to do with line 83
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,16 +40,17 @@ public class ElytraCheck {
|
||||
// This was a teleport, so skip check.
|
||||
return PASS;
|
||||
}
|
||||
if (!FlightCheck.isMovingExempt(player) && !Utilities.isHoveringOverWater(player.getLocation(), 1)
|
||||
/*if (!FlightCheck.isMovingExempt(player) && !Utilities.isHoveringOverWater(player.getLocation(), 1)
|
||||
&& Utilities.cantStandAtExp(player.getLocation())
|
||||
&& Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN),
|
||||
new Material[] { Material.FENCE, Material.FENCE_GATE, Material.COBBLE_WALL,
|
||||
Material.ACACIA_FENCE, Material.ACACIA_FENCE_GATE, Material.BIRCH_FENCE,
|
||||
Material.BIRCH_FENCE_GATE, Material.DARK_OAK_FENCE, Material.DARK_OAK_FENCE_GATE,
|
||||
Material.IRON_FENCE, Material.JUNGLE_FENCE, Material.JUNGLE_FENCE_GATE,
|
||||
Material.NETHER_FENCE, Material.SPRUCE_FENCE, Material.SPRUCE_FENCE_GATE, Material.IRON_BARDING })) {
|
||||
Material.fence, Material.SPRUCE_FENCE, Material.SPRUCE_FENCE_GATE, Material.IRON_BARS })) {
|
||||
|
||||
}
|
||||
}*/
|
||||
//TODO 1.15 update
|
||||
|
||||
return PASS;
|
||||
}
|
||||
|
||||
@@ -56,11 +56,11 @@ public class FlightCheck {
|
||||
if (!isMovingExempt(player) && !Utilities.isHoveringOverWater(player.getLocation(), 1)
|
||||
&& Utilities.cantStandAtExp(player.getLocation())
|
||||
&& Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN),
|
||||
new Material[] { Material.FENCE, Material.FENCE_GATE, Material.COBBLE_WALL,
|
||||
Material.ACACIA_FENCE, Material.ACACIA_FENCE_GATE, Material.BIRCH_FENCE,
|
||||
Material.BIRCH_FENCE_GATE, Material.DARK_OAK_FENCE, Material.DARK_OAK_FENCE_GATE,
|
||||
Material.IRON_FENCE, Material.JUNGLE_FENCE, Material.JUNGLE_FENCE_GATE,
|
||||
Material.NETHER_FENCE, Material.SPRUCE_FENCE, Material.SPRUCE_FENCE_GATE, Material.IRON_BARDING })) {
|
||||
new Material[] { Material.IRON_BARS })
|
||||
&& Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN), new String[] {
|
||||
"FENCE",
|
||||
"FENCE_GATE"
|
||||
})) {
|
||||
|
||||
if (!blocksOverFlight.containsKey(uuid)) {
|
||||
blocksOverFlight.put(uuid, 0D);
|
||||
|
||||
@@ -24,17 +24,13 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
public class GlideCheck {
|
||||
@@ -49,6 +45,9 @@ public class GlideCheck {
|
||||
if (VersionUtil.isFlying(player)) {
|
||||
return PASS;
|
||||
}
|
||||
if (player.getLocation().getBlock().getType() == Material.LADDER || player.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) {
|
||||
return PASS;
|
||||
}
|
||||
if (!lastDiff.containsKey(player.getUniqueId())) {
|
||||
lastDiff.put(player.getUniqueId(), distance.getYDifference());
|
||||
return PASS;
|
||||
|
||||
@@ -69,7 +69,7 @@ public class WaterWalkCheck {
|
||||
}
|
||||
if (!b && !Utilities.isFullyInWater(player.getLocation())
|
||||
&& Utilities.isHoveringOverWater(player.getLocation(), 1) && y == 0D
|
||||
&& !block.getType().equals(Material.WATER_LILY)) {
|
||||
&& !block.getType().equals(Material.LILY_PAD)) {
|
||||
b = true;
|
||||
}
|
||||
if (b) {
|
||||
|
||||
@@ -126,7 +126,8 @@ public class YAxisCheck {
|
||||
}
|
||||
|
||||
public static boolean isMoveUpBlock(Block block) {
|
||||
return VersionUtil.getMoveUpBlocks().contains(block.getType());
|
||||
Material type = block.getType();
|
||||
return type.name().endsWith("STAIRS"); // TODO slabs/others?
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user