mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 14:38:45 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0288a9734a | ||
|
|
a7419e3968 | ||
|
|
df3c410436 | ||
|
|
27bb684736 | ||
|
|
aa9fa9b290 | ||
|
|
da4a61e228 | ||
|
|
9771387909 | ||
|
|
76c595e255 | ||
|
|
91f5fcd31c | ||
|
|
80b5e64924 | ||
|
|
67e824ef28 | ||
|
|
661718d001 | ||
|
|
7c9a05ff92 |
No files matched your search
@@ -1,10 +1,11 @@
|
|||||||
AntiCheatReloaded
|
AntiCheatReloaded
|
||||||
=============
|
=============
|
||||||
AntiCheatReloaded helps server admins easily identify and block malicious users by monitoring and analyzing the behaviour of their players. It is based on one of the oldest anti-cheats in the community, AntiCheat.
|
AntiCheatReloaded helps server admins combat the use of hacked clients and spambots. It analyses the behavior of players and can prevent malicious gameplay. The plugin offers a lot of customizability and can be connected across multiple servers in case it is used in a server network context. AntiCheatReloaded is based on gravitylow's AntiCheat and has been around since 2012.
|
||||||
|
|
||||||
+ BTC donations: bc1q5qgmzq9e63h7ptf3kneg78uf0mghtwsmvwxt8m
|
Installation
|
||||||
+ LTC donations: LYZLe6AGRQZTey5UHe7CCF3e9HAyQooSmh
|
------------
|
||||||
+ ETH donations: 0x2a2171fB3600fc67951734c2872E0Ad742741Cf2
|
AntiCheatReloaded requires you to have ProtocolLib. You can download it [here](https://www.spigotmc.org/resources/protocollib.1997/).
|
||||||
|
Simply drag and drop the AntiCheatReloaded and ProtocolLib jars in your plugin folder. You can now use AntiCheatReloaded, but be sure to have a look at the configuration files, which allow you to change every aspect of the plugin.
|
||||||
|
|
||||||
Bug Reporting
|
Bug Reporting
|
||||||
------------
|
------------
|
||||||
@@ -18,13 +19,8 @@ Please include the following information with your issue, this allows me to fix
|
|||||||
* Whether or not you are using protocol hacks (ViaVersion etc.)
|
* Whether or not you are using protocol hacks (ViaVersion etc.)
|
||||||
* Any logs relating to the issue
|
* Any logs relating to the issue
|
||||||
|
|
||||||
Usage
|
|
||||||
-------
|
|
||||||
Simply drag and drop the plugin file and the ProtocolLib jar into your Plugins folder.
|
|
||||||
|
|
||||||
Hacks blocked
|
Hacks blocked
|
||||||
-------
|
-------
|
||||||
* Blink
|
|
||||||
* Flight
|
* Flight
|
||||||
* Glide
|
* Glide
|
||||||
* Jesus
|
* Jesus
|
||||||
@@ -39,7 +35,6 @@ Hacks blocked
|
|||||||
* NoFall
|
* NoFall
|
||||||
* Sneak
|
* Sneak
|
||||||
* vClip
|
* vClip
|
||||||
* Timer
|
|
||||||
* FastBreak
|
* FastBreak
|
||||||
* FastPlace
|
* FastPlace
|
||||||
* Spam
|
* Spam
|
||||||
@@ -49,3 +44,5 @@ Hacks blocked
|
|||||||
* GhostHand
|
* GhostHand
|
||||||
* KillAura
|
* KillAura
|
||||||
* Scaffold
|
* Scaffold
|
||||||
|
* MorePackets
|
||||||
|
* BadPackets
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.rammelkast.anticheatreloaded</groupId>
|
<groupId>com.rammelkast.anticheatreloaded</groupId>
|
||||||
<artifactId>AntiCheatReloaded</artifactId>
|
<artifactId>AntiCheatReloaded</artifactId>
|
||||||
<version>1.8.0</version>
|
<version>1.8.1</version>
|
||||||
<name>AntiCheatReloaded</name>
|
<name>AntiCheatReloaded</name>
|
||||||
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
|
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
|
||||||
<properties>
|
<properties>
|
||||||
@@ -44,6 +44,7 @@
|
|||||||
<artifactSet>
|
<artifactSet>
|
||||||
<includes>
|
<includes>
|
||||||
<include>com.rammelkast.*</include>
|
<include>com.rammelkast.*</include>
|
||||||
|
<include>com.cryptomorin.*</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -70,6 +71,12 @@
|
|||||||
<artifactId>ProtocolLib</artifactId>
|
<artifactId>ProtocolLib</artifactId>
|
||||||
<version>4.5.1-SNAPSHOT</version>
|
<version>4.5.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot</artifactId>
|
||||||
|
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck;
|
||||||
import com.rammelkast.anticheatreloaded.check.movement.BlinkCheck;
|
|
||||||
import com.rammelkast.anticheatreloaded.command.CommandHandler;
|
import com.rammelkast.anticheatreloaded.command.CommandHandler;
|
||||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
import com.rammelkast.anticheatreloaded.event.BlockListener;
|
import com.rammelkast.anticheatreloaded.event.BlockListener;
|
||||||
@@ -44,23 +44,27 @@ import com.rammelkast.anticheatreloaded.event.PlayerListener;
|
|||||||
import com.rammelkast.anticheatreloaded.event.VehicleListener;
|
import com.rammelkast.anticheatreloaded.event.VehicleListener;
|
||||||
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||||
import com.rammelkast.anticheatreloaded.metrics.Metrics;
|
import com.rammelkast.anticheatreloaded.metrics.Metrics;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.PacketListener;
|
||||||
import com.rammelkast.anticheatreloaded.util.UpdateManager;
|
import com.rammelkast.anticheatreloaded.util.UpdateManager;
|
||||||
import com.rammelkast.anticheatreloaded.util.User;
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
public class AntiCheatReloaded extends JavaPlugin {
|
public class AntiCheatReloaded extends JavaPlugin {
|
||||||
|
|
||||||
|
public static final List<UUID> MUTE_ENABLED_MODS = new ArrayList<UUID>();
|
||||||
|
|
||||||
private static AntiCheatManager manager;
|
private static AntiCheatManager manager;
|
||||||
private static AntiCheatReloaded plugin;
|
private static AntiCheatReloaded plugin;
|
||||||
private static List<Listener> eventList = new ArrayList<Listener>();
|
private static List<Listener> eventList = new ArrayList<Listener>();
|
||||||
private static Configuration config;
|
private static Configuration config;
|
||||||
private static boolean verbose;
|
private static boolean verbose;
|
||||||
private static boolean developer;
|
|
||||||
private static ProtocolManager protocolManager;
|
private static ProtocolManager protocolManager;
|
||||||
private static SecureRandom random;
|
private static SecureRandom random;
|
||||||
private static Long loadTime;
|
private static Long loadTime;
|
||||||
private static UpdateManager updateManager;
|
private static UpdateManager updateManager;
|
||||||
|
|
||||||
|
private double tps = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
plugin = this;
|
plugin = this;
|
||||||
@@ -91,14 +95,13 @@ public class AntiCheatReloaded extends JavaPlugin {
|
|||||||
|
|
||||||
getLogger().info("NMS version is " + VersionUtil.getVersion());
|
getLogger().info("NMS version is " + VersionUtil.getVersion());
|
||||||
if (!VersionUtil.isSupported()) {
|
if (!VersionUtil.isSupported()) {
|
||||||
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.RED + "The version of this server is NOT supported by ACR! The plugin will be buggy!");
|
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.RED
|
||||||
|
+ "The version of this server is NOT supported by ACR! The plugin will not work as expected!");
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger().info("Enabling checks that use ProtcolLib");
|
getLogger().info("Enabling packet listeners");
|
||||||
// Enable packetlisteners
|
PacketListener.listenKeepAlivePackets();
|
||||||
BlinkCheck.startTimer();
|
PacketListener.listenMovementPackets();
|
||||||
BlinkCheck.listenPackets();
|
|
||||||
KillAuraCheck.listenPackets();
|
|
||||||
|
|
||||||
updateManager = new UpdateManager();
|
updateManager = new UpdateManager();
|
||||||
|
|
||||||
@@ -132,6 +135,26 @@ public class AntiCheatReloaded extends JavaPlugin {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Launch TPS check
|
||||||
|
new BukkitRunnable() {
|
||||||
|
long sec;
|
||||||
|
long currentSec;
|
||||||
|
int ticks;
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
sec = (System.currentTimeMillis() / 1000L);
|
||||||
|
if (currentSec == sec) {
|
||||||
|
ticks += 1;
|
||||||
|
} else {
|
||||||
|
currentSec = sec;
|
||||||
|
tps = (tps == 0.0D ? ticks : (tps + ticks) / 2.0D);
|
||||||
|
ticks = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskTimer(this, 40L, 1L);
|
||||||
|
// Launch MorePackets timer
|
||||||
|
MorePacketsCheck.startTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -209,18 +232,10 @@ public class AntiCheatReloaded extends JavaPlugin {
|
|||||||
config = null;
|
config = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean developerMode() {
|
|
||||||
return developer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setDeveloperMode(boolean b) {
|
|
||||||
developer = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void debugLog(final String string) {
|
public static void debugLog(final String string) {
|
||||||
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
|
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (developer) {
|
if (getManager().getConfiguration().getConfig().debugMode.getValue()) {
|
||||||
manager.debugLog("[DEBUG] " + string);
|
manager.debugLog("[DEBUG] " + string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,15 +270,29 @@ public class AntiCheatReloaded extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void sendToMainThread(Runnable runnable) {
|
public static void sendToMainThread(Runnable runnable) {
|
||||||
Bukkit.getServer().getScheduler().runTask(AntiCheatReloaded.getPlugin(), runnable);
|
Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendToStaff(String message) {
|
public void sendToStaff(String message) {
|
||||||
Bukkit.broadcast(message, "anticheat.system.alert");
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
|
if (player.hasPermission("anticheat.system.alert")) {
|
||||||
|
if (!MUTE_ENABLED_MODS.contains(player.getUniqueId())) {
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Bukkit.getConsoleSender().sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UpdateManager getUpdateManager() {
|
public static UpdateManager getUpdateManager() {
|
||||||
return updateManager;
|
return updateManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getTPS() {
|
||||||
|
if (this.tps < 0 || this.tps > 20) {
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
return this.tps;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.rammelkast.anticheatreloaded.check;
|
package com.rammelkast.anticheatreloaded.check;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -31,22 +30,20 @@ import org.bukkit.GameMode;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
|
||||||
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||||
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
|
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
|
||||||
import com.rammelkast.anticheatreloaded.check.movement.BlinkCheck;
|
|
||||||
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
|
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
|
||||||
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
|
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
|
||||||
import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
|
import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
|
||||||
import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck;
|
import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck;
|
||||||
import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck;
|
import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck;
|
||||||
import com.rammelkast.anticheatreloaded.check.movement.YAxisCheck;
|
import com.rammelkast.anticheatreloaded.check.movement.YAxisCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck;
|
||||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
import com.rammelkast.anticheatreloaded.config.providers.Lang;
|
import com.rammelkast.anticheatreloaded.config.providers.Lang;
|
||||||
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
||||||
@@ -57,8 +54,8 @@ import com.rammelkast.anticheatreloaded.util.Utilities;
|
|||||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
public class Backend {
|
public class Backend {
|
||||||
|
public Map<UUID, Long> velocitized = new HashMap<UUID, Long>();
|
||||||
private List<UUID> isAscending = new ArrayList<UUID>();
|
private List<UUID> isAscending = new ArrayList<UUID>();
|
||||||
private Map<UUID, Integer> ascensionCount = new HashMap<UUID, Integer>();
|
|
||||||
private Map<UUID, Integer> chatLevel = new HashMap<UUID, Integer>();
|
private Map<UUID, Integer> chatLevel = new HashMap<UUID, Integer>();
|
||||||
private Map<UUID, Integer> commandLevel = new HashMap<UUID, Integer>();
|
private Map<UUID, Integer> commandLevel = new HashMap<UUID, Integer>();
|
||||||
private Map<UUID, Integer> nofallViolation = new HashMap<UUID, Integer>();
|
private Map<UUID, Integer> nofallViolation = new HashMap<UUID, Integer>();
|
||||||
@@ -71,7 +68,6 @@ public class Backend {
|
|||||||
private Map<UUID, Long> lastBlockPlaceTime = new HashMap<UUID, Long>();
|
private Map<UUID, Long> lastBlockPlaceTime = new HashMap<UUID, Long>();
|
||||||
private Map<UUID, Integer> blockPunches = new HashMap<UUID, Integer>();
|
private Map<UUID, Integer> blockPunches = new HashMap<UUID, Integer>();
|
||||||
private Map<UUID, Integer> projectilesShot = new HashMap<UUID, Integer>();
|
private Map<UUID, Integer> projectilesShot = new HashMap<UUID, Integer>();
|
||||||
private Map<UUID, Long> velocitized = new HashMap<UUID, Long>();
|
|
||||||
private Map<UUID, Integer> velocitytrack = new HashMap<UUID, Integer>();
|
private Map<UUID, Integer> velocitytrack = new HashMap<UUID, Integer>();
|
||||||
private Map<UUID, Long> startEat = new HashMap<UUID, Long>();
|
private Map<UUID, Long> startEat = new HashMap<UUID, Long>();
|
||||||
private Map<UUID, Long> lastHeal = new HashMap<UUID, Long>();
|
private Map<UUID, Long> lastHeal = new HashMap<UUID, Long>();
|
||||||
@@ -87,11 +83,9 @@ public class Backend {
|
|||||||
private Map<UUID, Long> inventoryTime = new HashMap<UUID, Long>();
|
private Map<UUID, Long> inventoryTime = new HashMap<UUID, Long>();
|
||||||
private Map<UUID, Integer> inventoryClicks = new HashMap<UUID, Integer>();
|
private Map<UUID, Integer> inventoryClicks = new HashMap<UUID, Integer>();
|
||||||
private Map<UUID, Material> itemInHand = new HashMap<UUID, Material>();
|
private Map<UUID, Material> itemInHand = new HashMap<UUID, Material>();
|
||||||
private Map<UUID, Integer> steps = new HashMap<UUID, Integer>();
|
|
||||||
private Map<UUID, Long> stepTime = new HashMap<UUID, Long>();
|
|
||||||
private HashSet<Byte> transparent = new HashSet<Byte>();
|
private HashSet<Byte> transparent = new HashSet<Byte>();
|
||||||
private Map<UUID, Long> lastFallPacket = new HashMap<UUID, Long>();
|
private Map<UUID, Long> lastFallPacket = new HashMap<UUID, Long>();
|
||||||
private Map<String, Integer> fastSneakViolations = new HashMap<String, Integer>();
|
private Map<UUID, Integer> fastSneakViolations = new HashMap<UUID, Integer>();
|
||||||
|
|
||||||
private Magic magic;
|
private Magic magic;
|
||||||
private AntiCheatManager manager = null;
|
private AntiCheatManager manager = null;
|
||||||
@@ -119,68 +113,66 @@ public class Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void garbageClean(Player player) {
|
public void garbageClean(Player player) {
|
||||||
UUID pU = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
|
|
||||||
VelocityCheck.cleanPlayer(player);
|
blocksDropped.remove(uuid);
|
||||||
BlinkCheck.MOVE_COUNT.remove(player.getUniqueId());
|
blockTime.remove(uuid);
|
||||||
blocksDropped.remove(pU);
|
brokenBlock.remove(uuid);
|
||||||
blockTime.remove(pU);
|
placedBlock.remove(uuid);
|
||||||
FlightCheck.MOVING_EXEMPT.remove(pU);
|
bowWindUp.remove(uuid);
|
||||||
brokenBlock.remove(pU);
|
startEat.remove(uuid);
|
||||||
placedBlock.remove(pU);
|
lastHeal.remove(uuid);
|
||||||
bowWindUp.remove(pU);
|
sprinted.remove(uuid);
|
||||||
startEat.remove(pU);
|
instantBreakExempt.remove(uuid);
|
||||||
lastHeal.remove(pU);
|
isAscending.remove(uuid);
|
||||||
sprinted.remove(pU);
|
nofallViolation.remove(uuid);
|
||||||
WaterWalkCheck.IS_IN_WATER.remove(pU);
|
fastBreakViolation.remove(uuid);
|
||||||
WaterWalkCheck.IS_IN_WATER_CACHE.remove(pU);
|
fastBreaks.remove(uuid);
|
||||||
instantBreakExempt.remove(pU);
|
blockBreakHolder.remove(uuid);
|
||||||
isAscending.remove(player.getUniqueId());
|
lastBlockBroken.remove(uuid);
|
||||||
ascensionCount.remove(player.getUniqueId());
|
fastPlaceViolation.remove(uuid);
|
||||||
FlightCheck.BLOCKS_OVER_FLIGHT.remove(pU);
|
lastBlockPlaced.remove(uuid);
|
||||||
nofallViolation.remove(pU);
|
lastBlockPlaceTime.remove(uuid);
|
||||||
fastBreakViolation.remove(pU);
|
blockPunches.remove(uuid);
|
||||||
YAxisCheck.Y_AXIS_VIOLATIONS.remove(pU);
|
projectilesShot.remove(uuid);
|
||||||
YAxisCheck.LAST_Y_AXIS_VIOLATION.remove(pU);
|
velocitized.remove(uuid);
|
||||||
YAxisCheck.LAST_Y_COORD_CACHE.remove(pU);
|
velocitytrack.remove(uuid);
|
||||||
YAxisCheck.LAST_Y_TIME.remove(pU);
|
startEat.remove(uuid);
|
||||||
fastBreaks.remove(pU);
|
lastHeal.remove(uuid);
|
||||||
blockBreakHolder.remove(pU);
|
projectileTime.remove(uuid);
|
||||||
lastBlockBroken.remove(pU);
|
bowWindUp.remove(uuid);
|
||||||
fastPlaceViolation.remove(pU);
|
instantBreakExempt.remove(uuid);
|
||||||
lastBlockPlaced.remove(pU);
|
sprinted.remove(uuid);
|
||||||
lastBlockPlaceTime.remove(pU);
|
brokenBlock.remove(uuid);
|
||||||
blockPunches.remove(pU);
|
placedBlock.remove(uuid);
|
||||||
WaterWalkCheck.WATER_ASCENSION_VIOLATIONS.remove(pU);
|
blockTime.remove(uuid);
|
||||||
WaterWalkCheck.WATER_SPEED_VIOLATIONS.remove(pU);
|
blocksDropped.remove(uuid);
|
||||||
projectilesShot.remove(pU);
|
lastInventoryTime.remove(uuid);
|
||||||
velocitized.remove(pU);
|
inventoryTime.remove(uuid);
|
||||||
velocitytrack.remove(pU);
|
inventoryClicks.remove(uuid);
|
||||||
startEat.remove(pU);
|
lastFallPacket.remove(uuid);
|
||||||
lastHeal.remove(pU);
|
fastSneakViolations.remove(uuid);
|
||||||
projectileTime.remove(pU);
|
VelocityCheck.VIOLATIONS.remove(uuid);
|
||||||
bowWindUp.remove(pU);
|
MorePacketsCheck.MOVE_COUNT.remove(uuid);
|
||||||
instantBreakExempt.remove(pU);
|
GlideCheck.LAST_MOTION_Y.remove(uuid);
|
||||||
sprinted.remove(pU);
|
GlideCheck.LAST_FALL_DISTANCE.remove(uuid);
|
||||||
brokenBlock.remove(pU);
|
GlideCheck.VIOLATIONS.remove(uuid);
|
||||||
placedBlock.remove(pU);
|
SpeedCheck.SPEED_VIOLATIONS.remove(uuid);
|
||||||
FlightCheck.MOVING_EXEMPT.remove(pU);
|
ElytraCheck.JUMP_Y_VALUE.remove(uuid);
|
||||||
blockTime.remove(pU);
|
KillAuraCheck.ANGLE_FLAGS.remove(uuid);
|
||||||
blocksDropped.remove(pU);
|
KillAuraCheck.PITCH_MOVEMENTS_CACHE.remove(uuid);
|
||||||
lastInventoryTime.remove(pU);
|
KillAuraCheck.GCD_CACHE.remove(uuid);
|
||||||
inventoryTime.remove(pU);
|
FlightCheck.MOVING_EXEMPT.remove(uuid);
|
||||||
inventoryClicks.remove(pU);
|
FlightCheck.ASCENSION_COUNT.remove(uuid);
|
||||||
lastFallPacket.remove(pU);
|
FlightCheck.BLOCKS_OVER_FLIGHT.remove(uuid);
|
||||||
fastSneakViolations.remove(player.getUniqueId().toString());
|
YAxisCheck.Y_AXIS_VIOLATIONS.remove(uuid);
|
||||||
GlideCheck.LAST_DIFFERENCE.remove(pU);
|
YAxisCheck.LAST_Y_AXIS_VIOLATION.remove(uuid);
|
||||||
GlideCheck.LAST_FALL_DISTANCE.remove(pU);
|
YAxisCheck.LAST_Y_COORD_CACHE.remove(uuid);
|
||||||
GlideCheck.VIOLATIONS.remove(pU);
|
YAxisCheck.LAST_Y_TIME.remove(uuid);
|
||||||
SpeedCheck.SPEED_VIOLATIONS.remove(player.getUniqueId());
|
WaterWalkCheck.IS_IN_WATER.remove(uuid);
|
||||||
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId().toString());
|
WaterWalkCheck.IS_IN_WATER_CACHE.remove(uuid);
|
||||||
KillAuraCheck.ANGLE_FLAGS.remove(player.getUniqueId().toString());
|
WaterWalkCheck.WATER_ASCENSION_VIOLATIONS.remove(uuid);
|
||||||
KillAuraCheck.CLICKSPEED_MAP.remove(player.getUniqueId().toString());
|
WaterWalkCheck.WATER_SPEED_VIOLATIONS.remove(uuid);
|
||||||
KillAuraCheck.DEVIATION_SCORES.remove(player.getUniqueId().toString());
|
|
||||||
KillAuraCheck.DIFF_MAP.remove(player.getUniqueId().toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckResult checkFastBow(Player player, float force) {
|
public CheckResult checkFastBow(Player player, float force) {
|
||||||
@@ -194,7 +186,8 @@ public class Backend {
|
|||||||
f = (f * f + f * 2.0F) / 3.0F;
|
f = (f * f + f * 2.0F) / 3.0F;
|
||||||
f = f > 1.0F ? 1.0F : f;
|
f = f > 1.0F ? 1.0F : f;
|
||||||
if (Math.abs(force - f) > magic.BOW_ERROR()) {
|
if (Math.abs(force - f) > magic.BOW_ERROR()) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "fired their bow too fast (actual force=" + force + ", calculated force=" + f + ")");
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"fired their bow too fast (actual force=" + force + ", calculated force=" + f + ")");
|
||||||
} else {
|
} else {
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
@@ -210,7 +203,8 @@ public class Backend {
|
|||||||
projectileTime.remove(player.getUniqueId());
|
projectileTime.remove(player.getUniqueId());
|
||||||
projectilesShot.remove(player.getUniqueId());
|
projectilesShot.remove(player.getUniqueId());
|
||||||
if (time < magic.PROJECTILE_TIME_MIN()) {
|
if (time < magic.PROJECTILE_TIME_MIN()) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "wound up a bow too fast (actual time=" + time + ", min time=" + magic.PROJECTILE_TIME_MIN() + ")");
|
return new CheckResult(CheckResult.Result.FAILED, "wound up a bow too fast (actual time=" + time
|
||||||
|
+ ", min time=" + magic.PROJECTILE_TIME_MIN() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PASS;
|
return PASS;
|
||||||
@@ -226,7 +220,8 @@ public class Backend {
|
|||||||
blockTime.remove(player.getUniqueId());
|
blockTime.remove(player.getUniqueId());
|
||||||
blocksDropped.remove(player.getUniqueId());
|
blocksDropped.remove(player.getUniqueId());
|
||||||
if (time < magic.DROP_TIME_MIN()) {
|
if (time < magic.DROP_TIME_MIN()) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED,"dropped an item too fast (actual time=" + time + ", min time=" + magic.DROP_TIME_MIN() + ")");
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"dropped an item too fast (actual time=" + time + ", min time=" + magic.DROP_TIME_MIN() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PASS;
|
return PASS;
|
||||||
@@ -237,13 +232,13 @@ public class Backend {
|
|||||||
return new CheckResult(CheckResult.Result.PASSED);
|
return new CheckResult(CheckResult.Result.PASSED);
|
||||||
} else {
|
} else {
|
||||||
String string = "reached too far for a block";
|
String string = "reached too far for a block";
|
||||||
double distance =
|
double distance = player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
||||||
player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
|
||||||
: player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
: player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
||||||
: magic.BLOCK_MAX_DISTANCE();
|
: magic.BLOCK_MAX_DISTANCE();
|
||||||
double i = x >= distance ? x : y > distance ? y : z > distance ? z : -1;
|
double i = x >= distance ? x : y > distance ? y : z > distance ? z : -1;
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, string + " (distance=" + i + ", max=" + magic.BLOCK_MAX_DISTANCE() + ")");
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
string + " (distance=" + i + ", max=" + magic.BLOCK_MAX_DISTANCE() + ")");
|
||||||
} else {
|
} else {
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
@@ -252,25 +247,35 @@ public class Backend {
|
|||||||
|
|
||||||
public CheckResult checkLongReachDamage(Player player, double x, double y, double z) {
|
public CheckResult checkLongReachDamage(Player player, double x, double y, double z) {
|
||||||
String string = "reached too far for an entity";
|
String string = "reached too far for an entity";
|
||||||
double i = x >= magic.ENTITY_MAX_DISTANCE() ? x : y > magic.ENTITY_MAX_DISTANCE() ? y : z > magic.ENTITY_MAX_DISTANCE() ? z : -1;
|
double i = x >= magic.ENTITY_MAX_DISTANCE() ? x
|
||||||
|
: y > magic.ENTITY_MAX_DISTANCE() ? y : z > magic.ENTITY_MAX_DISTANCE() ? z : -1;
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, string + " (distance=" + i + ", max=" + magic.ENTITY_MAX_DISTANCE() + ")");
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
string + " (distance=" + i + ", max=" + magic.ENTITY_MAX_DISTANCE() + ")");
|
||||||
} else {
|
} else {
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckResult checkSpider(Player player, double y) {
|
public CheckResult checkSpider(Player player, double y) {
|
||||||
if (y <= magic.LADDER_Y_MAX() && y >= magic.LADDER_Y_MIN() && !Utilities.isClimbableBlock(player.getLocation().getBlock())) {
|
if (y <= magic.LADDER_Y_MAX() && y >= magic.LADDER_Y_MIN()
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "tried to climb a non-ladder (" + player.getLocation().getBlock().getType() + ")");
|
&& !Utilities.isClimbableBlock(player.getLocation().getBlock())
|
||||||
|
&& !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
|
||||||
|
&& !Utilities.isClimbableBlock(player.getLocation().clone().add(0, -0.98, 0).getBlock())) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"tried to climb a non-climbable block (" + player.getLocation().getBlock().getType() + ")");
|
||||||
} else {
|
} else {
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckResult checkYSpeed(Player player, double y) {
|
public CheckResult checkYSpeed(Player player, double y) {
|
||||||
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)) {
|
if (!isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping() && (y > magic.Y_SPEED_MAX())
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "y speed was too high (speed=" + y + ", max=" + magic.Y_SPEED_MAX() + ")");
|
&& !isDoing(player, velocitized, magic.VELOCITY_TIME())
|
||||||
|
&& !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)
|
||||||
|
&& !Utilities.isSlime(player.getLocation().getBlock())) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"y speed was too high (speed=" + y + ", max=" + magic.Y_SPEED_MAX() + ")");
|
||||||
} else {
|
} else {
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
@@ -278,7 +283,10 @@ public class Backend {
|
|||||||
|
|
||||||
public CheckResult checkNoFall(Player player, double y) {
|
public CheckResult checkNoFall(Player player, double y) {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping() && !isMovingExempt(player) && !justPlaced(player) && !Utilities.isInWater(player) && !Utilities.isInWeb(player)) {
|
if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping()
|
||||||
|
&& !isMovingExempt(player) && !justPlaced(player) && !Utilities.isInWater(player)
|
||||||
|
&& !Utilities.isInWeb(player)
|
||||||
|
&& !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")) {
|
||||||
if (player.getFallDistance() == 0) {
|
if (player.getFallDistance() == 0) {
|
||||||
if (nofallViolation.get(uuid) == null) {
|
if (nofallViolation.get(uuid) == null) {
|
||||||
nofallViolation.put(uuid, 1);
|
nofallViolation.put(uuid, 1);
|
||||||
@@ -289,7 +297,8 @@ public class Backend {
|
|||||||
int i = nofallViolation.get(uuid);
|
int i = nofallViolation.get(uuid);
|
||||||
if (i >= magic.NOFALL_LIMIT()) {
|
if (i >= magic.NOFALL_LIMIT()) {
|
||||||
nofallViolation.put(player.getUniqueId(), 1);
|
nofallViolation.put(player.getUniqueId(), 1);
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "tried to avoid fall damage (fall distance = 0 " + i + " times in a row, max=" + magic.NOFALL_LIMIT() + ")");
|
return new CheckResult(CheckResult.Result.FAILED, "tried to avoid fall damage (fall distance = 0 "
|
||||||
|
+ i + " times in a row, max=" + magic.NOFALL_LIMIT() + ")");
|
||||||
} else {
|
} else {
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
@@ -302,34 +311,38 @@ public class Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CheckResult checkSneak(Player player, Location location, double x, double z) {
|
public CheckResult checkSneak(Player player, Location location, double x, double z) {
|
||||||
if (player.isSneaking() && !VersionUtil.isFlying(player) && !isMovingExempt(player) && !player.isInsideVehicle() && !Utilities.cantStandAtExp(location)) {
|
if (player.isSneaking() && !VersionUtil.isFlying(player) && !isMovingExempt(player) && !player.isInsideVehicle()
|
||||||
|
&& !Utilities.cantStandAtExp(location)) {
|
||||||
double i = x > magic.XZ_SPEED_MAX_SNEAK() ? x : z > magic.XZ_SPEED_MAX_SNEAK() ? z : -1;
|
double i = x > magic.XZ_SPEED_MAX_SNEAK() ? x : z > magic.XZ_SPEED_MAX_SNEAK() ? z : -1;
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
if (this.fastSneakViolations.containsKey(player.getUniqueId().toString())) {
|
if (this.fastSneakViolations.containsKey(player.getUniqueId())) {
|
||||||
int flags = this.fastSneakViolations.get(player.getUniqueId().toString());
|
int flags = this.fastSneakViolations.get(player.getUniqueId());
|
||||||
if (flags >= 3) { // TODO possible config
|
if (flags >= 3) { // TODO possible config
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")");
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")");
|
||||||
}
|
}
|
||||||
this.fastSneakViolations.put(player.getUniqueId().toString(), flags + 1);
|
this.fastSneakViolations.put(player.getUniqueId(), flags + 1);
|
||||||
return PASS;
|
return PASS;
|
||||||
} else {
|
} else {
|
||||||
this.fastSneakViolations.put(player.getUniqueId().toString(), 1);
|
this.fastSneakViolations.put(player.getUniqueId(), 1);
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.fastSneakViolations.remove(player.getUniqueId().toString());
|
this.fastSneakViolations.remove(player.getUniqueId());
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.fastSneakViolations.remove(player.getUniqueId().toString());
|
this.fastSneakViolations.remove(player.getUniqueId());
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckResult checkSprintHungry(PlayerToggleSprintEvent event) {
|
public CheckResult checkSprintHungry(PlayerToggleSprintEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (event.isSprinting() && player.getGameMode() != GameMode.CREATIVE && player.getFoodLevel() <= magic.SPRINT_FOOD_MIN()) {
|
if (event.isSprinting() && player.getGameMode() != GameMode.CREATIVE
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "sprinted while hungry (food=" + player.getFoodLevel() + ", min=" + magic.SPRINT_FOOD_MIN() + ")");
|
&& player.getFoodLevel() <= magic.SPRINT_FOOD_MIN()) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"sprinted while hungry (food=" + player.getFoodLevel() + ", min=" + magic.SPRINT_FOOD_MIN() + ")");
|
||||||
} else {
|
} else {
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
@@ -344,35 +357,17 @@ public class Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < (Math.round(distance.getYDifference())) + 1; i++) {
|
for (int i = 0; i < (Math.round(distance.getYDifference())) + 1; i++) {
|
||||||
Block block = new Location(player.getWorld(), player.getLocation().getX(), to + i, player.getLocation().getZ()).getBlock();
|
Block block = new Location(player.getWorld(), player.getLocation().getX(), to + i,
|
||||||
|
player.getLocation().getZ()).getBlock();
|
||||||
if (block.getType() != Material.AIR && block.getType().isSolid()) {
|
if (block.getType() != Material.AIR && block.getType().isSolid()) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "tried to move through a solid block", (int) from + 3);
|
return new CheckResult(CheckResult.Result.FAILED, "tried to move through a solid block",
|
||||||
|
(int) from + 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckResult checkTimer(Player player) {
|
|
||||||
UUID uuid = player.getUniqueId();
|
|
||||||
int step = 1;
|
|
||||||
if (steps.containsKey(uuid)) {
|
|
||||||
step = steps.get(uuid) + 1;
|
|
||||||
}
|
|
||||||
if (step == 1) {
|
|
||||||
stepTime.put(uuid, System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
incrementOld(player, steps, step);
|
|
||||||
if (step == magic.TIMER_STEP_CHECK()) {
|
|
||||||
long time = System.currentTimeMillis() - stepTime.get(uuid);
|
|
||||||
steps.put(uuid, 0);
|
|
||||||
if (time < magic.TIMER_TIMEMIN()) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "tried to alter their timer, took " + step + " steps in " + time + " ms (min = " + magic.TIMER_TIMEMIN() + " ms)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logAscension(Player player, double y1, double y2) {
|
public void logAscension(Player player, double y1, double y2) {
|
||||||
UUID name = player.getUniqueId();
|
UUID name = player.getUniqueId();
|
||||||
if (y1 < y2 && !isAscending.contains(name)) {
|
if (y1 < y2 && !isAscending.contains(name)) {
|
||||||
@@ -382,44 +377,17 @@ public class Backend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckResult checkAscension(Player player, double y1, double y2) {
|
|
||||||
int max = magic.ASCENSION_COUNT_MAX();
|
|
||||||
String string = "";
|
|
||||||
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
|
|
||||||
max += 12;
|
|
||||||
string = " with jump potion";
|
|
||||||
}
|
|
||||||
Block block = player.getLocation().getBlock();
|
|
||||||
if (!isMovingExempt(player) && !Utilities.isInWater(player) && !VersionUtil.isFlying(player)
|
|
||||||
&& !justBroke(player) && !Utilities.isClimbableBlock(player.getLocation().getBlock())
|
|
||||||
&& !player.isInsideVehicle() && !YAxisCheck.isMoveUpBlock(player.getLocation().add(0, -1, 0).getBlock())
|
|
||||||
&& !YAxisCheck.isMoveUpBlock(player.getLocation().add(0, -1.5, 0).getBlock())) {
|
|
||||||
if (y1 < y2) {
|
|
||||||
if (!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid()
|
|
||||||
&& !block.getRelative(BlockFace.EAST).isLiquid()
|
|
||||||
&& !block.getRelative(BlockFace.WEST).isLiquid()) {
|
|
||||||
increment(player, ascensionCount, max);
|
|
||||||
if (ascensionCount.get(player.getUniqueId()) >= max) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED,
|
|
||||||
"ascended " + ascensionCount.get(player.getUniqueId())
|
|
||||||
+ " times in a row (max = " + max + string + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ascensionCount.put(player.getUniqueId(), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkSwing(Player player, Block block) {
|
public CheckResult checkSwing(Player player, Block block) {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
if (!isInstantBreakExempt(player)) {
|
if (!isInstantBreakExempt(player)) {
|
||||||
if (!VersionUtil.getItemInHand(player).containsEnchantment(Enchantment.DIG_SPEED) && !(VersionUtil.getItemInHand(player).getType() == Material.SHEARS && block.getType().name().endsWith("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) {
|
if (blockPunches.get(uuid) != null && player.getGameMode() != GameMode.CREATIVE) {
|
||||||
int i = blockPunches.get(uuid);
|
int i = blockPunches.get(uuid);
|
||||||
if (i < magic.BLOCK_PUNCH_MIN()) {
|
if (i < magic.BLOCK_PUNCH_MIN()) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "tried to break a block of " + block.getType() + " after only " + i + " punches (min=" + magic.BLOCK_PUNCH_MIN() + ")");
|
return new CheckResult(CheckResult.Result.FAILED, "tried to break a block of " + block.getType()
|
||||||
|
+ " after only " + i + " punches (min=" + magic.BLOCK_PUNCH_MIN() + ")");
|
||||||
} else {
|
} else {
|
||||||
blockPunches.put(uuid, 0); // it should reset after EACH block break.
|
blockPunches.put(uuid, 0); // it should reset after EACH block break.
|
||||||
}
|
}
|
||||||
@@ -431,7 +399,8 @@ public class Backend {
|
|||||||
|
|
||||||
public CheckResult checkFastBreak(Player player, Block block) {
|
public CheckResult checkFastBreak(Player player, Block block) {
|
||||||
int violations = magic.FASTBREAK_MAXVIOLATIONS();
|
int violations = magic.FASTBREAK_MAXVIOLATIONS();
|
||||||
long timemax = isInstantBreakExempt(player) ? 0 : Utilities.calcSurvivalFastBreak(VersionUtil.getItemInHand(player), block.getType());
|
long timemax = isInstantBreakExempt(player) ? 0
|
||||||
|
: Utilities.calcSurvivalFastBreak(VersionUtil.getItemInHand(player), block.getType());
|
||||||
if (player.getGameMode() == GameMode.CREATIVE) {
|
if (player.getGameMode() == GameMode.CREATIVE) {
|
||||||
violations = magic.FASTBREAK_MAXVIOLATIONS_CREATIVE();
|
violations = magic.FASTBREAK_MAXVIOLATIONS_CREATIVE();
|
||||||
timemax = magic.FASTBREAK_TIMEMAX_CREATIVE();
|
timemax = magic.FASTBREAK_TIMEMAX_CREATIVE();
|
||||||
@@ -444,7 +413,8 @@ public class Backend {
|
|||||||
int i = fastBreakViolation.get(uuid);
|
int i = fastBreakViolation.get(uuid);
|
||||||
if (i > violations && math < magic.FASTBREAK_MAXVIOLATIONTIME()) {
|
if (i > violations && math < magic.FASTBREAK_MAXVIOLATIONTIME()) {
|
||||||
lastBlockBroken.put(uuid, System.currentTimeMillis());
|
lastBlockBroken.put(uuid, System.currentTimeMillis());
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "broke blocks too fast " + i + " times in a row (max=" + violations + ")");
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"broke blocks too fast " + i + " times in a row (max=" + violations + ")");
|
||||||
} else if (fastBreakViolation.get(uuid) > 0 && math > magic.FASTBREAK_MAXVIOLATIONTIME()) {
|
} else if (fastBreakViolation.get(uuid) > 0 && math > magic.FASTBREAK_MAXVIOLATIONTIME()) {
|
||||||
fastBreakViolation.put(uuid, 0);
|
fastBreakViolation.put(uuid, 0);
|
||||||
}
|
}
|
||||||
@@ -471,7 +441,8 @@ public class Backend {
|
|||||||
int i = fastBreaks.get(uuid);
|
int i = fastBreaks.get(uuid);
|
||||||
fastBreaks.put(uuid, 0);
|
fastBreaks.put(uuid, 0);
|
||||||
fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) + 1);
|
fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) + 1);
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "tried to break " + i + " blocks in " + math + " ms (max=" + magic.FASTBREAK_LIMIT() + " in " + timemax + " ms)");
|
return new CheckResult(CheckResult.Result.FAILED, "tried to break " + i + " blocks in " + math
|
||||||
|
+ " ms (max=" + magic.FASTBREAK_LIMIT() + " in " + timemax + " ms)");
|
||||||
} else if (fastBreaks.get(uuid) >= magic.FASTBREAK_LIMIT() || fastBreakViolation.get(uuid) > 0) {
|
} else if (fastBreaks.get(uuid) >= magic.FASTBREAK_LIMIT() || fastBreakViolation.get(uuid) > 0) {
|
||||||
if (!blockBreakHolder.containsKey(uuid) || !blockBreakHolder.get(uuid)) {
|
if (!blockBreakHolder.containsKey(uuid) || !blockBreakHolder.get(uuid)) {
|
||||||
blockBreakHolder.put(uuid, true);
|
blockBreakHolder.put(uuid, true);
|
||||||
@@ -491,7 +462,8 @@ public class Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CheckResult checkFastPlace(Player player) {
|
public CheckResult checkFastPlace(Player player) {
|
||||||
int violations = player.getGameMode() == GameMode.CREATIVE ? magic.FASTPLACE_MAXVIOLATIONS_CREATIVE() : magic.FASTPLACE_MAXVIOLATIONS();
|
int violations = player.getGameMode() == GameMode.CREATIVE ? magic.FASTPLACE_MAXVIOLATIONS_CREATIVE()
|
||||||
|
: magic.FASTPLACE_MAXVIOLATIONS();
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
if (!lastBlockPlaceTime.containsKey(uuid) || !fastPlaceViolation.containsKey(uuid)) {
|
if (!lastBlockPlaceTime.containsKey(uuid) || !fastPlaceViolation.containsKey(uuid)) {
|
||||||
@@ -500,14 +472,12 @@ public class Backend {
|
|||||||
fastPlaceViolation.put(uuid, 0);
|
fastPlaceViolation.put(uuid, 0);
|
||||||
}
|
}
|
||||||
} else if (fastPlaceViolation.containsKey(uuid) && fastPlaceViolation.get(uuid) > violations) {
|
} else if (fastPlaceViolation.containsKey(uuid) && fastPlaceViolation.get(uuid) > violations) {
|
||||||
AntiCheatReloaded.debugLog("Noted that fastPlaceViolation contains key " + uuid + " with value " + fastPlaceViolation.get(uuid));
|
|
||||||
Long math = System.currentTimeMillis() - lastBlockPlaced.get(uuid);
|
Long math = System.currentTimeMillis() - lastBlockPlaced.get(uuid);
|
||||||
AntiCheatReloaded.debugLog("Player lastBlockPlaced value = " + lastBlockPlaced + ", diff=" + math);
|
|
||||||
if (lastBlockPlaced.get(uuid) > 0 && math < magic.FASTPLACE_MAXVIOLATIONTIME()) {
|
if (lastBlockPlaced.get(uuid) > 0 && math < magic.FASTPLACE_MAXVIOLATIONTIME()) {
|
||||||
lastBlockPlaced.put(uuid, time);
|
lastBlockPlaced.put(uuid, time);
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "placed blocks too fast " + fastBreakViolation.get(uuid) + " times in a row (max=" + violations + ")");
|
return new CheckResult(CheckResult.Result.FAILED, "placed blocks too fast "
|
||||||
|
+ fastBreakViolation.get(uuid) + " times in a row (max=" + violations + ")");
|
||||||
} else if (lastBlockPlaced.get(uuid) > 0 && math > magic.FASTPLACE_MAXVIOLATIONTIME()) {
|
} else if (lastBlockPlaced.get(uuid) > 0 && math > magic.FASTPLACE_MAXVIOLATIONTIME()) {
|
||||||
AntiCheatReloaded.debugLog("Reset facePlaceViolation for " + uuid);
|
|
||||||
fastPlaceViolation.put(uuid, 0);
|
fastPlaceViolation.put(uuid, 0);
|
||||||
}
|
}
|
||||||
} else if (lastBlockPlaced.containsKey(uuid)) {
|
} else if (lastBlockPlaced.containsKey(uuid)) {
|
||||||
@@ -519,7 +489,8 @@ public class Backend {
|
|||||||
lastBlockPlaceTime.put(uuid, (time - last));
|
lastBlockPlaceTime.put(uuid, (time - last));
|
||||||
lastBlockPlaced.put(uuid, time);
|
lastBlockPlaced.put(uuid, time);
|
||||||
fastPlaceViolation.put(uuid, fastPlaceViolation.get(uuid) + 1);
|
fastPlaceViolation.put(uuid, fastPlaceViolation.get(uuid) + 1);
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "tried to place a block " + thisTime + " ms after the last one (min=" + magic.FASTPLACE_TIMEMIN() + " ms)");
|
return new CheckResult(CheckResult.Result.FAILED, "tried to place a block " + thisTime
|
||||||
|
+ " ms after the last one (min=" + magic.FASTPLACE_TIMEMIN() + " ms)");
|
||||||
}
|
}
|
||||||
lastBlockPlaceTime.put(uuid, (time - last));
|
lastBlockPlaceTime.put(uuid, (time - last));
|
||||||
}
|
}
|
||||||
@@ -535,6 +506,10 @@ public class Backend {
|
|||||||
startEat.put(player.getUniqueId(), System.currentTimeMillis());
|
startEat.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEating(Player player) {
|
||||||
|
return startEat.containsKey(player.getUniqueId()) && startEat.get(player.getUniqueId()) < magic.EAT_TIME_MIN();
|
||||||
|
}
|
||||||
|
|
||||||
public void logHeal(Player player) {
|
public void logHeal(Player player) {
|
||||||
lastHeal.put(player.getUniqueId(), System.currentTimeMillis());
|
lastHeal.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
@@ -554,10 +529,12 @@ public class Backend {
|
|||||||
user.clearMessages();
|
user.clearMessages();
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (manager.getConfiguration().getConfig().blockChatSpamRepetition.getValue() && m.equalsIgnoreCase(msg) && i == 1) {
|
if (manager.getConfiguration().getConfig().blockChatSpamRepetition.getValue()
|
||||||
|
&& m.equalsIgnoreCase(msg) && i == 1) {
|
||||||
manager.getLoggingManager().logFineInfo(player.getName() + " spam-repeated \"" + msg + "\"");
|
manager.getLoggingManager().logFineInfo(player.getName() + " spam-repeated \"" + msg + "\"");
|
||||||
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
||||||
} else if (manager.getConfiguration().getConfig().blockChatSpamSpeed.getValue() && System.currentTimeMillis() - user.getLastCommandTime() < magic.CHAT_MIN()) {
|
} else if (manager.getConfiguration().getConfig().blockChatSpamSpeed.getValue()
|
||||||
|
&& System.currentTimeMillis() - user.getLastCommandTime() < magic.CHAT_MIN()) {
|
||||||
manager.getLoggingManager().logFineInfo(player.getName() + " spammed quickly \"" + msg + "\"");
|
manager.getLoggingManager().logFineInfo(player.getName() + " spammed quickly \"" + msg + "\"");
|
||||||
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
||||||
}
|
}
|
||||||
@@ -571,17 +548,18 @@ public class Backend {
|
|||||||
public CheckResult checkChatUnicode(Player player, String msg) {
|
public CheckResult checkChatUnicode(Player player, String msg) {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
User user = manager.getUserManager().getUser(uuid);
|
User user = manager.getUserManager().getUser(uuid);
|
||||||
if (!isPureAscii(msg)) {
|
for (char ch : msg.toCharArray()) {
|
||||||
|
if (Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.BASIC_LATIN
|
||||||
|
&& Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.LATIN_1_SUPPLEMENT
|
||||||
|
&& Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.LATIN_EXTENDED_A
|
||||||
|
&& Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.GENERAL_PUNCTUATION) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "Unicode chat is not allowed.");
|
return new CheckResult(CheckResult.Result.FAILED, "Unicode chat is not allowed.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
user.addMessage(msg);
|
user.addMessage(msg);
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPureAscii(String v) {
|
|
||||||
return StandardCharsets.US_ASCII.newEncoder().canEncode(v.replaceAll("¡", "!").replaceAll("¿", "?"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkCommandSpam(Player player, String cmd) {
|
public CheckResult checkCommandSpam(Player player, String cmd) {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
User user = manager.getUserManager().getUser(uuid);
|
User user = manager.getUserManager().getUser(uuid);
|
||||||
@@ -597,9 +575,11 @@ public class Backend {
|
|||||||
user.clearCommands();
|
user.clearCommands();
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (manager.getConfiguration().getConfig().blockCommandSpamRepetition.getValue() && m.equalsIgnoreCase(cmd) && i == 1) {
|
if (manager.getConfiguration().getConfig().blockCommandSpamRepetition.getValue()
|
||||||
|
&& m.equalsIgnoreCase(cmd) && i == 1) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
||||||
} else if (manager.getConfiguration().getConfig().blockCommandSpamSpeed.getValue() && System.currentTimeMillis() - user.getLastCommandTime() < magic.COMMAND_MIN()) {
|
} else if (manager.getConfiguration().getConfig().blockCommandSpamSpeed.getValue()
|
||||||
|
&& System.currentTimeMillis() - user.getLastCommandTime() < magic.COMMAND_MIN()) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -625,15 +605,19 @@ public class Backend {
|
|||||||
long time = System.currentTimeMillis() - inventoryTime.get(uuid);
|
long time = System.currentTimeMillis() - inventoryTime.get(uuid);
|
||||||
inventoryClicks.put(uuid, 0);
|
inventoryClicks.put(uuid, 0);
|
||||||
if (time < magic.INVENTORY_TIMEMIN()) {
|
if (time < magic.INVENTORY_TIMEMIN()) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "clicked inventory slots " + clicks + " times in " + time + " ms (max=" + magic.INVENTORY_CHECK() + " in " + magic.INVENTORY_TIMEMIN() + " ms)");
|
return new CheckResult(CheckResult.Result.FAILED, "clicked inventory slots " + clicks + " times in "
|
||||||
|
+ time + " ms (max=" + magic.INVENTORY_CHECK() + " in " + magic.INVENTORY_TIMEMIN() + " ms)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckResult checkAutoTool(Player player) {
|
public CheckResult checkAutoTool(Player player) {
|
||||||
if (itemInHand.containsKey(player.getUniqueId()) && itemInHand.get(player.getUniqueId()) != VersionUtil.getItemInHand(player).getType()) {
|
if (itemInHand.containsKey(player.getUniqueId())
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "switched tools too fast (had " + itemInHand.get(player.getUniqueId()) + ", has " + VersionUtil.getItemInHand(player).getType() + ")");
|
&& itemInHand.get(player.getUniqueId()) != VersionUtil.getItemInHand(player).getType()) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"switched tools too fast (had " + itemInHand.get(player.getUniqueId()) + ", has "
|
||||||
|
+ VersionUtil.getItemInHand(player).getType() + ")");
|
||||||
} else {
|
} else {
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
@@ -641,7 +625,8 @@ public class Backend {
|
|||||||
|
|
||||||
public CheckResult checkSprintDamage(Player player) {
|
public CheckResult checkSprintDamage(Player player) {
|
||||||
if (isDoing(player, sprinted, magic.SPRINT_MAX())) {
|
if (isDoing(player, sprinted, magic.SPRINT_MAX())) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "sprinted and damaged an entity too fast (min sprint=" + magic.SPRINT_MAX() + " ms)");
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"sprinted and damaged an entity too fast (min sprint=" + magic.SPRINT_MAX() + " ms)");
|
||||||
} else {
|
} else {
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
@@ -650,11 +635,12 @@ public class Backend {
|
|||||||
public CheckResult checkFastHeal(Player player) {
|
public CheckResult checkFastHeal(Player player) {
|
||||||
if (lastHeal.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it.
|
if (lastHeal.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it.
|
||||||
{
|
{
|
||||||
long healTime = VersionUtil.getHealTime();
|
long healTime = magic.MIN_HEAL_TIME();
|
||||||
long l = lastHeal.get(player.getUniqueId());
|
long l = lastHeal.get(player.getUniqueId());
|
||||||
lastHeal.remove(player.getUniqueId());
|
lastHeal.remove(player.getUniqueId());
|
||||||
if ((System.currentTimeMillis() - l) < healTime) {
|
if ((System.currentTimeMillis() - l) < healTime) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "healed too quickly (time=" + (System.currentTimeMillis() - l) + " ms, min=" + healTime + " ms)");
|
return new CheckResult(CheckResult.Result.FAILED, "healed too quickly (time="
|
||||||
|
+ (System.currentTimeMillis() - l) + " ms, min=" + healTime + " ms)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PASS;
|
return PASS;
|
||||||
@@ -666,7 +652,8 @@ public class Backend {
|
|||||||
long l = startEat.get(player.getUniqueId());
|
long l = startEat.get(player.getUniqueId());
|
||||||
startEat.remove(player.getUniqueId());
|
startEat.remove(player.getUniqueId());
|
||||||
if ((System.currentTimeMillis() - l) < magic.EAT_TIME_MIN()) {
|
if ((System.currentTimeMillis() - l) < magic.EAT_TIME_MIN()) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "ate too quickly (time=" + (System.currentTimeMillis() - l) + " ms, min=" + magic.EAT_TIME_MIN() + " ms)");
|
return new CheckResult(CheckResult.Result.FAILED, "ate too quickly (time="
|
||||||
|
+ (System.currentTimeMillis() - l) + " ms, min=" + magic.EAT_TIME_MIN() + " ms)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PASS;
|
return PASS;
|
||||||
@@ -686,7 +673,8 @@ public class Backend {
|
|||||||
|
|
||||||
public boolean isHoveringOverWaterAfterViolation(Player player) {
|
public boolean isHoveringOverWaterAfterViolation(Player player) {
|
||||||
if (WaterWalkCheck.WATER_SPEED_VIOLATIONS.containsKey(player.getUniqueId())) {
|
if (WaterWalkCheck.WATER_SPEED_VIOLATIONS.containsKey(player.getUniqueId())) {
|
||||||
if (WaterWalkCheck.WATER_SPEED_VIOLATIONS.get(player.getUniqueId()) >= magic.WATER_SPEED_VIOLATION_MAX() && Utilities.isHoveringOverWater(player.getLocation())) {
|
if (WaterWalkCheck.WATER_SPEED_VIOLATIONS.get(player.getUniqueId()) >= magic.WATER_SPEED_VIOLATION_MAX()
|
||||||
|
&& Utilities.isHoveringOverWater(player.getLocation())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -706,7 +694,9 @@ public class Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean justVelocity(Player player) {
|
public boolean justVelocity(Player player) {
|
||||||
return (velocitized.containsKey(player.getUniqueId()) ? (System.currentTimeMillis() - velocitized.get(player.getUniqueId())) < magic.VELOCITY_CHECKTIME() : false);
|
return (velocitized.containsKey(player.getUniqueId())
|
||||||
|
? (System.currentTimeMillis() - velocitized.get(player.getUniqueId())) < magic.VELOCITY_CHECKTIME()
|
||||||
|
: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendVelocityTime(final Player player) {
|
public boolean extendVelocityTime(final Player player) {
|
||||||
@@ -714,7 +704,8 @@ public class Backend {
|
|||||||
velocitytrack.put(player.getUniqueId(), velocitytrack.get(player.getUniqueId()) + 1);
|
velocitytrack.put(player.getUniqueId(), velocitytrack.get(player.getUniqueId()) + 1);
|
||||||
if (velocitytrack.get(player.getUniqueId()) > magic.VELOCITY_MAXTIMES()) {
|
if (velocitytrack.get(player.getUniqueId()) > magic.VELOCITY_MAXTIMES()) {
|
||||||
velocitized.put(player.getUniqueId(), System.currentTimeMillis() + magic.VELOCITY_PREVENT());
|
velocitized.put(player.getUniqueId(), System.currentTimeMillis() + magic.VELOCITY_PREVENT());
|
||||||
manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(manager.getPlugin(), new Runnable() {
|
manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(manager.getPlugin(),
|
||||||
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
velocitytrack.put(player.getUniqueId(), 0);
|
velocitytrack.put(player.getUniqueId(), 0);
|
||||||
@@ -736,6 +727,7 @@ public class Backend {
|
|||||||
public boolean justPlaced(Player player) {
|
public boolean justPlaced(Player player) {
|
||||||
return isDoing(player, placedBlock, magic.BLOCK_PLACE_MIN());
|
return isDoing(player, placedBlock, magic.BLOCK_PLACE_MIN());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logDamage(final Player player, int type) {
|
public void logDamage(final Player player, int type) {
|
||||||
long time;
|
long time;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -776,9 +768,9 @@ public class Backend {
|
|||||||
YAxisCheck.LAST_Y_COORD_CACHE.remove(player.getUniqueId());
|
YAxisCheck.LAST_Y_COORD_CACHE.remove(player.getUniqueId());
|
||||||
YAxisCheck.LAST_Y_TIME.remove(player.getUniqueId());
|
YAxisCheck.LAST_Y_TIME.remove(player.getUniqueId());
|
||||||
GlideCheck.LAST_FALL_DISTANCE.remove(player.getUniqueId());
|
GlideCheck.LAST_FALL_DISTANCE.remove(player.getUniqueId());
|
||||||
GlideCheck.LAST_DIFFERENCE.remove(player.getUniqueId());
|
GlideCheck.LAST_MOTION_Y.remove(player.getUniqueId());
|
||||||
GlideCheck.VIOLATIONS.remove(player.getUniqueId());
|
GlideCheck.VIOLATIONS.remove(player.getUniqueId());
|
||||||
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId().toString());
|
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logExitFly(final Player player) {
|
public void logExitFly(final Player player) {
|
||||||
@@ -797,7 +789,7 @@ public class Backend {
|
|||||||
return isAscending.contains(player.getUniqueId());
|
return isAscending.contains(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDoing(Player player, Map<UUID, Long> map, double max) {
|
public boolean isDoing(Player player, Map<UUID, Long> map, double max) {
|
||||||
if (map.containsKey(player.getUniqueId())) {
|
if (map.containsKey(player.getUniqueId())) {
|
||||||
if (max != -1) {
|
if (max != -1) {
|
||||||
if (((System.currentTimeMillis() - map.get(player.getUniqueId())) / 1000) > max) {
|
if (((System.currentTimeMillis() - map.get(player.getUniqueId())) / 1000) > max) {
|
||||||
@@ -832,8 +824,12 @@ public class Backend {
|
|||||||
User user = manager.getUserManager().getUser(player.getUniqueId());
|
User user = manager.getUserManager().getUser(player.getUniqueId());
|
||||||
int level = chatLevel.containsKey(user.getUUID()) ? chatLevel.get(user.getUUID()) : 0;
|
int level = chatLevel.containsKey(user.getUUID()) ? chatLevel.get(user.getUUID()) : 0;
|
||||||
if (player != null && player.isOnline() && level >= magic.CHAT_ACTION_ONE_LEVEL()) {
|
if (player != null && player.isOnline() && level >= magic.CHAT_ACTION_ONE_LEVEL()) {
|
||||||
String event = level >= magic.CHAT_ACTION_TWO_LEVEL() ? manager.getConfiguration().getConfig().chatSpamActionTwo.getValue() : manager.getConfiguration().getConfig().chatSpamActionOne.getValue();
|
String event = level >= magic.CHAT_ACTION_TWO_LEVEL()
|
||||||
manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()), Utilities.stringToList(event), CheckType.CHAT_SPAM, lang.SPAM_KICK_REASON(), Utilities.stringToList(lang.SPAM_WARNING()), lang.SPAM_BAN_REASON());
|
? manager.getConfiguration().getConfig().chatSpamActionTwo.getValue()
|
||||||
|
: manager.getConfiguration().getConfig().chatSpamActionOne.getValue();
|
||||||
|
manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()),
|
||||||
|
Utilities.stringToList(event), CheckType.CHAT_SPAM, lang.SPAM_KICK_REASON(),
|
||||||
|
Utilities.stringToList(lang.SPAM_WARNING()), lang.SPAM_BAN_REASON());
|
||||||
}
|
}
|
||||||
chatLevel.put(user.getUUID(), level + 1);
|
chatLevel.put(user.getUUID(), level + 1);
|
||||||
}
|
}
|
||||||
@@ -842,41 +838,45 @@ public class Backend {
|
|||||||
User user = manager.getUserManager().getUser(player.getUniqueId());
|
User user = manager.getUserManager().getUser(player.getUniqueId());
|
||||||
int level = commandLevel.containsKey(user.getUUID()) ? commandLevel.get(user.getUUID()) : 0;
|
int level = commandLevel.containsKey(user.getUUID()) ? commandLevel.get(user.getUUID()) : 0;
|
||||||
if (player != null && player.isOnline() && level >= magic.COMMAND_ACTION_ONE_LEVEL()) {
|
if (player != null && player.isOnline() && level >= magic.COMMAND_ACTION_ONE_LEVEL()) {
|
||||||
String event = level >= magic.COMMAND_ACTION_TWO_LEVEL() ? manager.getConfiguration().getConfig().commandSpamActionTwo.getValue() : manager.getConfiguration().getConfig().commandSpamActionOne.getValue();
|
String event = level >= magic.COMMAND_ACTION_TWO_LEVEL()
|
||||||
manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()), Utilities.stringToList(event), CheckType.COMMAND_SPAM, lang.SPAM_KICK_REASON(), Utilities.stringToList(lang.SPAM_WARNING()), lang.SPAM_BAN_REASON());
|
? manager.getConfiguration().getConfig().commandSpamActionTwo.getValue()
|
||||||
|
: manager.getConfiguration().getConfig().commandSpamActionOne.getValue();
|
||||||
|
manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()),
|
||||||
|
Utilities.stringToList(event), CheckType.COMMAND_SPAM, lang.SPAM_KICK_REASON(),
|
||||||
|
Utilities.stringToList(lang.SPAM_WARNING()), lang.SPAM_BAN_REASON());
|
||||||
}
|
}
|
||||||
commandLevel.put(user.getUUID(), level + 1);
|
commandLevel.put(user.getUUID(), level + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int increment(Player player, Map<UUID, Integer> ascensionCount2, int num) {
|
public int increment(Player player, Map<UUID, Integer> map, int num) {
|
||||||
UUID name = player.getUniqueId();
|
UUID name = player.getUniqueId();
|
||||||
if (ascensionCount2.get(name) == null) {
|
if (map.get(name) == null) {
|
||||||
ascensionCount2.put(name, 1);
|
map.put(name, 1);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
int amount = ascensionCount2.get(name) + 1;
|
int amount = map.get(name) + 1;
|
||||||
if (amount < num + 1) {
|
if (amount < num + 1) {
|
||||||
ascensionCount2.put(name, amount);
|
map.put(name, amount);
|
||||||
return amount;
|
return amount;
|
||||||
} else {
|
} else {
|
||||||
ascensionCount2.put(name, num);
|
map.put(name, num);
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int incrementOld(Player player, Map<UUID, Integer> ascensionCount2, int num) {
|
public int incrementOld(Player player, Map<UUID, Integer> map, int num) {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
if (ascensionCount2.get(uuid) == null) {
|
if (map.get(uuid) == null) {
|
||||||
ascensionCount2.put(uuid, 1);
|
map.put(uuid, 1);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
int amount = ascensionCount2.get(uuid) + 1;
|
int amount = map.get(uuid) + 1;
|
||||||
if (amount < num + 1) {
|
if (amount < num + 1) {
|
||||||
ascensionCount2.put(uuid, amount);
|
map.put(uuid, amount);
|
||||||
return amount;
|
return amount;
|
||||||
} else {
|
} else {
|
||||||
ascensionCount2.put(uuid, num);
|
map.put(uuid, num);
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ public enum CheckType {
|
|||||||
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
||||||
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
||||||
AUTOTOOL(Permission.CHECK_AUTOTOOL),
|
AUTOTOOL(Permission.CHECK_AUTOTOOL),
|
||||||
BLINK(Permission.CHECK_BLINK),
|
MOREPACKETS(Permission.CHECK_MOREPACKETS),
|
||||||
|
BADPACKETS(Permission.CHECK_BADPACKETS),
|
||||||
VELOCITY(Permission.CHECK_VELOCITY),
|
VELOCITY(Permission.CHECK_VELOCITY),
|
||||||
CRITICALS(Permission.CHECK_CRITICALS),
|
CRITICALS(Permission.CHECK_CRITICALS),
|
||||||
CHAT_UNICODE(Permission.CHECK_UNICODE),
|
CHAT_UNICODE(Permission.CHECK_UNICODE),
|
||||||
|
|||||||
@@ -16,151 +16,107 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.rammelkast.anticheatreloaded.check.combat;
|
package com.rammelkast.anticheatreloaded.check.combat;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
import com.rammelkast.anticheatreloaded.util.checkassist.KillauraAssist;
|
|
||||||
|
|
||||||
public class KillAuraCheck {
|
public class KillAuraCheck {
|
||||||
|
|
||||||
public static final Map<String, Integer> ANGLE_FLAGS = new HashMap<String, Integer>();
|
// Angle check
|
||||||
public static final Map<String, Integer> DEVIATION_SCORES = new HashMap<String, Integer>();
|
public static final Map<UUID, Integer> ANGLE_FLAGS = new HashMap<UUID, Integer>();
|
||||||
public static final Map<String, Integer> DIFF_MAP = new HashMap<String, Integer>();
|
// Aimbot check
|
||||||
public static final Map<String, ClickSpeed> CLICKSPEED_MAP = new HashMap<String, ClickSpeed>();
|
public static final Map<UUID, List<Float>> PITCH_MOVEMENTS_CACHE = new HashMap<UUID, List<Float>>();
|
||||||
private static final KillauraAssist KILLAURA_ASSIST;
|
public static final Map<UUID, Float> GCD_CACHE = new HashMap<UUID, Float>();
|
||||||
|
// Not used as of now, code not committed yet
|
||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
public static void listenPackets() {
|
|
||||||
/*AntiCheatReloaded.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(),
|
|
||||||
ListenerPriority.LOWEST, new PacketType[] { PacketType.Play.Client.POSITION_LOOK }) {
|
|
||||||
@Override
|
|
||||||
public void onPacketReceiving(PacketEvent e) {
|
|
||||||
Player player = e.getPlayer();
|
|
||||||
PacketContainer packet = e.getPacket();
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CheckResult checkAngle(Player player, EntityDamageEvent event) {
|
public static CheckResult checkAngle(Player player, EntityDamageEvent event) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity) {
|
||||||
LivingEntity living = (LivingEntity) entity;
|
LivingEntity living = (LivingEntity) entity;
|
||||||
Location eyeLocation = player.getEyeLocation();
|
Location eyeLocation = player.getEyeLocation();
|
||||||
|
|
||||||
double yawDifference = KillauraAssist.calculateYawDifference(eyeLocation, living.getLocation());
|
double yawDifference = calculateYawDifference(eyeLocation, living.getLocation());
|
||||||
double playerYaw = player.getEyeLocation().getYaw();
|
double playerYaw = player.getEyeLocation().getYaw();
|
||||||
|
|
||||||
double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
|
double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
|
||||||
if (Math.round(angleDifference) > AntiCheatReloaded.getManager().getConfiguration().getMagic().KILLAURA_MAX_ANGLE_DIFFERENCE()) {
|
if (Math.round(angleDifference) > AntiCheatReloaded.getManager().getConfiguration().getMagic().KILLAURA_MAX_ANGLE_DIFFERENCE()) {
|
||||||
if (!ANGLE_FLAGS.containsKey(player.getUniqueId().toString())) {
|
if (!ANGLE_FLAGS.containsKey(uuid)) {
|
||||||
ANGLE_FLAGS.put(player.getUniqueId().toString(), 1);
|
ANGLE_FLAGS.put(uuid, 1);
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int flags = ANGLE_FLAGS.get(player.getUniqueId().toString());
|
int flags = ANGLE_FLAGS.get(uuid);
|
||||||
if (flags >= AntiCheatReloaded.getManager().getConfiguration().getMagic().KILLAURA_MAX_ANGLE_VIOLATIONS()) {
|
if (flags >= AntiCheatReloaded.getManager().getConfiguration().getMagic().KILLAURA_MAX_ANGLE_VIOLATIONS()) {
|
||||||
ANGLE_FLAGS.remove(player.getUniqueId().toString());
|
ANGLE_FLAGS.remove(uuid);
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "tried to attack from an illegal angle (angle=" + Math.round(angleDifference) + ")");
|
return new CheckResult(CheckResult.Result.FAILED, "tried to attack from an illegal angle (angle=" + Math.round(angleDifference) + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
ANGLE_FLAGS.put(player.getUniqueId().toString(), flags + 1);
|
ANGLE_FLAGS.put(uuid, flags + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CheckResult checkFightSpeed(Player player, EntityDamageEvent event) {
|
/**
|
||||||
if (!CLICKSPEED_MAP.containsKey(player.getUniqueId().toString())) {
|
* Check idea by Hawk AntiCheat (https://github.com/HawkAnticheat/Hawk)
|
||||||
CLICKSPEED_MAP.put(player.getUniqueId().toString(), new ClickSpeed());
|
*/
|
||||||
|
public static CheckResult checkAimbot(Player player, PlayerMoveEvent event) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
float pitchMovement = event.getTo().getPitch() - event.getFrom().getPitch();
|
||||||
|
if (!PITCH_MOVEMENTS_CACHE.containsKey(uuid)) {
|
||||||
|
PITCH_MOVEMENTS_CACHE.put(uuid, new ArrayList<Float>());
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
ClickSpeed clickSpeed = CLICKSPEED_MAP.get(player.getUniqueId().toString());
|
List<Float> pitchMovements = PITCH_MOVEMENTS_CACHE.get(uuid);
|
||||||
clickSpeed.registerClick();
|
if (pitchMovement != 0 && Math.abs(pitchMovement) <= 10 && Math.abs(event.getTo().getPitch()) != 90) {
|
||||||
int deviationScore = clickSpeed.getDeviationScore();
|
pitchMovements.add(Math.abs(pitchMovement));
|
||||||
// Prevents false positives since scores under 2000 aren't reliable
|
}
|
||||||
if (deviationScore < 2000) {
|
|
||||||
|
if (pitchMovements.size() >= 20) {
|
||||||
|
float greatestCommonDivisor = Utilities.gcdRational(pitchMovements);
|
||||||
|
if (!GCD_CACHE.containsKey(uuid)) {
|
||||||
|
GCD_CACHE.put(uuid, greatestCommonDivisor);
|
||||||
|
}
|
||||||
|
|
||||||
|
float divisorDifference = Math.abs(greatestCommonDivisor - GCD_CACHE.get(uuid));
|
||||||
|
if (divisorDifference > 0.00425 || greatestCommonDivisor < 0.00001) {
|
||||||
|
pitchMovements.clear();
|
||||||
|
GCD_CACHE.put(uuid, greatestCommonDivisor);
|
||||||
|
PITCH_MOVEMENTS_CACHE.put(uuid, pitchMovements);
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "performed aimbot-like movements (divisor-diff=" + divisorDifference + ")");
|
||||||
|
}
|
||||||
|
pitchMovements.clear();
|
||||||
|
GCD_CACHE.put(uuid, greatestCommonDivisor);
|
||||||
|
PITCH_MOVEMENTS_CACHE.put(uuid, pitchMovements);
|
||||||
|
}
|
||||||
|
PITCH_MOVEMENTS_CACHE.put(uuid, pitchMovements);
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DEVIATION_SCORES.containsKey(player.getUniqueId().toString())) {
|
|
||||||
DEVIATION_SCORES.put(player.getUniqueId().toString(), deviationScore);
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
|
public static double calculateYawDifference(Location from, Location to) {
|
||||||
int lastScore = DEVIATION_SCORES.get(player.getUniqueId().toString());
|
Location clonedFrom = from.clone();
|
||||||
DEVIATION_SCORES.put(player.getUniqueId().toString(), deviationScore);
|
Vector startVector = clonedFrom.toVector();
|
||||||
int diff = Math.abs(deviationScore - lastScore);
|
Vector targetVector = to.toVector();
|
||||||
if (!DIFF_MAP.containsKey(player.getUniqueId().toString())) {
|
clonedFrom.setDirection(targetVector.subtract(startVector));
|
||||||
DIFF_MAP.put(player.getUniqueId().toString(), diff);
|
return clonedFrom.getYaw();
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
int lastDiff = DIFF_MAP.get(player.getUniqueId().toString());
|
|
||||||
DIFF_MAP.put(player.getUniqueId().toString(), diff);
|
|
||||||
if (Math.abs(diff - lastDiff) < magic.KILLAURA_FIGHTSPEED_MINDIFF()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "had a suspiciously consistant fighting speed (absdiff=" + Math.abs(diff - lastDiff) + ")");
|
|
||||||
}
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ClickSpeed {
|
|
||||||
private final List<Long> clicks;
|
|
||||||
private long lastClick;
|
|
||||||
|
|
||||||
public ClickSpeed() {
|
|
||||||
this.clicks = new ArrayList<Long>();
|
|
||||||
this.lastClick = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerClick() {
|
|
||||||
this.lastClick = System.currentTimeMillis();
|
|
||||||
this.clicks.add(this.lastClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDeviationScore() {
|
|
||||||
long last = 0;
|
|
||||||
List<Integer> deviation = new ArrayList<Integer>();
|
|
||||||
List<Long> toRemove = new ArrayList<Long>();
|
|
||||||
for (long clickTime : this.clicks) {
|
|
||||||
if (clickTime > (this.lastClick - 5000)) {
|
|
||||||
if (last == 0) {
|
|
||||||
last = clickTime;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
deviation.add((int) (clickTime - last));
|
|
||||||
} else {
|
|
||||||
toRemove.add(clickTime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.clicks.removeAll(toRemove);
|
|
||||||
if (deviation.isEmpty()) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
float averageDeviationScore = deviation.get(0);
|
|
||||||
for (int i = 1; i < deviation.size(); i++) {
|
|
||||||
averageDeviationScore += deviation.get(i);
|
|
||||||
}
|
|
||||||
return Math.round(averageDeviationScore / deviation.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
KILLAURA_ASSIST = new KillauraAssist();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -35,40 +35,36 @@ import com.rammelkast.anticheatreloaded.event.EventListener;
|
|||||||
|
|
||||||
public class VelocityCheck {
|
public class VelocityCheck {
|
||||||
|
|
||||||
private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>();
|
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
|
||||||
|
|
||||||
public static void cleanPlayer(Player p) {
|
public static void runCheck(EntityDamageByEntityEvent e, final Player player) {
|
||||||
VL_COUNT.remove(p.getUniqueId());
|
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.VELOCITY))
|
||||||
}
|
|
||||||
|
|
||||||
public static void runCheck(EntityDamageByEntityEvent e, final Player p) {
|
|
||||||
if (AntiCheatReloaded.getManager().getCheckManager().isOpExempt(p)
|
|
||||||
|| AntiCheatReloaded.getManager().getCheckManager().isExempt(p, CheckType.VELOCITY))
|
|
||||||
return;
|
return;
|
||||||
final Location then = p.getLocation();
|
final Location then = player.getLocation();
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!p.isOnline())
|
if (!player.isOnline())
|
||||||
return;
|
return;
|
||||||
if (then.distance(p.getLocation()) < 0.125) {
|
if (then.distance(player.getLocation()) < 0.125) {
|
||||||
if (!VL_COUNT.containsKey(p.getUniqueId()))
|
if (!VIOLATIONS.containsKey(player.getUniqueId()))
|
||||||
VL_COUNT.put(p.getUniqueId(), 1);
|
VIOLATIONS.put(player.getUniqueId(), 1);
|
||||||
else {
|
else {
|
||||||
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
|
VIOLATIONS.put(player.getUniqueId(), VIOLATIONS.get(player.getUniqueId()) + 1);
|
||||||
if (VL_COUNT.get(p.getUniqueId()) > AntiCheatReloaded.getManager().getBackend().getMagic()
|
if (VIOLATIONS.get(player.getUniqueId()) > AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||||
.VELOCITY_MAX_FLAGS()) {
|
.VELOCITY_MAX_FLAGS()) {
|
||||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED,
|
EventListener.log(
|
||||||
"had zero/low velocity "
|
new CheckResult(CheckResult.Result.FAILED,
|
||||||
+ VL_COUNT.get(p.getUniqueId()) + " times (max="
|
"had zero/low velocity " + VIOLATIONS.get(player.getUniqueId()) + " times (max="
|
||||||
+ AntiCheatReloaded.getManager().getBackend().getMagic().VELOCITY_MAX_FLAGS()
|
+ AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||||
+ ", dist=" + then.distance(p.getLocation()) + ")").getMessage(),
|
.VELOCITY_MAX_FLAGS()
|
||||||
p, CheckType.VELOCITY);
|
+ ", dist=" + then.distance(player.getLocation()) + ")").getMessage(),
|
||||||
VL_COUNT.remove(p.getUniqueId());
|
player, CheckType.VELOCITY);
|
||||||
|
VIOLATIONS.remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
VL_COUNT.remove(p.getUniqueId());
|
VIOLATIONS.remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskLater(AntiCheatReloaded.getPlugin(), 4);
|
}.runTaskLater(AntiCheatReloaded.getPlugin(), 4);
|
||||||
|
|||||||
@@ -1,110 +0,0 @@
|
|||||||
/*
|
|
||||||
* AntiCheatReloaded for Bukkit and Spigot.
|
|
||||||
* Copyright (c) 2012-2015 AntiCheat Team
|
|
||||||
* Copyright (c) 2016-2020 Rammelkast
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.rammelkast.anticheatreloaded.check.movement;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
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.VersionUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Rammelkast
|
|
||||||
*/
|
|
||||||
public class BlinkCheck {
|
|
||||||
|
|
||||||
public static final Map<UUID, Integer> MOVE_COUNT = new HashMap<UUID, Integer>();
|
|
||||||
|
|
||||||
public static void startTimer() {
|
|
||||||
new BukkitRunnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MOVE_COUNT.clear();
|
|
||||||
}
|
|
||||||
}.runTaskTimer(AntiCheatReloaded.getPlugin(), 20, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void listenPackets() {
|
|
||||||
AntiCheatReloaded.getProtocolManager()
|
|
||||||
.addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST,
|
|
||||||
new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK }) {
|
|
||||||
@Override
|
|
||||||
public void onPacketReceiving(PacketEvent e) {
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
Location cur = e.getPlayer().getLocation();
|
|
||||||
if (!MOVE_COUNT.containsKey(p.getUniqueId())) {
|
|
||||||
MOVE_COUNT.put(p.getUniqueId(), 1);
|
|
||||||
} else {
|
|
||||||
MOVE_COUNT.put(p.getUniqueId(), MOVE_COUNT.get(p.getUniqueId()) + 1);
|
|
||||||
if (AntiCheatReloaded.getManager().getCheckManager().checkInWorld(p)
|
|
||||||
&& !AntiCheatReloaded.getManager().getCheckManager().isOpExempt(p)
|
|
||||||
&& !AntiCheatReloaded.getManager().getCheckManager().isExempt(p, CheckType.BLINK)) {
|
|
||||||
int ping = VersionUtil.getPlayerPing(p);
|
|
||||||
int blinkMagic = AntiCheatReloaded.getManager().getBackend().getMagic().BLINK_PACKET();
|
|
||||||
int averagePing = AntiCheatReloaded.getManager().getBackend().getMagic()
|
|
||||||
.BLINK_AVERAGE_PING();
|
|
||||||
float pingLeniency = (float) ((ping / averagePing));
|
|
||||||
if (pingLeniency < 1)
|
|
||||||
pingLeniency = 1;
|
|
||||||
if (pingLeniency > 2.5F)
|
|
||||||
pingLeniency = 2.5F;
|
|
||||||
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,
|
|
||||||
"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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
package com.rammelkast.anticheatreloaded.check.movement;
|
package com.rammelkast.anticheatreloaded.check.movement;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -29,14 +30,20 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
public class ElytraCheck {
|
public class ElytraCheck {
|
||||||
|
|
||||||
public static final HashMap<String, Double> JUMP_Y_VALUE = new HashMap<String, Double>();
|
public static final HashMap<UUID, Double> JUMP_Y_VALUE = new HashMap<UUID, Double>();
|
||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
public static CheckResult runCheck(Player player, Distance distance) {
|
public static CheckResult runCheck(Player player, Distance distance) {
|
||||||
String uuid = player.getUniqueId().toString();
|
// No elytra in server version
|
||||||
|
if (VersionUtil.isBountifulUpdate()) {
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()) {
|
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()) {
|
||||||
// This was a teleport, so skip check.
|
// This was a teleport, so skip check.
|
||||||
JUMP_Y_VALUE.remove(uuid);
|
JUMP_Y_VALUE.remove(uuid);
|
||||||
|
|||||||
@@ -24,10 +24,13 @@ import java.util.Map;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
@@ -40,6 +43,7 @@ public class FlightCheck {
|
|||||||
|
|
||||||
public static final Map<UUID, Double> BLOCKS_OVER_FLIGHT = new HashMap<UUID, Double>();
|
public static final Map<UUID, Double> BLOCKS_OVER_FLIGHT = new HashMap<UUID, Double>();
|
||||||
public static final Map<UUID, Long> MOVING_EXEMPT = new HashMap<UUID, Long>();
|
public static final Map<UUID, Long> MOVING_EXEMPT = new HashMap<UUID, Long>();
|
||||||
|
public static final Map<UUID, Integer> ASCENSION_COUNT = new HashMap<UUID, Integer>();
|
||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
public static CheckResult runCheck(Player player, Distance distance) {
|
public static CheckResult runCheck(Player player, Distance distance) {
|
||||||
@@ -55,7 +59,7 @@ public class FlightCheck {
|
|||||||
if (!isMovingExempt(player) && !Utilities.isHoveringOverWater(player.getLocation(), 1)
|
if (!isMovingExempt(player) && !Utilities.isHoveringOverWater(player.getLocation(), 1)
|
||||||
&& Utilities.cantStandAtExp(player.getLocation())
|
&& Utilities.cantStandAtExp(player.getLocation())
|
||||||
&& Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN),
|
&& Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN),
|
||||||
new Material[] { Material.IRON_BARS })
|
new Material[] { Utilities.IRON_BARS })
|
||||||
&& Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN),
|
&& Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN),
|
||||||
new String[] { "FENCE", "FENCE_GATE" })) {
|
new String[] { "FENCE", "FENCE_GATE" })) {
|
||||||
if (!BLOCKS_OVER_FLIGHT.containsKey(uuid)) {
|
if (!BLOCKS_OVER_FLIGHT.containsKey(uuid)) {
|
||||||
@@ -81,8 +85,42 @@ public class FlightCheck {
|
|||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CheckResult checkAscension(Player player, double y1, double y2) {
|
||||||
|
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||||
|
int max = backend.getMagic().ASCENSION_COUNT_MAX();
|
||||||
|
String string = "";
|
||||||
|
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
|
||||||
|
max += 12;
|
||||||
|
string = " with jump potion";
|
||||||
|
}
|
||||||
|
Block block = player.getLocation().getBlock();
|
||||||
|
if (!isMovingExempt(player) && !Utilities.isInWater(player) && !VersionUtil.isFlying(player)
|
||||||
|
&& !backend.justBroke(player) && !Utilities.isClimbableBlock(player.getLocation().getBlock())
|
||||||
|
&& !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
|
||||||
|
&& !Utilities.isClimbableBlock(player.getLocation().clone().add(0, -0.98, 0).getBlock())
|
||||||
|
&& !player.isInsideVehicle() && !YAxisCheck.isMoveUpBlock(player.getLocation().add(0, -1, 0).getBlock())
|
||||||
|
&& !YAxisCheck.isMoveUpBlock(player.getLocation().add(0, -0.5, 0).getBlock())) {
|
||||||
|
// TODO isMoveUpBlock does not seem to be a success with stairs
|
||||||
|
if (y1 < y2) {
|
||||||
|
if (!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid()
|
||||||
|
&& !block.getRelative(BlockFace.EAST).isLiquid()
|
||||||
|
&& !block.getRelative(BlockFace.WEST).isLiquid()) {
|
||||||
|
backend.increment(player, ASCENSION_COUNT, max);
|
||||||
|
if (ASCENSION_COUNT.get(player.getUniqueId()) >= max) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"ascended " + ASCENSION_COUNT.get(player.getUniqueId()) + " times in a row (max = " + max
|
||||||
|
+ string + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ASCENSION_COUNT.put(player.getUniqueId(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isMovingExempt(Player player) {
|
public static boolean isMovingExempt(Player player) {
|
||||||
return isDoing(player, MOVING_EXEMPT, -1);
|
return isDoing(player, MOVING_EXEMPT, -1) || player.isInsideVehicle();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isDoing(Player player, Map<UUID, Long> map, double max) {
|
private static boolean isDoing(Player player, Map<UUID, Long> map, double max) {
|
||||||
|
|||||||
@@ -32,60 +32,94 @@ import org.bukkit.entity.Player;
|
|||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
public class GlideCheck {
|
public class GlideCheck {
|
||||||
|
|
||||||
public static final Map<UUID, Double> LAST_DIFFERENCE = new HashMap<UUID, Double>();
|
public static final Map<UUID, Double> LAST_MOTION_Y = new HashMap<UUID, Double>();
|
||||||
public static final Map<UUID, Float> LAST_FALL_DISTANCE = new HashMap<UUID, Float>();
|
public static final Map<UUID, Float> LAST_FALL_DISTANCE = new HashMap<UUID, Float>();
|
||||||
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
|
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
|
||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
public static CheckResult runCheck(Player player, Distance distance) {
|
public static CheckResult runCheck(Player player, Distance distance) {
|
||||||
if (VersionUtil.isFlying(player)) {
|
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|
||||||
|
|| VersionUtil.isFlying(player) || FlightCheck.isMovingExempt(player)) {
|
||||||
|
VIOLATIONS.put(player.getUniqueId(), 0);
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
if (player.getLocation().getBlock().getType() == Material.LADDER
|
if (player.getLocation().getBlock().getType() == Material.LADDER
|
||||||
|| player.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) {
|
|| player.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) {
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
if (!LAST_DIFFERENCE.containsKey(player.getUniqueId())) {
|
if (!LAST_MOTION_Y.containsKey(player.getUniqueId())) {
|
||||||
LAST_DIFFERENCE.put(player.getUniqueId(), distance.getYDifference());
|
LAST_MOTION_Y.put(player.getUniqueId(), distance.getYDifference());
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
if (!LAST_FALL_DISTANCE.containsKey(player.getUniqueId())) {
|
if (!LAST_FALL_DISTANCE.containsKey(player.getUniqueId())) {
|
||||||
LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance());
|
LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance());
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
double yDiff = distance.getYDifference();
|
int violations = VIOLATIONS.getOrDefault(player.getUniqueId(), 0);
|
||||||
|
double motionY = distance.getYDifference();
|
||||||
float fallDistance = player.getFallDistance();
|
float fallDistance = player.getFallDistance();
|
||||||
if (yDiff == LAST_DIFFERENCE.get(player.getUniqueId())
|
if (motionY == LAST_MOTION_Y.get(player.getUniqueId())
|
||||||
&& fallDistance > LAST_FALL_DISTANCE.get(player.getUniqueId())) {
|
&& fallDistance > LAST_FALL_DISTANCE.get(player.getUniqueId())) {
|
||||||
if (!VIOLATIONS.containsKey(player.getUniqueId())) {
|
if (violations + 1 >= AntiCheatReloaded.getManager().getBackend().getMagic().GLIDE_LIMIT()) {
|
||||||
VIOLATIONS.put(player.getUniqueId(), 1);
|
VIOLATIONS.put(player.getUniqueId(), 0);
|
||||||
} else {
|
|
||||||
if (VIOLATIONS.get(player.getUniqueId()) + 1 >= AntiCheatReloaded.getManager().getBackend().getMagic()
|
|
||||||
.GLIDE_LIMIT()) {
|
|
||||||
VIOLATIONS.remove(player.getUniqueId());
|
|
||||||
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
||||||
Location prev = player.getLocation();
|
Location prev = player.getLocation().clone();
|
||||||
prev.setY(prev.getY() - distanceToFall(prev));
|
prev.setY(prev.getY() - distanceToFall(prev));
|
||||||
player.teleport(AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
player.teleport(AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||||
.getGoodLocation(prev));
|
.getGoodLocation(prev));
|
||||||
}
|
}
|
||||||
return new CheckResult(CheckResult.Result.FAILED,
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
"type=glide, desc_amount=" + new BigDecimal(yDiff).setScale(2, RoundingMode.HALF_UP) + ")");
|
"type=glide, desc_amount=" + new BigDecimal(motionY).setScale(2, RoundingMode.HALF_UP) + ")");
|
||||||
} else {
|
} else {
|
||||||
VIOLATIONS.put(player.getUniqueId(), VIOLATIONS.get(player.getUniqueId()) + 1);
|
VIOLATIONS.put(player.getUniqueId(), violations + 1);
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// TODO more sophisticated check
|
|
||||||
}
|
|
||||||
LAST_DIFFERENCE.put(player.getUniqueId(), distance.getYDifference());
|
|
||||||
LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance());
|
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (fallDistance > LAST_FALL_DISTANCE.get(player.getUniqueId()) && !player.isOnGround()
|
||||||
|
&& Utilities.isNotNearSlime(distance.getTo().getBlock()) && fallDistance < 1.5
|
||||||
|
&& !Utilities.isClimbableBlock(distance.getTo().getBlock()) && !player.isSneaking()
|
||||||
|
&& !AntiCheatReloaded.getManager().getBackend().isEating(player)) {
|
||||||
|
// TODO that fallDistance check is a horrible way to prevent a certain false
|
||||||
|
// positive
|
||||||
|
// Needs to be fixed since this only works for slight above ground movements
|
||||||
|
float predicted = calculateNextMotionY(LAST_MOTION_Y.get(player.getUniqueId()).floatValue());
|
||||||
|
float actual = Double.valueOf(motionY).floatValue();
|
||||||
|
float scaledDifference = Math.abs((predicted - actual) + 0.1568f);
|
||||||
|
if (scaledDifference > 3E-8) {
|
||||||
|
if (violations + 1 >= AntiCheatReloaded.getManager().getBackend().getMagic().GLIDE_LIMIT()
|
||||||
|
&& !Utilities.canStand(distance.getTo().getBlock())) {
|
||||||
|
VIOLATIONS.put(player.getUniqueId(), 1);
|
||||||
|
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
||||||
|
Location prev = player.getLocation().clone();
|
||||||
|
prev.setY(prev.getY() - distanceToFall(prev));
|
||||||
|
player.teleport(AntiCheatReloaded.getManager().getUserManager()
|
||||||
|
.getUser(player.getUniqueId()).getGoodLocation(prev));
|
||||||
|
}
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "type=gravity, offset="
|
||||||
|
+ new BigDecimal(scaledDifference).setScale(2, RoundingMode.HALF_UP) + ")");
|
||||||
|
} else {
|
||||||
|
VIOLATIONS.put(player.getUniqueId(), violations + 1);
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LAST_MOTION_Y.put(player.getUniqueId(), distance.getYDifference());
|
||||||
|
LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance());
|
||||||
|
if (violations > Math.round(AntiCheatReloaded.getManager().getBackend().getMagic().GLIDE_LIMIT() / 2)) {
|
||||||
|
VIOLATIONS.put(player.getUniqueId(), violations - 1);
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float calculateNextMotionY(float motionY) {
|
||||||
|
return (motionY - 0.08f) * 0.98f;
|
||||||
|
}
|
||||||
|
|
||||||
private static double distanceToFall(Location location) {
|
private static double distanceToFall(Location location) {
|
||||||
location = location.clone();
|
location = location.clone();
|
||||||
|
|||||||
@@ -28,57 +28,67 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This check is an outdated mess which needs to be replaced
|
||||||
|
*/
|
||||||
public class SpeedCheck {
|
public class SpeedCheck {
|
||||||
|
|
||||||
public static final Map<UUID, Integer> SPEED_VIOLATIONS = new HashMap<UUID, Integer>();
|
public static final Map<UUID, Integer> SPEED_VIOLATIONS = new HashMap<UUID, Integer>();
|
||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
public static boolean isSpeedExempt(Player player) {
|
public static boolean isSpeedExempt(Player player, Backend backend) {
|
||||||
return AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)
|
return backend.isMovingExempt(player) || backend.justVelocity(player) || VersionUtil.isFlying(player);
|
||||||
|| AntiCheatReloaded.getManager().getBackend().justVelocity(player) || VersionUtil.isFlying(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CheckResult checkXZSpeed(Player player, double x, double z) {
|
public static CheckResult checkXZSpeed(Player player, double x, double z) {
|
||||||
if (!isSpeedExempt(player) && player.getVehicle() == null) {
|
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||||
|
if (!isSpeedExempt(player, backend) && player.getVehicle() == null) {
|
||||||
String reason = "";
|
String reason = "";
|
||||||
double max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX();
|
double max = backend.getMagic().XZ_SPEED_MAX();
|
||||||
if (player.getLocation().getBlock().getType() == Material.SOUL_SAND) {
|
if (player.getLocation().getBlock().getType() == Material.SOUL_SAND) {
|
||||||
if (player.isSprinting()) {
|
if (player.isSprinting()) {
|
||||||
reason = "on soulsand while sprinting ";
|
reason = "on soulsand while sprinting ";
|
||||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND_SPRINT();
|
max = backend.getMagic().XZ_SPEED_MAX_SOULSAND_SPRINT();
|
||||||
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
|
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
|
||||||
reason = "on soulsand with speed potion ";
|
reason = "on soulsand with speed potion ";
|
||||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND_POTION();
|
max = backend.getMagic().XZ_SPEED_MAX_SOULSAND_POTION();
|
||||||
} else {
|
} else {
|
||||||
reason = "on soulsand ";
|
reason = "on soulsand ";
|
||||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND();
|
max = backend.getMagic().XZ_SPEED_MAX_SOULSAND();
|
||||||
}
|
}
|
||||||
} else if (VersionUtil.isFlying(player)) {
|
} else if (VersionUtil.isFlying(player)) {
|
||||||
reason = "while flying ";
|
reason = "while flying ";
|
||||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_FLY();
|
max = backend.getMagic().XZ_SPEED_MAX_FLY();
|
||||||
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
|
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
|
||||||
if (player.isSprinting()) {
|
if (player.isSprinting()) {
|
||||||
reason = "with speed potion while sprinting ";
|
reason = "with speed potion while sprinting ";
|
||||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_POTION_SPRINT();
|
max = backend.getMagic().XZ_SPEED_MAX_POTION_SPRINT();
|
||||||
} else {
|
} else {
|
||||||
reason = "with speed potion ";
|
reason = "with speed potion ";
|
||||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_POTION();
|
max = backend.getMagic().XZ_SPEED_MAX_POTION();
|
||||||
}
|
}
|
||||||
} else if (player.isSprinting()) {
|
} else if (player.isSprinting()) {
|
||||||
String blockDownName = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType().name();
|
String blockDownName = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType().name();
|
||||||
if (blockDownName.endsWith("ICE")
|
if (blockDownName.endsWith("ICE")
|
||||||
&& ((player.getEyeLocation().getBlock().getRelative(BlockFace.UP).getType() != Material.AIR)
|
&& (player.getEyeLocation().getBlock().getRelative(BlockFace.UP).getType() != Material.AIR)) {
|
||||||
&& (player.getEyeLocation().getBlock().getRelative(BlockFace.UP)
|
if (player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")) {
|
||||||
.getType() != Material.CAVE_AIR))) {
|
reason = "while boosting on " + blockDownName.toLowerCase().replaceAll("_", " ")
|
||||||
|
+ " and trapdoor";
|
||||||
|
max = backend.getMagic().XZ_SPEED_MAX_SPRINT()
|
||||||
|
+ (blockDownName.equals("BLUE_ICE") ? 0.35925D : 0.35D);
|
||||||
|
} else {
|
||||||
reason = "while boosting on " + blockDownName.toLowerCase().replaceAll("_", " ") + " ";
|
reason = "while boosting on " + blockDownName.toLowerCase().replaceAll("_", " ") + " ";
|
||||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT()
|
max = backend.getMagic().XZ_SPEED_MAX_SPRINT()
|
||||||
+ (blockDownName.equals("BLUE_ICE") ? 0.20925D : 0.165D);
|
+ (blockDownName.equals("BLUE_ICE") ? 0.20925D : 0.2D);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
reason = "while sprinting ";
|
reason = "while sprinting ";
|
||||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT();
|
max = backend.getMagic().XZ_SPEED_MAX_SPRINT();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,13 +96,12 @@ public class SpeedCheck {
|
|||||||
max += speed > 0 ? player.getWalkSpeed() - 0.2f : 0;
|
max += speed > 0 ? player.getWalkSpeed() - 0.2f : 0;
|
||||||
|
|
||||||
if (x > max || z > max) {
|
if (x > max || z > max) {
|
||||||
int num = AntiCheatReloaded.getManager().getBackend().increment(player, SPEED_VIOLATIONS,
|
int num = backend.increment(player, SPEED_VIOLATIONS, backend.getMagic().SPEED_MAX());
|
||||||
AntiCheatReloaded.getManager().getBackend().getMagic().SPEED_MAX());
|
if (num >= backend.getMagic().SPEED_MAX()) {
|
||||||
if (num >= AntiCheatReloaded.getManager().getBackend().getMagic().SPEED_MAX()) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED,
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
"speed was too high " + reason + num + " times in a row (max="
|
"speed was too high " + reason + num + " times in a row (max="
|
||||||
+ AntiCheatReloaded.getManager().getBackend().getMagic().SPEED_MAX() + ", speed="
|
+ backend.getMagic().SPEED_MAX() + ", speed=" + (x > z ? x : z) + ", max speed="
|
||||||
+ (x > z ? x : z) + ", max speed=" + max + ")");
|
+ max + ")");
|
||||||
} else {
|
} else {
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
@@ -105,4 +114,19 @@ public class SpeedCheck {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CheckResult checkYSpeed(Player player, double y) {
|
||||||
|
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||||
|
if (!backend.isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping()
|
||||||
|
&& (y > backend.getMagic().Y_SPEED_MAX())
|
||||||
|
&& !backend.isDoing(player, backend.velocitized, backend.getMagic().VELOCITY_TIME())
|
||||||
|
&& !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)
|
||||||
|
&& !Utilities.isSlime(AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||||
|
.getGoodLocation(player.getLocation()).getBlock())) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"y speed was too high (speed=" + y + ", max=" + backend.getMagic().Y_SPEED_MAX() + ")");
|
||||||
|
} else {
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,12 +25,12 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
@@ -47,6 +47,7 @@ public class WaterWalkCheck {
|
|||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
public static CheckResult runCheck(Player player, double x, double y, double z) {
|
public static CheckResult runCheck(Player player, double x, double y, double z) {
|
||||||
|
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||||
Block block = player.getLocation().getBlock();
|
Block block = player.getLocation().getBlock();
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
|
|
||||||
@@ -57,26 +58,21 @@ public class WaterWalkCheck {
|
|||||||
if (player.getNearbyEntities(1, 1, 1).isEmpty()) {
|
if (player.getNearbyEntities(1, 1, 1).isEmpty()) {
|
||||||
boolean violation;
|
boolean violation;
|
||||||
if (!Utilities.sprintFly(player)) {
|
if (!Utilities.sprintFly(player)) {
|
||||||
violation = x > AntiCheatReloaded.getManager().getBackend().getMagic()
|
violation = x > backend.getMagic().XZ_SPEED_MAX_WATER()
|
||||||
.XZ_SPEED_MAX_WATER()
|
|| z > backend.getMagic().XZ_SPEED_MAX_WATER();
|
||||||
|| z > AntiCheatReloaded.getManager().getBackend().getMagic()
|
|
||||||
.XZ_SPEED_MAX_WATER();
|
|
||||||
} else {
|
} else {
|
||||||
violation = x > AntiCheatReloaded.getManager().getBackend().getMagic()
|
violation = x > backend.getMagic().XZ_SPEED_MAX_WATER_SPRINT()
|
||||||
.XZ_SPEED_MAX_WATER_SPRINT()
|
|| z > backend.getMagic().XZ_SPEED_MAX_WATER_SPRINT();
|
||||||
|| z > AntiCheatReloaded.getManager().getBackend().getMagic()
|
|
||||||
.XZ_SPEED_MAX_WATER_SPRINT();
|
|
||||||
}
|
}
|
||||||
if (!violation && !Utilities.isFullyInWater(player.getLocation())
|
if (!violation && !Utilities.isFullyInWater(player.getLocation())
|
||||||
&& Utilities.isHoveringOverWater(player.getLocation(), 1) && y == 0D
|
&& Utilities.isHoveringOverWater(player.getLocation(), 1) && y == 0D
|
||||||
&& !block.getType().equals(Material.LILY_PAD)) {
|
&& !block.getType().equals(Utilities.LILY_PAD)) {
|
||||||
violation = true;
|
violation = true;
|
||||||
}
|
}
|
||||||
if (violation) {
|
if (violation) {
|
||||||
if (WATER_SPEED_VIOLATIONS.containsKey(uuid)) {
|
if (WATER_SPEED_VIOLATIONS.containsKey(uuid)) {
|
||||||
int v = WATER_SPEED_VIOLATIONS.get(uuid);
|
int v = WATER_SPEED_VIOLATIONS.get(uuid);
|
||||||
if (v >= AntiCheatReloaded.getManager().getBackend().getMagic()
|
if (v >= backend.getMagic().WATER_SPEED_VIOLATION_MAX()) {
|
||||||
.WATER_SPEED_VIOLATION_MAX()) {
|
|
||||||
WATER_SPEED_VIOLATIONS.put(uuid, 0);
|
WATER_SPEED_VIOLATIONS.put(uuid, 0);
|
||||||
return new CheckResult(CheckResult.Result.FAILED,
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
"stood on water " + v + " times (can't stand on " + block.getType()
|
"stood on water " + v + " times (can't stand on " + block.getType()
|
||||||
@@ -97,12 +93,13 @@ public class WaterWalkCheck {
|
|||||||
IS_IN_WATER.add(uuid);
|
IS_IN_WATER.add(uuid);
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
} else if (block.getRelative(BlockFace.DOWN).isLiquid()
|
} else if (block.getRelative(BlockFace.DOWN).isLiquid() && !backend.isAscending(player)
|
||||||
&& !AntiCheatReloaded.getManager().getBackend().isAscending(player) && Utilities.cantStandAt(block)
|
&& Utilities.cantStandAt(block) && Utilities.cantStandAt(block.getRelative(BlockFace.DOWN))
|
||||||
&& Utilities.cantStandAt(block.getRelative(BlockFace.DOWN))) {
|
&& (y < 0.025 || y == 0.09999999999999964 || y == 0.14999999999999947
|
||||||
|
|| y == 0.04999999999999982)) {
|
||||||
if (WATER_ASCENSION_VIOLATIONS.containsKey(uuid)) {
|
if (WATER_ASCENSION_VIOLATIONS.containsKey(uuid)) {
|
||||||
int v = WATER_ASCENSION_VIOLATIONS.get(uuid);
|
int v = WATER_ASCENSION_VIOLATIONS.get(uuid);
|
||||||
if (v >= AntiCheatReloaded.getManager().getBackend().getMagic().WATER_ASCENSION_VIOLATION_MAX()) {
|
if (v >= backend.getMagic().WATER_ASCENSION_VIOLATION_MAX()) {
|
||||||
WATER_ASCENSION_VIOLATIONS.put(uuid, 0);
|
WATER_ASCENSION_VIOLATIONS.put(uuid, 0);
|
||||||
return new CheckResult(CheckResult.Result.FAILED,
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
"stood on water " + v + " times (can't stand on " + block.getType() + " or "
|
"stood on water " + v + " times (can't stand on " + block.getType() + " or "
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class YAxisCheck {
|
|||||||
LAST_Y_AXIS_VIOLATION.put(uuid, System.currentTimeMillis());
|
LAST_Y_AXIS_VIOLATION.put(uuid, System.currentTimeMillis());
|
||||||
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
||||||
g.setY(LAST_Y_COORD_CACHE.get(uuid));
|
g.setY(LAST_Y_COORD_CACHE.get(uuid));
|
||||||
if (g.getBlock().getType() == Material.AIR || g.getBlock().getType() == Material.CAVE_AIR) {
|
if (g.getBlock().getType() == Material.AIR) {
|
||||||
player.teleport(g);
|
player.teleport(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ public class YAxisCheck {
|
|||||||
}
|
}
|
||||||
long i = System.currentTimeMillis() - LAST_Y_TIME.get(uuid);
|
long i = System.currentTimeMillis() - LAST_Y_TIME.get(uuid);
|
||||||
double diff = AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXDIFF()
|
double diff = AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXDIFF()
|
||||||
+ (Utilities.isStair(player.getLocation().add(0, -1, 0).getBlock()) ? 0.5 : 0.0);
|
+ ((Utilities.isStair(player.getLocation().add(0, -1, 0).getBlock()) || Utilities.isStair(player.getLocation().add(0, -0.5, 0).getBlock())) ? 0.5 : 0.0);
|
||||||
if ((y1 - LAST_Y_COORD_CACHE.get(uuid)) > diff
|
if ((y1 - LAST_Y_COORD_CACHE.get(uuid)) > diff
|
||||||
&& i < AntiCheatReloaded.getManager().getBackend().getMagic().Y_TIME()) {
|
&& i < AntiCheatReloaded.getManager().getBackend().getMagic().Y_TIME()) {
|
||||||
Location g = player.getLocation();
|
Location g = player.getLocation();
|
||||||
@@ -103,7 +103,7 @@ public class YAxisCheck {
|
|||||||
LAST_Y_AXIS_VIOLATION.put(uuid, System.currentTimeMillis());
|
LAST_Y_AXIS_VIOLATION.put(uuid, System.currentTimeMillis());
|
||||||
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
||||||
g.setY(LAST_Y_COORD_CACHE.get(uuid));
|
g.setY(LAST_Y_COORD_CACHE.get(uuid));
|
||||||
if (g.getBlock().getType() == Material.AIR || g.getBlock().getType() == Material.CAVE_AIR) {
|
if (g.getBlock().getType() == Material.AIR) {
|
||||||
player.teleport(g);
|
player.teleport(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,8 +125,7 @@ public class YAxisCheck {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMoveUpBlock(Block block) {
|
public static boolean isMoveUpBlock(Block block) {
|
||||||
Material type = block.getType();
|
return Utilities.isStair(block);
|
||||||
return type.name().endsWith("STAIRS"); // TODO slabs/others?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.rammelkast.anticheatreloaded.check.packet;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||||
|
|
||||||
|
public class BadPacketsCheck {
|
||||||
|
|
||||||
|
public static void runCheck(Player player, PacketEvent event) {
|
||||||
|
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||||
|
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.BADPACKETS)
|
||||||
|
|| backend.isMovingExempt(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketContainer packet = event.getPacket();
|
||||||
|
float pitch = packet.getFloat().read(1);
|
||||||
|
// Check for derp
|
||||||
|
if (Math.abs(pitch) > 90) {
|
||||||
|
flag(player, event, "had an illegal pitch");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO more precise checking for this
|
||||||
|
if (AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()).isLagging()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
double x = packet.getDoubles().read(0);
|
||||||
|
double y = packet.getDoubles().read(1);
|
||||||
|
double z = packet.getDoubles().read(2);
|
||||||
|
float yaw = packet.getFloat().read(0);
|
||||||
|
// Create location from new data
|
||||||
|
Location previous = player.getLocation();
|
||||||
|
Location current = new Location(previous.getWorld(), x, y, z, yaw, pitch);
|
||||||
|
double distance = previous.distanceSquared(current);
|
||||||
|
double maxDistance = backend.getMagic().BADPACKETS_MAX_DISTANCE();
|
||||||
|
boolean hasNewLocation = packet.getBooleans().read(0);
|
||||||
|
if (distance > maxDistance) {
|
||||||
|
flag(player, event, "moved too far between packets (distance=" + new BigDecimal(distance).setScale(1, RoundingMode.HALF_UP) + ", max=" + maxDistance + ")");
|
||||||
|
return;
|
||||||
|
} else if (distance < 1E-10 && !hasNewLocation) {
|
||||||
|
// TODO this gives false positives when teleporting
|
||||||
|
// Only found this in 1.8.8 though
|
||||||
|
//flag(player, event, "sent the same packet twice");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void flag(Player player, PacketEvent event, String message) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
// We are currently not in the main server thread, so switch
|
||||||
|
AntiCheatReloaded.sendToMainThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player,
|
||||||
|
CheckType.BADPACKETS);
|
||||||
|
player.teleport(player.getLocation());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.rammelkast.anticheatreloaded.check.packet;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Rammelkast
|
||||||
|
*/
|
||||||
|
public class MorePacketsCheck {
|
||||||
|
|
||||||
|
public static final Map<UUID, Integer> MOVE_COUNT = new HashMap<UUID, Integer>();
|
||||||
|
|
||||||
|
public static void startTimer() {
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MOVE_COUNT.clear();
|
||||||
|
}
|
||||||
|
}.runTaskTimer(AntiCheatReloaded.getPlugin(), 20, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void runCheck(Player player, PacketEvent event) {
|
||||||
|
// Confirm if we should even check for MorePackets
|
||||||
|
// If your TPS is lower than 15 you are running a shitshow
|
||||||
|
double tps = AntiCheatReloaded.getPlugin().getTPS();
|
||||||
|
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.MOREPACKETS) || tps < 15) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Location currentLocation = event.getPlayer().getLocation();
|
||||||
|
if (!MOVE_COUNT.containsKey(player.getUniqueId())) {
|
||||||
|
MOVE_COUNT.put(player.getUniqueId(), 1);
|
||||||
|
} else {
|
||||||
|
MOVE_COUNT.put(player.getUniqueId(), MOVE_COUNT.get(player.getUniqueId()) + 1);
|
||||||
|
int ping = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()).getPing();
|
||||||
|
int limit = AntiCheatReloaded.getManager().getBackend().getMagic().MOREPACKETS_LIMIT();
|
||||||
|
int averagePing = AntiCheatReloaded.getManager().getBackend().getMagic().MOREPACKETS_AVERAGE_PING();
|
||||||
|
float pingLeniency = (float) ((ping / averagePing));
|
||||||
|
if (pingLeniency < 1)
|
||||||
|
pingLeniency = 1;
|
||||||
|
if (pingLeniency > 2)
|
||||||
|
pingLeniency = 2;
|
||||||
|
float tpsLeniency = (float) ((19 / tps));
|
||||||
|
if (tps > 19) {
|
||||||
|
tpsLeniency = 1;
|
||||||
|
}
|
||||||
|
float leniency = pingLeniency * tpsLeniency;
|
||||||
|
limit = Math.round(leniency * limit);
|
||||||
|
final float finalLeniency = leniency;
|
||||||
|
try {
|
||||||
|
if (MOVE_COUNT.get(player.getUniqueId()) > limit) {
|
||||||
|
final int packets = MOVE_COUNT.get(player.getUniqueId());
|
||||||
|
MOVE_COUNT.remove(player.getUniqueId());
|
||||||
|
event.setCancelled(true);
|
||||||
|
// We are currently not in the main server thread, so switch
|
||||||
|
AntiCheatReloaded.sendToMainThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
EventListener
|
||||||
|
.log(new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"sent " + packets + " packets in one second (max="
|
||||||
|
+ AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||||
|
.MOREPACKETS_LIMIT()
|
||||||
|
+ ", leniency=" + finalLeniency + ")").getMessage(),
|
||||||
|
player, CheckType.MOREPACKETS);
|
||||||
|
player.teleport(currentLocation);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (NullPointerException nullPointer) {
|
||||||
|
// TODO this is thrown sometimes, might have something to do with line 83
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -29,9 +29,10 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
|
|
||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||||
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
||||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
import com.rammelkast.anticheatreloaded.util.checkassist.KillauraAssist;
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
public class IllegalInteract {
|
public class IllegalInteract {
|
||||||
|
|
||||||
@@ -48,27 +49,24 @@ public class IllegalInteract {
|
|||||||
|
|
||||||
private static CheckResult checkBlockBreak(Player player, BlockBreakEvent event) {
|
private static CheckResult checkBlockBreak(Player player, BlockBreakEvent event) {
|
||||||
if (!isValidTarget(player, event.getBlock())) {
|
if (!isValidTarget(player, event.getBlock())) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED,
|
return new CheckResult(CheckResult.Result.FAILED, "tried to break a block which was out of view");
|
||||||
"tried to break a block which was out of view");
|
|
||||||
}
|
}
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CheckResult checkBlockPlace(Player player, BlockPlaceEvent event) {
|
private static CheckResult checkBlockPlace(Player player, BlockPlaceEvent event) {
|
||||||
if (!isValidTarget(player, event.getBlock())) {
|
if (!isValidTarget(player, event.getBlock())) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED,
|
return new CheckResult(CheckResult.Result.FAILED, "tried to place a block out of their view");
|
||||||
"tried to place a block out of their view");
|
|
||||||
}
|
}
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isValidTarget(Player player, Block block) {
|
private static boolean isValidTarget(Player player, Block block) {
|
||||||
Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
|
Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
|
||||||
double distance =
|
double distance = player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
||||||
player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
|
||||||
: player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
: player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
||||||
: magic.BLOCK_MAX_DISTANCE();
|
: magic.BLOCK_MAX_DISTANCE();
|
||||||
Block targetBlock = player.getTargetBlockExact((int) Math.ceil(distance));
|
Block targetBlock = VersionUtil.getTargetBlock(player, ((int) Math.ceil(distance)));
|
||||||
if (targetBlock == null) {
|
if (targetBlock == null) {
|
||||||
// TODO better check here
|
// TODO better check here
|
||||||
return true;
|
return true;
|
||||||
@@ -85,7 +83,7 @@ public class IllegalInteract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Location eyeLocation = player.getEyeLocation();
|
Location eyeLocation = player.getEyeLocation();
|
||||||
double yawDifference = KillauraAssist.calculateYawDifference(eyeLocation, block.getLocation());
|
double yawDifference = KillAuraCheck.calculateYawDifference(eyeLocation, block.getLocation());
|
||||||
double playerYaw = player.getEyeLocation().getYaw();
|
double playerYaw = player.getEyeLocation().getYaw();
|
||||||
double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
|
double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
|
||||||
if (Math.round(angleDifference) > magic.ILLEGALINTERACT_MAX_ANGLE_DIFFERENCE()) {
|
if (Math.round(angleDifference) > magic.ILLEGALINTERACT_MAX_ANGLE_DIFFERENCE()) {
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.rammelkast.anticheatreloaded.command.executors.CommandCheck;
|
import com.rammelkast.anticheatreloaded.command.executors.CommandCheck;
|
||||||
import com.rammelkast.anticheatreloaded.command.executors.CommandDeveloper;
|
|
||||||
import com.rammelkast.anticheatreloaded.command.executors.CommandHelp;
|
import com.rammelkast.anticheatreloaded.command.executors.CommandHelp;
|
||||||
import com.rammelkast.anticheatreloaded.command.executors.CommandLog;
|
import com.rammelkast.anticheatreloaded.command.executors.CommandLog;
|
||||||
|
import com.rammelkast.anticheatreloaded.command.executors.CommandMute;
|
||||||
import com.rammelkast.anticheatreloaded.command.executors.CommandReload;
|
import com.rammelkast.anticheatreloaded.command.executors.CommandReload;
|
||||||
import com.rammelkast.anticheatreloaded.command.executors.CommandReport;
|
import com.rammelkast.anticheatreloaded.command.executors.CommandReport;
|
||||||
import com.rammelkast.anticheatreloaded.command.executors.CommandReset;
|
import com.rammelkast.anticheatreloaded.command.executors.CommandReset;
|
||||||
@@ -42,10 +42,10 @@ public class CommandHandler implements CommandExecutor {
|
|||||||
public CommandHandler() {
|
public CommandHandler() {
|
||||||
commands.add(new CommandHelp());
|
commands.add(new CommandHelp());
|
||||||
commands.add(new CommandCheck());
|
commands.add(new CommandCheck());
|
||||||
commands.add(new CommandDeveloper());
|
|
||||||
commands.add(new CommandLog());
|
commands.add(new CommandLog());
|
||||||
commands.add(new CommandReload());
|
commands.add(new CommandReload());
|
||||||
commands.add(new CommandReport());
|
commands.add(new CommandReport());
|
||||||
|
commands.add(new CommandMute());
|
||||||
commands.add(new CommandReset());
|
commands.add(new CommandReset());
|
||||||
commands.add(new CommandVersion());
|
commands.add(new CommandVersion());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CommandCheck extends CommandBase {
|
public class CommandCheck extends CommandBase {
|
||||||
|
|
||||||
private static final String NAME = "AntiCheat Check Management";
|
private static final String NAME = "AntiCheatReloaded Check Management";
|
||||||
private static final String COMMAND = "check";
|
private static final String COMMAND = "check";
|
||||||
private static final String USAGE = "anticheat check [check] [on/off]";
|
private static final String USAGE = "anticheat check [check] [on/off]";
|
||||||
private static final Permission PERMISSION = Permission.SYSTEM_CHECK;
|
private static final Permission PERMISSION = Permission.SYSTEM_CHECK;
|
||||||
|
|||||||
-46
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* AntiCheatReloaded for Bukkit and Spigot.
|
|
||||||
* Copyright (c) 2012-2015 AntiCheat Team
|
|
||||||
* Copyright (c) 2016-2020 Rammelkast
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.rammelkast.anticheatreloaded.command.executors;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
|
||||||
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
|
||||||
import com.rammelkast.anticheatreloaded.util.Permission;
|
|
||||||
|
|
||||||
public class CommandDeveloper extends CommandBase {
|
|
||||||
|
|
||||||
private static final String NAME = "AntiCheat Developer Mode";
|
|
||||||
private static final String COMMAND = "developer";
|
|
||||||
private static final String USAGE = "anticheat developer";
|
|
||||||
private static final Permission PERMISSION = Permission.SYSTEM_DEBUG;
|
|
||||||
private static final String[] HELP = {
|
|
||||||
GRAY + "Use: " + AQUA + "/anticheat developer" + GRAY + " to turn on developer mode",
|
|
||||||
};
|
|
||||||
|
|
||||||
public CommandDeveloper() {
|
|
||||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void execute(CommandSender cs, String[] args) {
|
|
||||||
AntiCheatReloaded.setDeveloperMode(!AntiCheatReloaded.developerMode());
|
|
||||||
cs.sendMessage(GREEN + "Developer mode " + (AntiCheatReloaded.developerMode() ? "ON" : "OFF"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -33,6 +33,8 @@ public class CommandHelp extends CommandBase {
|
|||||||
private static final String[] HELP = {
|
private static final String[] HELP = {
|
||||||
GOLD + "/acr " + GRAY + "help",
|
GOLD + "/acr " + GRAY + "help",
|
||||||
GOLD + "/acr " + GRAY + "reload",
|
GOLD + "/acr " + GRAY + "reload",
|
||||||
|
GOLD + "/acr " + GRAY + "version",
|
||||||
|
GOLD + "/acr " + GRAY + "mute",
|
||||||
GOLD + "/acr " + GRAY + "check " + WHITE + "[check] [on/off]",
|
GOLD + "/acr " + GRAY + "check " + WHITE + "[check] [on/off]",
|
||||||
GOLD + "/acr " + GRAY + "log " + WHITE + "[file/console] [on/off]",
|
GOLD + "/acr " + GRAY + "log " + WHITE + "[file/console] [on/off]",
|
||||||
GOLD + "/acr " + GRAY + "report " + WHITE + "[group/user]",
|
GOLD + "/acr " + GRAY + "report " + WHITE + "[group/user]",
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import com.rammelkast.anticheatreloaded.util.Permission;
|
|||||||
|
|
||||||
public class CommandLog extends CommandBase {
|
public class CommandLog extends CommandBase {
|
||||||
|
|
||||||
private static final String NAME = "AntiCheat Logging";
|
private static final String NAME = "AntiCheatReloaded Logging";
|
||||||
private static final String COMMAND = "log";
|
private static final String COMMAND = "log";
|
||||||
private static final String USAGE = "anticheat log [file/console] [on/off]";
|
private static final String USAGE = "anticheat log [file/console] [on/off]";
|
||||||
private static final Permission PERMISSION = Permission.SYSTEM_LOG;
|
private static final Permission PERMISSION = Permission.SYSTEM_LOG;
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.rammelkast.anticheatreloaded.command.executors;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||||
|
|
||||||
|
public class CommandMute extends CommandBase {
|
||||||
|
|
||||||
|
private static final String NAME = "AntiCheatReloaded Mute";
|
||||||
|
private static final String COMMAND = "mute";
|
||||||
|
private static final String USAGE = "anticheat reload";
|
||||||
|
private static final Permission PERMISSION = Permission.SYSTEM_RELOAD;
|
||||||
|
private static final String[] HELP = {
|
||||||
|
GRAY + "Use: " + AQUA + "/anticheat mute" + GRAY + " to mute all notifications", };
|
||||||
|
|
||||||
|
public CommandMute() {
|
||||||
|
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute(CommandSender cs, String[] args) {
|
||||||
|
if (!(cs instanceof Player)) {
|
||||||
|
cs.sendMessage(ChatColor.BOLD + "" + GOLD + "ACR " + GRAY + "This command is only for players");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UUID uuid = ((Player) cs).getUniqueId();
|
||||||
|
if (AntiCheatReloaded.MUTE_ENABLED_MODS.contains(uuid)) {
|
||||||
|
cs.sendMessage(GOLD + "" + ChatColor.BOLD + "ACR " + GRAY + "Player alerts have been unmuted");
|
||||||
|
AntiCheatReloaded.MUTE_ENABLED_MODS.remove(uuid);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
cs.sendMessage(GOLD + "" + ChatColor.BOLD + "ACR " + GRAY + "Player alerts have been muted");
|
||||||
|
AntiCheatReloaded.MUTE_ENABLED_MODS.add(uuid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,7 +26,7 @@ import com.rammelkast.anticheatreloaded.util.Permission;
|
|||||||
|
|
||||||
public class CommandReload extends CommandBase {
|
public class CommandReload extends CommandBase {
|
||||||
|
|
||||||
private static final String NAME = "AntiCheat Reload";
|
private static final String NAME = "AntiCheatReloaded Reload";
|
||||||
private static final String COMMAND = "reload";
|
private static final String COMMAND = "reload";
|
||||||
private static final String USAGE = "anticheat reload";
|
private static final String USAGE = "anticheat reload";
|
||||||
private static final Permission PERMISSION = Permission.SYSTEM_RELOAD;
|
private static final Permission PERMISSION = Permission.SYSTEM_RELOAD;
|
||||||
|
|||||||
+9
-21
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
package com.rammelkast.anticheatreloaded.command.executors;
|
package com.rammelkast.anticheatreloaded.command.executors;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -27,16 +31,14 @@ import org.bukkit.entity.Player;
|
|||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||||
import com.rammelkast.anticheatreloaded.manage.CheckManager;
|
import com.rammelkast.anticheatreloaded.util.Group;
|
||||||
import com.rammelkast.anticheatreloaded.util.*;
|
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
import java.util.ArrayList;
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class CommandReport extends CommandBase {
|
public class CommandReport extends CommandBase {
|
||||||
|
|
||||||
private static final String NAME = "AntiCheat Reports";
|
private static final String NAME = "AntiCheatReloaded Reports";
|
||||||
private static final String COMMAND = "report";
|
private static final String COMMAND = "report";
|
||||||
private static final String USAGE = "anticheat report [group/user]";
|
private static final String USAGE = "anticheat report [group/user]";
|
||||||
private static final Permission PERMISSION = Permission.SYSTEM_REPORT;
|
private static final Permission PERMISSION = Permission.SYSTEM_REPORT;
|
||||||
@@ -182,19 +184,5 @@ public class CommandReport extends CommandBase {
|
|||||||
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages + 1);
|
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AntiCheatReloaded.developerMode()) {
|
|
||||||
int permission = 0;
|
|
||||||
int check = 0;
|
|
||||||
for (Permission perm : Permission.values()) {
|
|
||||||
if (perm.get(user.getPlayer())) permission++;
|
|
||||||
}
|
|
||||||
CheckManager manager = AntiCheatReloaded.getManager().getCheckManager();
|
|
||||||
for (CheckType type : CheckType.values()) {
|
|
||||||
if (manager.willCheck(user.getPlayer(), type)) check++;
|
|
||||||
}
|
|
||||||
cs.sendMessage(ChatColor.GOLD + "User has " + permission + "/" + Permission.values().length + " permissions");
|
|
||||||
cs.sendMessage(ChatColor.GOLD + "User will be checked for " + check + "/" + CheckType.values().length + " checks");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ import com.rammelkast.anticheatreloaded.util.User;
|
|||||||
|
|
||||||
public class CommandReset extends CommandBase {
|
public class CommandReset extends CommandBase {
|
||||||
|
|
||||||
private static final String NAME = "AntiCheat Resetting";
|
private static final String NAME = "AntiCheatReloaded Resetting";
|
||||||
private static final String COMMAND = "reset";
|
private static final String COMMAND = "reset";
|
||||||
private static final String USAGE = "anticheat reset [user]";
|
private static final String USAGE = "anticheat reset [user]";
|
||||||
private static final Permission PERMISSION = Permission.SYSTEM_RESET;
|
private static final Permission PERMISSION = Permission.SYSTEM_RESET;
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ public class CommandVersion extends CommandBase {
|
|||||||
private static final String NAME = "AntiCheatReloaded Version";
|
private static final String NAME = "AntiCheatReloaded Version";
|
||||||
private static final String COMMAND = "version";
|
private static final String COMMAND = "version";
|
||||||
private static final String USAGE = "anticheat version";
|
private static final String USAGE = "anticheat version";
|
||||||
private static final Permission PERMISSION = Permission.SYSTEM_NOTICE;
|
private static final Permission PERMISSION = Permission.SYSTEM_VERSION;
|
||||||
private static final String[] HELP = {
|
private static final String[] HELP = {
|
||||||
GRAY + "Use: " + AQUA + "/anticheat version" + GRAY + " to get update information", };
|
GRAY + "Use: " + AQUA + "/anticheat version" + GRAY + " to get update information", };
|
||||||
|
|
||||||
|
|||||||
@@ -350,14 +350,6 @@ public interface Magic {
|
|||||||
* The minimum time it should have taken for the player to click X times; Type=INTEGER; Leniency=INCREASE.
|
* The minimum time it should have taken for the player to click X times; Type=INTEGER; Leniency=INCREASE.
|
||||||
*/
|
*/
|
||||||
public int INVENTORY_TIMEMIN();
|
public int INVENTORY_TIMEMIN();
|
||||||
/**
|
|
||||||
* The number of steps we should wait before checking if the player has used timer cheating; Type=INTEGER; Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int TIMER_STEP_CHECK();
|
|
||||||
/**
|
|
||||||
* The minimum time it should have taken for the player to travel X steps; Type=SYSTEM; Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public int TIMER_TIMEMIN();
|
|
||||||
/**
|
/**
|
||||||
* Minimum travel distance for move to be considered a teleport and subsequently be ignored; Type=INTEGER, Leniency=INCREASE.
|
* Minimum travel distance for move to be considered a teleport and subsequently be ignored; Type=INTEGER, Leniency=INCREASE.
|
||||||
*/
|
*/
|
||||||
@@ -365,11 +357,11 @@ public interface Magic {
|
|||||||
/**
|
/**
|
||||||
* Maximum amount of packets a player can send in a second; Type=INTEGER, Leniency=INCREASE.
|
* Maximum amount of packets a player can send in a second; Type=INTEGER, Leniency=INCREASE.
|
||||||
*/
|
*/
|
||||||
public int BLINK_PACKET();
|
public int MOREPACKETS_LIMIT();
|
||||||
/**
|
/**
|
||||||
* The average ping settings used to account for lag; TYPE=INTEGER, Leniency=INCREASE
|
* The average ping settings used to account for lag; TYPE=INTEGER, Leniency=INCREASE
|
||||||
*/
|
*/
|
||||||
public int BLINK_AVERAGE_PING();
|
public int MOREPACKETS_AVERAGE_PING();
|
||||||
/**
|
/**
|
||||||
* Maximum amount of low/zero velocity moments before flagging; Type=INTEGER, Leniency=INCREASE.
|
* Maximum amount of low/zero velocity moments before flagging; Type=INTEGER, Leniency=INCREASE.
|
||||||
*/
|
*/
|
||||||
@@ -390,4 +382,12 @@ public interface Magic {
|
|||||||
* The maximum angle difference allowed when breaking or placing blocks; TYPE=INTEGER, Leniency=INCREASE
|
* The maximum angle difference allowed when breaking or placing blocks; TYPE=INTEGER, Leniency=INCREASE
|
||||||
*/
|
*/
|
||||||
public int ILLEGALINTERACT_MAX_ANGLE_DIFFERENCE();
|
public int ILLEGALINTERACT_MAX_ANGLE_DIFFERENCE();
|
||||||
|
/**
|
||||||
|
* The minimum time it takes to regenerate health; TYPE=INTEGER, Leniency=DECREASE
|
||||||
|
*/
|
||||||
|
public int MIN_HEAL_TIME();
|
||||||
|
/**
|
||||||
|
* Maximum distance allowed between two movement packets; Type=DOUBLE, Leniency=INCREASE.
|
||||||
|
*/
|
||||||
|
public double BADPACKETS_MAX_DISTANCE();
|
||||||
}
|
}
|
||||||
@@ -39,6 +39,7 @@ import com.rammelkast.anticheatreloaded.check.combat.CriticalsCheck;
|
|||||||
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||||
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
|
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
|
||||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
public class EntityListener extends EventListener {
|
public class EntityListener extends EventListener {
|
||||||
|
|
||||||
@@ -114,7 +115,7 @@ public class EntityListener extends EventListener {
|
|||||||
if (e.getDamager() instanceof Player) {
|
if (e.getDamager() instanceof Player) {
|
||||||
Player p = (Player) e.getDamager();
|
Player p = (Player) e.getDamager();
|
||||||
getBackend().logDamage(p, 1);
|
getBackend().logDamage(p, 1);
|
||||||
int value = p.getInventory().getItemInMainHand().containsEnchantment(Enchantment.KNOCKBACK) ? 2 : 1;
|
int value = VersionUtil.getItemInHand(player).containsEnchantment(Enchantment.KNOCKBACK) ? 2 : 1;
|
||||||
getBackend().logDamage(player, value);
|
getBackend().logDamage(player, value);
|
||||||
if (getCheckManager().willCheck(p, CheckType.LONG_REACH)) {
|
if (getCheckManager().willCheck(p, CheckType.LONG_REACH)) {
|
||||||
Distance distance = new Distance(player.getLocation(), p.getLocation());
|
Distance distance = new Distance(player.getLocation(), p.getLocation());
|
||||||
@@ -160,14 +161,6 @@ public class EntityListener extends EventListener {
|
|||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
|
|
||||||
CheckResult result = KillAuraCheck.checkFightSpeed(player, event);
|
|
||||||
if (result.failed()) {
|
|
||||||
event.setCancelled(!silentMode());
|
|
||||||
log(result.getMessage(), player, CheckType.KILLAURA);
|
|
||||||
noHack = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (noHack) {
|
if (noHack) {
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,12 @@
|
|||||||
|
|
||||||
package com.rammelkast.anticheatreloaded.event;
|
package com.rammelkast.anticheatreloaded.event;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -27,14 +33,10 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
|||||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
import com.rammelkast.anticheatreloaded.manage.*;
|
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.manage.CheckManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.manage.UserManager;
|
||||||
import com.rammelkast.anticheatreloaded.util.User;
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
|
||||||
|
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class EventListener implements Listener {
|
public class EventListener implements Listener {
|
||||||
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
|
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
|
||||||
@@ -44,13 +46,18 @@ public class EventListener implements Listener {
|
|||||||
private static final AntiCheatReloaded PLUGIN = AntiCheatReloaded.getManager().getPlugin();
|
private static final AntiCheatReloaded PLUGIN = AntiCheatReloaded.getManager().getPlugin();
|
||||||
private static final UserManager USER_MANAGER = AntiCheatReloaded.getManager().getUserManager();
|
private static final UserManager USER_MANAGER = AntiCheatReloaded.getManager().getUserManager();
|
||||||
private static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration();
|
private static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration();
|
||||||
|
private static final DecimalFormat TPS_FORMAT = new DecimalFormat("##.##");
|
||||||
|
|
||||||
public static void log(String message, Player player, CheckType type) {
|
public static void log(String message, Player player, CheckType type) {
|
||||||
User user = getUserManager().getUser(player.getUniqueId());
|
User user = getUserManager().getUser(player.getUniqueId());
|
||||||
if (message == null || message.equals("")) {
|
if (message == null || message.equals("")) {
|
||||||
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed " + CheckType.getName(type);
|
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed "
|
||||||
|
+ CheckType.getName(type);
|
||||||
} else {
|
} else {
|
||||||
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed " + CheckType.getName(type) + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + VersionUtil.getPlayerPing(player) + "ms";
|
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed "
|
||||||
|
+ CheckType.getName(type) + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message
|
||||||
|
+ ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms"
|
||||||
|
+ ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS());
|
||||||
}
|
}
|
||||||
if (user != null) { // npc
|
if (user != null) { // npc
|
||||||
logCheat(type, user);
|
logCheat(type, user);
|
||||||
@@ -62,9 +69,8 @@ public class EventListener implements Listener {
|
|||||||
|
|
||||||
if (CONFIG.getConfig().debugMode.getValue()) {
|
if (CONFIG.getConfig().debugMode.getValue()) {
|
||||||
player.sendMessage(message);
|
player.sendMessage(message);
|
||||||
} else {
|
|
||||||
AntiCheatReloaded.getPlugin().sendToStaff(message);
|
|
||||||
}
|
}
|
||||||
|
AntiCheatReloaded.getPlugin().sendToStaff(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void logCheat(CheckType type, User user) {
|
private static void logCheat(CheckType type, User user) {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||||
@@ -44,6 +43,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.event.player.PlayerKickEvent;
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||||
@@ -57,6 +57,7 @@ import org.bukkit.inventory.PlayerInventory;
|
|||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||||
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
|
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
|
||||||
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
|
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
|
||||||
import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
|
import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
|
||||||
@@ -246,18 +247,26 @@ public class PlayerListener extends EventListener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
PlayerInventory inv = player.getInventory();
|
PlayerInventory inv = player.getInventory();
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
ItemStack itemInHand = ((event.getHand() == EquipmentSlot.HAND) ? inv.getItemInMainHand() : inv.getItemInOffHand());
|
ItemStack itemInHand;
|
||||||
|
if (VersionUtil.isBountifulUpdate()) {
|
||||||
|
itemInHand = VersionUtil.getItemInHand(player);
|
||||||
|
} else {
|
||||||
|
itemInHand = ((event.getHand() == EquipmentSlot.HAND) ? inv.getItemInMainHand() : inv.getItemInOffHand());
|
||||||
|
}
|
||||||
|
|
||||||
if (itemInHand.getType() == Material.BOW) {
|
if (itemInHand.getType() == Material.BOW) {
|
||||||
getBackend().logBowWindUp(player);
|
getBackend().logBowWindUp(player);
|
||||||
} else if (Utilities.isFood(itemInHand.getType()) || Utilities.isFood(itemInHand.getType())) {
|
} else if (Utilities.isFood(itemInHand.getType()) || Utilities.isFood(itemInHand.getType())) {
|
||||||
getBackend().logEatingStart(player);
|
getBackend().logEatingStart(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!VersionUtil.isBountifulUpdate()) {
|
||||||
if (itemInHand.getType() == Material.FIREWORK_ROCKET) {
|
if (itemInHand.getType() == Material.FIREWORK_ROCKET) {
|
||||||
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId().toString());
|
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
|
||||||
if (player.isGliding()) {
|
if (player.isGliding()) {
|
||||||
// TODO config max elytra height?
|
// TODO config max elytra height?
|
||||||
ElytraCheck.JUMP_Y_VALUE.put(player.getUniqueId().toString(), 9999.99D);
|
ElytraCheck.JUMP_Y_VALUE.put(player.getUniqueId(), 9999.99D);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,14 +325,6 @@ public class PlayerListener extends EventListener {
|
|||||||
getConfig().getLevels().loadLevelToUser(user);
|
getConfig().getLevels().loadLevelToUser(user);
|
||||||
getUserManager().addUser(user);
|
getUserManager().addUser(user);
|
||||||
|
|
||||||
if (player.hasMetadata(Utilities.SPY_METADATA)) {
|
|
||||||
for (Player p : player.getServer().getOnlinePlayers()) {
|
|
||||||
if (!Permission.SYSTEM_SPY.get(p)) {
|
|
||||||
p.hidePlayer(AntiCheatReloaded.getPlugin(), player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
|
||||||
if (player.hasPermission("anticheat.admin") && !AntiCheatReloaded.getUpdateManager().isLatest()) {
|
if (player.hasPermission("anticheat.admin") && !AntiCheatReloaded.getUpdateManager().isLatest()) {
|
||||||
@@ -345,9 +346,6 @@ public class PlayerListener extends EventListener {
|
|||||||
final User user = getUserManager().getUser(player.getUniqueId());
|
final User user = getUserManager().getUser(player.getUniqueId());
|
||||||
user.setTo(to.getX(), to.getY(), to.getZ());
|
user.setTo(to.getX(), to.getY(), to.getZ());
|
||||||
|
|
||||||
//KillAuraCheck.doMove(event);
|
|
||||||
//TODO
|
|
||||||
|
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) {
|
if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) {
|
||||||
CheckResult result = FlightCheck.runCheck(player, distance);
|
CheckResult result = FlightCheck.runCheck(player, distance);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
@@ -360,7 +358,6 @@ public class PlayerListener extends EventListener {
|
|||||||
if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) {
|
if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) {
|
||||||
CheckResult result = GlideCheck.runCheck(player, distance);
|
CheckResult result = GlideCheck.runCheck(player, distance);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
// NO TELEPORT NEEDED HERE, HANDLED BY CHECK ITSELF
|
|
||||||
log(result.getMessage(), player, CheckType.FLIGHT);
|
log(result.getMessage(), player, CheckType.FLIGHT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -456,14 +453,20 @@ public class PlayerListener extends EventListener {
|
|||||||
user.setGoodLocation(event.getFrom());
|
user.setGoodLocation(event.getFrom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (getCheckManager().willCheckQuick(player, CheckType.KILLAURA)) {
|
||||||
|
CheckResult result = KillAuraCheck.checkAimbot(player, event);
|
||||||
|
if (result.failed()) {
|
||||||
|
log(result.getMessage(), player, CheckType.KILLAURA);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.HIGHEST)
|
@EventHandler(priority=EventPriority.HIGHEST)
|
||||||
public void onDeath(PlayerDeathEvent e) {
|
public void onRespawn(PlayerRespawnEvent event) {
|
||||||
//KillAuraCheck.cleanPlayer(e.getEntity()); // Remove bots on death to reduce lag
|
getBackend().logTeleport(event.getPlayer());
|
||||||
//TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@@ -481,7 +484,7 @@ public class PlayerListener extends EventListener {
|
|||||||
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.FLIGHT) && !player.isFlying()) {
|
if (getCheckManager().willCheck(player, CheckType.FLIGHT) && !player.isFlying()) {
|
||||||
CheckResult result1 = YAxisCheck.runCheck(player, new Distance(from, to));
|
CheckResult result1 = YAxisCheck.runCheck(player, new Distance(from, to));
|
||||||
CheckResult result2 = getBackend().checkAscension(player, from.getY(), to.getY());
|
CheckResult result2 = FlightCheck.checkAscension(player, from.getY(), to.getY());
|
||||||
String log = result1.failed() ? result1.getMessage() : result2.failed() ? result2.getMessage() : "";
|
String log = result1.failed() ? result1.getMessage() : result2.failed() ? result2.getMessage() : "";
|
||||||
if (!log.equals("")) {
|
if (!log.equals("")) {
|
||||||
if (!silentMode()) {
|
if (!silentMode()) {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import org.bukkit.event.vehicle.VehicleEnterEvent;
|
|||||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||||
|
|
||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
public class VehicleListener extends EventListener {
|
public class VehicleListener extends EventListener {
|
||||||
|
|
||||||
@@ -48,15 +49,17 @@ public class VehicleListener extends EventListener {
|
|||||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
||||||
// TODO fix deprecations
|
if (VersionUtil.isBountifulUpdate()) {
|
||||||
//if (event.getVehicle().getPassenger() != null && event.getVehicle().getPassenger() instanceof Player) {
|
if (event.getVehicle().getPassenger() != null) {
|
||||||
// getBackend().logEnterExit((Player) event.getVehicle().getPassenger());
|
Entity entity = event.getVehicle().getPassenger();
|
||||||
//}
|
if (entity instanceof Player) {
|
||||||
|
getBackend().logEnterExit((Player) entity);
|
||||||
// TODO this should work, untested though.
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (!event.getVehicle().getPassengers().isEmpty()) {
|
if (!event.getVehicle().getPassengers().isEmpty()) {
|
||||||
for (Entity entity : event.getVehicle().getPassengers()) {
|
for (Entity entity : event.getVehicle().getPassengers()) {
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
@@ -64,6 +67,7 @@ public class VehicleListener extends EventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,20 +19,19 @@
|
|||||||
|
|
||||||
package com.rammelkast.anticheatreloaded.manage;
|
package com.rammelkast.anticheatreloaded.manage;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
|
||||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
|
||||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p/>
|
* <p/>
|
||||||
* The manager that AntiCheat will check with to see if it should watch certain checks and certain players.
|
* The manager that AntiCheat will check with to see if it should watch certain checks and certain players.
|
||||||
@@ -177,7 +176,6 @@ public class CheckManager {
|
|||||||
&& !isExempt(player, type)
|
&& !isExempt(player, type)
|
||||||
&& !type.checkPermission(player)
|
&& !type.checkPermission(player)
|
||||||
&& !isOpExempt(player);
|
&& !isOpExempt(player);
|
||||||
AntiCheatReloaded.debugLog("Check " + type + (check ? " run " : " not run ") + "on " + player.getName());
|
|
||||||
if ((type == CheckType.FLIGHT || type == CheckType.SPEED) && VersionUtil.isFlying(player))
|
if ((type == CheckType.FLIGHT || type == CheckType.SPEED) && VersionUtil.isFlying(player))
|
||||||
return false;
|
return false;
|
||||||
return check;
|
return check;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public class Distance {
|
|||||||
private final double ZDiff;
|
private final double ZDiff;
|
||||||
|
|
||||||
private final Location from;
|
private final Location from;
|
||||||
|
private final Location to;
|
||||||
|
|
||||||
public Distance(Location from, Location to) {
|
public Distance(Location from, Location to) {
|
||||||
l1Y = to.getY();
|
l1Y = to.getY();
|
||||||
@@ -40,6 +41,7 @@ public class Distance {
|
|||||||
YDiff = Math.abs(l1Y - l2Y);
|
YDiff = Math.abs(l1Y - l2Y);
|
||||||
|
|
||||||
this.from = from;
|
this.from = from;
|
||||||
|
this.to = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double fromY() {
|
public double fromY() {
|
||||||
@@ -65,4 +67,8 @@ public class Distance {
|
|||||||
public Location getFrom() {
|
public Location getFrom() {
|
||||||
return this.from;
|
return this.from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Location getTo() {
|
||||||
|
return this.to;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.rammelkast.anticheatreloaded.util;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
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.packet.BadPacketsCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck;
|
||||||
|
|
||||||
|
public class PacketListener {
|
||||||
|
|
||||||
|
public static void listenMovementPackets() {
|
||||||
|
AntiCheatReloaded.getProtocolManager()
|
||||||
|
.addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST,
|
||||||
|
new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK }) {
|
||||||
|
@Override
|
||||||
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
// Run MorePackets check
|
||||||
|
MorePacketsCheck.runCheck(player, event);
|
||||||
|
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
// Run BadPackets check
|
||||||
|
BadPacketsCheck.runCheck(player, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void listenKeepAlivePackets() {
|
||||||
|
AntiCheatReloaded.getProtocolManager()
|
||||||
|
.addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST,
|
||||||
|
new PacketType[] { PacketType.Play.Client.KEEP_ALIVE, PacketType.Play.Server.KEEP_ALIVE }) {
|
||||||
|
@Override
|
||||||
|
public void onPacketSending(PacketEvent event) {
|
||||||
|
User user = AntiCheatReloaded.getManager().getUserManager().getUser(event.getPlayer().getUniqueId());
|
||||||
|
user.onServerPing();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
|
User user = AntiCheatReloaded.getManager().getUserManager().getUser(event.getPlayer().getUniqueId());
|
||||||
|
user.onClientPong();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -26,10 +26,10 @@ public enum Permission {
|
|||||||
CHECK_FLIGHT, CHECK_ELYTRA, CHECK_WATERWALK, CHECK_NOSWING, CHECK_FASTBREAK,
|
CHECK_FLIGHT, CHECK_ELYTRA, CHECK_WATERWALK, CHECK_NOSWING, CHECK_FASTBREAK,
|
||||||
CHECK_FASTPLACE, CHECK_CHATSPAM, CHECK_COMMANDSPAM, CHECK_SPRINT, CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP,
|
CHECK_FASTPLACE, CHECK_CHATSPAM, CHECK_COMMANDSPAM, CHECK_SPRINT, CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP,
|
||||||
CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, CHECK_KILLAURA, CHECK_LONGREACH, CHECK_UNICODE,
|
CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, CHECK_KILLAURA, CHECK_LONGREACH, CHECK_UNICODE,
|
||||||
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_BLINK, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGAL_INTERACT,
|
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGAL_INTERACT,
|
||||||
|
|
||||||
/* System Nodes */
|
/* System Nodes */
|
||||||
SYSTEM_LOG, SYSTEM_RESET, SYSTEM_SPY, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_ALERT, SYSTEM_NOTICE,
|
SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_ALERT, SYSTEM_NOTICE,
|
||||||
SYSTEM_CALIBRATE, SYSTEM_CHECK, SYSTEM_DEBUG, SYSTEM_RELOAD;
|
SYSTEM_CALIBRATE, SYSTEM_CHECK, SYSTEM_DEBUG, SYSTEM_RELOAD;
|
||||||
|
|
||||||
private static final String PERMISSION_ALL = "anticheat.*";
|
private static final String PERMISSION_ALL = "anticheat.*";
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public class UpdateManager {
|
|||||||
builder.append((char) readChar);
|
builder.append((char) readChar);
|
||||||
}
|
}
|
||||||
data = builder.toString();
|
data = builder.toString();
|
||||||
|
reader.close();
|
||||||
} catch (IOException exception) {}
|
} catch (IOException exception) {}
|
||||||
finally {
|
finally {
|
||||||
if (stream != null) {
|
if (stream != null) {
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ public class User {
|
|||||||
private boolean isWaitingOnLevelSync;
|
private boolean isWaitingOnLevelSync;
|
||||||
private Timestamp levelSyncTimestamp;
|
private Timestamp levelSyncTimestamp;
|
||||||
|
|
||||||
|
private long lastServerPing, lastClientPong;
|
||||||
|
private int ping = -1;
|
||||||
|
private int lastPing = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize an AntiCheat user
|
* Initialize an AntiCheat user
|
||||||
*
|
*
|
||||||
@@ -63,16 +67,6 @@ public class User {
|
|||||||
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1;
|
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize an AntiCheat user
|
|
||||||
*
|
|
||||||
* @param name Player's name
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* public User(String name) { this.uuid = Bukkit.getPlayer(name).getUniqueId();
|
|
||||||
* this.name = name; this.id = getPlayer() != null && getPlayer().isOnline() ?
|
|
||||||
* getPlayer().getEntityId() : -1; }
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Get the player's UUID
|
* Get the player's UUID
|
||||||
*
|
*
|
||||||
@@ -429,6 +423,36 @@ public class User {
|
|||||||
return levelSyncTimestamp;
|
return levelSyncTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onServerPing() {
|
||||||
|
this.lastServerPing = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClientPong() {
|
||||||
|
this.lastClientPong = System.currentTimeMillis();
|
||||||
|
this.lastPing = this.ping;
|
||||||
|
this.ping = (int) (this.lastClientPong - this.lastServerPing);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPing() {
|
||||||
|
int ping = this.ping;
|
||||||
|
if (ping < 0) {
|
||||||
|
return VersionUtil.getPlayerPing(this.getPlayer());
|
||||||
|
}
|
||||||
|
return ping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLastPing() {
|
||||||
|
int lastPing = this.lastPing;
|
||||||
|
if (lastPing < 0) {
|
||||||
|
return this.getPing();
|
||||||
|
}
|
||||||
|
return lastPing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLagging() {
|
||||||
|
return Math.abs(this.ping - this.lastPing) > 50;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "User {name = " + getName() + ", level = " + level + "}";
|
return "User {name = " + getName() + ", level = " + level + "}";
|
||||||
|
|||||||
@@ -38,9 +38,12 @@ import org.bukkit.util.NumberConversions;
|
|||||||
public final class Utilities {
|
public final class Utilities {
|
||||||
private static final List<Material> INSTANT_BREAK = new ArrayList<Material>();
|
private static final List<Material> INSTANT_BREAK = new ArrayList<Material>();
|
||||||
private static final List<Material> FOOD = new ArrayList<Material>();
|
private static final List<Material> FOOD = new ArrayList<Material>();
|
||||||
|
private static final List<Material> CLIMBABLE = new ArrayList<Material>();
|
||||||
private static final Map<Material, Material> COMBO = new HashMap<Material, Material>();
|
private static final Map<Material, Material> COMBO = new HashMap<Material, Material>();
|
||||||
|
|
||||||
public static final String SPY_METADATA = "ac-spydata";
|
public static final Material LILY_PAD;
|
||||||
|
public static final Material COB_WEB;
|
||||||
|
public static final Material IRON_BARS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if only the block beneath them is standable (includes water + lava)
|
* Check if only the block beneath them is standable (includes water + lava)
|
||||||
@@ -50,7 +53,7 @@ public final class Utilities {
|
|||||||
*/
|
*/
|
||||||
public static boolean cantStandAtSingle(Block block) {
|
public static boolean cantStandAtSingle(Block block) {
|
||||||
Block otherBlock = block.getLocation().add(0, -0.5, 0).getBlock();
|
Block otherBlock = block.getLocation().add(0, -0.5, 0).getBlock();
|
||||||
boolean center = otherBlock.getType() == Material.AIR || otherBlock.getType() == Material.CAVE_AIR;
|
boolean center = otherBlock.getType() == Material.AIR;
|
||||||
return center;
|
return center;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +109,16 @@ public final class Utilities {
|
|||||||
* @return true if the player can stand here
|
* @return true if the player can stand here
|
||||||
*/
|
*/
|
||||||
public static boolean canStand(Block block) {
|
public static boolean canStand(Block block) {
|
||||||
return !(block.isLiquid() || block.getType() == Material.AIR || block.getType() == Material.CAVE_AIR);
|
return !(block.isLiquid() || block.getType() == Material.AIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSlime(Block block) {
|
||||||
|
return block.getType() == Material.SLIME_BLOCK;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isNotNearSlime(Block block) {
|
||||||
|
return !isSlime(block.getRelative(BlockFace.NORTH)) && !isSlime(block.getRelative(BlockFace.EAST))
|
||||||
|
&& !isSlime(block.getRelative(BlockFace.SOUTH)) && !isSlime(block.getRelative(BlockFace.WEST)) && !isSlime(block.getRelative(BlockFace.DOWN));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -159,7 +171,7 @@ public final class Utilities {
|
|||||||
public static boolean isHoveringOverWater(Location player, int blocks) {
|
public static boolean isHoveringOverWater(Location player, int blocks) {
|
||||||
for (int i = player.getBlockY(); i > player.getBlockY() - blocks; i--) {
|
for (int i = player.getBlockY(); i > player.getBlockY() - blocks; i--) {
|
||||||
Block newloc = (new Location(player.getWorld(), player.getBlockX(), i, player.getBlockZ())).getBlock();
|
Block newloc = (new Location(player.getWorld(), player.getBlockX(), i, player.getBlockZ())).getBlock();
|
||||||
if (newloc.getType() != Material.AIR && newloc.getType() != Material.CAVE_AIR) {
|
if (newloc.getType() != Material.AIR) {
|
||||||
return newloc.isLiquid();
|
return newloc.isLiquid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,12 +249,11 @@ public final class Utilities {
|
|||||||
*/
|
*/
|
||||||
public static boolean isOnLilyPad(Player player) {
|
public static boolean isOnLilyPad(Player player) {
|
||||||
Block block = player.getLocation().getBlock();
|
Block block = player.getLocation().getBlock();
|
||||||
Material lily = Material.LILY_PAD;
|
|
||||||
// TODO: Can we fix X this?
|
// TODO: Can we fix X this?
|
||||||
return block.getType() == lily || block.getRelative(BlockFace.NORTH).getType() == lily
|
return block.getType() == LILY_PAD || block.getRelative(BlockFace.NORTH).getType() == LILY_PAD
|
||||||
|| block.getRelative(BlockFace.SOUTH).getType() == lily
|
|| block.getRelative(BlockFace.SOUTH).getType() == LILY_PAD
|
||||||
|| block.getRelative(BlockFace.EAST).getType() == lily
|
|| block.getRelative(BlockFace.EAST).getType() == LILY_PAD
|
||||||
|| block.getRelative(BlockFace.WEST).getType() == lily;
|
|| block.getRelative(BlockFace.WEST).getType() == LILY_PAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -275,9 +286,9 @@ public final class Utilities {
|
|||||||
* @return true if in web
|
* @return true if in web
|
||||||
*/
|
*/
|
||||||
public static boolean isInWeb(Player player) {
|
public static boolean isInWeb(Player player) {
|
||||||
return player.getLocation().getBlock().getType() == Material.COBWEB
|
return player.getLocation().getBlock().getType() == COB_WEB
|
||||||
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.COBWEB
|
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == COB_WEB
|
||||||
|| player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == Material.COBWEB;
|
|| player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == COB_WEB;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -287,8 +298,7 @@ public final class Utilities {
|
|||||||
* @return true if climbable
|
* @return true if climbable
|
||||||
*/
|
*/
|
||||||
public static boolean isClimbableBlock(Block block) {
|
public static boolean isClimbableBlock(Block block) {
|
||||||
return block.getType() == Material.VINE || block.getType() == Material.LADDER
|
return CLIMBABLE.contains(block.getType());
|
||||||
|| block.getType() == Material.WATER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -504,7 +514,151 @@ public final class Utilities {
|
|||||||
return seconds;
|
return seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code by Hawk Anticheat
|
||||||
|
* (https://github.com/HawkAnticheat/Hawk/blob/master/src/me/islandscout/hawk/util/MathPlus.java)
|
||||||
|
*
|
||||||
|
* @param a
|
||||||
|
* @param b
|
||||||
|
* @return the greatest common divisor between two floats
|
||||||
|
*/
|
||||||
|
public static float gcdRational(float a, float b) {
|
||||||
|
if (a == 0) {
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
int quotient = getIntQuotient(b, a);
|
||||||
|
float remainder = ((b / a) - quotient) * a;
|
||||||
|
if (Math.abs(remainder) < Math.max(a, b) * 1E-3F)
|
||||||
|
remainder = 0;
|
||||||
|
return gcdRational(remainder, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code by Hawk Anticheat
|
||||||
|
* (https://github.com/HawkAnticheat/Hawk/blob/master/src/me/islandscout/hawk/util/MathPlus.java)
|
||||||
|
*
|
||||||
|
* @param numbers
|
||||||
|
* @return the greatest common divisor between a list of floats
|
||||||
|
*/
|
||||||
|
public static float gcdRational(List<Float> numbers) {
|
||||||
|
float result = numbers.get(0);
|
||||||
|
for (int i = 1; i < numbers.size(); i++) {
|
||||||
|
result = gcdRational(numbers.get(i), result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code by Hawk Anticheat
|
||||||
|
* (https://github.com/HawkAnticheat/Hawk/blob/master/src/me/islandscout/hawk/util/MathPlus.java)
|
||||||
|
*
|
||||||
|
* @param dividend
|
||||||
|
* @param divisor
|
||||||
|
*/
|
||||||
|
public static int getIntQuotient(float dividend, float divisor) {
|
||||||
|
float ans = dividend / divisor;
|
||||||
|
float error = Math.max(dividend, divisor) * 1E-3F;
|
||||||
|
return (int) (ans + error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isHoneyBlock(Block block) {
|
||||||
|
if (!VersionUtil.isOfVersion("v1_15")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return block.getType() == Material.HONEY_BLOCK;
|
||||||
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
// Start 1.8.8
|
||||||
|
if (VersionUtil.isBountifulUpdate()) {
|
||||||
|
LILY_PAD = XMaterial.LILY_PAD.parseMaterial();
|
||||||
|
COB_WEB = XMaterial.COBWEB.parseMaterial();
|
||||||
|
IRON_BARS = XMaterial.IRON_BARS.parseMaterial();
|
||||||
|
|
||||||
|
// Start instant break materials
|
||||||
|
INSTANT_BREAK.add(XMaterial.COMPARATOR.parseMaterial());
|
||||||
|
INSTANT_BREAK.add(XMaterial.REPEATER.parseMaterial());
|
||||||
|
INSTANT_BREAK.add(Material.TORCH);
|
||||||
|
INSTANT_BREAK.add(XMaterial.REDSTONE_TORCH.parseMaterial());
|
||||||
|
INSTANT_BREAK.add(Material.REDSTONE_WIRE);
|
||||||
|
INSTANT_BREAK.add(Material.TRIPWIRE);
|
||||||
|
INSTANT_BREAK.add(Material.TRIPWIRE_HOOK);
|
||||||
|
INSTANT_BREAK.add(Material.FIRE);
|
||||||
|
INSTANT_BREAK.add(Material.FLOWER_POT);
|
||||||
|
INSTANT_BREAK.add(Material.TNT);
|
||||||
|
INSTANT_BREAK.add(Material.SLIME_BLOCK);
|
||||||
|
INSTANT_BREAK.add(Material.CARROT);
|
||||||
|
INSTANT_BREAK.add(Material.DEAD_BUSH);
|
||||||
|
INSTANT_BREAK.add(Material.GRASS);
|
||||||
|
INSTANT_BREAK.add(XMaterial.TALL_GRASS.parseMaterial());
|
||||||
|
INSTANT_BREAK.add(LILY_PAD);
|
||||||
|
INSTANT_BREAK.add(Material.MELON_STEM);
|
||||||
|
INSTANT_BREAK.add(Material.MELON_STEM);
|
||||||
|
INSTANT_BREAK.add(Material.BROWN_MUSHROOM);
|
||||||
|
INSTANT_BREAK.add(Material.RED_MUSHROOM);
|
||||||
|
INSTANT_BREAK.add(XMaterial.NETHER_WART.parseMaterial());
|
||||||
|
INSTANT_BREAK.add(Material.POTATO);
|
||||||
|
INSTANT_BREAK.add(Material.PUMPKIN_STEM);
|
||||||
|
INSTANT_BREAK.add(Material.PUMPKIN_STEM);
|
||||||
|
INSTANT_BREAK.add(XMaterial.OAK_SAPLING.parseMaterial());
|
||||||
|
INSTANT_BREAK.add(Material.SUGAR_CANE);
|
||||||
|
INSTANT_BREAK.add(Material.WHEAT);
|
||||||
|
// End instant break materials
|
||||||
|
|
||||||
|
// Start food
|
||||||
|
FOOD.add(Material.APPLE);
|
||||||
|
FOOD.add(Material.BAKED_POTATO);
|
||||||
|
FOOD.add(Material.BREAD);
|
||||||
|
FOOD.add(Material.CAKE);
|
||||||
|
FOOD.add(Material.CARROT);
|
||||||
|
FOOD.add(Material.COOKED_CHICKEN);
|
||||||
|
FOOD.add(XMaterial.COOKED_COD.parseMaterial());
|
||||||
|
FOOD.add(XMaterial.COD.parseMaterial());
|
||||||
|
FOOD.add(Material.COOKED_MUTTON);
|
||||||
|
FOOD.add(XMaterial.COOKED_PORKCHOP.parseMaterial());
|
||||||
|
FOOD.add(Material.COOKED_RABBIT);
|
||||||
|
FOOD.add(Material.COOKIE);
|
||||||
|
FOOD.add(Material.GOLDEN_APPLE);
|
||||||
|
FOOD.add(Material.GOLDEN_CARROT);
|
||||||
|
FOOD.add(XMaterial.GLISTERING_MELON_SLICE.parseMaterial());
|
||||||
|
FOOD.add(XMaterial.MUSHROOM_STEM.parseMaterial());
|
||||||
|
FOOD.add(Material.POISONOUS_POTATO);
|
||||||
|
FOOD.add(Material.POTATO);
|
||||||
|
FOOD.add(Material.PUMPKIN_PIE);
|
||||||
|
FOOD.add(Material.RABBIT_STEW);
|
||||||
|
FOOD.add(Material.COOKED_BEEF);
|
||||||
|
FOOD.add(XMaterial.BEEF.parseMaterial());
|
||||||
|
FOOD.add(Material.COOKED_CHICKEN);
|
||||||
|
FOOD.add(XMaterial.CHICKEN.parseMaterial());
|
||||||
|
FOOD.add(Material.MUTTON);
|
||||||
|
FOOD.add(XMaterial.PORKCHOP.parseMaterial());
|
||||||
|
FOOD.add(Material.RABBIT);
|
||||||
|
FOOD.add(Material.COOKED_RABBIT);
|
||||||
|
FOOD.add(Material.ROTTEN_FLESH);
|
||||||
|
FOOD.add(Material.SPIDER_EYE);
|
||||||
|
|
||||||
|
// Start combos
|
||||||
|
COMBO.put(Material.SHEARS, XMaterial.WHITE_WOOL.parseMaterial());
|
||||||
|
|
||||||
|
COMBO.put(Material.IRON_SWORD, COB_WEB);
|
||||||
|
COMBO.put(Material.DIAMOND_SWORD, COB_WEB);
|
||||||
|
COMBO.put(Material.STONE_SWORD, COB_WEB);
|
||||||
|
COMBO.put(XMaterial.WOODEN_SWORD.parseMaterial(), COB_WEB);
|
||||||
|
// End combos
|
||||||
|
|
||||||
|
// Start climbable
|
||||||
|
CLIMBABLE.add(Material.VINE);
|
||||||
|
CLIMBABLE.add(Material.LADDER);
|
||||||
|
CLIMBABLE.add(Material.WATER);
|
||||||
|
// End climbable
|
||||||
|
}
|
||||||
|
// End 1.8.8
|
||||||
|
// Start other version
|
||||||
|
else {
|
||||||
|
LILY_PAD = Material.LILY_PAD;
|
||||||
|
COB_WEB = Material.COBWEB;
|
||||||
|
IRON_BARS = Material.IRON_BARS;
|
||||||
|
|
||||||
// Start instant break materials
|
// Start instant break materials
|
||||||
INSTANT_BREAK.add(Material.COMPARATOR);
|
INSTANT_BREAK.add(Material.COMPARATOR);
|
||||||
INSTANT_BREAK.add(Material.REPEATER);
|
INSTANT_BREAK.add(Material.REPEATER);
|
||||||
@@ -549,7 +703,7 @@ public final class Utilities {
|
|||||||
INSTANT_BREAK.add(Material.TALL_SEAGRASS);
|
INSTANT_BREAK.add(Material.TALL_SEAGRASS);
|
||||||
INSTANT_BREAK.add(Material.WHEAT);
|
INSTANT_BREAK.add(Material.WHEAT);
|
||||||
// Start 1.14 objects
|
// Start 1.14 objects
|
||||||
if (VersionUtil.isOfVersion("v1_14")) {
|
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15")) {
|
||||||
INSTANT_BREAK.add(Material.BAMBOO_SAPLING);
|
INSTANT_BREAK.add(Material.BAMBOO_SAPLING);
|
||||||
INSTANT_BREAK.add(Material.CORNFLOWER);
|
INSTANT_BREAK.add(Material.CORNFLOWER);
|
||||||
}
|
}
|
||||||
@@ -600,7 +754,7 @@ public final class Utilities {
|
|||||||
FOOD.add(Material.SPIDER_EYE);
|
FOOD.add(Material.SPIDER_EYE);
|
||||||
FOOD.add(Material.TROPICAL_FISH);
|
FOOD.add(Material.TROPICAL_FISH);
|
||||||
// Start 1.14 objects
|
// Start 1.14 objects
|
||||||
if (VersionUtil.isOfVersion("v1_14")) {
|
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15")) {
|
||||||
FOOD.add(Material.SUSPICIOUS_STEW);
|
FOOD.add(Material.SUSPICIOUS_STEW);
|
||||||
FOOD.add(Material.SWEET_BERRIES);
|
FOOD.add(Material.SWEET_BERRIES);
|
||||||
}
|
}
|
||||||
@@ -636,5 +790,18 @@ public final class Utilities {
|
|||||||
COMBO.put(Material.STONE_SWORD, Material.COBWEB);
|
COMBO.put(Material.STONE_SWORD, Material.COBWEB);
|
||||||
COMBO.put(Material.WOODEN_SWORD, Material.COBWEB);
|
COMBO.put(Material.WOODEN_SWORD, Material.COBWEB);
|
||||||
// End combos
|
// End combos
|
||||||
|
|
||||||
|
// Start climbable
|
||||||
|
CLIMBABLE.add(Material.VINE);
|
||||||
|
CLIMBABLE.add(Material.LADDER);
|
||||||
|
CLIMBABLE.add(Material.WATER);
|
||||||
|
// Start 1.14 objects
|
||||||
|
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15")) {
|
||||||
|
CLIMBABLE.add(Material.SCAFFOLDING);
|
||||||
|
}
|
||||||
|
// End 1.14 objects
|
||||||
|
// End climbable
|
||||||
|
}
|
||||||
|
// End other versions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,8 +21,11 @@ package com.rammelkast.anticheatreloaded.util;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -31,7 +34,7 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
public class VersionUtil {
|
public class VersionUtil {
|
||||||
|
|
||||||
private static final List<String> SUPPORTED_VERSIONS = Arrays
|
private static final List<String> SUPPORTED_VERSIONS = Arrays
|
||||||
.asList(new String[] { "v1_15", "v1_14", "v1_13" });
|
.asList(new String[] { "v1_15", "v1_14", "v1_13", "v1_8_R3" });
|
||||||
|
|
||||||
public static String getVersion() {
|
public static String getVersion() {
|
||||||
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||||
@@ -53,23 +56,32 @@ public class VersionUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the if server is running Bountiful Update (1.8)
|
||||||
|
*/
|
||||||
|
public static boolean isBountifulUpdate() {
|
||||||
|
return isOfVersion("v1_8");
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isFlying(Player p) {
|
public static boolean isFlying(Player p) {
|
||||||
|
if (isBountifulUpdate()) {
|
||||||
|
return p.isFlying();
|
||||||
|
}
|
||||||
return p.isFlying() || p.isGliding() || p.hasPotionEffect(PotionEffectType.LEVITATION);
|
return p.isFlying() || p.isGliding() || p.hasPotionEffect(PotionEffectType.LEVITATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getHealTime() {
|
|
||||||
return 495;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isFrostWalk(Player player) {
|
public static boolean isFrostWalk(Player player) {
|
||||||
if (player.getInventory().getBoots() == null) {
|
if (player.getInventory().getBoots() == null || isBountifulUpdate()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return player.getInventory().getBoots().containsEnchantment(Enchantment.FROST_WALKER);
|
return player.getInventory().getBoots().containsEnchantment(Enchantment.FROST_WALKER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public static ItemStack getItemInHand(Player player) {
|
public static ItemStack getItemInHand(Player player) {
|
||||||
|
if (isBountifulUpdate()) {
|
||||||
|
return player.getItemInHand();
|
||||||
|
}
|
||||||
return player.getInventory().getItemInMainHand();
|
return player.getInventory().getItemInMainHand();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,4 +95,11 @@ public class VersionUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Block getTargetBlock(Player player, int distance) {
|
||||||
|
if (isBountifulUpdate()) {
|
||||||
|
return player.getTargetBlock((Set<Material>) null, distance);
|
||||||
|
}
|
||||||
|
return player.getTargetBlockExact(distance);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* AntiCheatReloaded for Bukkit and Spigot.
|
|
||||||
* Copyright (c) 2012-2015 AntiCheat Team
|
|
||||||
* Copyright (c) 2016-2020 Rammelkast
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.rammelkast.anticheatreloaded.util.checkassist;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
public class KillauraAssist {
|
|
||||||
|
|
||||||
public KillauraAssist() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static double calculateYawDifference(Location from, Location to) {
|
|
||||||
Location clonedFrom = from.clone();
|
|
||||||
Vector startVector = clonedFrom.toVector();
|
|
||||||
Vector targetVector = to.toVector();
|
|
||||||
clonedFrom.setDirection(targetVector.subtract(startVector));
|
|
||||||
return clonedFrom.getYaw();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -30,7 +30,7 @@ system:
|
|||||||
event-chains: true
|
event-chains: true
|
||||||
# Should Enterprise options be enabled? Only set this to true if you're an advanced user.
|
# Should Enterprise options be enabled? Only set this to true if you're an advanced user.
|
||||||
enterprise: false
|
enterprise: false
|
||||||
# Running AntiCheatReloaded in debug mode will send alerts to the cheating players
|
# Running AntiCheatReloaded in debug mode will send alerts to the cheating players and enable debug logging
|
||||||
# Do NOT enable this in a production environment!
|
# Do NOT enable this in a production environment!
|
||||||
debug-mode: false
|
debug-mode: false
|
||||||
# Use /AntiCheatReloaded check for a list of valid checks
|
# Use /AntiCheatReloaded check for a list of valid checks
|
||||||
|
|||||||
@@ -165,13 +165,7 @@ SPRINT_MAX: 0.2
|
|||||||
TELEPORT_MIN: 400
|
TELEPORT_MIN: 400
|
||||||
# Time to exempt a player from moving because of teleporting
|
# Time to exempt a player from moving because of teleporting
|
||||||
# Increase in case of false positives
|
# Increase in case of false positives
|
||||||
TELEPORT_TIME: 1000
|
TELEPORT_TIME: 800
|
||||||
# The number of steps we should wait before checking if the player has used timer cheating
|
|
||||||
# Increase in case of false positives
|
|
||||||
TIMER_STEP_CHECK: 50
|
|
||||||
# The minimum time it should have taken for the player to travel X steps
|
|
||||||
# Decrease in case of false positives
|
|
||||||
TIMER_TIMEMIN: 2000
|
|
||||||
# Maximum time a player is considered to have a change in velocity
|
# Maximum time a player is considered to have a change in velocity
|
||||||
# This is a set value and shouldn't be changed unless you know what you're doing
|
# This is a set value and shouldn't be changed unless you know what you're doing
|
||||||
VELOCITY_CHECKTIME: 2100
|
VELOCITY_CHECKTIME: 2100
|
||||||
@@ -185,13 +179,13 @@ VELOCITY_SCHETIME: 2
|
|||||||
VELOCITY_TIME: 3
|
VELOCITY_TIME: 3
|
||||||
# Number of times a player can fail the ascension check while in water before being considered a cheater
|
# Number of times a player can fail the ascension check while in water before being considered a cheater
|
||||||
# Increase in case of false positives
|
# Increase in case of false positives
|
||||||
WATER_ASCENSION_VIOLATION_MAX: 12
|
WATER_ASCENSION_VIOLATION_MAX: 8
|
||||||
# Maximum speed that a player can climb a waterfall
|
# Maximum speed that a player can climb a waterfall
|
||||||
# Can be increased in case of false positives, shouldn't be necesary
|
# Can be increased in case of false positives, shouldn't be necesary
|
||||||
WATER_CLIMB_MAX: 0.15
|
WATER_CLIMB_MAX: 0.15
|
||||||
# Number of times a player can be caught speeding in water before being considered a cheater
|
# Number of times a player can be caught speeding in water before being considered a cheater
|
||||||
# Increase in case of false positives
|
# Increase in case of false positives
|
||||||
WATER_SPEED_VIOLATION_MAX: 4
|
WATER_SPEED_VIOLATION_MAX: 6
|
||||||
# Maximum speed a player can travel forwards or backwards
|
# Maximum speed a player can travel forwards or backwards
|
||||||
# This is a set value and shouldn't be changed unless you know what you're doing
|
# This is a set value and shouldn't be changed unless you know what you're doing
|
||||||
XZ_SPEED_MAX: 0.25
|
XZ_SPEED_MAX: 0.25
|
||||||
@@ -243,16 +237,16 @@ Y_SPEED_MAX: 0.5175
|
|||||||
Y_TIME: 800
|
Y_TIME: 800
|
||||||
# Amount of suspicious mid-air movements before a player is suspected of glide
|
# Amount of suspicious mid-air movements before a player is suspected of glide
|
||||||
# Increase this in case of false positives
|
# Increase this in case of false positives
|
||||||
GLIDE_LIMIT: 10
|
GLIDE_LIMIT: 5
|
||||||
# Maximum amount of movement packets allowed per second
|
# Maximum amount of movement packets allowed per second
|
||||||
# Increase this in case of false positives
|
# Increase this in case of false positives
|
||||||
BLINK_PACKET: 25
|
MOREPACKETS_LIMIT: 30
|
||||||
# If the blink check gives false positives replace this with the average user ping on your server
|
# If the MorePackets check gives false positives replace this with the average user ping on your server
|
||||||
# Not a good idea to use a value lower than 100 or higher than 200
|
# Not a good idea to use a value lower than 75 or higher than 250
|
||||||
BLINK_AVERAGE_PING: 120
|
MOREPACKETS_AVERAGE_PING: 80
|
||||||
# Maximum amount zero-velocity moments before a player is suspected
|
# Maximum amount zero-velocity moments before a player is suspected
|
||||||
# Increase this in case of false positives
|
# Increase this in case of false positives
|
||||||
VELOCITY_MAX_FLAGS: 5
|
VELOCITY_MAX_FLAGS: 3
|
||||||
# The maximum angle difference allowed when attacking
|
# The maximum angle difference allowed when attacking
|
||||||
# Increase this in case of false positives
|
# Increase this in case of false positives
|
||||||
KILLAURA_MAX_ANGLE_DIFFERENCE: 50
|
KILLAURA_MAX_ANGLE_DIFFERENCE: 50
|
||||||
@@ -266,3 +260,9 @@ KILLAURA_FIGHTSPEED_MINDIFF: 3
|
|||||||
# The maximum angle difference allowed when placing or breaking a block
|
# The maximum angle difference allowed when placing or breaking a block
|
||||||
# Increase this in case of false positives, can be slightly decreased to tighten check
|
# Increase this in case of false positives, can be slightly decreased to tighten check
|
||||||
ILLEGALINTERACT_MAX_ANGLE_DIFFERENCE: 75
|
ILLEGALINTERACT_MAX_ANGLE_DIFFERENCE: 75
|
||||||
|
# The minimum time it takes to regenerate health
|
||||||
|
# Decrease this in case of false positives
|
||||||
|
MIN_HEAL_TIME: 490
|
||||||
|
# Maximum distance allowed between two movement packets
|
||||||
|
# Increase this in case of false positives
|
||||||
|
BADPACKETS_MAX_DISTANCE: 25.0
|
||||||
@@ -18,10 +18,10 @@ permissions:
|
|||||||
description: See alerts when a player might be cheating
|
description: See alerts when a player might be cheating
|
||||||
anticheat.system.help:
|
anticheat.system.help:
|
||||||
description: Access the help message
|
description: Access the help message
|
||||||
|
anticheat.system.mute:
|
||||||
|
description: Access the mute function
|
||||||
anticheat.system.report:
|
anticheat.system.report:
|
||||||
description: Access cheat reports
|
description: Access cheat reports
|
||||||
anticheat.system.spy:
|
|
||||||
description: Access the spy system
|
|
||||||
anticheat.mod:
|
anticheat.mod:
|
||||||
description: Mod helper perm
|
description: Mod helper perm
|
||||||
children:
|
children:
|
||||||
@@ -29,7 +29,7 @@ permissions:
|
|||||||
anticheat.system.alert: true
|
anticheat.system.alert: true
|
||||||
anticheat.system.help: true
|
anticheat.system.help: true
|
||||||
anticheat.system.report: true
|
anticheat.system.report: true
|
||||||
anticheat.system.spy: true
|
anticheat.system.mute: true
|
||||||
anticheat.system.log:
|
anticheat.system.log:
|
||||||
description: Access turning console logging on or off
|
description: Access turning console logging on or off
|
||||||
anticheat.system.reload:
|
anticheat.system.reload:
|
||||||
@@ -38,10 +38,6 @@ permissions:
|
|||||||
description: Access resetting a player's cheat level
|
description: Access resetting a player's cheat level
|
||||||
anticheat.system.version:
|
anticheat.system.version:
|
||||||
description: Access information about whether the system is updated
|
description: Access information about whether the system is updated
|
||||||
anticheat.system.calibrate:
|
|
||||||
description: Access the calibration system
|
|
||||||
anticheat.system.debug:
|
|
||||||
description: Access debug reports
|
|
||||||
anticheat.admin:
|
anticheat.admin:
|
||||||
description: Admin helper perm
|
description: Admin helper perm
|
||||||
children:
|
children:
|
||||||
@@ -49,9 +45,7 @@ permissions:
|
|||||||
anticheat.system.log: true
|
anticheat.system.log: true
|
||||||
anticheat.system.reload: true
|
anticheat.system.reload: true
|
||||||
anticheat.system.reset: true
|
anticheat.system.reset: true
|
||||||
anticheat.system.update: true
|
anticheat.system.mute: true
|
||||||
anticheat.system.calibrate: true
|
|
||||||
anticheat.system.debug: true
|
|
||||||
anticheat.check.flight:
|
anticheat.check.flight:
|
||||||
description: Allow players to use fly cheats
|
description: Allow players to use fly cheats
|
||||||
default: false
|
default: false
|
||||||
@@ -121,7 +115,7 @@ permissions:
|
|||||||
anticheat.check.autotool:
|
anticheat.check.autotool:
|
||||||
description: Allow players to use autotool to switch tools quickly
|
description: Allow players to use autotool to switch tools quickly
|
||||||
default: false
|
default: false
|
||||||
anticheat.check.blink:
|
anticheat.check.morepackets:
|
||||||
description: Allow players to send lots of movement packets
|
description: Allow players to send lots of movement packets
|
||||||
default: false
|
default: false
|
||||||
anticheat.check.velocity:
|
anticheat.check.velocity:
|
||||||
@@ -163,7 +157,7 @@ permissions:
|
|||||||
anticheat.check.fastinventory: true
|
anticheat.check.fastinventory: true
|
||||||
anticheat.check.autotool: true
|
anticheat.check.autotool: true
|
||||||
anticheat.check.fastanimation: true
|
anticheat.check.fastanimation: true
|
||||||
anticheat.check.blink: true
|
anticheat.check.morepackets: true
|
||||||
anticheat.check.velocity: true
|
anticheat.check.velocity: true
|
||||||
anticheat.check.criticals: true
|
anticheat.check.criticals: true
|
||||||
anticheat.check.unicode: true
|
anticheat.check.unicode: true
|
||||||
|
|||||||
Reference in new issue
Block a user