mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 14:38:45 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16c778c17f | ||
|
|
97534e5df0 | ||
|
|
e770d0e01c | ||
|
|
a59a4baf28 | ||
|
|
7caf7376ba | ||
|
|
a6a39e352a | ||
|
|
700c0145f3 | ||
|
|
c74fc92da9 | ||
|
|
3bc49141fc | ||
|
|
cffd6d07ae | ||
|
|
e9a99f0463 | ||
|
|
4deb8ae0fb | ||
|
|
07f957cf35 | ||
|
|
9850f48a4e | ||
|
|
656841b046 | ||
|
|
fc006c39f2 | ||
|
|
f4ca2ea8bf | ||
|
|
6966582e4c | ||
|
|
168c25e5d2 | ||
|
|
07f3c3abce | ||
|
|
128a668e6c | ||
|
|
ad618ffaf0 | ||
|
|
2086a01f80 | ||
|
|
add3fe5eae | ||
|
|
20635a2acb | ||
|
|
636f94b408 | ||
|
|
610d53550f | ||
|
|
db9aa97ca1 | ||
|
|
992c67d894 | ||
|
|
12c85b3939 | ||
|
|
37d580a4ba | ||
|
|
f94a430d41 | ||
|
|
918549bc11 | ||
|
|
c6e4ce091a | ||
|
|
7d13aae057 | ||
|
|
3538b8934c | ||
|
|
b2701fa057 | ||
|
|
8cf2702708 | ||
|
|
cd3184f17b | ||
|
|
9078846511 | ||
|
|
50247f28c9 | ||
|
|
cc51e9307f | ||
|
|
0288a9734a | ||
|
|
a7419e3968 | ||
|
|
df3c410436 | ||
|
|
27bb684736 | ||
|
|
aa9fa9b290 | ||
|
|
da4a61e228 | ||
|
|
9771387909 | ||
|
|
76c595e255 | ||
|
|
91f5fcd31c | ||
|
|
80b5e64924 | ||
|
|
67e824ef28 | ||
|
|
661718d001 | ||
|
|
7c9a05ff92 | ||
|
|
3af7bde9db | ||
|
|
7e37e8558b | ||
|
|
d41d08ccc6 | ||
|
|
f88c31051b | ||
|
|
6afe0049c5 | ||
|
|
f77d45a78d | ||
|
|
2ba98f9f9c | ||
|
|
e89a6cfd88 | ||
|
|
07bf56cc93 | ||
|
|
773900594d | ||
|
|
27ca12aec3 | ||
|
|
fec1286c8d | ||
|
|
acea36929b | ||
|
|
8da9d7f365 | ||
|
|
c9c3b2397f | ||
|
|
a140afe33e | ||
|
|
08c484bfb1 | ||
|
|
ae66b0ed3c | ||
|
|
0963458be5 | ||
|
|
d9639c81d9 | ||
|
|
0428c4796a | ||
|
|
8e92077bb6 | ||
|
|
9d32c8f2de | ||
|
|
d6917b81f7 | ||
|
|
1a64403223 | ||
|
|
7ae3f010a3 | ||
|
|
06c1eab2e6 | ||
|
|
f609758d28 | ||
|
|
2d064ee849 | ||
|
|
717b7acb67 | ||
|
|
2617aa1225 | ||
|
|
dd8c495ee6 | ||
|
|
09ddbfba8f | ||
|
|
7f13a0ad4c | ||
|
|
21d0108c16 | ||
|
|
15181ab6ad | ||
|
|
347eec8ff0 | ||
|
|
518e4c32e7 | ||
|
|
583d2de244 | ||
|
|
792a4ae0a5 | ||
|
|
406ba01523 | ||
|
|
b2571a32f1 | ||
|
|
52b96bedc4 | ||
|
|
01602e187c | ||
|
|
db13527498 | ||
|
|
1e4aaab2c0 | ||
|
|
3baa074b6f | ||
|
|
b264bb1e43 | ||
|
|
57d7ee9b62 | ||
|
|
24125e9195 | ||
|
|
eca5a60d22 | ||
|
|
8e4cef9a7d | ||
|
|
db821e4809 | ||
|
|
c229252f7a | ||
|
|
93a5595bb1 | ||
|
|
92f5f30188 | ||
|
|
8773c05000 | ||
|
|
33811b9fca | ||
|
|
fade626bcb | ||
|
|
e4e0d4ee01 | ||
|
|
1727f673f5 | ||
|
|
b0864be3d4 |
No files matched your search
@@ -1,43 +1,52 @@
|
|||||||
AntiCheatReloaded
|
AntiCheatReloaded
|
||||||
=============
|
=============
|
||||||
AntiCheatReloaded is a fork of the old 'AntiCheat' project.
|
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.
|
||||||
AntiCheat helps server admins easily identify and block malicious users by monitoring and analyzing the behaviour of their players.
|
|
||||||
|
|
||||||
###Want to help me out?
|
Installation
|
||||||
First of all, i've put a lot of time and work in this project, so donations (especially in (m)BTC) are appreciated!
|
------------
|
||||||
My BTC address is 1JfyX6hvGUazHTtKVLaNcYaUxnyjR5HtMY
|
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.
|
||||||
|
|
||||||
###Hacks blocked
|
Bug Reporting
|
||||||
-------
|
|
||||||
* Blink
|
|
||||||
* Flight
|
|
||||||
* Glide
|
|
||||||
* Jesus
|
|
||||||
* Step
|
|
||||||
* Criticals
|
|
||||||
* KillAura
|
|
||||||
* Anti-Knockback
|
|
||||||
* FastBow
|
|
||||||
* FastDrop
|
|
||||||
* Reach
|
|
||||||
* Spider
|
|
||||||
* Speed
|
|
||||||
* NoFall
|
|
||||||
* Sneak
|
|
||||||
* vClip
|
|
||||||
* Timer
|
|
||||||
* FastBreak
|
|
||||||
* FastPlace
|
|
||||||
* Spam
|
|
||||||
* FastEat
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-------
|
|
||||||
Simply drag and drop the plugin and the ProtoclLib into your Plugins folder.
|
|
||||||
|
|
||||||
Bug Reporting/Support/Questions
|
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Issues should be filed by hitting the [issues](https://github.com/Rammelkast/AntiCheatReloaded/issues?state=open) tab above. Please make sure you search your issue before opening a new ticket.
|
Issues should be filed by hitting the [issues](https://github.com/Rammelkast/AntiCheatReloaded/issues?state=open) tab above. Please make sure you search your issue before opening a new ticket.
|
||||||
|
|
||||||
All opened tickets that are bug reports require a debug log that includes logs of the issue in question. To obtain this, type `/anticheat debug` on your server. Note that for the debug output to contain valid information and help us diagnose your issue, you need to issue this command AFTER the issue occurs at least once and BEFORE you reload or restart it.
|
Please include the following information with your issue, this allows me to fix it quicker;
|
||||||
|
* Your AntiCheatReloaded version
|
||||||
|
* Your server software (Bukkit/Spigot/Other) and it's version
|
||||||
|
* Your ProtocolLib version
|
||||||
|
* Whether or not you are using protocol hacks (ViaVersion etc.)
|
||||||
|
* Any logs relating to the issue
|
||||||
|
|
||||||
|
Hacks blocked
|
||||||
|
-------
|
||||||
|
* Flight/Glide
|
||||||
|
* ElytraFly
|
||||||
|
* WaterWalk/Jesus
|
||||||
|
* NoSwing
|
||||||
|
* FastBreak
|
||||||
|
* FastPlace
|
||||||
|
* Chat spam
|
||||||
|
* Command spam
|
||||||
|
* Sprint
|
||||||
|
* (Packet)Sneak
|
||||||
|
* Speed
|
||||||
|
* Vclip
|
||||||
|
* Spider
|
||||||
|
* NoFall
|
||||||
|
* FastBow
|
||||||
|
* FastEat
|
||||||
|
* FastHeal
|
||||||
|
* KillAura
|
||||||
|
* Aimbot
|
||||||
|
* Reach
|
||||||
|
* Unicode chat
|
||||||
|
* FastProjectile
|
||||||
|
* ItemSpam
|
||||||
|
* FastInventory
|
||||||
|
* MorePackets/Timer
|
||||||
|
* BadPackets
|
||||||
|
* Velocity/Anti-Knockback
|
||||||
|
* IllegalInteract (Scaffold)
|
||||||
|
* FastLadder
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.gravitydevelopment.anticheat</groupId>
|
<groupId>com.rammelkast.anticheatreloaded</groupId>
|
||||||
<artifactId>AntiCheat</artifactId>
|
<artifactId>AntiCheatReloaded</artifactId>
|
||||||
<version>1.5.0-ALPHA</version>
|
<version>1.9.3</version>
|
||||||
<name>AntiCheatReloaded</name>
|
<name>AntiCheatReloaded</name>
|
||||||
<url>https://rammelkast.com</url>
|
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.version>${project.version}</project.build.version>
|
<project.build.version>${project.version}</project.build.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
@@ -13,11 +13,7 @@
|
|||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>dmulloy2-repo</id>
|
<id>dmulloy2-repo</id>
|
||||||
<url>http://repo.dmulloy2.net/content/groups/public/</url>
|
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>spigot-repo</id>
|
|
||||||
<url>http://maven.elmakers.com/repository/</url>
|
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<build>
|
<build>
|
||||||
@@ -26,16 +22,16 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.1</version>
|
<version>3.5</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.8</source>
|
||||||
<target>1.6</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>1.3</version>
|
<version>3.1.1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@@ -47,7 +43,8 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<artifactSet>
|
<artifactSet>
|
||||||
<includes>
|
<includes>
|
||||||
<include>net.gravitydevelopment.*</include>
|
<include>com.rammelkast.*</include>
|
||||||
|
<include>com.cryptomorin.*</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -68,43 +65,23 @@
|
|||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>jenkins</id>
|
|
||||||
<activation>
|
|
||||||
<property>
|
|
||||||
<name>env.BUILD_NUMBER</name>
|
|
||||||
</property>
|
|
||||||
</activation>
|
|
||||||
<properties>
|
|
||||||
<project.build.version>${project.version}-b${env.BUILD_NUMBER}</project.build.version>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.comphenix.protocol</groupId>
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
<artifactId>ProtocolLib</artifactId>
|
<artifactId>ProtocolLib</artifactId>
|
||||||
<version>4.1.0-SNAPSHOT</version>
|
<version>4.6.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>4.11</version>
|
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||||
<type>jar</type>
|
<scope>provided</scope>
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.10-R0.1-SNAPSHOT</version>
|
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<distributionManagement>
|
|
||||||
<repository>
|
|
||||||
<id>anticheat-repo</id>
|
|
||||||
<url>file:///var/lib/jenkins/repo</url>
|
|
||||||
</repository>
|
|
||||||
</distributionManagement>
|
|
||||||
</project>
|
</project>
|
||||||
@@ -0,0 +1,351 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.command.CommandHandler;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.event.BlockListener;
|
||||||
|
import com.rammelkast.anticheatreloaded.event.EntityListener;
|
||||||
|
import com.rammelkast.anticheatreloaded.event.InventoryListener;
|
||||||
|
import com.rammelkast.anticheatreloaded.event.PlayerListener;
|
||||||
|
import com.rammelkast.anticheatreloaded.event.VehicleListener;
|
||||||
|
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.metrics.Metrics;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.PacketListener;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.UpdateManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
|
public class AntiCheatReloaded extends JavaPlugin {
|
||||||
|
|
||||||
|
public static final List<UUID> MUTE_ENABLED_MODS = new ArrayList<UUID>();
|
||||||
|
|
||||||
|
private static AntiCheatManager manager;
|
||||||
|
private static AntiCheatReloaded plugin;
|
||||||
|
private static List<Listener> eventList = new ArrayList<Listener>();
|
||||||
|
private static Configuration config;
|
||||||
|
private static boolean verbose;
|
||||||
|
private static ProtocolManager protocolManager;
|
||||||
|
private static SecureRandom random;
|
||||||
|
private static Long loadTime;
|
||||||
|
private static UpdateManager updateManager;
|
||||||
|
|
||||||
|
private double tps = -1;
|
||||||
|
private String symbiosisMetric = "None";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
plugin = this;
|
||||||
|
random = new SecureRandom();
|
||||||
|
loadTime = System.currentTimeMillis();
|
||||||
|
manager = new AntiCheatManager(this, getLogger());
|
||||||
|
eventList.add(new PlayerListener());
|
||||||
|
eventList.add(new BlockListener());
|
||||||
|
eventList.add(new EntityListener());
|
||||||
|
eventList.add(new VehicleListener());
|
||||||
|
eventList.add(new InventoryListener());
|
||||||
|
// Order is important in some cases, don't screw with these unless
|
||||||
|
// needed, especially config
|
||||||
|
this.setupConfig();
|
||||||
|
this.setupEvents();
|
||||||
|
this.setupCommands();
|
||||||
|
// Enterprise must come before levels
|
||||||
|
this.setupEnterprise();
|
||||||
|
this.restoreLevels();
|
||||||
|
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
||||||
|
this.setupProtocol();
|
||||||
|
} else {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.RED
|
||||||
|
+ "Could not find ProtocolLib. Shutting down!");
|
||||||
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getConsoleSender()
|
||||||
|
.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY
|
||||||
|
+ "Running Minecraft version " + VersionUtil.getVersion() + " "
|
||||||
|
+ (VersionUtil.isSupported() ? (ChatColor.GREEN + "(supported)")
|
||||||
|
: (ChatColor.RED + "(NOT SUPPORTED!)")));
|
||||||
|
|
||||||
|
getLogger().info("Enabling packet listeners");
|
||||||
|
PacketListener.listenKeepAlivePackets();
|
||||||
|
PacketListener.listenMovementPackets();
|
||||||
|
|
||||||
|
updateManager = new UpdateManager();
|
||||||
|
|
||||||
|
// End tests
|
||||||
|
verboseLog("Finished loading.");
|
||||||
|
|
||||||
|
// Metrics
|
||||||
|
getServer().getScheduler().runTaskLater(this, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
checkForSymbiosis();
|
||||||
|
try {
|
||||||
|
Metrics metrics = new Metrics(AntiCheatReloaded.this, 202);
|
||||||
|
metrics.addCustomChart(new Metrics.SingleLineChart("cheaters_kicked", new Callable<Integer>() {
|
||||||
|
@Override
|
||||||
|
public Integer call() throws Exception {
|
||||||
|
int kicked = playersKicked;
|
||||||
|
// Reset so we don't keep sending the same value
|
||||||
|
playersKicked = 0;
|
||||||
|
return kicked;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("protocollib_version", new Callable<String>() {
|
||||||
|
@Override
|
||||||
|
public String call() throws Exception {
|
||||||
|
return Bukkit.getPluginManager().getPlugin("ProtocolLib").getDescription().getVersion();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("nms_version", new Callable<String>() {
|
||||||
|
@Override
|
||||||
|
public String call() throws Exception {
|
||||||
|
return VersionUtil.getVersion();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("symbiosis", new Callable<String>() {
|
||||||
|
@Override
|
||||||
|
public String call() throws Exception {
|
||||||
|
return symbiosisMetric;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 90L);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
verboseLog("Saving user levels...");
|
||||||
|
config.getLevels().saveLevelsFromUsers(getManager().getUserManager().getUsers());
|
||||||
|
|
||||||
|
AntiCheatManager.close();
|
||||||
|
getServer().getScheduler().cancelTasks(this);
|
||||||
|
cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupProtocol() {
|
||||||
|
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
|
verboseLog("Hooked into ProtocolLib");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupEvents() {
|
||||||
|
for (Listener listener : eventList) {
|
||||||
|
getServer().getPluginManager().registerEvents(listener, this);
|
||||||
|
verboseLog("Registered events for ".concat(listener.toString().split("@")[0].split(".anticheat.")[1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupCommands() {
|
||||||
|
getCommand("anticheat").setExecutor(new CommandHandler());
|
||||||
|
verboseLog("Registered commands.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupConfig() {
|
||||||
|
config = manager.getConfiguration();
|
||||||
|
verboseLog("Setup the config.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupEnterprise() {
|
||||||
|
if (config.getConfig().enterprise.getValue()) {
|
||||||
|
if (config.getEnterprise().loggingEnabled.getValue()) {
|
||||||
|
config.getEnterprise().database.cleanEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreLevels() {
|
||||||
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
|
||||||
|
User user = new User(uuid);
|
||||||
|
user.setIsWaitingOnLevelSync(true);
|
||||||
|
config.getLevels().loadLevelToUser(user);
|
||||||
|
|
||||||
|
manager.getUserManager().addUser(user);
|
||||||
|
verboseLog("Data for " + uuid + " loaded");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AntiCheatReloaded getPlugin() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AntiCheatManager getManager() {
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SecureRandom getRandom() {
|
||||||
|
return random;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getVersion() {
|
||||||
|
return manager.getPlugin().getDescription().getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cleanup() {
|
||||||
|
eventList = null;
|
||||||
|
manager = null;
|
||||||
|
config = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void debugLog(final String string) {
|
||||||
|
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
if (getManager().getConfiguration().getConfig().debugMode.getValue()) {
|
||||||
|
manager.debugLog("[DEBUG] " + string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void verboseLog(final String string) {
|
||||||
|
if (verbose) {
|
||||||
|
getLogger().info(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVerbose(boolean b) {
|
||||||
|
verbose = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getLoadTime() {
|
||||||
|
return loadTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProtocolManager getProtocolManager() {
|
||||||
|
return protocolManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Amount of players kicked since start
|
||||||
|
*/
|
||||||
|
private int playersKicked = 0;
|
||||||
|
|
||||||
|
public void onPlayerKicked() {
|
||||||
|
this.playersKicked++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates metric that checks for anti-cheat symbiosis
|
||||||
|
* I use this to see if AntiCheatReloaded is actively being used
|
||||||
|
* together with other anti-cheats, so I can account for that.
|
||||||
|
*/
|
||||||
|
protected void checkForSymbiosis() {
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
|
||||||
|
if (this.symbiosisMetric.equals("None")) {
|
||||||
|
this.symbiosisMetric = "NoCheatPlus";
|
||||||
|
} else {
|
||||||
|
this.symbiosisMetric += ", NoCheatPlus";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("Matrix") != null) {
|
||||||
|
if (this.symbiosisMetric.equals("None")) {
|
||||||
|
this.symbiosisMetric = "Matrix";
|
||||||
|
} else {
|
||||||
|
this.symbiosisMetric += ", Matrix";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("AAC") != null) {
|
||||||
|
if (this.symbiosisMetric.equals("None")) {
|
||||||
|
this.symbiosisMetric = "AAC";
|
||||||
|
} else {
|
||||||
|
this.symbiosisMetric += ", AAC";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("Spartan") != null) {
|
||||||
|
if (this.symbiosisMetric.equals("None")) {
|
||||||
|
this.symbiosisMetric = "Spartan";
|
||||||
|
} else {
|
||||||
|
this.symbiosisMetric += ", Spartan";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("Negativity") != null) {
|
||||||
|
if (this.symbiosisMetric.equals("None")) {
|
||||||
|
this.symbiosisMetric = "Negativity";
|
||||||
|
} else {
|
||||||
|
this.symbiosisMetric += ", Negativity";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendToMainThread(Runnable runnable) {
|
||||||
|
Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), runnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendToStaff(String message) {
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
|
if (player.hasPermission("anticheat.system.alert")) {
|
||||||
|
if (!MUTE_ENABLED_MODS.contains(player.getUniqueId())) {
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UpdateManager getUpdateManager() {
|
||||||
|
return updateManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getTPS() {
|
||||||
|
if (this.tps < 0 || this.tps > 20) {
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
return this.tps;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+19
-43
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,26 +17,26 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.api;
|
package com.rammelkast.anticheatreloaded.api;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
import net.gravitydevelopment.anticheat.manage.AntiCheatManager;
|
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||||
import net.gravitydevelopment.anticheat.manage.CheckManager;
|
import com.rammelkast.anticheatreloaded.manage.CheckManager;
|
||||||
import net.gravitydevelopment.anticheat.manage.UserManager;
|
import com.rammelkast.anticheatreloaded.manage.UserManager;
|
||||||
import net.gravitydevelopment.anticheat.util.Group;
|
import com.rammelkast.anticheatreloaded.util.Group;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Developer's interface for all things AntiCheat.
|
* Developer's interface for all things AntiCheat.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AntiCheatAPI {
|
public class AntiCheatAPI {
|
||||||
private static CheckManager chk = AntiCheat.getManager().getCheckManager();
|
private static CheckManager chk = AntiCheatReloaded.getManager().getCheckManager();
|
||||||
private static UserManager umr = AntiCheat.getManager().getUserManager();
|
private static UserManager umr = AntiCheatReloaded.getManager().getUserManager();
|
||||||
|
|
||||||
// CheckManager API
|
// CheckManager API
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ public class AntiCheatAPI {
|
|||||||
*
|
*
|
||||||
* @param type Check to start watching for
|
* @param type Check to start watching for
|
||||||
*/
|
*/
|
||||||
public static void activateCheck(CheckType type, Class caller) {
|
public static void activateCheck(CheckType type, Class<?> caller) {
|
||||||
chk.activateCheck(type, caller.getName());
|
chk.activateCheck(type, caller.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ public class AntiCheatAPI {
|
|||||||
*
|
*
|
||||||
* @param type Check to stop watching for
|
* @param type Check to stop watching for
|
||||||
*/
|
*/
|
||||||
public static void deactivateCheck(CheckType type, Class caller) {
|
public static void deactivateCheck(CheckType type, Class<?> caller) {
|
||||||
chk.deactivateCheck(type, caller.getName());
|
chk.deactivateCheck(type, caller.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ public class AntiCheatAPI {
|
|||||||
* @param player Player to stop watching
|
* @param player Player to stop watching
|
||||||
* @param type Check to stop watching for
|
* @param type Check to stop watching for
|
||||||
*/
|
*/
|
||||||
public static void exemptPlayer(Player player, CheckType type, Class caller) {
|
public static void exemptPlayer(Player player, CheckType type, Class<?> caller) {
|
||||||
chk.exemptPlayer(player, type, caller.getName());
|
chk.exemptPlayer(player, type, caller.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +84,7 @@ public class AntiCheatAPI {
|
|||||||
* @param player Player to start watching
|
* @param player Player to start watching
|
||||||
* @param type Check to start watching for
|
* @param type Check to start watching for
|
||||||
*/
|
*/
|
||||||
public static void unexemptPlayer(Player player, CheckType type, Class caller) {
|
public static void unexemptPlayer(Player player, CheckType type, Class<?> caller) {
|
||||||
chk.unexemptPlayer(player, type, caller.getName());
|
chk.unexemptPlayer(player, type, caller.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,31 +112,6 @@ public class AntiCheatAPI {
|
|||||||
|
|
||||||
// PlayerManager API
|
// PlayerManager API
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a player's integer hack level
|
|
||||||
*
|
|
||||||
* @param player Player to check
|
|
||||||
* @return player's hack level
|
|
||||||
* @deprecated see {@link #getGroup(org.bukkit.entity.Player)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static int getLevel(Player player) {
|
|
||||||
return umr.safeGetLevel(player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set a player's hack level
|
|
||||||
*
|
|
||||||
* @param player Player to set
|
|
||||||
* @param level Group to set to
|
|
||||||
* @deprecated see {@link #resetPlayer(org.bukkit.entity.Player)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static void setLevel(Player player, int level) {
|
|
||||||
umr.safeSetLevel(player.getUniqueId(), level);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset a player's hack level to 0
|
* Reset a player's hack level to 0
|
||||||
*
|
*
|
||||||
@@ -146,7 +122,7 @@ public class AntiCheatAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a user's {@link net.gravitydevelopment.anticheat.util.Group}
|
* Get a user's {@link com.rammelkast.anticheatreloaded.util.Group}
|
||||||
*
|
*
|
||||||
* @param player Player whose group to find
|
* @param player Player whose group to find
|
||||||
* @return The player's group
|
* @return The player's group
|
||||||
@@ -159,7 +135,7 @@ public class AntiCheatAPI {
|
|||||||
* Get all configured Groups
|
* Get all configured Groups
|
||||||
*
|
*
|
||||||
* @return List of all groups
|
* @return List of all groups
|
||||||
* @see net.gravitydevelopment.anticheat.util.Group
|
* @see com.rammelkast.anticheatreloaded.util.Group
|
||||||
*/
|
*/
|
||||||
public static List<Group> getGroups() {
|
public static List<Group> getGroups() {
|
||||||
return getManager().getConfiguration().getGroups().getGroups();
|
return getManager().getConfiguration().getGroups().getGroups();
|
||||||
@@ -173,7 +149,7 @@ public class AntiCheatAPI {
|
|||||||
* @return the AntiCheat Manager
|
* @return the AntiCheat Manager
|
||||||
*/
|
*/
|
||||||
public static AntiCheatManager getManager() {
|
public static AntiCheatManager getManager() {
|
||||||
return AntiCheat.getManager();
|
return AntiCheatReloaded.getManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
+15
-9
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,13 +17,14 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.api;
|
package com.rammelkast.anticheatreloaded.api;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when a player fails an AntiCheat check
|
* Fired when a player fails an AntiCheat check
|
||||||
*/
|
*/
|
||||||
@@ -40,18 +42,18 @@ public class CheckFailEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link net.gravitydevelopment.anticheat.util.User} who failed the check
|
* Get the {@link com.rammelkast.anticheatreloaded.util.User} who failed the check
|
||||||
*
|
*
|
||||||
* @return a {@link net.gravitydevelopment.anticheat.util.User}
|
* @return a {@link com.rammelkast.anticheatreloaded.util.User}
|
||||||
*/
|
*/
|
||||||
public User getUser() {
|
public User getUser() {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link net.gravitydevelopment.anticheat.check.CheckType} failed
|
* Get the {@link com.rammelkast.anticheatreloaded.check.CheckType} failed
|
||||||
*
|
*
|
||||||
* @return a {@link net.gravitydevelopment.anticheat.check.CheckType}
|
* @return a {@link com.rammelkast.anticheatreloaded.check.CheckType}
|
||||||
*/
|
*/
|
||||||
public CheckType getCheck() {
|
public CheckType getCheck() {
|
||||||
return type;
|
return type;
|
||||||
@@ -61,4 +63,8 @@ public class CheckFailEvent extends Event {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,740 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Lang;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
||||||
|
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
|
public class Backend {
|
||||||
|
public Map<UUID, Long> velocitized = new HashMap<UUID, Long>();
|
||||||
|
private Map<UUID, Long> levitatingEnd = new HashMap<UUID, Long>();
|
||||||
|
private List<UUID> isAscending = new ArrayList<UUID>();
|
||||||
|
private Map<UUID, Integer> chatLevel = 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, Boolean> blockBreakHolder = new HashMap<UUID, Boolean>();
|
||||||
|
private Map<UUID, Integer> fastPlaceViolation = new HashMap<UUID, Integer>();
|
||||||
|
private Map<UUID, Long> lastBlockPlaced = 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> projectilesShot = 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> lastHeal = new HashMap<UUID, Long>();
|
||||||
|
private Map<UUID, Long> projectileTime = new HashMap<UUID, Long>();
|
||||||
|
private Map<UUID, Long> bowWindUp = new HashMap<UUID, Long>();
|
||||||
|
private Map<UUID, Long> sprinted = new HashMap<UUID, Long>();
|
||||||
|
private Map<UUID, Long> brokenBlock = new HashMap<UUID, Long>();
|
||||||
|
public Map<UUID, Long> placedBlock = new HashMap<UUID, Long>();
|
||||||
|
private Map<UUID, Long> blockTime = new HashMap<UUID, Long>();
|
||||||
|
private Map<UUID, Integer> blocksDropped = new HashMap<UUID, Integer>();
|
||||||
|
private Map<UUID, Long> lastInventoryTime = new HashMap<UUID, Long>();
|
||||||
|
private Map<UUID, Long> inventoryTime = new HashMap<UUID, Long>();
|
||||||
|
private Map<UUID, Integer> inventoryClicks = new HashMap<UUID, Integer>();
|
||||||
|
private HashSet<Byte> transparent = new HashSet<Byte>();
|
||||||
|
private Map<UUID, Long> lastFallPacket = new HashMap<UUID, Long>();
|
||||||
|
private Map<UUID, Integer> fastSneakViolations = new HashMap<UUID, Integer>();
|
||||||
|
private Map<UUID, Long> lastSneak = new HashMap<UUID, Long>();
|
||||||
|
|
||||||
|
private Magic magic;
|
||||||
|
private Checks checksConfig;
|
||||||
|
private AntiCheatManager manager = null;
|
||||||
|
private Lang lang = null;
|
||||||
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
|
public Backend(AntiCheatManager instance) {
|
||||||
|
magic = instance.getConfiguration().getMagic();
|
||||||
|
checksConfig = instance.getConfiguration().getChecks();
|
||||||
|
manager = instance;
|
||||||
|
lang = manager.getConfiguration().getLang();
|
||||||
|
transparent.add((byte) -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Magic getMagic() {
|
||||||
|
return magic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateConfig(Configuration config) {
|
||||||
|
magic = config.getMagic();
|
||||||
|
lang = config.getLang();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetChatLevel(User user) {
|
||||||
|
chatLevel.put(user.getUUID(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void garbageClean(Player player) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
|
||||||
|
blocksDropped.remove(uuid);
|
||||||
|
blockTime.remove(uuid);
|
||||||
|
brokenBlock.remove(uuid);
|
||||||
|
placedBlock.remove(uuid);
|
||||||
|
bowWindUp.remove(uuid);
|
||||||
|
startEat.remove(uuid);
|
||||||
|
lastHeal.remove(uuid);
|
||||||
|
sprinted.remove(uuid);
|
||||||
|
isAscending.remove(uuid);
|
||||||
|
nofallViolation.remove(uuid);
|
||||||
|
blockBreakHolder.remove(uuid);
|
||||||
|
fastPlaceViolation.remove(uuid);
|
||||||
|
lastBlockPlaced.remove(uuid);
|
||||||
|
lastBlockPlaceTime.remove(uuid);
|
||||||
|
blockPunches.remove(uuid);
|
||||||
|
projectilesShot.remove(uuid);
|
||||||
|
velocitized.remove(uuid);
|
||||||
|
velocitytrack.remove(uuid);
|
||||||
|
startEat.remove(uuid);
|
||||||
|
lastHeal.remove(uuid);
|
||||||
|
projectileTime.remove(uuid);
|
||||||
|
bowWindUp.remove(uuid);
|
||||||
|
sprinted.remove(uuid);
|
||||||
|
brokenBlock.remove(uuid);
|
||||||
|
placedBlock.remove(uuid);
|
||||||
|
blockTime.remove(uuid);
|
||||||
|
blocksDropped.remove(uuid);
|
||||||
|
lastInventoryTime.remove(uuid);
|
||||||
|
inventoryTime.remove(uuid);
|
||||||
|
inventoryClicks.remove(uuid);
|
||||||
|
lastFallPacket.remove(uuid);
|
||||||
|
fastSneakViolations.remove(uuid);
|
||||||
|
lastSneak.remove(uuid);
|
||||||
|
levitatingEnd.remove(uuid);
|
||||||
|
AimbotCheck.LAST_DELTA_YAW.remove(uuid);
|
||||||
|
VelocityCheck.VIOLATIONS.remove(uuid);
|
||||||
|
MorePacketsCheck.LAST_PACKET_TIME.remove(uuid);
|
||||||
|
MorePacketsCheck.PACKET_BALANCE.remove(uuid);
|
||||||
|
MorePacketsCheck.EXEMPT_TIMINGS.remove(uuid);
|
||||||
|
ElytraCheck.JUMP_Y_VALUE.remove(uuid);
|
||||||
|
KillAuraCheck.ANGLE_FLAGS.remove(uuid);
|
||||||
|
KillAuraCheck.PACKETORDER_FLAGS.remove(uuid);
|
||||||
|
FlightCheck.MOVING_EXEMPT.remove(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckResult checkFastBow(Player player, float force) {
|
||||||
|
// Ignore magic numbers here, they are minecrafty vanilla stuff.
|
||||||
|
if (!bowWindUp.containsKey(player.getUniqueId())) {
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
int ticks = (int) ((((System.currentTimeMillis() - bowWindUp.get(player.getUniqueId())) * 20) / 1000) + 3);
|
||||||
|
bowWindUp.remove(player.getUniqueId());
|
||||||
|
float f = (float) ticks / 20.0F;
|
||||||
|
f = (f * f + f * 2.0F) / 3.0F;
|
||||||
|
f = f > 1.0F ? 1.0F : f;
|
||||||
|
double bowError = checksConfig.getDouble(CheckType.FAST_BOW, "bowError");
|
||||||
|
if (Math.abs(force - f) > bowError) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"fired their bow too fast (actual force=" + force + ", calculated force=" + f + ")");
|
||||||
|
} else {
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckResult checkProjectile(Player player) {
|
||||||
|
incrementOld(player, projectilesShot, 10);
|
||||||
|
int projectilesToWait = checksConfig.getInteger(CheckType.FAST_PROJECTILE, "projectilesToWait");
|
||||||
|
if (!projectileTime.containsKey(player.getUniqueId())) {
|
||||||
|
projectileTime.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
return new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
} else if (projectilesShot.get(player.getUniqueId()) == projectilesToWait) {
|
||||||
|
long time = System.currentTimeMillis() - projectileTime.get(player.getUniqueId());
|
||||||
|
int minimumTime = checksConfig.getInteger(CheckType.FAST_PROJECTILE, "minimumTime");
|
||||||
|
projectileTime.remove(player.getUniqueId());
|
||||||
|
projectilesShot.remove(player.getUniqueId());
|
||||||
|
if (time < minimumTime) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"wound up a bow too fast (actual time=" + time + ", min time=" + minimumTime + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckResult checkFastDrop(Player player) {
|
||||||
|
incrementOld(player, blocksDropped, 10);
|
||||||
|
int dropsToWait = checksConfig.getInteger(CheckType.ITEM_SPAM, "dropsToWait");
|
||||||
|
if (!blockTime.containsKey(player.getUniqueId())) {
|
||||||
|
blockTime.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
return new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
} else if (blocksDropped.get(player.getUniqueId()) == dropsToWait) {
|
||||||
|
long time = System.currentTimeMillis() - blockTime.get(player.getUniqueId());
|
||||||
|
int minimumTime = checksConfig.getInteger(CheckType.ITEM_SPAM, "minimumTime");
|
||||||
|
blockTime.remove(player.getUniqueId());
|
||||||
|
blocksDropped.remove(player.getUniqueId());
|
||||||
|
if (time < minimumTime) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"dropped an item too fast (actual time=" + time + ", min time=" + minimumTime + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckResult checkSpider(Player player, double y) {
|
||||||
|
if (y <= 0.11761 && y >= 0.11759 && !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 {
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckResult checkNoFall(Player player, double y) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping()
|
||||||
|
&& !isMovingExempt(player) && !justPlaced(player) && !Utilities.isNearWater(player)
|
||||||
|
&& !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")
|
||||||
|
&& !VersionUtil.isSlowFalling(player) && !Utilities
|
||||||
|
.isNearShulkerBox(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation())) {
|
||||||
|
if (player.getFallDistance() == 0) {
|
||||||
|
if (nofallViolation.get(uuid) == null) {
|
||||||
|
nofallViolation.put(uuid, 1);
|
||||||
|
} else {
|
||||||
|
nofallViolation.put(uuid, nofallViolation.get(player.getUniqueId()) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = nofallViolation.get(uuid);
|
||||||
|
int vlBeforeFlag = checksConfig.getInteger(CheckType.NOFALL, "vlBeforeFlag");
|
||||||
|
if (i >= vlBeforeFlag) {
|
||||||
|
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=" + vlBeforeFlag + ")");
|
||||||
|
} else {
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nofallViolation.put(uuid, 0);
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckResult checkSneakToggle(Player player) {
|
||||||
|
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||||
|
final long lastSneak = this.lastSneak.getOrDefault(player.getUniqueId(), (long) 0);
|
||||||
|
this.lastSneak.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
if (System.currentTimeMillis() - lastSneak < checksConfig.getInteger(CheckType.SNEAK, "minToggleTime")
|
||||||
|
&& (AntiCheatReloaded.getPlugin().getTPS() > checksConfig.getInteger(CheckType.SNEAK, "minimumTps"))) {
|
||||||
|
if (user.isLagging() && checksConfig.getBoolean(CheckType.SNEAK, "disableForLagging"))
|
||||||
|
return PASS;
|
||||||
|
|
||||||
|
if (!this.silentMode())
|
||||||
|
player.teleport(user.getGoodLocation(player.getLocation()));
|
||||||
|
|
||||||
|
return new CheckResult(Result.FAILED,
|
||||||
|
"toggled sneak too fast (time=" + (System.currentTimeMillis() - lastSneak) + ")");
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckResult checkSprintHungry(PlayerToggleSprintEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
int sprintFoodMin = checksConfig.getInteger(CheckType.SPRINT, "sprintFoodMin");
|
||||||
|
if (event.isSprinting() && player.getGameMode() != GameMode.CREATIVE
|
||||||
|
&& player.getFoodLevel() <= sprintFoodMin) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"sprinted while hungry (food=" + player.getFoodLevel() + ", min=" + sprintFoodMin + ")");
|
||||||
|
} else {
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckResult checkVClip(Player player, Distance distance) {
|
||||||
|
double from = Math.round(distance.fromY());
|
||||||
|
double to = Math.round(distance.toY());
|
||||||
|
|
||||||
|
if (player.isInsideVehicle() || (from == to || from < to) || Math.round(distance.getYDifference()) < 2) {
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
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 PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logAscension(Player player, double y1, double y2) {
|
||||||
|
UUID name = player.getUniqueId();
|
||||||
|
if (y1 < y2 && !isAscending.contains(name)) {
|
||||||
|
isAscending.add(name);
|
||||||
|
} else {
|
||||||
|
isAscending.remove(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckResult checkFastPlace(Player player) {
|
||||||
|
int vlBeforeFlagSurvival = checksConfig.getInteger(CheckType.FAST_PLACE, "vlBeforeFlagSurvival");
|
||||||
|
int vlBeforeFlagCreative = checksConfig.getInteger(CheckType.FAST_PLACE, "vlBeforeFlagCreative");
|
||||||
|
int blockPlacementTime = checksConfig.getInteger(CheckType.FAST_PLACE, "blockPlacementTime");
|
||||||
|
int violations = player.getGameMode() == GameMode.CREATIVE ? vlBeforeFlagCreative : vlBeforeFlagSurvival;
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
if (!lastBlockPlaceTime.containsKey(uuid) || !fastPlaceViolation.containsKey(uuid)) {
|
||||||
|
lastBlockPlaceTime.put(uuid, 0L);
|
||||||
|
if (!fastPlaceViolation.containsKey(uuid)) {
|
||||||
|
fastPlaceViolation.put(uuid, 0);
|
||||||
|
}
|
||||||
|
} else if (fastPlaceViolation.containsKey(uuid) && fastPlaceViolation.get(uuid) > violations) {
|
||||||
|
Long math = System.currentTimeMillis() - lastBlockPlaced.get(uuid);
|
||||||
|
if (lastBlockPlaced.get(uuid) > 0 && math < blockPlacementTime) {
|
||||||
|
lastBlockPlaced.put(uuid, time);
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "placed blocks too fast "
|
||||||
|
+ fastPlaceViolation.get(uuid) + " times in a row (max=" + violations + ")");
|
||||||
|
} else if (lastBlockPlaced.get(uuid) > 0 && math > blockPlacementTime) {
|
||||||
|
fastPlaceViolation.put(uuid, 0);
|
||||||
|
}
|
||||||
|
} else if (lastBlockPlaced.containsKey(uuid)) {
|
||||||
|
long last = lastBlockPlaced.get(uuid);
|
||||||
|
long lastTime = lastBlockPlaceTime.get(uuid);
|
||||||
|
long thisTime = time - last;
|
||||||
|
int minimumTime = checksConfig.getInteger(CheckType.FAST_PLACE, "minimumTime");
|
||||||
|
|
||||||
|
if (lastTime != 0 && thisTime < minimumTime) {
|
||||||
|
lastBlockPlaceTime.put(uuid, (time - last));
|
||||||
|
lastBlockPlaced.put(uuid, time);
|
||||||
|
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=" + minimumTime + " ms)");
|
||||||
|
}
|
||||||
|
lastBlockPlaceTime.put(uuid, (time - last));
|
||||||
|
}
|
||||||
|
lastBlockPlaced.put(uuid, time);
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logBowWindUp(Player player) {
|
||||||
|
bowWindUp.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logEatingStart(Player player) {
|
||||||
|
startEat.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEating(Player player) {
|
||||||
|
return startEat.containsKey(player.getUniqueId())
|
||||||
|
&& startEat.get(player.getUniqueId()) < checksConfig.getInteger(CheckType.FAST_EAT, "eatTimeMin");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logHeal(Player player) {
|
||||||
|
lastHeal.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckResult checkChatSpam(Player player, String msg) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
User user = manager.getUserManager().getUser(uuid);
|
||||||
|
if (user.getLastMessageTime() != -1) {
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
String m = user.getMessage(i);
|
||||||
|
if (m == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Long l = user.getMessageTime(i);
|
||||||
|
|
||||||
|
int repeatIgnore = checksConfig.getInteger(CheckType.CHAT_SPAM, "repeatIgnore");
|
||||||
|
if (System.currentTimeMillis() - l > repeatIgnore) {
|
||||||
|
user.clearMessages();
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
int timeMin = checksConfig.getInteger(CheckType.CHAT_SPAM, "timeMin");
|
||||||
|
if (manager.getConfiguration().getConfig().blockChatSpamRepetition.getValue()
|
||||||
|
&& m.equalsIgnoreCase(msg) && i == 1) {
|
||||||
|
manager.getLoggingManager().logFineInfo(player.getName() + " spam-repeated \"" + msg + "\"");
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
||||||
|
} else if (manager.getConfiguration().getConfig().blockChatSpamSpeed.getValue()
|
||||||
|
&& System.currentTimeMillis() - user.getLastCommandTime() < timeMin) {
|
||||||
|
manager.getLoggingManager().logFineInfo(player.getName() + " spammed quickly \"" + msg + "\"");
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
user.addMessage(msg);
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckResult checkChatUnicode(Player player, String msg) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
User user = manager.getUserManager().getUser(uuid);
|
||||||
|
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
|
||||||
|
&& Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.CYRILLIC
|
||||||
|
&& Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.CYRILLIC_EXTENDED_A) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "Unicode chat is not allowed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
user.addMessage(msg);
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckResult checkCommandSpam(Player player, String cmd) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
User user = manager.getUserManager().getUser(uuid);
|
||||||
|
if (user.getLastCommandTime() != -1) {
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
String m = user.getCommand(i);
|
||||||
|
if (m == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Long l = user.getCommandTime(i);
|
||||||
|
|
||||||
|
int repeatIgnore = checksConfig.getInteger(CheckType.COMMAND_SPAM, "repeatIgnore");
|
||||||
|
if (System.currentTimeMillis() - l > repeatIgnore) {
|
||||||
|
user.clearCommands();
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
int timeMin = checksConfig.getInteger(CheckType.COMMAND_SPAM, "timeMin");
|
||||||
|
if (manager.getConfiguration().getConfig().blockCommandSpamRepetition.getValue()
|
||||||
|
&& m.equalsIgnoreCase(cmd) && i == 1) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
||||||
|
} else if (manager.getConfiguration().getConfig().blockCommandSpamSpeed.getValue()
|
||||||
|
&& System.currentTimeMillis() - user.getLastCommandTime() < timeMin) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
user.addCommand(cmd);
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckResult checkInventoryClicks(Player player) {
|
||||||
|
if (player.getGameMode() == GameMode.CREATIVE) {
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
int clicks = 1;
|
||||||
|
if (inventoryClicks.containsKey(uuid)) {
|
||||||
|
clicks = inventoryClicks.get(uuid) + 1;
|
||||||
|
}
|
||||||
|
inventoryClicks.put(uuid, clicks);
|
||||||
|
int clicksToWait = checksConfig.getInteger(CheckType.FAST_INVENTORY, "clicksToWait");
|
||||||
|
if (clicks == 1) {
|
||||||
|
inventoryTime.put(uuid, System.currentTimeMillis());
|
||||||
|
} else if (clicks == clicksToWait) {
|
||||||
|
int minimumTime = checksConfig.getInteger(CheckType.FAST_INVENTORY, "clicksToWait");
|
||||||
|
long time = System.currentTimeMillis() - inventoryTime.get(uuid);
|
||||||
|
inventoryClicks.put(uuid, 0);
|
||||||
|
if (time < minimumTime) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "clicked inventory slots " + clicks + " times in "
|
||||||
|
+ time + " ms (max=" + clicksToWait + " in " + minimumTime + " ms)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckResult checkFastHeal(Player player) {
|
||||||
|
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||||
|
if (lastHeal.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it.
|
||||||
|
{
|
||||||
|
double tps = AntiCheatReloaded.getPlugin().getTPS();
|
||||||
|
if (tps < checksConfig.getDouble(CheckType.FAST_HEAL, "minimumTps")
|
||||||
|
|| (user.isLagging() && checksConfig.getBoolean(CheckType.FAST_HEAL, "disableForLagging"))) {
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
long minHealTime = checksConfig.getInteger(CheckType.FAST_HEAL, "minHealTime");
|
||||||
|
long lastHealTime = lastHeal.get(player.getUniqueId());
|
||||||
|
int ping = user.getPing();
|
||||||
|
double pingCompensation = checksConfig.getInteger(CheckType.FAST_HEAL, "pingCompensation");
|
||||||
|
long allowedHealTime = (long) (minHealTime - (ping * pingCompensation));
|
||||||
|
lastHeal.remove(player.getUniqueId());
|
||||||
|
if ((System.currentTimeMillis() - lastHealTime) < allowedHealTime) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "healed too quickly (time="
|
||||||
|
+ (System.currentTimeMillis() - lastHealTime) + " ms, min=" + allowedHealTime + " ms)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckResult checkFastEat(Player player) {
|
||||||
|
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||||
|
if (startEat.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it.
|
||||||
|
{
|
||||||
|
if (AntiCheatReloaded.getPlugin().getTPS() < 17.5 || user.isLagging()) {
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
long l = startEat.get(player.getUniqueId());
|
||||||
|
startEat.remove(player.getUniqueId());
|
||||||
|
int eatTimeMin = checksConfig.getInteger(CheckType.FAST_EAT, "eatTimeMin");
|
||||||
|
if ((System.currentTimeMillis() - l) < eatTimeMin) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "ate too quickly (time="
|
||||||
|
+ (System.currentTimeMillis() - l) + " ms, min=" + eatTimeMin + " ms)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logSprint(final Player player) {
|
||||||
|
sprinted.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logBlockBreak(final Player player) {
|
||||||
|
brokenBlock.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean justBroke(Player player) {
|
||||||
|
// TODO config??
|
||||||
|
return isDoing(player, brokenBlock, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logVelocity(final Player player) {
|
||||||
|
velocitized.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logLevitating(final Player player, final int duration) {
|
||||||
|
levitatingEnd.put(player.getUniqueId(), System.currentTimeMillis() + (duration * 1000L));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean justVelocity(Player player) {
|
||||||
|
return (velocitized.containsKey(player.getUniqueId())
|
||||||
|
? (System.currentTimeMillis() - velocitized.get(player.getUniqueId())) < magic.VELOCITY_TIME()
|
||||||
|
: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean justLevitated(Player player) {
|
||||||
|
return (levitatingEnd.containsKey(player.getUniqueId())
|
||||||
|
? (System.currentTimeMillis() - levitatingEnd.get(player.getUniqueId())) < magic.VELOCITY_TIME()
|
||||||
|
: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean extendVelocityTime(final Player player) {
|
||||||
|
if (velocitytrack.containsKey(player.getUniqueId())) {
|
||||||
|
velocitytrack.put(player.getUniqueId(), velocitytrack.get(player.getUniqueId()) + 1);
|
||||||
|
if (velocitytrack.get(player.getUniqueId()) > magic.VELOCITY_MAXTIMES()) {
|
||||||
|
velocitized.put(player.getUniqueId(), System.currentTimeMillis() + magic.VELOCITY_PREVENT());
|
||||||
|
manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(manager.getPlugin(),
|
||||||
|
new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
velocitytrack.put(player.getUniqueId(), 0);
|
||||||
|
}
|
||||||
|
}, magic.VELOCITY_EXTENSION() * 20L);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
velocitytrack.put(player.getUniqueId(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logBlockPlace(final Player player) {
|
||||||
|
placedBlock.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean justPlaced(Player player) {
|
||||||
|
// TODO config??
|
||||||
|
return isDoing(player, placedBlock, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logDamage(final Player player, int type) {
|
||||||
|
long time;
|
||||||
|
switch (type) {
|
||||||
|
case 1:
|
||||||
|
time = magic.DAMAGE_TIME();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
time = magic.KNOCKBACK_DAMAGE_TIME();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
time = magic.EXPLOSION_DAMAGE_TIME();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
time = magic.DAMAGE_TIME();
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + time);
|
||||||
|
// Only map in which termination time is calculated beforehand.
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logEnterExit(final Player player) {
|
||||||
|
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.ENTERED_EXITED_TIME());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logTeleport(final Player player) {
|
||||||
|
manager.getUserManager().getUser(player.getUniqueId()).getMovementManager().lastTeleport = System
|
||||||
|
.currentTimeMillis();
|
||||||
|
/* Data for fly/speed should be reset */
|
||||||
|
nofallViolation.remove(player.getUniqueId());
|
||||||
|
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logExitFly(final Player player) {
|
||||||
|
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.EXIT_FLY_TIME());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logBoatCollision(final Player player) {
|
||||||
|
// TODO config??
|
||||||
|
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + 100 /* 2 ticks */);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logJoin(final Player player) {
|
||||||
|
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.JOIN_TIME());
|
||||||
|
MorePacketsCheck.EXEMPT_TIMINGS.put(player.getUniqueId(), System.currentTimeMillis() + magic.JOIN_TIME());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMovingExempt(Player player) {
|
||||||
|
return isDoing(player, FlightCheck.MOVING_EXEMPT, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAscending(Player player) {
|
||||||
|
return isAscending.contains(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDoing(Player player, Map<UUID, Long> map, double max) {
|
||||||
|
if (map.containsKey(player.getUniqueId())) {
|
||||||
|
if (max != -1) {
|
||||||
|
if (((System.currentTimeMillis() - map.get(player.getUniqueId())) / 1000) > max) {
|
||||||
|
map.remove(player.getUniqueId());
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Termination time has already been calculated
|
||||||
|
if (map.get(player.getUniqueId()) < System.currentTimeMillis()) {
|
||||||
|
map.remove(player.getUniqueId());
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasJumpPotion(Player player) {
|
||||||
|
return player.hasPotionEffect(PotionEffectType.JUMP);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasSpeedPotion(Player player) {
|
||||||
|
return player.hasPotionEffect(PotionEffectType.SPEED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processChatSpammer(Player player) {
|
||||||
|
User user = manager.getUserManager().getUser(player.getUniqueId());
|
||||||
|
int level = chatLevel.containsKey(user.getUUID()) ? chatLevel.get(user.getUUID()) : 0;
|
||||||
|
int levelActionOne = checksConfig.getInteger(CheckType.CHAT_SPAM, "levelActionOne");
|
||||||
|
int levelActionTwo = checksConfig.getInteger(CheckType.CHAT_SPAM, "levelActionTwo");
|
||||||
|
if (player != null && player.isOnline() && level >= levelActionOne) {
|
||||||
|
String event = level >= levelActionTwo ? 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processCommandSpammer(Player player) {
|
||||||
|
User user = manager.getUserManager().getUser(player.getUniqueId());
|
||||||
|
int level = commandLevel.containsKey(user.getUUID()) ? commandLevel.get(user.getUUID()) : 0;
|
||||||
|
int levelActionOne = checksConfig.getInteger(CheckType.COMMAND_SPAM, "levelActionOne");
|
||||||
|
int levelActionTwo = checksConfig.getInteger(CheckType.COMMAND_SPAM, "levelActionTwo");
|
||||||
|
if (player != null && player.isOnline() && level >= levelActionOne) {
|
||||||
|
String event = level >= levelActionTwo
|
||||||
|
? 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int increment(Player player, Map<UUID, Integer> map, int num) {
|
||||||
|
UUID name = player.getUniqueId();
|
||||||
|
if (map.get(name) == null) {
|
||||||
|
map.put(name, 1);
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
int amount = map.get(name) + 1;
|
||||||
|
if (amount < num + 1) {
|
||||||
|
map.put(name, amount);
|
||||||
|
return amount;
|
||||||
|
} else {
|
||||||
|
map.put(name, num);
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int incrementOld(Player player, Map<UUID, Integer> map, int num) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
if (map.get(uuid) == null) {
|
||||||
|
map.put(uuid, 1);
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
int amount = map.get(uuid) + 1;
|
||||||
|
if (amount < num + 1) {
|
||||||
|
map.put(uuid, amount);
|
||||||
|
return amount;
|
||||||
|
} else {
|
||||||
|
map.put(uuid, num);
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean silentMode() {
|
||||||
|
return manager.getConfiguration().getConfig().silentMode.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-3
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,7 +17,7 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.check;
|
package com.rammelkast.anticheatreloaded.check;
|
||||||
|
|
||||||
public class CheckResult {
|
public class CheckResult {
|
||||||
|
|
||||||
+44
-43
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,14 +17,15 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.check;
|
package com.rammelkast.anticheatreloaded.check;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.api.CheckFailEvent;
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Permission;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.api.CheckFailEvent;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -34,46 +36,48 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public enum CheckType {
|
public enum CheckType {
|
||||||
ZOMBE_FLY(Permission.CHECK_ZOMBE_FLY),
|
FLIGHT(Permission.CHECK_FLIGHT, "Flight"),
|
||||||
ZOMBE_NOCLIP(Permission.CHECK_ZOMBE_NOCLIP),
|
ELYTRAFLY(Permission.CHECK_FLIGHT, "ElytraFly"),
|
||||||
ZOMBE_CHEAT(Permission.CHECK_ZOMBE_CHEAT),
|
WATER_WALK(Permission.CHECK_WATERWALK, "WaterWalk"),
|
||||||
FLY(Permission.CHECK_FLY),
|
FAST_PLACE(Permission.CHECK_FASTPLACE, "FastPlace"),
|
||||||
WATER_WALK(Permission.CHECK_WATERWALK),
|
CHAT_SPAM(Permission.CHECK_CHATSPAM, "ChatSpam"),
|
||||||
NO_SWING(Permission.CHECK_NOSWING),
|
COMMAND_SPAM(Permission.CHECK_COMMANDSPAM, "CommandSpam"),
|
||||||
FAST_BREAK(Permission.CHECK_FASTBREAK),
|
SPRINT(Permission.CHECK_SPRINT, "Sprint"),
|
||||||
FAST_PLACE(Permission.CHECK_FASTPLACE),
|
SNEAK(Permission.CHECK_SNEAK, "Sneak"),
|
||||||
CHAT_SPAM(Permission.CHECK_CHATSPAM),
|
SPEED(Permission.CHECK_SPEED, "Speed"),
|
||||||
COMMAND_SPAM(Permission.CHECK_COMMANDSPAM),
|
VCLIP(Permission.CHECK_VCLIP, "vClip"),
|
||||||
SPRINT(Permission.CHECK_SPRINT),
|
SPIDER(Permission.CHECK_SPIDER, "Spider"),
|
||||||
SNEAK(Permission.CHECK_SNEAK),
|
NOFALL(Permission.CHECK_NOFALL, "NoFall"),
|
||||||
SPEED(Permission.CHECK_SPEED),
|
FAST_BOW(Permission.CHECK_FASTBOW, "FastBow"),
|
||||||
VCLIP(Permission.CHECK_VCLIP),
|
FAST_EAT(Permission.CHECK_FASTEAT, "FastEat"),
|
||||||
SPIDER(Permission.CHECK_SPIDER),
|
FAST_HEAL(Permission.CHECK_FASTHEAL, "FastHeal"),
|
||||||
NOFALL(Permission.CHECK_NOFALL),
|
KILLAURA(Permission.CHECK_KILLAURA, "KillAura"),
|
||||||
FAST_BOW(Permission.CHECK_FASTBOW),
|
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE, "FastProjectile"),
|
||||||
FAST_EAT(Permission.CHECK_FASTEAT),
|
ITEM_SPAM(Permission.CHECK_ITEMSPAM, "ItemSpam"),
|
||||||
FAST_HEAL(Permission.CHECK_FASTHEAL),
|
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY, "FastInventory"),
|
||||||
FORCEFIELD(Permission.CHECK_FORCEFIELD),
|
MOREPACKETS(Permission.CHECK_MOREPACKETS, "MorePackets"),
|
||||||
LONG_REACH(Permission.CHECK_LONGREACH),
|
BADPACKETS(Permission.CHECK_BADPACKETS, "BadPackets"),
|
||||||
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE),
|
VELOCITY(Permission.CHECK_VELOCITY, "Velocity"),
|
||||||
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
CRITICALS(Permission.CHECK_CRITICALS, "Criticals"),
|
||||||
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
CHAT_UNICODE(Permission.CHECK_UNICODE, "ChatUnicode"),
|
||||||
AUTOTOOL(Permission.CHECK_AUTOTOOL),
|
ILLEGAL_INTERACT(Permission.CHECK_ILLEGALINTERACT, "IllegalInteract"),
|
||||||
KILLAURA(Permission.CHECK_KILLAURA),
|
FASTLADDER(Permission.CHECK_FASTLADDER, "FastLadder"),
|
||||||
BLINK(Permission.CHECK_BLINK),
|
AIMBOT(Permission.CHECK_AIMBOT, "Aimbot"),
|
||||||
VELOCITY(Permission.VELOCITY),
|
STRAFE(Permission.CHECK_STRAFE, "Strafe");
|
||||||
CRITICALS(Permission.CRITICALS);
|
|
||||||
|
|
||||||
private final Permission permission;
|
private final Permission permission;
|
||||||
|
private final String displayName;
|
||||||
private final Map<UUID, Integer> level = new HashMap<UUID, Integer>();
|
private final Map<UUID, Integer> level = new HashMap<UUID, Integer>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize a CheckType
|
* Initialize a CheckType
|
||||||
*
|
*
|
||||||
* @param perm Permission that applies to this check
|
* @param permission Permission that applies to this check
|
||||||
|
* @peram displayName The chat display name
|
||||||
*/
|
*/
|
||||||
private CheckType(Permission perm) {
|
private CheckType(Permission permission, String displayName) {
|
||||||
this.permission = perm;
|
this.permission = permission;
|
||||||
|
this.displayName = displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,12 +123,9 @@ public enum CheckType {
|
|||||||
/**
|
/**
|
||||||
* Get the reference name of a check
|
* Get the reference name of a check
|
||||||
*
|
*
|
||||||
* @param type Type of check
|
|
||||||
* @return reference name
|
* @return reference name
|
||||||
*/
|
*/
|
||||||
public static String getName(CheckType type) {
|
public String getName() {
|
||||||
char[] chars = type.toString().replaceAll("_", " ").toLowerCase().toCharArray();
|
return this.displayName;
|
||||||
chars[0] = Character.toUpperCase(chars[0]);
|
|
||||||
return new String(chars);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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.combat;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
|
||||||
|
public class CriticalsCheck {
|
||||||
|
|
||||||
|
public static void doDamageEvent(EntityDamageByEntityEvent event, Player damager) {
|
||||||
|
if (!(event.getDamager() instanceof Player) || event.getCause() != DamageCause.ENTITY_ATTACK)
|
||||||
|
return;
|
||||||
|
Player player = (Player) event.getDamager();
|
||||||
|
if (isCritical(player)) {
|
||||||
|
if ((player.getLocation().getY() % 1.0 == 0 || player.getLocation().getY() % 0.5 == 0)
|
||||||
|
&& player.getLocation().clone().subtract(0, 1.0, 0).getBlock().getType().isSolid()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
EventListener.log(new CheckResult(CheckResult.Result.FAILED, "tried to do a critical without needed conditions")
|
||||||
|
.getMessage(),
|
||||||
|
player, CheckType.CRITICALS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
private static boolean isCritical(Player player) {
|
||||||
|
return player.getFallDistance() > 0.0f && !player.isOnGround() && !player.isInsideVehicle()
|
||||||
|
&& !player.hasPotionEffect(PotionEffectType.BLINDNESS)
|
||||||
|
&& !Utilities.isHoveringOverWater(player.getLocation())
|
||||||
|
&& player.getEyeLocation().getBlock().getType() != Material.LADDER;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
/*
|
||||||
|
* 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.combat;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
|
||||||
|
public class KillAuraCheck {
|
||||||
|
|
||||||
|
// Angle check
|
||||||
|
public static final Map<UUID, Integer> ANGLE_FLAGS = new HashMap<UUID, Integer>();
|
||||||
|
// PacketOrder check
|
||||||
|
public static final Map<UUID, Integer> PACKETORDER_FLAGS = new HashMap<UUID, Integer>();
|
||||||
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
|
public static CheckResult checkReach(Player player, Entity target) {
|
||||||
|
if (!(target instanceof LivingEntity))
|
||||||
|
return PASS;
|
||||||
|
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
|
||||||
|
// Check if enabled
|
||||||
|
if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "reach"))
|
||||||
|
return PASS;
|
||||||
|
|
||||||
|
double allowedReach = target.getVelocity().length() < 0.08
|
||||||
|
? checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.normal")
|
||||||
|
: checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.velocitized");
|
||||||
|
// Lag compensation
|
||||||
|
double lagExtraReach = checksConfig.getDouble(CheckType.KILLAURA, "reach", "lagCompensation.lagExtraReach");
|
||||||
|
double pingCompensation = checksConfig.getDouble(CheckType.KILLAURA, "reach",
|
||||||
|
"lagCompensation.pingCompensation");
|
||||||
|
allowedReach += user.getPing() * pingCompensation;
|
||||||
|
if (user.isLagging())
|
||||||
|
allowedReach += lagExtraReach;
|
||||||
|
if (target instanceof Player) {
|
||||||
|
User targetUser = AntiCheatReloaded.getManager().getUserManager().getUser(target.getUniqueId());
|
||||||
|
allowedReach += targetUser.getPing() * pingCompensation;
|
||||||
|
if (targetUser.isLagging())
|
||||||
|
allowedReach += lagExtraReach;
|
||||||
|
}
|
||||||
|
// Velocity compensation
|
||||||
|
double velocityMultiplier = checksConfig.getDouble(CheckType.KILLAURA, "reach", "velocityMultiplier");
|
||||||
|
allowedReach += Math.abs(target.getVelocity().length()) * velocityMultiplier;
|
||||||
|
double reachedDistance = ((LivingEntity) target).getLocation().toVector()
|
||||||
|
.distance(player.getLocation().toVector());
|
||||||
|
if (reachedDistance > allowedReach)
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"reached too far (distance=" + Utilities.roundDouble(reachedDistance, 6) + ", max=" + Utilities.roundDouble(allowedReach, 6) + ")");
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CheckResult checkAngle(Player player, EntityDamageEvent event) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
Entity entity = event.getEntity();
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
|
||||||
|
// Check if enabled
|
||||||
|
if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "angle"))
|
||||||
|
return PASS;
|
||||||
|
|
||||||
|
if (entity instanceof LivingEntity) {
|
||||||
|
LivingEntity living = (LivingEntity) entity;
|
||||||
|
Location eyeLocation = player.getEyeLocation();
|
||||||
|
|
||||||
|
double yawDifference = calculateYawDifference(eyeLocation, living.getLocation());
|
||||||
|
double playerYaw = player.getEyeLocation().getYaw();
|
||||||
|
|
||||||
|
double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
|
||||||
|
int maxDifference = checksConfig.getInteger(CheckType.KILLAURA, "angle", "maxDifference");
|
||||||
|
if (Math.round(angleDifference) > maxDifference) {
|
||||||
|
if (!ANGLE_FLAGS.containsKey(uuid)) {
|
||||||
|
ANGLE_FLAGS.put(uuid, 1);
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int flags = ANGLE_FLAGS.get(uuid);
|
||||||
|
int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "angle", "vlBeforeFlag");
|
||||||
|
if (flags >= vlBeforeFlag) {
|
||||||
|
ANGLE_FLAGS.remove(uuid);
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"tried to attack from an illegal angle (angle=" + Math.round(angleDifference) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
ANGLE_FLAGS.put(uuid, flags + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CheckResult checkPacketOrder(Player player, Entity entity) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
|
||||||
|
MovementManager movementManager = user.getMovementManager();
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
|
||||||
|
// Check if enabled
|
||||||
|
if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "packetOrder"))
|
||||||
|
return PASS;
|
||||||
|
|
||||||
|
if (user.isLagging() || (System.currentTimeMillis() - movementManager.lastTeleport) <= 100
|
||||||
|
|| AntiCheatReloaded.getPlugin().getTPS() < checksConfig.getDouble(CheckType.KILLAURA, "packetOrder", "minimumTps"))
|
||||||
|
return PASS;
|
||||||
|
|
||||||
|
long elapsed = System.currentTimeMillis() - movementManager.lastUpdate;
|
||||||
|
if (elapsed < checksConfig.getInteger(CheckType.KILLAURA, "packetOrder", "minElapsedTime")) {
|
||||||
|
if (!PACKETORDER_FLAGS.containsKey(uuid)) {
|
||||||
|
PACKETORDER_FLAGS.put(uuid, 1);
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int flags = PACKETORDER_FLAGS.get(uuid);
|
||||||
|
int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "packetOrder", "vlBeforeFlag");
|
||||||
|
if (flags >= vlBeforeFlag) {
|
||||||
|
PACKETORDER_FLAGS.remove(uuid);
|
||||||
|
return new CheckResult(Result.FAILED, "suspicious packet order (elapsed=" + elapsed + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
PACKETORDER_FLAGS.put(uuid, flags + 1);
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* 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.combat;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
|
||||||
|
public class VelocityCheck {
|
||||||
|
|
||||||
|
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
|
||||||
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
|
public static CheckResult runCheck(Player player, Distance distance) {
|
||||||
|
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||||
|
MovementManager movementManager = user.getMovementManager();
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
final int minimumPercentage = checksConfig.getInteger(CheckType.VELOCITY, "minimumPercentage");
|
||||||
|
final int vlBeforeFlag = checksConfig.getInteger(CheckType.VELOCITY, "vlBeforeFlag");
|
||||||
|
|
||||||
|
if (movementManager.velocityExpectedMotionY > 0 && !movementManager.onGround) {
|
||||||
|
double percentage = (movementManager.motionY / movementManager.velocityExpectedMotionY) * 100;
|
||||||
|
if (percentage < 0)
|
||||||
|
percentage = 0;
|
||||||
|
// Reset expected Y motion
|
||||||
|
movementManager.velocityExpectedMotionY = 0;
|
||||||
|
if (percentage < minimumPercentage) {
|
||||||
|
int vl = VIOLATIONS.getOrDefault(player.getUniqueId(), 0) + 1;
|
||||||
|
VIOLATIONS.put(player.getUniqueId(), vl);
|
||||||
|
if (vl >= vlBeforeFlag)
|
||||||
|
return new CheckResult(Result.FAILED, "ignored server velocity (pct=" + Utilities.roundDouble(percentage, 2) + ")");
|
||||||
|
} else {
|
||||||
|
VIOLATIONS.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
} else if (movementManager.airTicks > 5 && movementManager.velocityExpectedMotionY > 0)
|
||||||
|
movementManager.velocityExpectedMotionY = 0;
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* 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.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
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.config.providers.Checks;
|
||||||
|
|
||||||
|
public class AimbotCheck {
|
||||||
|
|
||||||
|
public static final Map<UUID, Float> LAST_DELTA_YAW = new HashMap<UUID, Float>();
|
||||||
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
|
public static CheckResult runCheck(Player player, PlayerMoveEvent event) {
|
||||||
|
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
if (backend.isMovingExempt(player)) {
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
float dYaw = Math.abs(event.getTo().getYaw() - event.getFrom().getYaw());
|
||||||
|
float dPitch = Math.abs(event.getTo().getPitch() - event.getFrom().getPitch());
|
||||||
|
// Not interesting
|
||||||
|
if (dYaw < 0.05 && dPitch < 0.05) {
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
final float lastDeltaYaw = LAST_DELTA_YAW.getOrDefault(uuid, -1F);
|
||||||
|
if (lastDeltaYaw == -1F) {
|
||||||
|
LAST_DELTA_YAW.put(uuid, dYaw);
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
LAST_DELTA_YAW.put(uuid, dYaw);
|
||||||
|
|
||||||
|
float absoluteYawDifference = Math.abs(dYaw - lastDeltaYaw);
|
||||||
|
int minYaw = checksConfig.getInteger(CheckType.AIMBOT, "minYaw");
|
||||||
|
int maxYaw = checksConfig.getInteger(CheckType.AIMBOT, "maxYaw");
|
||||||
|
if (absoluteYawDifference < 1E-8 && minYaw > 30 && dYaw < maxYaw)
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "repeated yaw difference (dYaw=" + dYaw + ")");
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* 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.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
|
public class ElytraCheck {
|
||||||
|
|
||||||
|
public static final HashMap<UUID, Double> JUMP_Y_VALUE = new HashMap<UUID, Double>();
|
||||||
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
|
public static CheckResult runCheck(Player player, Distance distance) {
|
||||||
|
// No elytra in server version or not relevant
|
||||||
|
if (VersionUtil.isBountifulUpdate() || Utilities.isNearWater(player))
|
||||||
|
return PASS;
|
||||||
|
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()) {
|
||||||
|
// This was a teleport, so skip check.
|
||||||
|
JUMP_Y_VALUE.remove(uuid);
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.isFlying() || player.hasPotionEffect(PotionEffectType.LEVITATION) || !player.isGliding()) {
|
||||||
|
JUMP_Y_VALUE.remove(uuid);
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
double changeY = distance.toY() - distance.fromY();
|
||||||
|
boolean upwardMovement = changeY > 0;
|
||||||
|
if (player.getInventory().getItemInMainHand().getType() == Material.TRIDENT) {
|
||||||
|
if (upwardMovement) {
|
||||||
|
// TODO continue check here
|
||||||
|
JUMP_Y_VALUE.remove(uuid);
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changeY == 0.0D) {
|
||||||
|
// Seen no false positives here yet
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "had no Y-axis dropoff when gliding with Elytra");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!JUMP_Y_VALUE.containsKey(uuid)) {
|
||||||
|
JUMP_Y_VALUE.put(uuid, distance.toY());
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
double lastY = JUMP_Y_VALUE.get(uuid);
|
||||||
|
if (lastY < distance.toY()) {
|
||||||
|
double diff = distance.toY() - lastY;
|
||||||
|
if (diff > 0.7675) {
|
||||||
|
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
||||||
|
Location to = player.getLocation();
|
||||||
|
to.setY(to.getY() - diff);
|
||||||
|
player.teleport(to);
|
||||||
|
}
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "tried to glide above jump level");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* 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.entity.Player;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
|
||||||
|
public class FastLadderCheck {
|
||||||
|
|
||||||
|
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
|
||||||
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
|
public static CheckResult runCheck(Player player, double y) {
|
||||||
|
// Only check if fully on ladder
|
||||||
|
// Liquids are climbable blocks, so we have to add a seperate check
|
||||||
|
if (!Utilities.isClimbableBlock(player.getLocation().getBlock())
|
||||||
|
|| !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
|
||||||
|
|| player.getLocation().getBlock().isLiquid()) {
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int vlCount = VIOLATIONS.getOrDefault(player.getUniqueId(), 0);
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
int vlBeforeFlag = checksConfig.getInteger(CheckType.FASTLADDER, "vlBeforeFlag");
|
||||||
|
if (y > 0) {
|
||||||
|
// Check moving up
|
||||||
|
double max = checksConfig.getDouble(CheckType.FASTLADDER, "speedUpMax");
|
||||||
|
// Check if going faster than max Y climbing speed
|
||||||
|
if (y - max > 0) {
|
||||||
|
if (vlCount++ > vlBeforeFlag) {
|
||||||
|
vlCount = 0;
|
||||||
|
return new CheckResult(Result.FAILED,
|
||||||
|
"tried to climb up too fast (speed=" + y + ", max=" + max + ")");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (vlCount > 0)
|
||||||
|
vlCount--;
|
||||||
|
}
|
||||||
|
} else if (y < 0) {
|
||||||
|
// Check moving down
|
||||||
|
double max = checksConfig.getDouble(CheckType.FASTLADDER, "speedDownMax");
|
||||||
|
if (Math.abs(y) > max + 6E-9) {
|
||||||
|
if (vlCount++ > vlBeforeFlag) {
|
||||||
|
vlCount = 0;
|
||||||
|
return new CheckResult(Result.FAILED, "tried to climb down too fast (speed=" + Math.abs(y)
|
||||||
|
+ ", max=" + max + ")");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (vlCount > 0)
|
||||||
|
vlCount--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (vlCount > 0)
|
||||||
|
vlCount--;
|
||||||
|
}
|
||||||
|
|
||||||
|
VIOLATIONS.put(player.getUniqueId(), vlCount);
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
/*
|
||||||
|
* 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.block.BlockFace;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
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.config.providers.Checks;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Rammelkast
|
||||||
|
*/
|
||||||
|
public class FlightCheck {
|
||||||
|
|
||||||
|
public static final Map<UUID, Long> MOVING_EXEMPT = new HashMap<UUID, Long>();
|
||||||
|
public static final Map<UUID, Integer> GRAVITY_VIOLATIONS = new HashMap<UUID, Integer>();
|
||||||
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
private static final double GRAVITY_FRICTION = 0.9800000190734863D;
|
||||||
|
|
||||||
|
public static CheckResult runCheck(Player player, Distance distance) {
|
||||||
|
if (distance.getYDifference() >= AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|
||||||
|
|| VersionUtil.isFlying(player) || player.getVehicle() != null
|
||||||
|
|| AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)) {
|
||||||
|
// This was a teleport or user is flying/using elytra/in a vehicle, so we don't
|
||||||
|
// care
|
||||||
|
// about it.
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||||
|
MovementManager movementManager = user.getMovementManager();
|
||||||
|
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
|
||||||
|
if (movementManager.nearLiquidTicks > 0 || movementManager.halfMovement || Utilities.isNearClimbable(player))
|
||||||
|
return PASS;
|
||||||
|
|
||||||
|
int minAirTicks = 13;
|
||||||
|
if (player.hasPotionEffect(PotionEffectType.JUMP))
|
||||||
|
minAirTicks += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 3;
|
||||||
|
|
||||||
|
if (movementManager.halfMovementHistoryCounter > 25)
|
||||||
|
minAirTicks += 5;
|
||||||
|
|
||||||
|
// Start AirFlight
|
||||||
|
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airFlight") && movementManager.airTicks > minAirTicks
|
||||||
|
&& !backend.justVelocity(player) && movementManager.elytraEffectTicks <= 25) {
|
||||||
|
// Config default base is 1200ms
|
||||||
|
// Ping clamped to max. 1000 to prevent spoofing for an advantage
|
||||||
|
int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
|
||||||
|
"accountForBlockPlacement") + (0.25 * (user.getPing() > 1000 ? 1000 : user.getPing())));
|
||||||
|
// Config default account is 250ms
|
||||||
|
if (AntiCheatReloaded.getPlugin().getTPS() < 18.0)
|
||||||
|
blockPlaceAccountingTime += checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
|
||||||
|
"accountForTpsDrops");
|
||||||
|
long lastPlacedBlock = AntiCheatReloaded.getManager().getBackend().placedBlock
|
||||||
|
.containsKey(player.getUniqueId())
|
||||||
|
? AntiCheatReloaded.getManager().getBackend().placedBlock.get(player.getUniqueId())
|
||||||
|
: (blockPlaceAccountingTime + 1);
|
||||||
|
double maxMotionY = System.currentTimeMillis() - lastPlacedBlock > blockPlaceAccountingTime ? 0 : 0.42;
|
||||||
|
// Fixes snow false positive
|
||||||
|
if (movementManager.motionY < 0.004 && Utilities
|
||||||
|
.isNearHalfblock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN).getLocation()))
|
||||||
|
maxMotionY = 0.004D;
|
||||||
|
if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0
|
||||||
|
&& !Utilities.isNearClimbable(distance.getTo().clone().subtract(0, 1.25, 0)))
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"tried to fly on the Y-axis (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")");
|
||||||
|
|
||||||
|
if (Math.abs(movementManager.motionY - movementManager.lastMotionY) < 0.01
|
||||||
|
&& !Utilities.couldBeOnBoat(player)
|
||||||
|
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||||
|
.getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports"))
|
||||||
|
&& !VersionUtil.isSlowFalling(player) && !Utilities.isInWeb(player)
|
||||||
|
&& movementManager.elytraEffectTicks <= 25)
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "had too little Y dropoff (diff="
|
||||||
|
+ Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")");
|
||||||
|
}
|
||||||
|
// End AirFlight
|
||||||
|
|
||||||
|
// Start AirClimb
|
||||||
|
// TODO three hardcoded values here shouldn't be there, temp against false
|
||||||
|
// positive
|
||||||
|
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.lastMotionY > 0
|
||||||
|
&& movementManager.motionY > 0 && movementManager.airTicks == 2
|
||||||
|
&& Math.round(movementManager.lastMotionY * 1000) != 420
|
||||||
|
&& Math.round(movementManager.motionY * 1000) != 248
|
||||||
|
&& !(Math.round(movementManager.motionY * 1000) == 333
|
||||||
|
&& Math.round(movementManager.lastMotionY * 1000) != 333)
|
||||||
|
&& !AntiCheatReloaded.getManager().getBackend().justVelocity(player)
|
||||||
|
&& !player.hasPotionEffect(PotionEffectType.JUMP)
|
||||||
|
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||||
|
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
|
||||||
|
&& (!Utilities.isNearBed(distance.getTo())
|
||||||
|
|| (Utilities.isNearBed(distance.getTo()) && movementManager.motionY > 0.12675))
|
||||||
|
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25)
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"tried to climb air (mY=" + movementManager.motionY + ")");
|
||||||
|
|
||||||
|
// TODO hardcoded value against false again..
|
||||||
|
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.motionY > 0.42
|
||||||
|
&& movementManager.airTicks > 2 && !AntiCheatReloaded.getManager().getBackend().justVelocity(player)
|
||||||
|
&& !player.hasPotionEffect(PotionEffectType.JUMP)
|
||||||
|
&& !(Math.round(movementManager.motionY * 1000) == 425 && movementManager.airTicks == 11)
|
||||||
|
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||||
|
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
|
||||||
|
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
|
||||||
|
}
|
||||||
|
// End AirClimb
|
||||||
|
|
||||||
|
// Start GroundFlight
|
||||||
|
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "groundFlight") && movementManager.onGround
|
||||||
|
&& Utilities.cantStandAt(distance.getTo().getBlock().getRelative(BlockFace.DOWN))
|
||||||
|
&& Utilities.cantStandAt(distance.getFrom().getBlock().getRelative(BlockFace.DOWN))
|
||||||
|
&& Utilities.cantStandAt(distance.getTo().getBlock()) && movementManager.groundTicks > 2) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"faked ground to fly (mY=" + movementManager.motionY + ", gt=" + movementManager.groundTicks + ")");
|
||||||
|
}
|
||||||
|
// End GroundFlight
|
||||||
|
|
||||||
|
// Start Gravity
|
||||||
|
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "gravity") && !movementManager.onGround
|
||||||
|
&& movementManager.motionY < 0 && !backend.justVelocity(player)
|
||||||
|
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||||
|
.getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports"))
|
||||||
|
&& !Utilities.isInWeb(player) && movementManager.elytraEffectTicks <= 25) {
|
||||||
|
double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION;
|
||||||
|
double offset = Math.abs(gravitatedY - movementManager.motionY);
|
||||||
|
double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset");
|
||||||
|
if (offset > maxOffset && movementManager.airTicks > 2) {
|
||||||
|
int vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0) + 1;
|
||||||
|
GRAVITY_VIOLATIONS.put(player.getUniqueId(), vl);
|
||||||
|
int vlBeforeFlag = checksConfig.getInteger(CheckType.FLIGHT, "gravity", "vlBeforeFlag");
|
||||||
|
if (vl >= vlBeforeFlag)
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")");
|
||||||
|
} else {
|
||||||
|
GRAVITY_VIOLATIONS.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// End Gravity
|
||||||
|
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isMovingExempt(Player player) {
|
||||||
|
return isDoing(player, MOVING_EXEMPT, -1) || player.isInsideVehicle();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isDoing(Player player, Map<UUID, Long> map, double max) {
|
||||||
|
if (map.containsKey(player.getUniqueId())) {
|
||||||
|
if (max != -1) {
|
||||||
|
if (((System.currentTimeMillis() - map.get(player.getUniqueId())) / 1000) > max) {
|
||||||
|
map.remove(player.getUniqueId());
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Termination time has already been calculated
|
||||||
|
if (map.get(player.getUniqueId()) < System.currentTimeMillis()) {
|
||||||
|
map.remove(player.getUniqueId());
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,265 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.bukkit.Location;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
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.config.providers.Checks;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Rammelkast
|
||||||
|
* TODO soulsand speed
|
||||||
|
*/
|
||||||
|
public class SpeedCheck {
|
||||||
|
|
||||||
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
|
public static boolean isSpeedExempt(Player player, Backend backend) {
|
||||||
|
return backend.isMovingExempt(player) || backend.justVelocity(player) || VersionUtil.isFlying(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CheckResult checkXZSpeed(Player player, double x, double z, Location movingTowards) {
|
||||||
|
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||||
|
if (isSpeedExempt(player, backend) || player.getVehicle() != null || Utilities.isInWater(player))
|
||||||
|
return PASS;
|
||||||
|
|
||||||
|
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||||
|
.getMovementManager();
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
double distanceXZ = movementManager.distanceXZ;
|
||||||
|
boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid;
|
||||||
|
|
||||||
|
// AirSpeed
|
||||||
|
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airSpeed") && movementManager.airTicks > 1 && movementManager.elytraEffectTicks <= 0 && !Utilities.isNearClimbable(player)) {
|
||||||
|
double multiplier = 0.985D;
|
||||||
|
double predict = 0.36 * Math.pow(multiplier, movementManager.airTicks + 1);
|
||||||
|
double limit = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "baseLimit"); // Default 0.03125
|
||||||
|
// Adjust for ice
|
||||||
|
if (movementManager.iceInfluenceTicks > 0) {
|
||||||
|
double iceIncrement = 0.025 * Math.pow(1.038, movementManager.iceInfluenceTicks);
|
||||||
|
// Clamp to max value
|
||||||
|
if (iceIncrement > 0.18D)
|
||||||
|
iceIncrement = 0.18D;
|
||||||
|
if (boxedIn)
|
||||||
|
iceIncrement += 0.45D;
|
||||||
|
if (!Utilities.couldBeOnIce(movingTowards))
|
||||||
|
iceIncrement *= 2.5D;
|
||||||
|
predict += iceIncrement;
|
||||||
|
}
|
||||||
|
// Leniency when boxed in
|
||||||
|
if (boxedIn && movementManager.airTicks < 3)
|
||||||
|
limit *= 1.2D;
|
||||||
|
// Adjust for slime
|
||||||
|
if (movementManager.slimeInfluenceTicks > 0) {
|
||||||
|
double slimeIncrement = 0.022 * Math.pow(1.0375, movementManager.slimeInfluenceTicks);
|
||||||
|
// Clamp to max value
|
||||||
|
if (slimeIncrement > 0.12D)
|
||||||
|
slimeIncrement = 0.12D;
|
||||||
|
predict += slimeIncrement;
|
||||||
|
}
|
||||||
|
// Adjust for speed effects
|
||||||
|
if (player.hasPotionEffect(PotionEffectType.SPEED))
|
||||||
|
predict += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
|
||||||
|
// Adjust for jump boost effects
|
||||||
|
if (player.hasPotionEffect(PotionEffectType.JUMP))
|
||||||
|
predict += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.05D;
|
||||||
|
// Adjust for custom walking speed
|
||||||
|
double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "walkSpeedMultiplier"); // Default 1.4
|
||||||
|
predict += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1);
|
||||||
|
// Slabs sometimes allow for a slight boost after jump
|
||||||
|
if (movementManager.halfMovementHistoryCounter > 0)
|
||||||
|
predict *= 2.125D;
|
||||||
|
if (Utilities.couldBeOnHalfblock(movingTowards) && movementManager.halfMovementHistoryCounter == 0)
|
||||||
|
predict *= 1.25D;
|
||||||
|
// Boats sometimes give a false positive
|
||||||
|
if (Utilities.couldBeOnBoat(player, 0.5, true))
|
||||||
|
predict *= 1.25D;
|
||||||
|
// Strafing in air when nearing terminal velocity gives false positives
|
||||||
|
// This fixes the issue but gives hackers some leniency which means we need another check for this
|
||||||
|
double deltaMotionY = movementManager.motionY - movementManager.lastMotionY;
|
||||||
|
if (deltaMotionY < 0 && deltaMotionY >= -0.06)
|
||||||
|
predict *= 1.5D;
|
||||||
|
// Players can move faster in air with slow falling
|
||||||
|
if (VersionUtil.isSlowFalling(player))
|
||||||
|
predict *= 1.25D;
|
||||||
|
// Prevent NoSlow
|
||||||
|
// TODO better way for this
|
||||||
|
if (player.isBlocking() && movementManager.airTicks > 2)
|
||||||
|
predict *= 0.8D;
|
||||||
|
// Fixes false positive when coming out of water
|
||||||
|
if (movementManager.nearLiquidTicks >= 7 && movementManager.airTicks >= 14
|
||||||
|
&& movementManager.motionY < -0.18 && movementManager.motionY > -0.182)
|
||||||
|
predict += Math.abs(movementManager.motionY);
|
||||||
|
|
||||||
|
if (distanceXZ - predict > limit) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "moved too fast in air (speed=" + distanceXZ
|
||||||
|
+ ", limit=" + predict + ", block=" + player.isBlocking() + ", box=" + boxedIn + ", at=" + movementManager.airTicks + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AirAcceleration
|
||||||
|
// As of right now, this falses sometimes, dont know why
|
||||||
|
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airAcceleration") && movementManager.airTicks > 1
|
||||||
|
&& movementManager.iceInfluenceTicks <= 0 && movementManager.slimeInfluenceTicks <= 0
|
||||||
|
&& movementManager.elytraEffectTicks <= 0) {
|
||||||
|
double initialAcceleration = movementManager.acceleration;
|
||||||
|
double limit = checksConfig.getDouble(CheckType.SPEED, "airAcceleration", "baseLimit"); // Default 0.3725
|
||||||
|
// Slight increase when boxed in
|
||||||
|
if (boxedIn)
|
||||||
|
limit *= 1.05D;
|
||||||
|
// Adjust for speed effects
|
||||||
|
if (player.hasPotionEffect(PotionEffectType.SPEED))
|
||||||
|
limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.0225D;
|
||||||
|
// Adjust for slabs
|
||||||
|
if (movementManager.halfMovementHistoryCounter > 15)
|
||||||
|
limit *= 2.0D;
|
||||||
|
// Adjust for custom walking speed
|
||||||
|
double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airAcceleration", "walkSpeedMultiplier"); // Default 1.4
|
||||||
|
limit += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1);
|
||||||
|
// Boats sometimes give a false positive
|
||||||
|
if (Utilities.couldBeOnBoat(player))
|
||||||
|
limit *= 1.25D;
|
||||||
|
if (initialAcceleration > limit) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"exceeded acceleration limits (acceleration=" + initialAcceleration + ", max=" + limit + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// JumpBehaviour
|
||||||
|
// Works against YPorts and mini jumps
|
||||||
|
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "jumpBehaviour") && movementManager.touchedGroundThisTick
|
||||||
|
&& !boxedIn && movementManager.slimeInfluenceTicks <= 10) {
|
||||||
|
// This happens naturally
|
||||||
|
if (movementManager.airTicksBeforeGrounded == movementManager.groundTicks) {
|
||||||
|
double minimumDistXZ = checksConfig.getDouble(CheckType.SPEED, "jumpBehaviour", "minimumDistXZ"); // Default 0.42
|
||||||
|
if (distanceXZ >= minimumDistXZ) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "had unexpected jumping behaviour");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GroundSpeed
|
||||||
|
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "groundSpeed") && movementManager.groundTicks > 1) {
|
||||||
|
double initialLimit = checksConfig.getDouble(CheckType.SPEED, "groundSpeed", "initialLimit"); // Default 0.34
|
||||||
|
double limit = initialLimit - 0.0055 * Math.min(9, movementManager.groundTicks);
|
||||||
|
// Leniency when moving back on ground
|
||||||
|
if (movementManager.groundTicks < 5)
|
||||||
|
limit += 0.1D;
|
||||||
|
// Slab leniency
|
||||||
|
if (movementManager.halfMovementHistoryCounter > 8)
|
||||||
|
limit += 0.2D;
|
||||||
|
// LivingEntities can give players a small push boost
|
||||||
|
if (!movingTowards.getWorld().getNearbyEntities(movingTowards, 0.3, 0.3, 0.3).isEmpty())
|
||||||
|
limit += 0.2D;
|
||||||
|
// Leniency when boxed in
|
||||||
|
if (boxedIn)
|
||||||
|
limit *= 1.1D;
|
||||||
|
// Adjust for speed effects
|
||||||
|
if (player.hasPotionEffect(PotionEffectType.SPEED))
|
||||||
|
limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.06D;
|
||||||
|
if (movementManager.iceInfluenceTicks >= 50) {
|
||||||
|
// When moving off ice
|
||||||
|
if (!Utilities.couldBeOnIce(movingTowards))
|
||||||
|
limit *= 2.5D;
|
||||||
|
else {
|
||||||
|
// When boxed in and spamming space for boost
|
||||||
|
if (movementManager.topSolid && movementManager.bottomSolid)
|
||||||
|
limit *= 3.0D;
|
||||||
|
else
|
||||||
|
limit *= 1.25D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Increased speed when stepping on/off half blocks
|
||||||
|
if (Utilities.isNearBed(movingTowards) || Utilities.couldBeOnHalfblock(movingTowards)
|
||||||
|
|| Utilities.isNearBed(movingTowards.clone().add(0, -0.5, 0)))
|
||||||
|
limit *= 2.0D;
|
||||||
|
// Increased speed when stepping on/off boat
|
||||||
|
if (Utilities.couldBeOnBoat(player))
|
||||||
|
limit += 0.2D;
|
||||||
|
// Adjust for custom walk speed
|
||||||
|
limit += (player.getWalkSpeed() - 0.2) * 2.0D;
|
||||||
|
// Prevent NoSlow
|
||||||
|
if (player.isBlocking() && movementManager.groundTicks > 2)
|
||||||
|
limit *= 0.45D;
|
||||||
|
// Prevent NoWeb
|
||||||
|
// TODO config
|
||||||
|
if (Utilities.isInWeb(player))
|
||||||
|
limit *= 0.65D;
|
||||||
|
// Sneak speed check
|
||||||
|
// TODO config
|
||||||
|
if (movementManager.sneakingTicks > 1)
|
||||||
|
limit *= 0.68D;
|
||||||
|
|
||||||
|
if (distanceXZ - limit > 0) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"moved too fast on ground (speed=" + distanceXZ + ", limit=" + limit + ", blocking=" + player.isBlocking() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CheckResult checkVerticalSpeed(Player player, Distance distance) {
|
||||||
|
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||||
|
if (isSpeedExempt(player, backend) || player.getVehicle() != null || player.isSleeping()
|
||||||
|
|| VersionUtil.isRiptiding(player) || Utilities.isNearWater(player))
|
||||||
|
return PASS;
|
||||||
|
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||||
|
.getMovementManager();
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
if (!checksConfig.isSubcheckEnabled(CheckType.SPEED, "verticalSpeed"))
|
||||||
|
return PASS;
|
||||||
|
|
||||||
|
double maxMotionY = getMaxAcceptableMotionY(player, Utilities.isNearBed(distance.getTo()),
|
||||||
|
Utilities.couldBeOnBoat(player), Utilities.isClimbableBlock(distance.getFrom().getBlock())
|
||||||
|
|| Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)), movementManager.halfMovement, checksConfig);
|
||||||
|
// Fix false positive with soulsand boost
|
||||||
|
if (movementManager.nearLiquidTicks > 6)
|
||||||
|
maxMotionY *= 1.0525D;
|
||||||
|
if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"exceeded vertical speed limit (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")");
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double getMaxAcceptableMotionY(Player player, boolean nearBed, boolean couldBeOnBoat, boolean fromClimbable, boolean halfMovement, Checks checksConfig) {
|
||||||
|
// TODO config for these values
|
||||||
|
// TODO something funky vanilla stuff going on with 0.42, like 0.445.., check this..
|
||||||
|
double base = couldBeOnBoat ? 0.600000025 : (nearBed ? 0.5625 : ((halfMovement || VersionUtil.isBountifulUpdate()) ? 0.6 : 0.42));
|
||||||
|
if (fromClimbable)
|
||||||
|
base += checksConfig.getDouble(CheckType.SPEED, "verticalSpeed", "climbableCompensation"); // Default 0.04
|
||||||
|
|
||||||
|
if (player.hasPotionEffect(PotionEffectType.JUMP))
|
||||||
|
base += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.2D;
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Rammelkast
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class StrafeCheck {
|
||||||
|
|
||||||
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
|
public static CheckResult runCheck(Player player, double x, double z, Location from, Location to) {
|
||||||
|
if (!Utilities.cantStandAtExp(from) || !Utilities.cantStandAtExp(to) || Utilities.isNearWater(player)
|
||||||
|
|| Utilities.isNearClimbable(player))
|
||||||
|
return PASS;
|
||||||
|
|
||||||
|
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||||
|
.getMovementManager();
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
|
||||||
|
if (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig.getInteger(CheckType.STRAFE,
|
||||||
|
"accountForTeleports") || movementManager.elytraEffectTicks >= 20)
|
||||||
|
return PASS;
|
||||||
|
|
||||||
|
Vector oldAcceleration = new Vector(movementManager.lastDistanceX, 0, movementManager.lastDistanceZ);
|
||||||
|
Vector newAcceleration = new Vector(x, 0, z);
|
||||||
|
|
||||||
|
float angle = newAcceleration.angle(oldAcceleration);
|
||||||
|
double distance = newAcceleration.lengthSquared();
|
||||||
|
if (angle > checksConfig
|
||||||
|
.getDouble(CheckType.STRAFE, "maxAngleChange") && distance > checksConfig
|
||||||
|
.getDouble(CheckType.STRAFE, "minActivationDistance") && Utilities.cantStandFar(to.getBlock()))
|
||||||
|
return new CheckResult(Result.FAILED, "switched angle in air (angle=" + angle + ", dist=" + distance + ")");
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* 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.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
|
public class WaterWalkCheck {
|
||||||
|
|
||||||
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
|
public static CheckResult runCheck(Player player, double x, double y, double z) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
|
||||||
|
MovementManager movementManager = user.getMovementManager();
|
||||||
|
|
||||||
|
if (movementManager.distanceXZ <= 0 || player.getVehicle() != null || Utilities.isOnLilyPad(player)
|
||||||
|
|| VersionUtil.isRiptiding(player) || VersionUtil.isSwimming(player))
|
||||||
|
return PASS;
|
||||||
|
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
Block blockBeneath = player.getLocation().clone().subtract(0, 0.1, 0).getBlock();
|
||||||
|
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "walk") && blockBeneath.isLiquid()
|
||||||
|
&& Utilities.isSurroundedByWater(player)
|
||||||
|
&& ((movementManager.motionY == 0 && movementManager.lastMotionY == 0)
|
||||||
|
|| movementManager.motionY == Utilities.JUMP_MOTION_Y)
|
||||||
|
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "walk", "minimumDistXZ")
|
||||||
|
&& !movementManager.topSolid && !Utilities.couldBeOnBoat(player, 3, false))
|
||||||
|
return new CheckResult(Result.FAILED,
|
||||||
|
"tried to walk on water (xz=" + Utilities.roundDouble(movementManager.distanceXZ, 5) + ")");
|
||||||
|
|
||||||
|
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "hop") && blockBeneath.isLiquid()
|
||||||
|
&& Utilities.isSurroundedByWater(player) && movementManager.onGround
|
||||||
|
&& Math.abs(movementManager.motionY) < checksConfig.getDouble(CheckType.WATER_WALK, "hop", "maxMotionY")
|
||||||
|
&& !Utilities.couldBeOnBoat(player, 0.3, false))
|
||||||
|
return new CheckResult(Result.FAILED,
|
||||||
|
"tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")");
|
||||||
|
|
||||||
|
double minAbsMotionY = 0.12D;
|
||||||
|
if (player.hasPotionEffect(PotionEffectType.SPEED))
|
||||||
|
minAbsMotionY += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
|
||||||
|
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && blockBeneath.isLiquid()
|
||||||
|
&& Utilities.isSurroundedByWater(player)
|
||||||
|
&& Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY
|
||||||
|
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "lunge", "minimumDistXZ")
|
||||||
|
&& movementManager.lastMotionY > -0.25)
|
||||||
|
return new CheckResult(Result.FAILED, "tried to lunge in water (xz="
|
||||||
|
+ Utilities.roundDouble(movementManager.distanceXZ, 5) + ", absMotionY="
|
||||||
|
+ Utilities.roundDouble(Math.abs(movementManager.lastMotionY - movementManager.motionY), 5) + ")");
|
||||||
|
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* 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.config.providers.Checks;
|
||||||
|
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
|
||||||
|
public class BadPacketsCheck {
|
||||||
|
|
||||||
|
public static void runCheck(Player player, PacketEvent event) {
|
||||||
|
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||||
|
// Confirm if we should even check for BadPackets
|
||||||
|
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.BADPACKETS)
|
||||||
|
|| backend.isMovingExempt(player) || player.isDead())
|
||||||
|
return;
|
||||||
|
|
||||||
|
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
double tps = AntiCheatReloaded.getPlugin().getTPS();
|
||||||
|
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||||
|
.getMovementManager();
|
||||||
|
if (user.isLagging() || tps < checksConfig.getDouble(CheckType.MOREPACKETS, "minimumTps")
|
||||||
|
|| (System.currentTimeMillis() - movementManager.lastTeleport <= 100))
|
||||||
|
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 = checksConfig.getDouble(CheckType.BADPACKETS, "maxDistance");
|
||||||
|
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,104 @@
|
|||||||
|
/*
|
||||||
|
* 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.entity.Player;
|
||||||
|
|
||||||
|
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.config.providers.Checks;
|
||||||
|
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Rammelkast
|
||||||
|
*/
|
||||||
|
public class MorePacketsCheck {
|
||||||
|
|
||||||
|
public static final Map<UUID, Long> LAST_PACKET_TIME = new HashMap<UUID, Long>();
|
||||||
|
public static final Map<UUID, Long> EXEMPT_TIMINGS = new HashMap<UUID, Long>();
|
||||||
|
public static final Map<UUID, Double> PACKET_BALANCE = new HashMap<UUID, Double>();
|
||||||
|
|
||||||
|
public static void runCheck(Player player, PacketEvent event) {
|
||||||
|
// Confirm if we should even check for MorePackets
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
double tps = AntiCheatReloaded.getPlugin().getTPS();
|
||||||
|
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.MOREPACKETS)
|
||||||
|
|| tps < checksConfig.getDouble(CheckType.MOREPACKETS, "minimumTps")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
|
||||||
|
int maxPing = checksConfig.getInteger(CheckType.MOREPACKETS, "maxPing");
|
||||||
|
boolean disableForLagging = checksConfig.getBoolean(CheckType.MOREPACKETS, "disableForLagging");
|
||||||
|
if (AntiCheatReloaded.getManager().getBackend().isDoing(player, EXEMPT_TIMINGS, -1)
|
||||||
|
|| (maxPing > 0 && user.getPing() > maxPing) || (disableForLagging && user.isLagging())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long packetTimeNow = System.currentTimeMillis();
|
||||||
|
long lastPacketTime = LAST_PACKET_TIME.getOrDefault(uuid, packetTimeNow - 50L);
|
||||||
|
double packetBalance = PACKET_BALANCE.getOrDefault(uuid, 0D);
|
||||||
|
|
||||||
|
long rate = packetTimeNow - lastPacketTime;
|
||||||
|
packetBalance += 50;
|
||||||
|
packetBalance -= rate;
|
||||||
|
int triggerBalance = checksConfig.getInteger(CheckType.MOREPACKETS, "triggerBalance");
|
||||||
|
int minimumClamp = checksConfig.getInteger(CheckType.MOREPACKETS, "minimumClamp");
|
||||||
|
if (packetBalance >= triggerBalance) {
|
||||||
|
int ticks = (int) Math.round(packetBalance / 50);
|
||||||
|
packetBalance = -1 * (triggerBalance / 2);
|
||||||
|
flag(player, event, "overshot timer by " + ticks + " tick(s)");
|
||||||
|
} else if (packetBalance < -1 * minimumClamp) {
|
||||||
|
// Clamp minimum, 50ms=1tick of lag leniency
|
||||||
|
packetBalance = -1 * minimumClamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
LAST_PACKET_TIME.put(uuid, packetTimeNow);
|
||||||
|
PACKET_BALANCE.put(uuid, packetBalance);
|
||||||
|
}
|
||||||
|
|
||||||
|
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.MOREPACKETS);
|
||||||
|
player.teleport(player.getLocation());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void compensate(Player player) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
double packetBalance = PACKET_BALANCE.getOrDefault(uuid, 0D);
|
||||||
|
PACKET_BALANCE.put(uuid, packetBalance - checksConfig.getInteger(CheckType.MOREPACKETS, "teleportCompensation"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
* 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.player;
|
||||||
|
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
|
public class IllegalInteract {
|
||||||
|
|
||||||
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
|
public static CheckResult performCheck(Player player, Event event) {
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
if (event instanceof BlockPlaceEvent && checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "place")) {
|
||||||
|
return checkBlockPlace(player, (BlockPlaceEvent) event);
|
||||||
|
} else if (event instanceof BlockBreakEvent
|
||||||
|
&& checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "break")) {
|
||||||
|
return checkBlockBreak(player, (BlockBreakEvent) event);
|
||||||
|
} else if (event instanceof PlayerInteractEvent && checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "interact")) {
|
||||||
|
return checkInteract(player, (PlayerInteractEvent) event);
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CheckResult checkInteract(Player player, PlayerInteractEvent event) {
|
||||||
|
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
double distance = player.getEyeLocation().toVector().distance(event.getClickedBlock().getLocation().toVector());
|
||||||
|
double maxDistance = player.getGameMode() == GameMode.CREATIVE
|
||||||
|
? checksConfig.getDouble(CheckType.ILLEGAL_INTERACT, "interact", "creativeRange")
|
||||||
|
: checksConfig.getDouble(CheckType.ILLEGAL_INTERACT, "interact", "survivalRange");
|
||||||
|
|
||||||
|
maxDistance += user.isLagging() ? 0.12 : 0;
|
||||||
|
maxDistance += user.getPing()
|
||||||
|
* checksConfig.getInteger(CheckType.ILLEGAL_INTERACT, "interact", "pingCompensation");
|
||||||
|
maxDistance += player.getVelocity().length()
|
||||||
|
* checksConfig.getDouble(CheckType.ILLEGAL_INTERACT, "interact", "velocityMultiplier");
|
||||||
|
if (distance > maxDistance) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "tried to interact out of range (dist=" + distance + ", max=" + maxDistance + ")");
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CheckResult checkBlockBreak(Player player, BlockBreakEvent event) {
|
||||||
|
if (!isValidTarget(player, event.getBlock())) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "tried to break a block which was out of view");
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CheckResult checkBlockPlace(Player player, BlockPlaceEvent event) {
|
||||||
|
if (!isValidTarget(player, event.getBlock())) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, "tried to place a block out of their view");
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isValidTarget(Player player, Block block) {
|
||||||
|
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||||
|
double distance = player.getGameMode() == GameMode.CREATIVE ? 6.0
|
||||||
|
: player.getLocation().getDirection().getY() > 0.9 ? 6.0
|
||||||
|
: 5.5;
|
||||||
|
Block targetBlock = VersionUtil.getTargetBlock(player, ((int) Math.ceil(distance)));
|
||||||
|
if (targetBlock == null) {
|
||||||
|
// TODO better check here
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Utilities.isClimbableBlock(targetBlock)) {
|
||||||
|
if (targetBlock.getLocation().distance(player.getLocation()) <= distance) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetBlock.equals(block)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location eyeLocation = player.getEyeLocation();
|
||||||
|
double yawDifference = KillAuraCheck.calculateYawDifference(eyeLocation, block.getLocation());
|
||||||
|
double playerYaw = player.getEyeLocation().getYaw();
|
||||||
|
double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
|
||||||
|
if (Math.round(angleDifference) > checksConfig.getInteger(CheckType.ILLEGAL_INTERACT, "maxAngleDifference")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+20
-15
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,7 +17,7 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.command;
|
package com.rammelkast.anticheatreloaded.command;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@@ -24,17 +25,17 @@ import org.bukkit.Server;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
import net.gravitydevelopment.anticheat.manage.CheckManager;
|
import com.rammelkast.anticheatreloaded.manage.CheckManager;
|
||||||
import net.gravitydevelopment.anticheat.manage.UserManager;
|
import com.rammelkast.anticheatreloaded.manage.UserManager;
|
||||||
import net.gravitydevelopment.anticheat.util.Permission;
|
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||||
|
|
||||||
public class CommandBase {
|
public class CommandBase {
|
||||||
|
|
||||||
public static final Configuration CONFIG = AntiCheat.getManager().getConfiguration();
|
public static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration();
|
||||||
public static final UserManager USER_MANAGER = AntiCheat.getManager().getUserManager();
|
public static final UserManager USER_MANAGER = AntiCheatReloaded.getManager().getUserManager();
|
||||||
public static final CheckManager CHECK_MANAGER = AntiCheat.getManager().getCheckManager();
|
public static final CheckManager CHECK_MANAGER = AntiCheatReloaded.getManager().getCheckManager();
|
||||||
public static final ChatColor RED = ChatColor.RED;
|
public static final ChatColor RED = ChatColor.RED;
|
||||||
public static final ChatColor YELLOW = ChatColor.YELLOW;
|
public static final ChatColor YELLOW = ChatColor.YELLOW;
|
||||||
public static final ChatColor GREEN = ChatColor.GREEN;
|
public static final ChatColor GREEN = ChatColor.GREEN;
|
||||||
@@ -44,7 +45,7 @@ public class CommandBase {
|
|||||||
public static final ChatColor AQUA = ChatColor.AQUA;
|
public static final ChatColor AQUA = ChatColor.AQUA;
|
||||||
public static final Server SERVER = Bukkit.getServer();
|
public static final Server SERVER = Bukkit.getServer();
|
||||||
public static final String PERMISSIONS_ERROR = RED + "You don't have the permissions to use this command.";
|
public static final String PERMISSIONS_ERROR = RED + "You don't have the permissions to use this command.";
|
||||||
public static final String MENU_END = "-----------------------------------------------------";
|
public static final String MENU_END = GOLD + "-----------------------------------------------------";
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String command;
|
private final String command;
|
||||||
@@ -63,19 +64,23 @@ public class CommandBase {
|
|||||||
public void run(CommandSender cs, String[] args) {
|
public void run(CommandSender cs, String[] args) {
|
||||||
if (permission.get(cs)) {
|
if (permission.get(cs)) {
|
||||||
execute(cs, args);
|
execute(cs, args);
|
||||||
|
} else {
|
||||||
|
if (args == null) {
|
||||||
|
cs.sendMessage(GRAY + "Running " + GOLD + "" + "AntiCheatReloaded " + GRAY + "version " + AntiCheatReloaded.getVersion());
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(PERMISSIONS_ERROR + " (" + WHITE + permission.toString() + RED + ")");
|
cs.sendMessage(PERMISSIONS_ERROR + " (" + WHITE + permission.toString() + RED + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void execute(CommandSender cs, String[] args) {
|
protected void execute(CommandSender cs, String[] args) {
|
||||||
return; // Stub
|
return; // Stub
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendHelp(CommandSender cs) {
|
public void sendHelp(CommandSender cs) {
|
||||||
cs.sendMessage(RED + "== " + GRAY + getName() + RED + " ==");
|
cs.sendMessage(GOLD + "" + ChatColor.BOLD + "AntiCheatReloaded " + ChatColor.GRAY + "Help Menu");
|
||||||
cs.sendMessage(RED + "Usage: " + GRAY + (cs instanceof Player ? "/" : "") + getUsage());
|
cs.sendMessage(GOLD + "Usage: " + GRAY + (cs instanceof Player ? "/" : "") + getUsage());
|
||||||
cs.sendMessage(RED + "Permission: " + GRAY + getPermission().toString());
|
cs.sendMessage(GOLD + "Permission: " + GRAY + getPermission().toString());
|
||||||
for (String string : getHelp()) {
|
for (String string : getHelp()) {
|
||||||
cs.sendMessage(string);
|
cs.sendMessage(string);
|
||||||
}
|
}
|
||||||
+15
-14
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,7 +17,7 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.command;
|
package com.rammelkast.anticheatreloaded.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -25,14 +26,14 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.command.executors.CommandCheck;
|
import com.rammelkast.anticheatreloaded.command.executors.CommandChecks;
|
||||||
import net.gravitydevelopment.anticheat.command.executors.CommandDebug;
|
import com.rammelkast.anticheatreloaded.command.executors.CommandHelp;
|
||||||
import net.gravitydevelopment.anticheat.command.executors.CommandDeveloper;
|
import com.rammelkast.anticheatreloaded.command.executors.CommandLog;
|
||||||
import net.gravitydevelopment.anticheat.command.executors.CommandHelp;
|
import com.rammelkast.anticheatreloaded.command.executors.CommandMute;
|
||||||
import net.gravitydevelopment.anticheat.command.executors.CommandLog;
|
import com.rammelkast.anticheatreloaded.command.executors.CommandReload;
|
||||||
import net.gravitydevelopment.anticheat.command.executors.CommandReload;
|
import com.rammelkast.anticheatreloaded.command.executors.CommandReport;
|
||||||
import net.gravitydevelopment.anticheat.command.executors.CommandReport;
|
import com.rammelkast.anticheatreloaded.command.executors.CommandReset;
|
||||||
import net.gravitydevelopment.anticheat.command.executors.CommandReset;
|
import com.rammelkast.anticheatreloaded.command.executors.CommandVersion;
|
||||||
|
|
||||||
public class CommandHandler implements CommandExecutor {
|
public class CommandHandler implements CommandExecutor {
|
||||||
|
|
||||||
@@ -40,13 +41,13 @@ public class CommandHandler implements CommandExecutor {
|
|||||||
|
|
||||||
public CommandHandler() {
|
public CommandHandler() {
|
||||||
commands.add(new CommandHelp());
|
commands.add(new CommandHelp());
|
||||||
commands.add(new CommandCheck());
|
commands.add(new CommandChecks());
|
||||||
commands.add(new CommandDebug());
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* 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.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||||
|
import com.rammelkast.anticheatreloaded.manage.CheckManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||||
|
|
||||||
|
public class CommandChecks extends CommandBase {
|
||||||
|
|
||||||
|
private static final String NAME = "AntiCheatReloaded Checks Management";
|
||||||
|
private static final String COMMAND = "checks";
|
||||||
|
private static final String USAGE = "anticheat checks";
|
||||||
|
private static final Permission PERMISSION = Permission.SYSTEM_CHECK;
|
||||||
|
private static final String[] HELP = new String[2];
|
||||||
|
|
||||||
|
static {
|
||||||
|
HELP[0] = GRAY + "Use: " + AQUA + "/anticheat checks" + GRAY + " for a list of checks";
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
CheckManager checkManager = AntiCheatReloaded.getManager().getCheckManager();
|
||||||
|
builder.append(GRAY + "Checks: ");
|
||||||
|
for (int i = 0; i < CheckType.values().length; i++) {
|
||||||
|
CheckType type = CheckType.values()[i];
|
||||||
|
builder.append((checkManager.isActive(type) ? ChatColor.GREEN : ChatColor.RED) + type.getName());
|
||||||
|
if (i < CheckType.values().length - 1) {
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HELP[1] = builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandChecks() {
|
||||||
|
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute(CommandSender cs, String[] args) {
|
||||||
|
sendHelp(cs);
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
-13
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,12 +17,13 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.command.executors;
|
package com.rammelkast.anticheatreloaded.command.executors;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.command.CommandBase;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Permission;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||||
|
|
||||||
public class CommandHelp extends CommandBase {
|
public class CommandHelp extends CommandBase {
|
||||||
|
|
||||||
private static final String NAME = "AntiCheatReloaded Help";
|
private static final String NAME = "AntiCheatReloaded Help";
|
||||||
@@ -29,14 +31,14 @@ public class CommandHelp extends CommandBase {
|
|||||||
private static final String USAGE = "anticheat help";
|
private static final String USAGE = "anticheat help";
|
||||||
private static final Permission PERMISSION = Permission.SYSTEM_HELP;
|
private static final Permission PERMISSION = Permission.SYSTEM_HELP;
|
||||||
private static final String[] HELP = {
|
private static final String[] HELP = {
|
||||||
RED + "/anti " + GRAY + "help",
|
GOLD + "/acr " + GRAY + "help",
|
||||||
RED + "/anti " + GRAY + "reload",
|
GOLD + "/acr " + GRAY + "reload",
|
||||||
RED + "/anti " + GRAY + "update",
|
GOLD + "/acr " + GRAY + "version",
|
||||||
RED + "/anti " + GRAY + "debug " + WHITE + "<user>",
|
GOLD + "/acr " + GRAY + "mute",
|
||||||
RED + "/anti " + GRAY + "check " + WHITE + "[check] [on/off]",
|
GOLD + "/acr " + GRAY + "checks",
|
||||||
RED + "/anti " + GRAY + "log " + WHITE + "[file/console] [on/off]",
|
GOLD + "/acr " + GRAY + "log " + WHITE + "[file/console] [on/off]",
|
||||||
RED + "/anti " + GRAY + "report " + WHITE + "[group/user]",
|
GOLD + "/acr " + GRAY + "report " + WHITE + "[group/user]",
|
||||||
RED + "/anti " + GRAY + "reset " + WHITE + "[user]",
|
GOLD + "/acr " + GRAY + "reset " + WHITE + "[user]",
|
||||||
};
|
};
|
||||||
|
|
||||||
public CommandHelp() {
|
public CommandHelp() {
|
||||||
+9
-7
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,16 +17,17 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.command.executors;
|
package com.rammelkast.anticheatreloaded.command.executors;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.command.CommandBase;
|
|
||||||
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Permission;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||||
|
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 mute";
|
||||||
|
private static final Permission PERMISSION = Permission.SYSTEM_MUTE;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
-7
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,15 +17,17 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.command.executors;
|
package com.rammelkast.anticheatreloaded.command.executors;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.command.CommandBase;
|
import org.bukkit.ChatColor;
|
||||||
import net.gravitydevelopment.anticheat.util.Permission;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||||
|
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;
|
||||||
@@ -39,6 +42,6 @@ public class CommandReload extends CommandBase {
|
|||||||
@Override
|
@Override
|
||||||
protected void execute(CommandSender cs, String[] args) {
|
protected void execute(CommandSender cs, String[] args) {
|
||||||
CONFIG.load();
|
CONFIG.load();
|
||||||
cs.sendMessage(GREEN + "AntiCheat configuration reloaded.");
|
cs.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY + "The configuration was reloaded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+37
-39
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,32 +17,35 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.command.executors;
|
package com.rammelkast.anticheatreloaded.command.executors;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.command.CommandBase;
|
|
||||||
import net.gravitydevelopment.anticheat.manage.CheckManager;
|
|
||||||
import net.gravitydevelopment.anticheat.util.*;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Group;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
|
||||||
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;
|
||||||
private static final String[] HELP = {
|
private static final String[] HELP = {
|
||||||
GRAY + "Use: " + AQUA + "/anticheat report [group]" + GRAY + " to see all users in a given group",
|
GRAY + "Use: " + GOLD + "/anticheat report [group]" + GRAY + " to see all users in a given group",
|
||||||
GRAY + "Use: " + AQUA + "/anticheat report [user]" + GRAY + " to see a single user's report",
|
GRAY + "Use: " + GOLD + "/anticheat report [user]" + GRAY + " to see a single user's report",
|
||||||
GRAY + "Use: " + AQUA + "/anticheat report [user/group] [num]" + GRAY + " to see pages of a report",
|
GRAY + "Use: " + GOLD + "/anticheat report [user/group] [num]" + GRAY + " to see pages of a report",
|
||||||
};
|
};
|
||||||
|
|
||||||
public CommandReport() {
|
public CommandReport() {
|
||||||
@@ -69,7 +73,7 @@ public class CommandReport extends CommandBase {
|
|||||||
int numPlayers = USER_MANAGER.getUsersInGroup(g).size();
|
int numPlayers = USER_MANAGER.getUsersInGroup(g).size();
|
||||||
cs.sendMessage(g.getColor() + g.getName() + WHITE + ": " + numPlayers + " players");
|
cs.sendMessage(g.getColor() + g.getName() + WHITE + ": " + numPlayers + " players");
|
||||||
}
|
}
|
||||||
cs.sendMessage(GRAY + "Use " + AQUA + "/anticheat report [group]" + GRAY + " for a list of players in each group.");
|
cs.sendMessage(GRAY + "Use " + GOLD + "/anticheat report [group]" + GRAY + " for a list of players in each group.");
|
||||||
} else {
|
} else {
|
||||||
// Test groups
|
// Test groups
|
||||||
for (Group group : CONFIG.getGroups().getGroups()) {
|
for (Group group : CONFIG.getGroups().getGroups()) {
|
||||||
@@ -79,10 +83,16 @@ public class CommandReport extends CommandBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player targetPlayer = Bukkit.getPlayer(args[0]);
|
||||||
|
if (targetPlayer == null) {
|
||||||
|
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Test users
|
// Test users
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (player.getName().equalsIgnoreCase(args[0])) {
|
if (player.getUniqueId().equals(Bukkit.getPlayer(args[0]).getUniqueId())) {
|
||||||
User user = AntiCheat.getManager().getUserManager().getUser(player.getUniqueId());
|
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||||
playerReport(cs, user, page);
|
playerReport(cs, user, page);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -102,7 +112,7 @@ public class CommandReport extends CommandBase {
|
|||||||
String groupName = group == null ? "Low" : group.getName();
|
String groupName = group == null ? "Low" : group.getName();
|
||||||
int pages = (int) Math.ceil(((float) users.size()) / 7);
|
int pages = (int) Math.ceil(((float) users.size()) / 7);
|
||||||
if (page <= pages && page > 0) {
|
if (page <= pages && page > 0) {
|
||||||
cs.sendMessage("--------------------[" + GREEN + "REPORT[" + page + "/" + pages + "]" + WHITE + "]---------------------");
|
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD + "]----------------------");
|
||||||
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
||||||
for (int x = 0; x < 7; x++) {
|
for (int x = 0; x < 7; x++) {
|
||||||
int index = ((page - 1) * 6) + (x + ((page - 1) * 1));
|
int index = ((page - 1) * 6) + (x + ((page - 1) * 1));
|
||||||
@@ -114,7 +124,7 @@ public class CommandReport extends CommandBase {
|
|||||||
cs.sendMessage(MENU_END);
|
cs.sendMessage(MENU_END);
|
||||||
} else {
|
} else {
|
||||||
if (pages == 0) {
|
if (pages == 0) {
|
||||||
cs.sendMessage("--------------------[" + GREEN + "REPORT[1/1]" + WHITE + "]---------------------");
|
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
|
||||||
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
||||||
cs.sendMessage(GRAY + "There are no users in this group.");
|
cs.sendMessage(GRAY + "There are no users in this group.");
|
||||||
cs.sendMessage(MENU_END);
|
cs.sendMessage(MENU_END);
|
||||||
@@ -145,8 +155,9 @@ public class CommandReport extends CommandBase {
|
|||||||
groupString += " (" + user.getLevel() + ")";
|
groupString += " (" + user.getLevel() + ")";
|
||||||
|
|
||||||
if (page <= pages && page > 0) {
|
if (page <= pages && page > 0) {
|
||||||
cs.sendMessage("--------------------[" + GREEN + "REPORT[" + page + "/" + pages + "]" + WHITE + "]---------------------");
|
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD + "]----------------------");
|
||||||
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
||||||
|
cs.sendMessage(GRAY + "Ping: " + WHITE + user.getPing() + "ms " + (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"));
|
||||||
cs.sendMessage(GRAY + "Group: " + groupString);
|
cs.sendMessage(GRAY + "Group: " + groupString);
|
||||||
for (int x = 0; x < 6; x++) {
|
for (int x = 0; x < 6; x++) {
|
||||||
int index = ((page - 1) * 5) + (x + ((page - 1)));
|
int index = ((page - 1) * 5) + (x + ((page - 1)));
|
||||||
@@ -159,14 +170,15 @@ public class CommandReport extends CommandBase {
|
|||||||
} else if (use > 50) {
|
} else if (use > 50) {
|
||||||
color = RED;
|
color = RED;
|
||||||
}
|
}
|
||||||
cs.sendMessage(GRAY + CheckType.getName(type) + ": " + color + use);
|
cs.sendMessage(GRAY + type.getName() + ": " + color + use);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cs.sendMessage(MENU_END);
|
cs.sendMessage(MENU_END);
|
||||||
} else {
|
} else {
|
||||||
if (pages == 0 && page == 1) {
|
if (pages == 0 && page == 1) {
|
||||||
cs.sendMessage("--------------------[" + GREEN + "REPORT[1/1]" + WHITE + "]---------------------");
|
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
|
||||||
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
||||||
|
cs.sendMessage(GRAY + "Ping: " + WHITE + user.getPing() + "ms " + (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"));
|
||||||
cs.sendMessage(GRAY + "Group: " + groupString);
|
cs.sendMessage(GRAY + "Group: " + groupString);
|
||||||
cs.sendMessage(GRAY + "This user has not failed any checks.");
|
cs.sendMessage(GRAY + "This user has not failed any checks.");
|
||||||
cs.sendMessage(MENU_END);
|
cs.sendMessage(MENU_END);
|
||||||
@@ -174,19 +186,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 (AntiCheat.developerMode()) {
|
|
||||||
int permission = 0;
|
|
||||||
int check = 0;
|
|
||||||
for (Permission perm : Permission.values()) {
|
|
||||||
if (perm.get(user.getPlayer())) permission++;
|
|
||||||
}
|
|
||||||
CheckManager manager = AntiCheat.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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+13
-12
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,20 +17,19 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.command.executors;
|
package com.rammelkast.anticheatreloaded.command.executors;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.command.CommandBase;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Permission;
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
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;
|
||||||
|
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;
|
||||||
@@ -41,6 +41,7 @@ public class CommandReset extends CommandBase {
|
|||||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
protected void execute(CommandSender cs, String[] args) {
|
protected void execute(CommandSender cs, String[] args) {
|
||||||
User user;
|
User user;
|
||||||
@@ -53,8 +54,8 @@ public class CommandReset extends CommandBase {
|
|||||||
if (user != null) {
|
if (user != null) {
|
||||||
user.resetLevel();
|
user.resetLevel();
|
||||||
user.clearMessages();
|
user.clearMessages();
|
||||||
AntiCheat.getManager().getBackend().resetChatLevel(user);
|
AntiCheatReloaded.getManager().getBackend().resetChatLevel(user);
|
||||||
cs.sendMessage(args[0] + GREEN + " has been reset.");
|
cs.sendMessage(GOLD + args[0] + GRAY + " has been reset.");
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "Player: " +args[0] + " not found.");
|
cs.sendMessage(RED + "Player: " +args[0] + " not found.");
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.UpdateManager;
|
||||||
|
|
||||||
|
public class CommandVersion extends CommandBase {
|
||||||
|
|
||||||
|
private static final String NAME = "AntiCheatReloaded Version";
|
||||||
|
private static final String COMMAND = "version";
|
||||||
|
private static final String USAGE = "anticheat version";
|
||||||
|
private static final Permission PERMISSION = Permission.SYSTEM_VERSION;
|
||||||
|
private static final String[] HELP = {
|
||||||
|
GRAY + "Use: " + AQUA + "/anticheat version" + GRAY + " to get update information", };
|
||||||
|
|
||||||
|
public CommandVersion() {
|
||||||
|
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute(CommandSender cs, String[] args) {
|
||||||
|
UpdateManager updateManager = AntiCheatReloaded.getUpdateManager();
|
||||||
|
String status = RED + "behind";
|
||||||
|
if (updateManager.isLatest()) {
|
||||||
|
if (updateManager.isAhead()) {
|
||||||
|
status = GREEN + "ahead";
|
||||||
|
} else {
|
||||||
|
status = GOLD + "up-to-date";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cs.sendMessage(GOLD + "" + ChatColor.BOLD + "ACR " + GRAY + "You are running version " + GOLD
|
||||||
|
+ updateManager.getCurrentVersion() + GRAY + ". The latest version is " + GOLD
|
||||||
|
+ updateManager.getLatestVersion() + GRAY + ". This means you are " + status + GRAY + ".");
|
||||||
|
}
|
||||||
|
}
|
||||||
+55
-25
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,22 +17,37 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config;
|
package com.rammelkast.anticheatreloaded.config;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.config.files.Config;
|
|
||||||
import net.gravitydevelopment.anticheat.config.files.Enterprise;
|
|
||||||
import net.gravitydevelopment.anticheat.config.holders.mysql.*;
|
|
||||||
import net.gravitydevelopment.anticheat.config.holders.yaml.*;
|
|
||||||
import net.gravitydevelopment.anticheat.config.providers.*;
|
|
||||||
import net.gravitydevelopment.anticheat.manage.AntiCheatManager;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.files.Config;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.files.Enterprise;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.holders.mysql.MySQLGroupsHolder;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.holders.mysql.MySQLLangHolder;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.holders.mysql.MySQLLevelsHolder;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.holders.mysql.MySQLMagicHolder;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.holders.mysql.MySQLRulesHolder;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlChecksHolder;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlGroupsHolder;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlLangHolder;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlLevelsHolder;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlMagicHolder;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlRulesHolder;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Groups;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Lang;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Levels;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Rules;
|
||||||
|
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||||
|
|
||||||
public class Configuration {
|
public class Configuration {
|
||||||
|
|
||||||
private AntiCheatManager manager;
|
private AntiCheatManager manager;
|
||||||
@@ -43,11 +59,12 @@ public class Configuration {
|
|||||||
private Groups groups;
|
private Groups groups;
|
||||||
private Levels levels;
|
private Levels levels;
|
||||||
private Rules rules;
|
private Rules rules;
|
||||||
|
private Checks checks;
|
||||||
|
|
||||||
private ArrayList<ConfigurationFile> flatfiles;
|
private ArrayList<ConfigurationFile> flatfiles;
|
||||||
private ArrayList<ConfigurationTable> dbfiles;
|
private ArrayList<ConfigurationTable> dbfiles;
|
||||||
|
|
||||||
public Configuration(AntiCheat plugin, AntiCheatManager manager) {
|
public Configuration(AntiCheatReloaded plugin, AntiCheatManager manager) {
|
||||||
removeOldFiles();
|
removeOldFiles();
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
config = new Config(plugin, this);
|
config = new Config(plugin, this);
|
||||||
@@ -55,10 +72,13 @@ public class Configuration {
|
|||||||
// Now load others
|
// Now load others
|
||||||
enterprise = new Enterprise(plugin, this);
|
enterprise = new Enterprise(plugin, this);
|
||||||
|
|
||||||
flatfiles = new ArrayList<ConfigurationFile>() {{
|
flatfiles = new ArrayList<ConfigurationFile>() {
|
||||||
|
private static final long serialVersionUID = 4497798966909062852L;
|
||||||
|
{
|
||||||
add(config);
|
add(config);
|
||||||
add(enterprise);
|
add(enterprise);
|
||||||
}};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
dbfiles = new ArrayList<ConfigurationTable>();
|
dbfiles = new ArrayList<ConfigurationTable>();
|
||||||
|
|
||||||
@@ -79,6 +99,9 @@ public class Configuration {
|
|||||||
flatfiles.add((YamlRulesHolder) rules);
|
flatfiles.add((YamlRulesHolder) rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checks = new YamlChecksHolder(plugin, this);
|
||||||
|
flatfiles.add((YamlChecksHolder) checks);
|
||||||
|
|
||||||
InvocationHandler handler;
|
InvocationHandler handler;
|
||||||
if (config.enterprise.getValue() && enterprise.configMagic.getValue()) {
|
if (config.enterprise.getValue() && enterprise.configMagic.getValue()) {
|
||||||
handler = new MySQLMagicHolder(this);
|
handler = new MySQLMagicHolder(this);
|
||||||
@@ -128,12 +151,15 @@ public class Configuration {
|
|||||||
file.load();
|
file.load();
|
||||||
checkReload(file);
|
checkReload(file);
|
||||||
}
|
}
|
||||||
for (ConfigurationTable table : dbfiles) {
|
|
||||||
|
for (ConfigurationTable table : dbfiles)
|
||||||
table.load();
|
table.load();
|
||||||
}
|
|
||||||
if (manager.getBackend() != null) {
|
if (manager.getBackend() != null)
|
||||||
manager.getBackend().updateConfig(this);
|
manager.getBackend().updateConfig(this);
|
||||||
}
|
|
||||||
|
if (manager.getCheckManager() != null)
|
||||||
|
manager.getCheckManager().loadCheckIgnoreList(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkReload(ConfigurationFile file) {
|
private void checkReload(ConfigurationFile file) {
|
||||||
@@ -145,20 +171,20 @@ public class Configuration {
|
|||||||
|
|
||||||
private void removeOldFiles() {
|
private void removeOldFiles() {
|
||||||
ArrayList<String> removed = new ArrayList<String>();
|
ArrayList<String> removed = new ArrayList<String>();
|
||||||
File configFile = new File(AntiCheat.getPlugin().getDataFolder(), "config.yml");
|
File configFile = new File(AntiCheatReloaded.getPlugin().getDataFolder(), "config.yml");
|
||||||
if (configFile.exists() && YamlConfiguration.loadConfiguration(configFile).getString("System.Auto update") != null) {
|
if (configFile.exists() && YamlConfiguration.loadConfiguration(configFile).getString("System.Auto update") != null) {
|
||||||
configFile.renameTo(new File(AntiCheat.getPlugin().getDataFolder(), "config.old"));
|
configFile.renameTo(new File(AntiCheatReloaded.getPlugin().getDataFolder(), "config.old"));
|
||||||
removed.add("config.yml has been renamed to config.old and replaced with the new config.yml");
|
removed.add("config.yml has been renamed to config.old and replaced with the new config.yml");
|
||||||
}
|
}
|
||||||
File eventsFile = new File(AntiCheat.getPlugin().getDataFolder(), "events.yml");
|
File eventsFile = new File(AntiCheatReloaded.getPlugin().getDataFolder(), "events.yml");
|
||||||
if (eventsFile.exists()) {
|
if (eventsFile.exists()) {
|
||||||
eventsFile.renameTo(new File(AntiCheat.getPlugin().getDataFolder(), "events.old"));
|
eventsFile.renameTo(new File(AntiCheatReloaded.getPlugin().getDataFolder(), "events.old"));
|
||||||
removed.add("events.yml has been renamed to events.old and replaced with groups.yml and rules.yml");
|
removed.add("events.yml has been renamed to events.old and replaced with groups.yml and rules.yml");
|
||||||
}
|
}
|
||||||
if (removed.size() > 0) {
|
if (removed.size() > 0) {
|
||||||
AntiCheat.getPlugin().getLogger().info("You are upgrading from an old version of AntiCheat. Due to configuration changes, the following files have been modified:");
|
AntiCheatReloaded.getPlugin().getLogger().info("You are upgrading from an old version of AntiCheat. Due to configuration changes, the following files have been modified:");
|
||||||
for (String s : removed) {
|
for (String s : removed) {
|
||||||
AntiCheat.getPlugin().getLogger().info(s);
|
AntiCheatReloaded.getPlugin().getLogger().info(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,4 +216,8 @@ public class Configuration {
|
|||||||
public Magic getMagic() {
|
public Magic getMagic() {
|
||||||
return magic;
|
return magic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Checks getChecks() {
|
||||||
|
return checks;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+21
-10
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,15 +17,17 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config;
|
package com.rammelkast.anticheatreloaded.config;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.config.yaml.CommentedConfiguration;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.yaml.CommentedConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
public class ConfigurationFile {
|
public class ConfigurationFile {
|
||||||
|
|
||||||
@@ -35,21 +38,21 @@ public class ConfigurationFile {
|
|||||||
private FileConfiguration defaultConfigFile;
|
private FileConfiguration defaultConfigFile;
|
||||||
private Configuration config;
|
private Configuration config;
|
||||||
|
|
||||||
private AntiCheat plugin;
|
private AntiCheatReloaded plugin;
|
||||||
|
|
||||||
private boolean saveDefault;
|
private boolean saveDefault;
|
||||||
|
|
||||||
protected boolean needsReload;
|
protected boolean needsReload;
|
||||||
|
|
||||||
public ConfigurationFile(AntiCheat plugin, Configuration config, String fileName) {
|
public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName) {
|
||||||
this(plugin, config, fileName, true);
|
this(plugin, config, fileName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigurationFile(AntiCheat plugin, Configuration config, String fileName, boolean saveDefault) {
|
public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName, boolean saveDefault) {
|
||||||
this(plugin, config, fileName, saveDefault, new File(plugin.getDataFolder(), fileName));
|
this(plugin, config, fileName, saveDefault, new File(plugin.getDataFolder(), fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigurationFile(AntiCheat plugin, Configuration config, String fileName, boolean saveDefault, File rawFile) {
|
public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName, boolean saveDefault, File rawFile) {
|
||||||
// Can't change with user editing
|
// Can't change with user editing
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
@@ -58,7 +61,13 @@ public class ConfigurationFile {
|
|||||||
this.saveDefault = saveDefault;
|
this.saveDefault = saveDefault;
|
||||||
|
|
||||||
if (saveDefault) {
|
if (saveDefault) {
|
||||||
defaultConfigFile = YamlConfiguration.loadConfiguration(plugin.getResource(fileName));
|
InputStreamReader reader = new InputStreamReader(plugin.getResource(fileName));
|
||||||
|
defaultConfigFile = YamlConfiguration.loadConfiguration(reader);
|
||||||
|
try {
|
||||||
|
reader.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
@@ -161,6 +170,7 @@ public class ConfigurationFile {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public T getValue() {
|
public T getValue() {
|
||||||
return (T) value;
|
return (T) value;
|
||||||
}
|
}
|
||||||
@@ -171,6 +181,7 @@ public class ConfigurationFile {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public T getDefaultValue() {
|
public T getDefaultValue() {
|
||||||
return (T) getDefaultConfigFile().get(path);
|
return (T) getDefaultConfigFile().get(path);
|
||||||
}
|
}
|
||||||
+9
-6
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,12 +17,13 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config;
|
package com.rammelkast.anticheatreloaded.config;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.util.enterprise.Database;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.enterprise.Database;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -58,7 +60,7 @@ public class ConfigurationTable {
|
|||||||
|
|
||||||
public void reload() {
|
public void reload() {
|
||||||
// For after sql inserts have been made
|
// For after sql inserts have been made
|
||||||
Bukkit.getScheduler().runTask(AntiCheat.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
load();
|
load();
|
||||||
@@ -102,6 +104,7 @@ public class ConfigurationTable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public void convertToUUID(String colName) {
|
public void convertToUUID(String colName) {
|
||||||
String sqlSelect = "SELECT " + colName + " FROM " + getFullTable();
|
String sqlSelect = "SELECT " + colName + " FROM " + getFullTable();
|
||||||
String sqlUpdate = "UPDATE " + getFullTable() + " SET " + colName + " = ? WHERE " + colName + " = ?";
|
String sqlUpdate = "UPDATE " + getFullTable() + " SET " + colName + " = ? WHERE " + colName + " = ?";
|
||||||
+24
-13
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,26 +17,25 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config.files;
|
package com.rammelkast.anticheatreloaded.config.files;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||||
|
|
||||||
public class Config extends ConfigurationFile {
|
public class Config extends ConfigurationFile {
|
||||||
|
|
||||||
public static final String FILENAME = "config.yml";
|
public static final String FILENAME = "config.yml";
|
||||||
|
|
||||||
public ConfigValue<Boolean> logToConsole;
|
public ConfigValue<Boolean> logToConsole;
|
||||||
public ConfigValue<Boolean> autoUpdate;
|
|
||||||
public ConfigValue<Boolean> verboseStartup;
|
public ConfigValue<Boolean> verboseStartup;
|
||||||
public ConfigValue<Boolean> silentMode;
|
public ConfigValue<Boolean> silentMode;
|
||||||
public ConfigValue<Boolean> exemptOp;
|
public ConfigValue<Boolean> exemptOp;
|
||||||
|
|
||||||
public ConfigValue<Boolean> eventChains;
|
public ConfigValue<Boolean> eventChains;
|
||||||
public ConfigValue<Boolean> enterprise;
|
public ConfigValue<Boolean> enterprise;
|
||||||
|
public ConfigValue<Boolean> debugMode;
|
||||||
|
|
||||||
public ConfigValue<Boolean> blockChatSpamSpeed;
|
public ConfigValue<Boolean> blockChatSpamSpeed;
|
||||||
public ConfigValue<Boolean> blockCommandSpamSpeed;
|
public ConfigValue<Boolean> blockCommandSpamSpeed;
|
||||||
@@ -49,9 +49,11 @@ public class Config extends ConfigurationFile {
|
|||||||
public ConfigValue<Boolean> logToFile;
|
public ConfigValue<Boolean> logToFile;
|
||||||
|
|
||||||
public ConfigValue<List<String>> disabledWorlds;
|
public ConfigValue<List<String>> disabledWorlds;
|
||||||
public ConfigValue<List<String>> disabledChecks;
|
|
||||||
|
|
||||||
public Config(AntiCheat plugin, Configuration config) {
|
public ConfigValue<Integer> notifyEveryVl;
|
||||||
|
public ConfigValue<Integer> maxSetbackDistance;
|
||||||
|
|
||||||
|
public Config(AntiCheatReloaded plugin, Configuration config) {
|
||||||
super(plugin, config, FILENAME);
|
super(plugin, config, FILENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,12 +61,12 @@ public class Config extends ConfigurationFile {
|
|||||||
public void open() {
|
public void open() {
|
||||||
logToConsole = new ConfigValue<Boolean>("system.log-to-console");
|
logToConsole = new ConfigValue<Boolean>("system.log-to-console");
|
||||||
|
|
||||||
autoUpdate = new ConfigValue<Boolean>("system.auto-update");
|
|
||||||
verboseStartup = new ConfigValue<Boolean>("system.verbose-startup");
|
verboseStartup = new ConfigValue<Boolean>("system.verbose-startup");
|
||||||
silentMode = new ConfigValue<Boolean>("system.silent-mode");
|
silentMode = new ConfigValue<Boolean>("system.silent-mode");
|
||||||
exemptOp = new ConfigValue<Boolean>("system.exempt-op");
|
exemptOp = new ConfigValue<Boolean>("system.exempt-op");
|
||||||
eventChains = new ConfigValue<Boolean>("system.event-chains");
|
eventChains = new ConfigValue<Boolean>("system.event-chains");
|
||||||
enterprise = new ConfigValue<Boolean>("system.enterprise");
|
enterprise = new ConfigValue<Boolean>("system.enterprise");
|
||||||
|
debugMode = new ConfigValue<Boolean>("system.debug-mode");
|
||||||
|
|
||||||
blockChatSpamSpeed = new ConfigValue<Boolean>("spam.chat.block-speed");
|
blockChatSpamSpeed = new ConfigValue<Boolean>("spam.chat.block-speed");
|
||||||
blockChatSpamRepetition = new ConfigValue<Boolean>("spam.chat.block-repetition");
|
blockChatSpamRepetition = new ConfigValue<Boolean>("spam.chat.block-repetition");
|
||||||
@@ -79,6 +81,15 @@ public class Config extends ConfigurationFile {
|
|||||||
logToFile = new ConfigValue<Boolean>("system.log-to-file");
|
logToFile = new ConfigValue<Boolean>("system.log-to-file");
|
||||||
|
|
||||||
disabledWorlds = new ConfigValue<List<String>>("disable-in");
|
disabledWorlds = new ConfigValue<List<String>>("disable-in");
|
||||||
disabledChecks = new ConfigValue<List<String>>("disabled-checks");
|
|
||||||
|
notifyEveryVl = new ConfigValue<Integer>("system.notify-every-vl");
|
||||||
|
if (notifyEveryVl.getValue() < 1) {
|
||||||
|
notifyEveryVl.setValue(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
maxSetbackDistance = new ConfigValue<Integer>("system.max-setback-distance");
|
||||||
|
if (maxSetbackDistance.getValue() < 5) {
|
||||||
|
maxSetbackDistance.setValue(50);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-8
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,12 +17,12 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config.files;
|
package com.rammelkast.anticheatreloaded.config.files;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
|
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||||
import net.gravitydevelopment.anticheat.util.enterprise.Database;
|
import com.rammelkast.anticheatreloaded.util.enterprise.Database;
|
||||||
|
|
||||||
public class Enterprise extends ConfigurationFile {
|
public class Enterprise extends ConfigurationFile {
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ public class Enterprise extends ConfigurationFile {
|
|||||||
|
|
||||||
public Database database;
|
public Database database;
|
||||||
|
|
||||||
public Enterprise(AntiCheat plugin, Configuration config) {
|
public Enterprise(AntiCheatReloaded plugin, Configuration config) {
|
||||||
super(plugin, config, FILENAME);
|
super(plugin, config, FILENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
+9
-8
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,12 +17,7 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config.holders.mysql;
|
package com.rammelkast.anticheatreloaded.config.holders.mysql;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.config.ConfigurationTable;
|
|
||||||
import net.gravitydevelopment.anticheat.config.providers.Groups;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Group;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -29,6 +25,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Groups;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Group;
|
||||||
|
|
||||||
public class MySQLGroupsHolder extends ConfigurationTable implements Groups {
|
public class MySQLGroupsHolder extends ConfigurationTable implements Groups {
|
||||||
|
|
||||||
private static final String TABLE = "groups";
|
private static final String TABLE = "groups";
|
||||||
+19
-9
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,15 +17,18 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config.holders.mysql;
|
package com.rammelkast.anticheatreloaded.config.holders.mysql;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.config.ConfigurationTable;
|
|
||||||
import net.gravitydevelopment.anticheat.config.providers.Lang;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Lang;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@@ -49,7 +53,13 @@ public class MySQLLangHolder extends ConfigurationTable implements InvocationHan
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void open() {
|
public void open() {
|
||||||
defaults = YamlConfiguration.loadConfiguration(AntiCheat.getPlugin().getResource("lang.yml"));
|
InputStreamReader reader = new InputStreamReader(AntiCheatReloaded.getPlugin().getResource("lang.yml"));
|
||||||
|
defaults = YamlConfiguration.loadConfiguration(reader);
|
||||||
|
try {
|
||||||
|
reader.close();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
stringValues = new HashMap<String, String>();
|
stringValues = new HashMap<String, String>();
|
||||||
listValues = new HashMap<String, List<String>>();
|
listValues = new HashMap<String, List<String>>();
|
||||||
@@ -141,7 +151,7 @@ public class MySQLLangHolder extends ConfigurationTable implements InvocationHan
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AntiCheat.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
|
AntiCheatReloaded.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
|
||||||
return "Language error. See console for details.";
|
return "Language error. See console for details.";
|
||||||
}
|
}
|
||||||
|
|
||||||
+17
-15
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,15 +17,16 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config.holders.mysql;
|
package com.rammelkast.anticheatreloaded.config.holders.mysql;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.config.ConfigurationTable;
|
|
||||||
import net.gravitydevelopment.anticheat.config.providers.Levels;
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Levels;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -80,11 +82,11 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveLevelFromUser(final User user) {
|
public void saveLevelFromUser(final User user) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!user.isWaitingOnLevelSync()) {
|
if (!user.isWaitingOnLevelSync()) {
|
||||||
AntiCheat.debugLog("Saving level from " + user.getUUID() + ". Value: " + user.getLevel());
|
AntiCheatReloaded.debugLog("Saving level from " + user.getUUID() + ". Value: " + user.getLevel());
|
||||||
try {
|
try {
|
||||||
PreparedStatement statement = getConnection().prepareStatement(sqlSave);
|
PreparedStatement statement = getConnection().prepareStatement(sqlSave);
|
||||||
statement.setString(1, user.getUUID().toString());
|
statement.setString(1, user.getUUID().toString());
|
||||||
@@ -100,14 +102,14 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AntiCheat.getManager().getUserManager().remove(user);
|
AntiCheatReloaded.getManager().getUserManager().remove(user);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadLevelToUser(final User user) {
|
public void loadLevelToUser(final User user) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@@ -119,7 +121,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
|
|||||||
boolean has = false;
|
boolean has = false;
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
has = true;
|
has = true;
|
||||||
AntiCheat.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
|
AntiCheatReloaded.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
|
||||||
user.setLevel(set.getInt("level"));
|
user.setLevel(set.getInt("level"));
|
||||||
user.setLevelSyncTimestamp(set.getTimestamp("last_update"));
|
user.setLevelSyncTimestamp(set.getTimestamp("last_update"));
|
||||||
}
|
}
|
||||||
@@ -161,7 +163,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateLevelToUser(final User user) {
|
public void updateLevelToUser(final User user) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@@ -173,7 +175,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
|
|||||||
ResultSet set = statement.executeQuery();
|
ResultSet set = statement.executeQuery();
|
||||||
|
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
AntiCheat.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
|
AntiCheatReloaded.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
|
||||||
user.setLevel(set.getInt("level"));
|
user.setLevel(set.getInt("level"));
|
||||||
user.setLevelSyncTimestamp(set.getTimestamp("last_update"));
|
user.setLevelSyncTimestamp(set.getTimestamp("last_update"));
|
||||||
}
|
}
|
||||||
+20
-10
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,15 +17,18 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config.holders.mysql;
|
package com.rammelkast.anticheatreloaded.config.holders.mysql;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.config.ConfigurationTable;
|
|
||||||
import net.gravitydevelopment.anticheat.config.providers.Magic;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -46,7 +50,13 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void open() {
|
public void open() {
|
||||||
defaults = YamlConfiguration.loadConfiguration(AntiCheat.getPlugin().getResource("magic.yml"));
|
InputStreamReader reader = new InputStreamReader(AntiCheatReloaded.getPlugin().getResource("magic.yml"));
|
||||||
|
defaults = YamlConfiguration.loadConfiguration(reader);
|
||||||
|
try {
|
||||||
|
reader.close();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
ints = new HashMap<String, Integer>();
|
ints = new HashMap<String, Integer>();
|
||||||
doubles = new HashMap<String, Double>();
|
doubles = new HashMap<String, Double>();
|
||||||
@@ -93,7 +103,7 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
|
|||||||
} else if (set.getObject("value_double") != null) {
|
} else if (set.getObject("value_double") != null) {
|
||||||
doubles.put(key, set.getDouble("value_double"));
|
doubles.put(key, set.getDouble("value_double"));
|
||||||
} else {
|
} else {
|
||||||
AntiCheat.getPlugin().getLogger().severe("The magic value " + key + " loaded from the database did not have a value configured. Using the default value.");
|
AntiCheatReloaded.getPlugin().getLogger().severe("The magic value " + key + " loaded from the database did not have a value configured. Using the default value.");
|
||||||
for (int i=1;i<=methods.length;i++) {
|
for (int i=1;i<=methods.length;i++) {
|
||||||
String name = methods[i-1].getName();
|
String name = methods[i-1].getName();
|
||||||
if (name.equalsIgnoreCase(key)) {
|
if (name.equalsIgnoreCase(key)) {
|
||||||
@@ -140,7 +150,7 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AntiCheat.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
|
AntiCheatReloaded.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+11
-10
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,19 +17,19 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config.holders.mysql;
|
package com.rammelkast.anticheatreloaded.config.holders.mysql;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.config.ConfigurationTable;
|
|
||||||
import net.gravitydevelopment.anticheat.config.providers.Rules;
|
|
||||||
import net.gravitydevelopment.anticheat.util.rule.Rule;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Rules;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.rule.Rule;
|
||||||
|
|
||||||
public class MySQLRulesHolder extends ConfigurationTable implements Rules {
|
public class MySQLRulesHolder extends ConfigurationTable implements Rules {
|
||||||
|
|
||||||
private static final String TABLE = "rules";
|
private static final String TABLE = "rules";
|
||||||
@@ -65,7 +66,7 @@ public class MySQLRulesHolder extends ConfigurationTable implements Rules {
|
|||||||
if (rule != null) {
|
if (rule != null) {
|
||||||
this.rules.add(rule);
|
this.rules.add(rule);
|
||||||
} else {
|
} else {
|
||||||
AntiCheat.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from the database. Improper format used.");
|
AntiCheatReloaded.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from the database. Improper format used.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
+93
@@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* 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.config.holders.yaml;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||||
|
|
||||||
|
public class YamlChecksHolder extends ConfigurationFile implements Checks {
|
||||||
|
|
||||||
|
public static final String FILENAME = "checks.yml";
|
||||||
|
|
||||||
|
public YamlChecksHolder(AntiCheatReloaded plugin, Configuration config) {
|
||||||
|
super(plugin, config, FILENAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void open() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getBoolean(CheckType checkType, String subcheck, String name) {
|
||||||
|
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck)
|
||||||
|
.getBoolean(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSubcheckEnabled(CheckType checkType, String subcheck) {
|
||||||
|
return this.getBoolean(checkType, subcheck, "enabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getDouble(CheckType checkType, String subcheck, String name) {
|
||||||
|
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck)
|
||||||
|
.getDouble(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInteger(CheckType checkType, String subcheck, String name) {
|
||||||
|
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck)
|
||||||
|
.getInt(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getBoolean(CheckType checkType, String name) {
|
||||||
|
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getBoolean(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getDouble(CheckType checkType, String name) {
|
||||||
|
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getDouble(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInteger(CheckType checkType, String name) {
|
||||||
|
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getInt(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled(CheckType checkType) {
|
||||||
|
// If the root of a check has no enabled or disabled option, it has to be configured on a subcheck basis
|
||||||
|
if (!this.getConfigFile().isConfigurationSection(checkType.getName().toLowerCase())) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.RED
|
||||||
|
+ "Missing configuration settings for " + checkType.getName() + "!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).contains("enabled"))
|
||||||
|
return true;
|
||||||
|
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getBoolean("enabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
-10
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,16 +17,16 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config.holders.yaml;
|
package com.rammelkast.anticheatreloaded.config.holders.yaml;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
|
|
||||||
import net.gravitydevelopment.anticheat.config.providers.Groups;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Group;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Groups;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Group;
|
||||||
|
|
||||||
public class YamlGroupsHolder extends ConfigurationFile implements Groups {
|
public class YamlGroupsHolder extends ConfigurationFile implements Groups {
|
||||||
|
|
||||||
public static final String FILENAME = "groups.yml";
|
public static final String FILENAME = "groups.yml";
|
||||||
@@ -34,7 +35,7 @@ public class YamlGroupsHolder extends ConfigurationFile implements Groups {
|
|||||||
|
|
||||||
private int highestLevel;
|
private int highestLevel;
|
||||||
|
|
||||||
public YamlGroupsHolder(AntiCheat plugin, Configuration config) {
|
public YamlGroupsHolder(AntiCheatReloaded plugin, Configuration config) {
|
||||||
super(plugin, config, FILENAME);
|
super(plugin, config, FILENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
+10
-9
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,21 +17,21 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config.holders.yaml;
|
package com.rammelkast.anticheatreloaded.config.holders.yaml;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||||
|
|
||||||
public class YamlLangHolder extends ConfigurationFile implements InvocationHandler {
|
public class YamlLangHolder extends ConfigurationFile implements InvocationHandler {
|
||||||
|
|
||||||
public static final String FILENAME = "lang.yml";
|
public static final String FILENAME = "lang.yml";
|
||||||
|
|
||||||
public YamlLangHolder(AntiCheat plugin, Configuration config) {
|
public YamlLangHolder(AntiCheatReloaded plugin, Configuration config) {
|
||||||
super(plugin, config, FILENAME);
|
super(plugin, config, FILENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ public class YamlLangHolder extends ConfigurationFile implements InvocationHandl
|
|||||||
return value.getValue();
|
return value.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AntiCheat.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
|
AntiCheatReloaded.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
|
||||||
return "Language error. See console for details.";
|
return "Language error. See console for details.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+13
-12
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,22 +17,22 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config.holders.yaml;
|
package com.rammelkast.anticheatreloaded.config.holders.yaml;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
|
|
||||||
import net.gravitydevelopment.anticheat.config.providers.Levels;
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Levels;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
|
||||||
public class YamlLevelsHolder extends ConfigurationFile implements Levels {
|
public class YamlLevelsHolder extends ConfigurationFile implements Levels {
|
||||||
|
|
||||||
public static final String FILENAME = "data/levels.yml";
|
public static final String FILENAME = "data/levels.yml";
|
||||||
|
|
||||||
public YamlLevelsHolder(AntiCheat plugin, Configuration config) {
|
public YamlLevelsHolder(AntiCheatReloaded plugin, Configuration config) {
|
||||||
super(plugin, config, FILENAME, false);
|
super(plugin, config, FILENAME, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ public class YamlLevelsHolder extends ConfigurationFile implements Levels {
|
|||||||
|
|
||||||
private void saveLevelFromUser(User user, boolean remove) {
|
private void saveLevelFromUser(User user, boolean remove) {
|
||||||
saveLevel(user.getUUID(), user.getLevel());
|
saveLevel(user.getUUID(), user.getLevel());
|
||||||
if (remove) AntiCheat.getManager().getUserManager().remove(user);
|
if (remove) AntiCheatReloaded.getManager().getUserManager().remove(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -73,6 +74,6 @@ public class YamlLevelsHolder extends ConfigurationFile implements Levels {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void saveLevel(UUID uuid, int level) {
|
private void saveLevel(UUID uuid, int level) {
|
||||||
new ConfigValue<Integer>(uuid.toString(), false).setValue(new Integer(level));
|
new ConfigValue<Integer>(uuid.toString(), false).setValue(level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+10
-9
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,20 +17,20 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config.holders.yaml;
|
package com.rammelkast.anticheatreloaded.config.holders.yaml;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||||
|
|
||||||
public class YamlMagicHolder extends ConfigurationFile implements InvocationHandler {
|
public class YamlMagicHolder extends ConfigurationFile implements InvocationHandler {
|
||||||
|
|
||||||
public static final String FILENAME = "magic.yml";
|
public static final String FILENAME = "magic.yml";
|
||||||
|
|
||||||
public YamlMagicHolder(AntiCheat plugin, Configuration config) {
|
public YamlMagicHolder(AntiCheatReloaded plugin, Configuration config) {
|
||||||
super(plugin, config, FILENAME);
|
super(plugin, config, FILENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ public class YamlMagicHolder extends ConfigurationFile implements InvocationHand
|
|||||||
} else if (method.getReturnType().getSimpleName().equals("double")) {
|
} else if (method.getReturnType().getSimpleName().equals("double")) {
|
||||||
return new ConfigValue<Double>(key).getValue();
|
return new ConfigValue<Double>(key).getValue();
|
||||||
} else {
|
} else {
|
||||||
AntiCheat.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
|
AntiCheatReloaded.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+12
-11
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,24 +17,24 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config.holders.yaml;
|
package com.rammelkast.anticheatreloaded.config.holders.yaml;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
|
|
||||||
import net.gravitydevelopment.anticheat.config.providers.Rules;
|
|
||||||
import net.gravitydevelopment.anticheat.util.rule.Rule;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.providers.Rules;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.rule.Rule;
|
||||||
|
|
||||||
public class YamlRulesHolder extends ConfigurationFile implements Rules {
|
public class YamlRulesHolder extends ConfigurationFile implements Rules {
|
||||||
|
|
||||||
public static final String FILENAME = "rules.yml";
|
public static final String FILENAME = "rules.yml";
|
||||||
|
|
||||||
private List<Rule> rules;
|
private List<Rule> rules;
|
||||||
|
|
||||||
public YamlRulesHolder(AntiCheat plugin, Configuration config) {
|
public YamlRulesHolder(AntiCheatReloaded plugin, Configuration config) {
|
||||||
super(plugin, config, FILENAME);
|
super(plugin, config, FILENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ public class YamlRulesHolder extends ConfigurationFile implements Rules {
|
|||||||
if (rule != null) {
|
if (rule != null) {
|
||||||
this.rules.add(rule);
|
this.rules.add(rule);
|
||||||
} else {
|
} else {
|
||||||
AntiCheat.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from config. Improper format used.");
|
AntiCheatReloaded.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from config. Improper format used.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* 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.config.providers;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
|
||||||
|
public interface Checks {
|
||||||
|
|
||||||
|
public boolean getBoolean(CheckType checkType, String name);
|
||||||
|
|
||||||
|
public boolean getBoolean(CheckType checkType, String subcheck, String name);
|
||||||
|
|
||||||
|
public double getDouble(CheckType checkType, String name);
|
||||||
|
|
||||||
|
public double getDouble(CheckType checkType, String subcheck, String name);
|
||||||
|
|
||||||
|
public int getInteger(CheckType checkType, String name);
|
||||||
|
|
||||||
|
public int getInteger(CheckType checkType, String subcheck, String name);
|
||||||
|
|
||||||
|
public boolean isEnabled(CheckType checkType);
|
||||||
|
|
||||||
|
public boolean isSubcheckEnabled(CheckType checkType, String subcheck);
|
||||||
|
|
||||||
|
}
|
||||||
+6
-5
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,12 +17,12 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config.providers;
|
package com.rammelkast.anticheatreloaded.config.providers;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.util.Group;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Group;
|
||||||
|
|
||||||
public interface Groups {
|
public interface Groups {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+20
-1
@@ -1,4 +1,23 @@
|
|||||||
package net.gravitydevelopment.anticheat.config.providers;
|
/*
|
||||||
|
* 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.config.providers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
+6
-5
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,12 +17,12 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config.providers;
|
package com.rammelkast.anticheatreloaded.config.providers;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
|
||||||
public interface Levels {
|
public interface Levels {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* 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.config.providers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic number class. Modifications to values in magic.yml will be accepted here.
|
||||||
|
* <p/>
|
||||||
|
* Note that although each value is documented, changing it may have unintended side-effects. For instance, setting something to 0 that the plugin then uses as a dividend will result in an error. <br>
|
||||||
|
* Also realize that the smaller (more precise) a value is, the less you should change it; it's probably small for a reason. The larger a value is, the safer it is to make larger modifications to it.
|
||||||
|
* <p/>
|
||||||
|
* <b>How to read the value documentation:</b>
|
||||||
|
* <p/>
|
||||||
|
* First, you will see a description of the value. Then, you will see a type: <br>
|
||||||
|
* <b>Type SYSTEM:</b> This is a millisecond value used to compare past and future events with the current SYSTEM time. Remember, 1000 ms = 1 second. <br>
|
||||||
|
* <b>Type INTEGER:</b> This is a regular number. It's typically used as something trivial, such as how many times X event can occur. <br>
|
||||||
|
* <b>Type DOUBLE:</b> This is a number that has a decimal in it. It's typically used to evaluate speed or distance.
|
||||||
|
* <p/>
|
||||||
|
* After the type, you may see a recommendation labeled as 'Leniency'. This means 'In order to add leniency to this value, do X'<br>
|
||||||
|
* The suggestion for adding leniency will either be to INCREASE or DECREASE the variable. Doing what it suggests will cause the SYSTEM to not judge the people being checked so vigorously.<br>
|
||||||
|
* Some values may not have a leniency recommendation because they are internal numbers used for running checks. Values without these recommendations would be best left alone.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface Magic {
|
||||||
|
/**
|
||||||
|
* Time to exempt a player from moving because of entering/exiting a vehicle; Type=SYSTEM, Leniency=INCREASE.
|
||||||
|
*/
|
||||||
|
public int ENTERED_EXITED_TIME();
|
||||||
|
/**
|
||||||
|
* Time to exempt a player from moving because of teleporting; Type=SYSTEM, Leniency=INCREASE.
|
||||||
|
*/
|
||||||
|
public int TELEPORT_TIME();
|
||||||
|
/**
|
||||||
|
* Time to exempt a player from moving because of exiting fly mode; Type=SYSTEM, Leniency=INCREASE.
|
||||||
|
*/
|
||||||
|
public int EXIT_FLY_TIME();
|
||||||
|
/**
|
||||||
|
* Time to exempt a player from moving because of joining the server; Type=SYSTEM, Leniency=INCREASE.
|
||||||
|
*/
|
||||||
|
public int JOIN_TIME();
|
||||||
|
/**
|
||||||
|
* Time to exempt a player from moving because of taking damage; Type=SYSTEM, Leniency=INCREASE.
|
||||||
|
*/
|
||||||
|
public int DAMAGE_TIME();
|
||||||
|
/**
|
||||||
|
* Time to exempt a player from moving because of taking damage with knockback effects; Type=SYSTEM, Leniency=INCREASE.
|
||||||
|
*/
|
||||||
|
public int KNOCKBACK_DAMAGE_TIME();
|
||||||
|
/**
|
||||||
|
* Time to exempt a player from moving because of taking damage from an explosion; Type=SYSTEM, Leniency=INCREASE.
|
||||||
|
*/
|
||||||
|
public int EXPLOSION_DAMAGE_TIME();
|
||||||
|
/**
|
||||||
|
* Time used to schedule increasing a players velocity count - probably not touching this would be good; Type=INTEGER.
|
||||||
|
*/
|
||||||
|
public int VELOCITY_EXTENSION();
|
||||||
|
/**
|
||||||
|
* Time a player is considered to have a change in velocity; Type=SYSTEM, Leniency=INCREASE.
|
||||||
|
*/
|
||||||
|
public int VELOCITY_TIME();
|
||||||
|
/**
|
||||||
|
* Time to extend a player's velocity count by; Type=SYSTEM, Leniency=INCREASE.
|
||||||
|
*/
|
||||||
|
public int VELOCITY_PREVENT();
|
||||||
|
/**
|
||||||
|
* Maximum amount of velocity tracks; Type=INTEGER, Leniency=INCREASE.
|
||||||
|
*/
|
||||||
|
public int VELOCITY_MAXTIMES();
|
||||||
|
/**
|
||||||
|
* Minimum travel distance for move to be considered a teleport and subsequently be ignored; Type=INTEGER, Leniency=INCREASE.
|
||||||
|
*/
|
||||||
|
public int TELEPORT_MIN();
|
||||||
|
/**
|
||||||
|
* The change milliseconds between two keepalives before considering a player to be lagging; TYPE=INTEGER, Leniency=DECREASE
|
||||||
|
*/
|
||||||
|
public int LAG_DETERMINATION();
|
||||||
|
}
|
||||||
+6
-6
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,13 +17,12 @@
|
|||||||
* 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.config.providers;
|
||||||
package net.gravitydevelopment.anticheat.config.providers;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.util.rule.Rule;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.util.rule.Rule;
|
||||||
|
|
||||||
public interface Rules {
|
public interface Rules {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+8
-4
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,7 +17,7 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.config.yaml;
|
package com.rammelkast.anticheatreloaded.config.yaml;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -33,6 +34,7 @@ import java.io.File;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -188,7 +190,9 @@ public class CommentedConfiguration extends YamlConfiguration {
|
|||||||
CommentedConfiguration config = new CommentedConfiguration();
|
CommentedConfiguration config = new CommentedConfiguration();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
config.load(stream);
|
InputStreamReader reader = new InputStreamReader(stream);
|
||||||
|
config.load(reader);
|
||||||
|
reader.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
|
Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
|
||||||
} catch (InvalidConfigurationException ex) {
|
} catch (InvalidConfigurationException ex) {
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* 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.event;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.player.IllegalInteract;
|
||||||
|
|
||||||
|
public class BlockListener extends EventListener {
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
boolean noHack = true;
|
||||||
|
if (getCheckManager().willCheck(player, CheckType.FAST_PLACE)) {
|
||||||
|
CheckResult result = getBackend().checkFastPlace(player);
|
||||||
|
if (result.failed()) {
|
||||||
|
event.setCancelled(!silentMode());
|
||||||
|
log(result.getMessage(), player, CheckType.FAST_PLACE);
|
||||||
|
noHack = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) {
|
||||||
|
CheckResult result = IllegalInteract.performCheck(player, event);
|
||||||
|
if (result.failed()) {
|
||||||
|
event.setCancelled(!silentMode());
|
||||||
|
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT);
|
||||||
|
noHack = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (noHack) {
|
||||||
|
decrease(player);
|
||||||
|
getBackend().logBlockPlace(player);
|
||||||
|
}
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
boolean noHack = true;
|
||||||
|
CheckResult result;
|
||||||
|
if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) {
|
||||||
|
result = IllegalInteract.performCheck(player, event);
|
||||||
|
if (result.failed()) {
|
||||||
|
event.setCancelled(!silentMode());
|
||||||
|
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT);
|
||||||
|
noHack = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (noHack) {
|
||||||
|
decrease(player);
|
||||||
|
}
|
||||||
|
getBackend().logBlockBreak(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
+38
-41
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,10 +17,9 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.event;
|
package com.rammelkast.anticheatreloaded.event;
|
||||||
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Arrow;
|
|
||||||
import org.bukkit.entity.Creeper;
|
import org.bukkit.entity.Creeper;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
@@ -27,22 +27,33 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
import net.gravitydevelopment.anticheat.check.combat.CriticalsCheck;
|
import com.rammelkast.anticheatreloaded.check.combat.CriticalsCheck;
|
||||||
import net.gravitydevelopment.anticheat.check.combat.KillAuraCheck;
|
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||||
import net.gravitydevelopment.anticheat.check.combat.VelocityCheck;
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
import net.gravitydevelopment.anticheat.util.Distance;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
|
||||||
|
|
||||||
public class EntityListener extends EventListener {
|
public class EntityListener extends EventListener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityPotionEffect(EntityPotionEffectEvent event) {
|
||||||
|
if (!(event.getEntity() instanceof Player))
|
||||||
|
return;
|
||||||
|
if (event.getNewEffect() == null)
|
||||||
|
return;
|
||||||
|
if (!VersionUtil.isLevitationEffect(event.getNewEffect()))
|
||||||
|
return;
|
||||||
|
getBackend().logLevitating((Player) event.getEntity(), event.getNewEffect().getDuration());
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityShootBow(EntityShootBowEvent event) {
|
public void onEntityShootBow(EntityShootBowEvent event) {
|
||||||
if (event.getEntity() instanceof Player) {
|
if (event.getEntity() instanceof Player) {
|
||||||
@@ -58,7 +69,7 @@ public class EntityListener extends EventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -77,7 +88,7 @@ public class EntityListener extends EventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -96,7 +107,7 @@ public class EntityListener extends EventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@@ -105,30 +116,17 @@ public class EntityListener extends EventListener {
|
|||||||
if (event instanceof EntityDamageByEntityEvent) {
|
if (event instanceof EntityDamageByEntityEvent) {
|
||||||
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
||||||
if (e.getDamager() instanceof Player) {
|
if (e.getDamager() instanceof Player) {
|
||||||
if (getCheckManager().willCheck((Player)e.getDamager(), CheckType.KILLAURA)) {
|
|
||||||
KillAuraCheck.doDamageEvent(e, (Player)e.getDamager());
|
|
||||||
}
|
|
||||||
if (getCheckManager().willCheck((Player)e.getDamager(), CheckType.CRITICALS)) {
|
if (getCheckManager().willCheck((Player)e.getDamager(), CheckType.CRITICALS)) {
|
||||||
CriticalsCheck.doDamageEvent(e, (Player)e.getDamager());
|
CriticalsCheck.doDamageEvent(e, (Player)e.getDamager());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.getEntity() instanceof Player) {
|
if (event.getEntity() instanceof Player) {
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
VelocityCheck.runCheck(e, player);
|
|
||||||
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().getItemInHand().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)) {
|
|
||||||
Distance distance = new Distance(player.getLocation(), p.getLocation());
|
|
||||||
CheckResult result = getBackend().checkLongReachDamage(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
|
||||||
if (result.failed()) {
|
|
||||||
event.setCancelled(!silentMode());
|
|
||||||
log(result.getMessage(), p, CheckType.LONG_REACH);
|
|
||||||
noHack = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (e.getDamager() instanceof TNTPrimed || e.getDamager() instanceof Creeper) {
|
if (e.getDamager() instanceof TNTPrimed || e.getDamager() instanceof Creeper) {
|
||||||
getBackend().logDamage(player, 3);
|
getBackend().logDamage(player, 3);
|
||||||
@@ -137,30 +135,29 @@ public class EntityListener extends EventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e.getDamager() instanceof Player) {
|
if (e.getDamager() instanceof Player && event.getCause() == DamageCause.ENTITY_ATTACK) {
|
||||||
Player player = (Player) e.getDamager();
|
Player player = (Player) e.getDamager();
|
||||||
getBackend().logDamage(player, 1);
|
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
|
||||||
if (getCheckManager().willCheck(player, CheckType.AUTOTOOL)) {
|
CheckResult result = KillAuraCheck.checkAngle(player, event);
|
||||||
CheckResult result = getBackend().checkAutoTool(player);
|
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.AUTOTOOL);
|
log(result.getMessage(), player, CheckType.KILLAURA);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheck(player, CheckType.FORCEFIELD)) {
|
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
|
||||||
CheckResult result = getBackend().checkSprintDamage(player);
|
CheckResult result = KillAuraCheck.checkReach(player, event.getEntity());
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.FORCEFIELD);
|
log(result.getMessage(), player, CheckType.KILLAURA);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheck(player, CheckType.FORCEFIELD)) {
|
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
|
||||||
CheckResult result = getBackend().checkSight(player, e.getEntity());
|
CheckResult result = KillAuraCheck.checkPacketOrder(player, event.getEntity());
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.FORCEFIELD);
|
log(result.getMessage(), player, CheckType.KILLAURA);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,6 +167,6 @@ public class EntityListener extends EventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,181 @@
|
|||||||
|
/*
|
||||||
|
* 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.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.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.manage.CheckManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.manage.UserManager;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
|
||||||
|
public class EventListener implements Listener {
|
||||||
|
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
|
||||||
|
private static final Map<UUID, Integer> DECREASE_LIST = new HashMap<UUID, Integer>();
|
||||||
|
private static final CheckManager CHECK_MANAGER = AntiCheatReloaded.getManager().getCheckManager();
|
||||||
|
private static final Backend BACKEND = AntiCheatReloaded.getManager().getBackend();
|
||||||
|
private static final AntiCheatReloaded PLUGIN = AntiCheatReloaded.getManager().getPlugin();
|
||||||
|
private static final UserManager USER_MANAGER = AntiCheatReloaded.getManager().getUserManager();
|
||||||
|
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) {
|
||||||
|
User user = getUserManager().getUser(player.getUniqueId());
|
||||||
|
if (user == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
boolean debugMode = CONFIG.getConfig().debugMode.getValue();
|
||||||
|
int vlForType = type.getUses(player.getUniqueId()) + 1;
|
||||||
|
int notifyEveryVl = CONFIG.getConfig().notifyEveryVl.getValue();
|
||||||
|
if (message == null || message.equals("")) {
|
||||||
|
if (debugMode) {
|
||||||
|
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY + player.getName() + " failed "
|
||||||
|
+ type.getName();
|
||||||
|
} else {
|
||||||
|
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY + player.getName() + " failed "
|
||||||
|
+ type.getName() + ChatColor.GOLD + " (x" + vlForType + ")";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (debugMode) {
|
||||||
|
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY + player.getName() + " failed "
|
||||||
|
+ type.getName() + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message
|
||||||
|
+ ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms"
|
||||||
|
+ ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS());
|
||||||
|
} else {
|
||||||
|
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY + player.getName() + " failed "
|
||||||
|
+ type.getName() + ChatColor.GOLD + " (x" + vlForType + ")" + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms"
|
||||||
|
+ ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logCheat(type, user);
|
||||||
|
if (user.increaseLevel(type) && (!debugMode && vlForType % notifyEveryVl == 0)) {
|
||||||
|
AntiCheatReloaded.getManager().log(message);
|
||||||
|
}
|
||||||
|
removeDecrease(user);
|
||||||
|
|
||||||
|
if (debugMode) {
|
||||||
|
player.sendMessage(message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vlForType % notifyEveryVl == 0) {
|
||||||
|
AntiCheatReloaded.getPlugin().sendToStaff(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void logCheat(CheckType type, User user) {
|
||||||
|
USAGE_LIST.put(type, getCheats(type) + 1);
|
||||||
|
// Ignore plugins that are creating NPCs with no names (why the hell)
|
||||||
|
if (user != null && user.getUUID() != null) {
|
||||||
|
type.logUse(user);
|
||||||
|
if (CONFIG.getConfig().enterprise.getValue() && CONFIG.getEnterprise().loggingEnabled.getValue()) {
|
||||||
|
CONFIG.getEnterprise().database.logEvent(user, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetCheck(CheckType type) {
|
||||||
|
USAGE_LIST.put(type, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getCheats(CheckType type) {
|
||||||
|
int x = 0;
|
||||||
|
if (USAGE_LIST.get(type) != null) {
|
||||||
|
x = USAGE_LIST.get(type);
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void removeDecrease(User user) {
|
||||||
|
int x = 0;
|
||||||
|
// Ignore plugins that are creating NPCs with no names
|
||||||
|
if (user.getUUID() != null) {
|
||||||
|
if (DECREASE_LIST.get(user.getUUID()) != null) {
|
||||||
|
x = DECREASE_LIST.get(user.getUUID());
|
||||||
|
x -= 2;
|
||||||
|
if (x < 0) {
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DECREASE_LIST.put(user.getUUID(), x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void decrease(Player player) {
|
||||||
|
User user = getUserManager().getUser(player.getUniqueId());
|
||||||
|
// Ignore plugins that are creating NPCs with no names
|
||||||
|
if (user.getUUID() != null) {
|
||||||
|
int x = 0;
|
||||||
|
|
||||||
|
if (DECREASE_LIST.get(user.getUUID()) != null) {
|
||||||
|
x = DECREASE_LIST.get(user.getUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
x += 1;
|
||||||
|
DECREASE_LIST.put(user.getUUID(), x);
|
||||||
|
|
||||||
|
if (x >= 10) {
|
||||||
|
user.decreaseLevel();
|
||||||
|
DECREASE_LIST.put(user.getUUID(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CheckManager getCheckManager() {
|
||||||
|
return CHECK_MANAGER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AntiCheatManager getManager() {
|
||||||
|
return AntiCheatReloaded.getManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Backend getBackend() {
|
||||||
|
return BACKEND;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UserManager getUserManager() {
|
||||||
|
return USER_MANAGER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AntiCheatReloaded getPlugin() {
|
||||||
|
return PLUGIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Configuration getConfig() {
|
||||||
|
return CONFIG;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean silentMode() {
|
||||||
|
return CONFIG.getConfig().silentMode.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
-8
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,12 +17,8 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.event;
|
package com.rammelkast.anticheatreloaded.event;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
@@ -29,6 +26,11 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
|
|||||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
|
||||||
public class InventoryListener extends EventListener {
|
public class InventoryListener extends EventListener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -50,7 +52,7 @@ public class InventoryListener extends EventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -0,0 +1,521 @@
|
|||||||
|
/*
|
||||||
|
* 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.event;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Arrow;
|
||||||
|
import org.bukkit.entity.Boat;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||||
|
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||||
|
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||||
|
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
|
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||||
|
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||||
|
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
||||||
|
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||||
|
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.movement.FastLadderCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.movement.StrafeCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.player.IllegalInteract;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
|
public class PlayerListener extends EventListener {
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (getCheckManager().willCheck(player, CheckType.COMMAND_SPAM)
|
||||||
|
&& !Permission.getCommandExempt(player, event.getMessage().split(" ")[0])) {
|
||||||
|
CheckResult result = getBackend().checkCommandSpam(player, event.getMessage());
|
||||||
|
if (result.failed()) {
|
||||||
|
event.setCancelled(!silentMode());
|
||||||
|
if (!silentMode())
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', result.getMessage()));
|
||||||
|
getBackend().processCommandSpammer(player);
|
||||||
|
log(null, player, CheckType.COMMAND_SPAM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
|
||||||
|
if (!event.isFlying()) {
|
||||||
|
getBackend().logEnterExit(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||||
|
if (event.getNewGameMode() != GameMode.CREATIVE) {
|
||||||
|
getBackend().logEnterExit(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
||||||
|
if (event.getEntity().getShooter() instanceof Player) {
|
||||||
|
Player player = (Player) event.getEntity().getShooter();
|
||||||
|
|
||||||
|
if (event.getEntity() instanceof Arrow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCheckManager().willCheck(player, CheckType.FAST_PROJECTILE)) {
|
||||||
|
CheckResult result = getBackend().checkProjectile(player);
|
||||||
|
if (result.failed()) {
|
||||||
|
event.setCancelled(!silentMode());
|
||||||
|
log(result.getMessage(), player, CheckType.FAST_PROJECTILE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||||
|
if (event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.PLUGIN) {
|
||||||
|
getBackend().logTeleport(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerChangeWorlds(PlayerChangedWorldEvent event) {
|
||||||
|
getBackend().logTeleport(event.getPlayer());
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (event.isSneaking()) {
|
||||||
|
if (getCheckManager().willCheck(player, CheckType.SNEAK)) {
|
||||||
|
CheckResult result = getBackend().checkSneakToggle(player);
|
||||||
|
if (result.failed()) {
|
||||||
|
event.setCancelled(!silentMode());
|
||||||
|
log(result.getMessage(), player, CheckType.SNEAK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// getBackend().logToggleSneak(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerVelocity(PlayerVelocityEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (getCheckManager().willCheck(player, CheckType.FLIGHT)) {
|
||||||
|
if (getBackend().justVelocity(player) && getBackend().extendVelocityTime(player)) {
|
||||||
|
event.setCancelled(!silentMode());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getBackend().logVelocity(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Part of Velocity check
|
||||||
|
User user = AntiCheatReloaded.getManager().getUserManager()
|
||||||
|
.getUser(event.getPlayer().getUniqueId());
|
||||||
|
if (!user.getMovementManager().onGround)
|
||||||
|
return;
|
||||||
|
double motionY = event.getVelocity().getY();
|
||||||
|
user.getMovementManager().velocityExpectedMotionY = motionY;
|
||||||
|
// End part of Velocity check
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (getCheckManager().willCheck(player, CheckType.CHAT_SPAM)) {
|
||||||
|
CheckResult result = getBackend().checkChatSpam(player, event.getMessage());
|
||||||
|
if (result.failed()) {
|
||||||
|
event.setCancelled(!silentMode());
|
||||||
|
if (!result.getMessage().equals("") && !silentMode()) {
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', result.getMessage()));
|
||||||
|
}
|
||||||
|
getBackend().processChatSpammer(player);
|
||||||
|
AntiCheatReloaded.sendToMainThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
log(null, player, CheckType.CHAT_SPAM);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCheckManager().willCheck(player, CheckType.CHAT_UNICODE)) {
|
||||||
|
CheckResult result = getBackend().checkChatUnicode(player, event.getMessage());
|
||||||
|
if (result.failed()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', result.getMessage()));
|
||||||
|
AntiCheatReloaded.sendToMainThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
log(null, player, CheckType.CHAT_UNICODE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerKick(PlayerKickEvent event) {
|
||||||
|
getBackend().garbageClean(event.getPlayer());
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
getBackend().garbageClean(event.getPlayer());
|
||||||
|
|
||||||
|
User user = getUserManager().getUser(event.getPlayer().getUniqueId());
|
||||||
|
|
||||||
|
getConfig().getLevels().saveLevelFromUser(user);
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerVehicleCollide(VehicleEntityCollisionEvent event) {
|
||||||
|
if (!(event.getVehicle() instanceof Boat) || !(event.getEntity() instanceof Player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = (Player) event.getEntity();
|
||||||
|
getBackend().logBoatCollision(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerToggleSprint(PlayerToggleSprintEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (getCheckManager().willCheck(player, CheckType.SPRINT)) {
|
||||||
|
CheckResult result = getBackend().checkSprintHungry(event);
|
||||||
|
if (result.failed()) {
|
||||||
|
event.setCancelled(!silentMode());
|
||||||
|
log(result.getMessage(), player, CheckType.SPRINT);
|
||||||
|
} else {
|
||||||
|
decrease(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
PlayerInventory inv = player.getInventory();
|
||||||
|
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
|
ItemStack itemInHand;
|
||||||
|
if (VersionUtil.isBountifulUpdate()) {
|
||||||
|
itemInHand = VersionUtil.getItemInHand(player);
|
||||||
|
} else {
|
||||||
|
itemInHand = ((event.getHand() == EquipmentSlot.HAND) ? inv.getItemInMainHand()
|
||||||
|
: inv.getItemInOffHand());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemInHand.getType() == Material.BOW) {
|
||||||
|
getBackend().logBowWindUp(player);
|
||||||
|
} else if (Utilities.isFood(itemInHand.getType()) || Utilities.isFood(itemInHand.getType())) {
|
||||||
|
getBackend().logEatingStart(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!VersionUtil.isBountifulUpdate()) {
|
||||||
|
if (itemInHand.getType() == Material.FIREWORK_ROCKET) {
|
||||||
|
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
|
||||||
|
if (player.isGliding()) {
|
||||||
|
// TODO config max elytra height?
|
||||||
|
ElytraCheck.JUMP_Y_VALUE.put(player.getUniqueId(), 9999.99D);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Block block = event.getClickedBlock();
|
||||||
|
if (block != null
|
||||||
|
&& (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)) {
|
||||||
|
if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) {
|
||||||
|
CheckResult result = IllegalInteract.performCheck(player, event);
|
||||||
|
if (result.failed()) {
|
||||||
|
event.setCancelled(!silentMode());
|
||||||
|
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (getCheckManager().willCheck(player, CheckType.ITEM_SPAM)) {
|
||||||
|
CheckResult result = getBackend().checkFastDrop(player);
|
||||||
|
if (result.failed()) {
|
||||||
|
event.setCancelled(!silentMode());
|
||||||
|
log(result.getMessage(), player, CheckType.ITEM_SPAM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onPlayerEnterBed(PlayerBedEnterEvent event) {
|
||||||
|
if (event.getBed().getType().name().endsWith("BED"))
|
||||||
|
return;
|
||||||
|
getBackend().logEnterExit(event.getPlayer());
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onPlayerExitBed(PlayerBedLeaveEvent event) {
|
||||||
|
if (event.getBed().getType().name().endsWith("BED"))
|
||||||
|
return;
|
||||||
|
getBackend().logEnterExit(event.getPlayer());
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerAnimation(PlayerAnimationEvent event) {
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
getBackend().logJoin(player);
|
||||||
|
|
||||||
|
User user = new User(player.getUniqueId());
|
||||||
|
user.setIsWaitingOnLevelSync(true);
|
||||||
|
getConfig().getLevels().loadLevelToUser(user);
|
||||||
|
getUserManager().addUser(user);
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
|
||||||
|
if (player.hasPermission("anticheat.admin") && !AntiCheatReloaded.getUpdateManager().isLatest()) {
|
||||||
|
player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY
|
||||||
|
+ "Your version of AntiCheatReloaded is outdated! You can download "
|
||||||
|
+ AntiCheatReloaded.getUpdateManager().getLatestVersion()
|
||||||
|
+ " from the Spigot forums or DevBukkit.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
if (getCheckManager().checkInWorld(player) && !getCheckManager().isOpExempt(player)) {
|
||||||
|
final Location from = event.getFrom();
|
||||||
|
final Location to = event.getTo();
|
||||||
|
|
||||||
|
final Distance distance = new Distance(from, to);
|
||||||
|
final double y = distance.getYDifference();
|
||||||
|
getBackend().logAscension(player, from.getY(), to.getY());
|
||||||
|
|
||||||
|
final User user = getUserManager().getUser(player.getUniqueId());
|
||||||
|
user.setTo(to.getX(), to.getY(), to.getZ());
|
||||||
|
user.getMovementManager().handle(player, from, to, distance);
|
||||||
|
|
||||||
|
if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) {
|
||||||
|
CheckResult result = FlightCheck.runCheck(player, distance);
|
||||||
|
if (result.failed()) {
|
||||||
|
if (!silentMode()) {
|
||||||
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
|
}
|
||||||
|
log(result.getMessage(), player, CheckType.FLIGHT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getCheckManager().willCheckQuick(player, CheckType.ELYTRAFLY)) {
|
||||||
|
CheckResult result = ElytraCheck.runCheck(player, distance);
|
||||||
|
if (result.failed()) {
|
||||||
|
log(result.getMessage(), player, CheckType.ELYTRAFLY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getCheckManager().willCheckQuick(player, CheckType.VCLIP)
|
||||||
|
&& event.getFrom().getY() > event.getTo().getY()) {
|
||||||
|
CheckResult result = getBackend().checkVClip(player, new Distance(event.getFrom(), event.getTo()));
|
||||||
|
if (result.failed()) {
|
||||||
|
if (!silentMode()) {
|
||||||
|
int data = result.getData() > 3 ? 3 : result.getData();
|
||||||
|
Location newloc = new Location(player.getWorld(), event.getFrom().getX(),
|
||||||
|
event.getFrom().getY() + data, event.getFrom().getZ());
|
||||||
|
if (newloc.getBlock().getType() == Material.AIR) {
|
||||||
|
event.setTo(newloc);
|
||||||
|
} else {
|
||||||
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
|
}
|
||||||
|
player.damage(3);
|
||||||
|
}
|
||||||
|
log(result.getMessage(), player, CheckType.VCLIP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getCheckManager().willCheckQuick(player, CheckType.NOFALL)
|
||||||
|
&& getCheckManager().willCheck(player, CheckType.FLIGHT)
|
||||||
|
&& !Utilities.isClimbableBlock(player.getLocation().getBlock())
|
||||||
|
&& event.getFrom().getY() > event.getTo().getY()) {
|
||||||
|
CheckResult result = getBackend().checkNoFall(player, y);
|
||||||
|
if (result.failed()) {
|
||||||
|
if (!silentMode()) {
|
||||||
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
|
// TODO better handling of this
|
||||||
|
}
|
||||||
|
log(result.getMessage(), player, CheckType.NOFALL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getTo() != event.getFrom()) {
|
||||||
|
double x = distance.getXDifference();
|
||||||
|
double z = distance.getZDifference();
|
||||||
|
if (getCheckManager().willCheckQuick(player, CheckType.SPEED)
|
||||||
|
&& getCheckManager().willCheck(player, CheckType.FLIGHT)) {
|
||||||
|
if (event.getFrom().getY() < event.getTo().getY()) {
|
||||||
|
CheckResult result = SpeedCheck.checkVerticalSpeed(player, distance);
|
||||||
|
if (result.failed()) {
|
||||||
|
if (!silentMode()) {
|
||||||
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
|
}
|
||||||
|
log(result.getMessage(), player, CheckType.SPEED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CheckResult result = SpeedCheck.checkXZSpeed(player, x, z, event.getTo());
|
||||||
|
if (result.failed()) {
|
||||||
|
if (!silentMode()) {
|
||||||
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
|
}
|
||||||
|
log(result.getMessage(), player, CheckType.SPEED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) {
|
||||||
|
CheckResult result = WaterWalkCheck.runCheck(player, x, y, z);
|
||||||
|
if (result.failed()) {
|
||||||
|
if (!silentMode()) {
|
||||||
|
// TODO check this
|
||||||
|
player.teleport(player.getLocation().clone().subtract(0, 0.52, 0));
|
||||||
|
}
|
||||||
|
log(result.getMessage(), player, CheckType.WATER_WALK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getCheckManager().willCheckQuick(player, CheckType.SPIDER)) {
|
||||||
|
CheckResult result = getBackend().checkSpider(player, y);
|
||||||
|
if (result.failed()) {
|
||||||
|
if (!silentMode()) {
|
||||||
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
|
}
|
||||||
|
log(result.getMessage(), player, CheckType.SPIDER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getCheckManager().willCheckQuick(player, CheckType.FASTLADDER)) {
|
||||||
|
// Does not use y value created before because that value is absolute
|
||||||
|
CheckResult result = FastLadderCheck.runCheck(player,
|
||||||
|
event.getTo().getY() - event.getFrom().getY());
|
||||||
|
if (result.failed()) {
|
||||||
|
if (!silentMode()) {
|
||||||
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
|
}
|
||||||
|
log(result.getMessage(), player, CheckType.FASTLADDER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getCheckManager().willCheckQuick(player, CheckType.STRAFE)) {
|
||||||
|
CheckResult result = StrafeCheck.runCheck(player, x, z, event.getFrom(), event.getTo());
|
||||||
|
if (result.failed()) {
|
||||||
|
if (!silentMode()) {
|
||||||
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
|
}
|
||||||
|
log(result.getMessage(), player, CheckType.STRAFE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getCheckManager().willCheckQuick(player, CheckType.AIMBOT)) {
|
||||||
|
CheckResult result = AimbotCheck.runCheck(player, event);
|
||||||
|
if (result.failed()) {
|
||||||
|
log(result.getMessage(), player, CheckType.AIMBOT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getCheckManager().willCheckQuick(player, CheckType.VELOCITY)) {
|
||||||
|
CheckResult result = VelocityCheck.runCheck(player, distance);
|
||||||
|
if (result.failed()) {
|
||||||
|
log(result.getMessage(), player, CheckType.VELOCITY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void onRespawn(PlayerRespawnEvent event) {
|
||||||
|
getBackend().logTeleport(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* 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.event;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||||
|
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||||
|
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
|
public class VehicleListener extends EventListener {
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onVehicleEnter(VehicleEnterEvent event) {
|
||||||
|
if (event.getEntered() instanceof Player) {
|
||||||
|
getBackend().logEnterExit((Player) event.getEntered());
|
||||||
|
}
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onVehicleExit(VehicleExitEvent event) {
|
||||||
|
if (event.getExited() instanceof Player) {
|
||||||
|
getBackend().logEnterExit((Player) event.getExited());
|
||||||
|
}
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
||||||
|
if (VersionUtil.isBountifulUpdate()) {
|
||||||
|
if (event.getVehicle().getPassenger() != null) {
|
||||||
|
Entity entity = event.getVehicle().getPassenger();
|
||||||
|
if (entity instanceof Player) {
|
||||||
|
getBackend().logEnterExit((Player) entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!event.getVehicle().getPassengers().isEmpty()) {
|
||||||
|
for (Entity entity : event.getVehicle().getPassengers()) {
|
||||||
|
if (entity instanceof Player) {
|
||||||
|
getBackend().logEnterExit((Player) entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
-12
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -10,13 +11,12 @@
|
|||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.-
|
||||||
*
|
*
|
||||||
* 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.manage;
|
||||||
package net.gravitydevelopment.anticheat.manage;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@@ -25,16 +25,15 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.bukkit.plugin.RegisteredListener;
|
import org.bukkit.plugin.RegisteredListener;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
import net.gravitydevelopment.anticheat.check.Backend;
|
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The internal hub for all managers.
|
* The internal hub for all managers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AntiCheatManager {
|
public class AntiCheatManager {
|
||||||
private static AntiCheat plugin = null;
|
private static AntiCheatReloaded plugin = null;
|
||||||
private static Configuration configuration;
|
private static Configuration configuration;
|
||||||
private static UserManager userManager = null;
|
private static UserManager userManager = null;
|
||||||
private static CheckManager checkManager = null;
|
private static CheckManager checkManager = null;
|
||||||
@@ -43,7 +42,7 @@ public class AntiCheatManager {
|
|||||||
private static Map<String, RegisteredListener[]> eventchains = new ConcurrentHashMap<String, RegisteredListener[]>();
|
private static Map<String, RegisteredListener[]> eventchains = new ConcurrentHashMap<String, RegisteredListener[]>();
|
||||||
private static Map<String, Long> eventcache = new ConcurrentHashMap<String, Long>();
|
private static Map<String, Long> eventcache = new ConcurrentHashMap<String, Long>();
|
||||||
|
|
||||||
public AntiCheatManager(AntiCheat instance, Logger logger) {
|
public AntiCheatManager(AntiCheatReloaded instance, Logger logger) {
|
||||||
plugin = instance;
|
plugin = instance;
|
||||||
configuration = new Configuration(plugin, this);
|
configuration = new Configuration(plugin, this);
|
||||||
loggingManager = new LoggingManager(plugin, logger, configuration);
|
loggingManager = new LoggingManager(plugin, logger, configuration);
|
||||||
@@ -104,7 +103,7 @@ public class AntiCheatManager {
|
|||||||
return gen;
|
return gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AntiCheat getPlugin() {
|
public AntiCheatReloaded getPlugin() {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
+30
-22
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,18 +17,21 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.manage;
|
package com.rammelkast.anticheatreloaded.manage;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
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.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
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/>
|
||||||
@@ -38,19 +42,25 @@ public class CheckManager {
|
|||||||
private AntiCheatManager manager = null;
|
private AntiCheatManager manager = null;
|
||||||
private Configuration config;
|
private Configuration config;
|
||||||
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
|
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
|
||||||
private static Map<String, List<CheckType>> exemptList = new HashMap<String, List<CheckType>>();
|
private static Map<UUID, List<CheckType>> exemptList = new HashMap<UUID, List<CheckType>>();
|
||||||
|
|
||||||
public CheckManager(AntiCheatManager manager) {
|
public CheckManager(AntiCheatManager manager) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.config = manager.getConfiguration();
|
this.config = manager.getConfiguration();
|
||||||
|
this.loadCheckIgnoreList(this.config);
|
||||||
|
}
|
||||||
|
|
||||||
for (String string : config.getConfig().disabledChecks.getValue()) {
|
public void loadCheckIgnoreList(Configuration configuration) {
|
||||||
|
checkIgnoreList.clear();
|
||||||
for (CheckType type : CheckType.values()) {
|
for (CheckType type : CheckType.values()) {
|
||||||
if (type.toString().equalsIgnoreCase(string)) {
|
if (!configuration.getChecks().isEnabled(type)) {
|
||||||
checkIgnoreList.add(type);
|
checkIgnoreList.add(type);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!checkIgnoreList.isEmpty()) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY
|
||||||
|
+ checkIgnoreList.size() + " check(s) have been disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,11 +106,11 @@ public class CheckManager {
|
|||||||
*/
|
*/
|
||||||
public void exemptPlayer(Player player, CheckType type, String className) {
|
public void exemptPlayer(Player player, CheckType type, String className) {
|
||||||
if (!isExempt(player, type)) {
|
if (!isExempt(player, type)) {
|
||||||
if (!exemptList.containsKey(player.getName())) {
|
if (!exemptList.containsKey(player.getUniqueId())) {
|
||||||
exemptList.put(player.getName(), new ArrayList<CheckType>());
|
exemptList.put(player.getUniqueId(), new ArrayList<CheckType>());
|
||||||
}
|
}
|
||||||
manager.getLoggingManager().logFineInfo(player.getName() + " was exempted from the " + type.toString() + " check by " + className + ".");
|
manager.getLoggingManager().logFineInfo(player.getName() + " was exempted from the " + type.toString() + " check by " + className + ".");
|
||||||
exemptList.get(player.getName()).add(type);
|
exemptList.get(player.getUniqueId()).add(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +123,7 @@ public class CheckManager {
|
|||||||
public void unexemptPlayer(Player player, CheckType type, String className) {
|
public void unexemptPlayer(Player player, CheckType type, String className) {
|
||||||
if (isExempt(player, type)) {
|
if (isExempt(player, type)) {
|
||||||
manager.getLoggingManager().logFineInfo(player.getName() + " was unexempted from the " + type.toString() + " check by " + className + ".");
|
manager.getLoggingManager().logFineInfo(player.getName() + " was unexempted from the " + type.toString() + " check by " + className + ".");
|
||||||
exemptList.get(player.getName()).remove(type);
|
exemptList.get(player.getUniqueId()).remove(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +134,7 @@ public class CheckManager {
|
|||||||
* @param type The check
|
* @param type The check
|
||||||
*/
|
*/
|
||||||
public boolean isExempt(Player player, CheckType type) {
|
public boolean isExempt(Player player, CheckType type) {
|
||||||
return exemptList.containsKey(player.getName()) ? exemptList.get(player.getName()).contains(type) : false;
|
return exemptList.containsKey(player.getUniqueId()) ? exemptList.get(player.getUniqueId()).contains(type) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -173,9 +183,7 @@ public class CheckManager {
|
|||||||
&& !isExempt(player, type)
|
&& !isExempt(player, type)
|
||||||
&& !type.checkPermission(player)
|
&& !type.checkPermission(player)
|
||||||
&& !isOpExempt(player);
|
&& !isOpExempt(player);
|
||||||
AntiCheat.debugLog("Check " + type + (check ? " run " : " not run ") + "on " + player.getName());
|
if ((type == CheckType.FLIGHT || type == CheckType.SPEED) && VersionUtil.isFlying(player))
|
||||||
// TODO temp fix
|
|
||||||
if ((type == CheckType.FLY || type == CheckType.SPEED) && player.isFlying())
|
|
||||||
return false;
|
return false;
|
||||||
return check;
|
return check;
|
||||||
}
|
}
|
||||||
@@ -189,7 +197,7 @@ public class CheckManager {
|
|||||||
public boolean isOnline(Player player) {
|
public boolean isOnline(Player player) {
|
||||||
// Check if the player is on the user list, e.g. is not an NPC
|
// Check if the player is on the user list, e.g. is not an NPC
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
if (p.getName().equals(player.getName())) {
|
if (p.getUniqueId().equals(player.getUniqueId())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+13
-11
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,16 +17,17 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.manage;
|
package com.rammelkast.anticheatreloaded.manage;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.util.FileFormatter;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Permission;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.FileFormatter;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
@@ -41,8 +43,8 @@ public class LoggingManager {
|
|||||||
private static List<String> logs = new CopyOnWriteArrayList<String>();
|
private static List<String> logs = new CopyOnWriteArrayList<String>();
|
||||||
private final Configuration config;
|
private final Configuration config;
|
||||||
|
|
||||||
public LoggingManager(AntiCheat plugin, Logger logger, Configuration config) {
|
public LoggingManager(AntiCheatReloaded plugin, Logger logger, Configuration config) {
|
||||||
this.fileLogger = Logger.getLogger("net.gravitydevelopment.anticheat.AntiCheat");
|
this.fileLogger = Logger.getLogger("com.rammelkast.anticheatreloaded.AntiCheatReloaded");
|
||||||
this.config = config;
|
this.config = config;
|
||||||
try {
|
try {
|
||||||
File file = new File(plugin.getDataFolder(), "log");
|
File file = new File(plugin.getDataFolder(), "log");
|
||||||
@@ -69,12 +71,12 @@ public class LoggingManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void debugLog(String message) {
|
public void debugLog(String message) {
|
||||||
Bukkit.getConsoleSender().sendMessage("[AntiCheat] " + ChatColor.GRAY + message);
|
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + message);
|
||||||
logToLogs(message);
|
logToLogs(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logToConsole(String message) {
|
public void logToConsole(String message) {
|
||||||
Bukkit.getConsoleSender().sendMessage("[AntiCheat] " + ChatColor.RED + message);
|
Bukkit.getConsoleSender().sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logToFile(String message) {
|
public void logToFile(String message) {
|
||||||
+29
-48
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,29 +17,27 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.manage;
|
package com.rammelkast.anticheatreloaded.manage;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Group;
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.BanList.Type;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Group;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
|
||||||
public class UserManager {
|
public class UserManager {
|
||||||
private List<User> users = new ArrayList<User>();
|
private List<User> users = new ArrayList<User>();
|
||||||
private static AntiCheatManager manager;
|
private AntiCheatManager manager;
|
||||||
private static Configuration config;
|
private Configuration config;
|
||||||
private static final ChatColor GRAY = ChatColor.GRAY;
|
|
||||||
private static final ChatColor GOLD = ChatColor.GOLD;
|
|
||||||
private static final ChatColor RED = ChatColor.RED;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the user manager
|
* Initialize the user manager
|
||||||
*
|
*
|
||||||
@@ -159,15 +158,6 @@ public class UserManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the alert to use for a check being failed
|
|
||||||
*
|
|
||||||
* @return check fail alert message
|
|
||||||
*/
|
|
||||||
public List<String> getAlert() {
|
|
||||||
return config.getLang().ALERT();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fire an alert
|
* Fire an alert
|
||||||
*
|
*
|
||||||
@@ -176,19 +166,6 @@ public class UserManager {
|
|||||||
* @param type The CheckType that triggered the alert
|
* @param type The CheckType that triggered the alert
|
||||||
*/
|
*/
|
||||||
public void alert(User user, Group group, CheckType type) {
|
public void alert(User user, Group group, CheckType type) {
|
||||||
ArrayList<String> messageArray = new ArrayList<String>();
|
|
||||||
List<String> alert = getAlert();
|
|
||||||
for (int i = 0; i < alert.size(); i++) {
|
|
||||||
String message = alert.get(i);
|
|
||||||
if (!message.equals("")) {
|
|
||||||
message = message.replaceAll("&player", GOLD + user.getName() + GRAY);
|
|
||||||
message = message.replaceAll("&check", GOLD + CheckType.getName(type) + GRAY);
|
|
||||||
message = message.replaceAll("&group", group.getColor() + group.getName() + GRAY);
|
|
||||||
message = message.replaceAll("&level", "" + user.getLevel() + GRAY);
|
|
||||||
messageArray.add(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Utilities.alert(messageArray);
|
|
||||||
execute(user, group.getActions(), type);
|
execute(user, group.getActions(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,20 +192,24 @@ public class UserManager {
|
|||||||
*/
|
*/
|
||||||
public void execute(final User user, final List<String> actions, final CheckType type, final String kickReason, final List<String> warning, final String banReason) {
|
public void execute(final User user, final List<String> actions, final CheckType type, final String kickReason, final List<String> warning, final String banReason) {
|
||||||
// Execute synchronously for thread safety when called from AsyncPlayerChatEvent
|
// Execute synchronously for thread safety when called from AsyncPlayerChatEvent
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(AntiCheat.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(AntiCheatReloaded.getPlugin(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (user.getPlayer() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final String name = user.getName();
|
final String name = user.getName();
|
||||||
for (String event : actions) {
|
for (String event : actions) {
|
||||||
event = event.replaceAll("&player", name).replaceAll("&world", user.getPlayer().getWorld().getName()).replaceAll("&check", type.name());
|
event = event.replaceAll("%player%", name).replaceAll("%world%", user.getPlayer().getWorld().getName()).replaceAll("%check%", type.name());
|
||||||
|
|
||||||
if (event.startsWith("COMMAND[")) {
|
if (event.startsWith("COMMAND[")) {
|
||||||
for (String cmd : Utilities.getCommands(event)) {
|
for (String cmd : Utilities.getCommands(event)) {
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||||
}
|
}
|
||||||
} else if (event.equalsIgnoreCase("KICK")) {
|
} else if (event.equalsIgnoreCase("KICK")) {
|
||||||
user.getPlayer().kickPlayer(RED + kickReason);
|
user.getPlayer().kickPlayer(ChatColor.translateAlternateColorCodes('&', kickReason));
|
||||||
String msg = RED + config.getLang().KICK_BROADCAST().replaceAll("&player", name) + " (" + CheckType.getName(type) + ")";
|
AntiCheatReloaded.getPlugin().onPlayerKicked();
|
||||||
|
String msg = ChatColor.translateAlternateColorCodes('&', config.getLang().KICK_BROADCAST().replaceAll("%player%", name) + " (" + type.getName() + ")");
|
||||||
if (!msg.equals("")) {
|
if (!msg.equals("")) {
|
||||||
manager.log(msg);
|
manager.log(msg);
|
||||||
manager.playerLog(msg);
|
manager.playerLog(msg);
|
||||||
@@ -237,13 +218,13 @@ public class UserManager {
|
|||||||
List<String> message = warning;
|
List<String> message = warning;
|
||||||
for (String string : message) {
|
for (String string : message) {
|
||||||
if (!string.equals("")) {
|
if (!string.equals("")) {
|
||||||
user.getPlayer().sendMessage(RED + string);
|
user.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', string));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (event.equalsIgnoreCase("BAN")) {
|
} else if (event.equalsIgnoreCase("BAN")) {
|
||||||
user.getPlayer().setBanned(true);
|
Bukkit.getBanList(Type.NAME).addBan(user.getPlayer().getName(), ChatColor.translateAlternateColorCodes('&', banReason), null, null);
|
||||||
user.getPlayer().kickPlayer(RED + banReason);
|
user.getPlayer().kickPlayer(ChatColor.translateAlternateColorCodes('&', banReason));
|
||||||
String msg = RED + config.getLang().BAN_BROADCAST().replaceAll("&player", name) + " (" + CheckType.getName(type) + ")";
|
String msg = ChatColor.translateAlternateColorCodes('&', config.getLang().BAN_BROADCAST().replaceAll("%player%", name) + " (" + type.getName() + ")");
|
||||||
if (!msg.equals("")) {
|
if (!msg.equals("")) {
|
||||||
manager.log(msg);
|
manager.log(msg);
|
||||||
manager.playerLog(msg);
|
manager.playerLog(msg);
|
||||||
@@ -0,0 +1,766 @@
|
|||||||
|
/*
|
||||||
|
* 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.metrics;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
import org.bukkit.plugin.ServicePriority;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.google.gson.JsonPrimitive;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bStats collects some data for plugin authors.
|
||||||
|
* <p>
|
||||||
|
* Check out https://bStats.org/ to learn more about bStats!
|
||||||
|
*/
|
||||||
|
public class Metrics {
|
||||||
|
|
||||||
|
static {
|
||||||
|
// You can use the property to disable the check in your test environment
|
||||||
|
if (System.getProperty("bstats.relocatecheck") == null
|
||||||
|
|| !System.getProperty("bstats.relocatecheck").equals("false")) {
|
||||||
|
// Maven's Relocate is clever and changes strings, too. So we have to use this
|
||||||
|
// little "trick" ... :D
|
||||||
|
final String defaultPackage = new String(
|
||||||
|
new byte[] { 'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't' });
|
||||||
|
final String examplePackage = new String(
|
||||||
|
new byte[] { 'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e' });
|
||||||
|
// We want to make sure nobody just copy & pastes the example and use the wrong
|
||||||
|
// package names
|
||||||
|
if (Metrics.class.getPackage().getName().equals(defaultPackage)
|
||||||
|
|| Metrics.class.getPackage().getName().equals(examplePackage)) {
|
||||||
|
throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The version of this bStats class
|
||||||
|
public static final int B_STATS_VERSION = 1;
|
||||||
|
|
||||||
|
// The url to which the data is sent
|
||||||
|
private static final String URL = "https://bStats.org/submitData/bukkit";
|
||||||
|
|
||||||
|
// Is bStats enabled on this server?
|
||||||
|
private boolean enabled;
|
||||||
|
|
||||||
|
// Should failed requests be logged?
|
||||||
|
private static boolean logFailedRequests;
|
||||||
|
|
||||||
|
// Should the sent data be logged?
|
||||||
|
private static boolean logSentData;
|
||||||
|
|
||||||
|
// Should the response text be logged?
|
||||||
|
private static boolean logResponseStatusText;
|
||||||
|
|
||||||
|
// The uuid of the server
|
||||||
|
private static String serverUUID;
|
||||||
|
|
||||||
|
// The plugin
|
||||||
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
// The plugin id
|
||||||
|
private final int pluginId;
|
||||||
|
|
||||||
|
// A list with all custom charts
|
||||||
|
private final List<CustomChart> charts = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin which stats should be submitted.
|
||||||
|
* @param pluginId The id of the plugin. It can be found at
|
||||||
|
* <a href="https://bstats.org/what-is-my-plugin-id">What is my
|
||||||
|
* plugin id?</a>
|
||||||
|
*/
|
||||||
|
public Metrics(Plugin plugin, int pluginId) {
|
||||||
|
if (plugin == null) {
|
||||||
|
throw new IllegalArgumentException("Plugin cannot be null!");
|
||||||
|
}
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.pluginId = pluginId;
|
||||||
|
|
||||||
|
// Get the config file
|
||||||
|
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
|
||||||
|
File configFile = new File(bStatsFolder, "config.yml");
|
||||||
|
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||||
|
|
||||||
|
// Check if the config file exists
|
||||||
|
if (!config.isSet("serverUuid")) {
|
||||||
|
|
||||||
|
// Add default values
|
||||||
|
config.addDefault("enabled", true);
|
||||||
|
// Every server gets it's unique random id.
|
||||||
|
config.addDefault("serverUuid", UUID.randomUUID().toString());
|
||||||
|
// Should failed request be logged?
|
||||||
|
config.addDefault("logFailedRequests", false);
|
||||||
|
// Should the sent data be logged?
|
||||||
|
config.addDefault("logSentData", false);
|
||||||
|
// Should the response text be logged?
|
||||||
|
config.addDefault("logResponseStatusText", false);
|
||||||
|
|
||||||
|
// Inform the server owners about bStats
|
||||||
|
config.options().header(
|
||||||
|
"bStats collects some data for plugin authors like how many servers are using their plugins.\n"
|
||||||
|
+ "To honor their work, you should not disable it.\n"
|
||||||
|
+ "This has nearly no effect on the server performance!\n"
|
||||||
|
+ "Check out https://bStats.org/ to learn more :)")
|
||||||
|
.copyDefaults(true);
|
||||||
|
try {
|
||||||
|
config.save(configFile);
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load the data
|
||||||
|
enabled = config.getBoolean("enabled", true);
|
||||||
|
serverUUID = config.getString("serverUuid");
|
||||||
|
logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||||
|
logSentData = config.getBoolean("logSentData", false);
|
||||||
|
logResponseStatusText = config.getBoolean("logResponseStatusText", false);
|
||||||
|
|
||||||
|
if (enabled) {
|
||||||
|
boolean found = false;
|
||||||
|
// Search for all other bStats Metrics classes to see if we are the first one
|
||||||
|
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||||
|
try {
|
||||||
|
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||||
|
found = true; // We aren't the first
|
||||||
|
break;
|
||||||
|
} catch (NoSuchFieldException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Register our service
|
||||||
|
Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal);
|
||||||
|
if (!found) {
|
||||||
|
// We are the first!
|
||||||
|
startSubmitting();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if bStats is enabled.
|
||||||
|
*
|
||||||
|
* @return Whether bStats is enabled or not.
|
||||||
|
*/
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a custom chart.
|
||||||
|
*
|
||||||
|
* @param chart The chart to add.
|
||||||
|
*/
|
||||||
|
public void addCustomChart(CustomChart chart) {
|
||||||
|
if (chart == null) {
|
||||||
|
throw new IllegalArgumentException("Chart cannot be null!");
|
||||||
|
}
|
||||||
|
charts.add(chart);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the Scheduler which submits our data every 30 minutes.
|
||||||
|
*/
|
||||||
|
private void startSubmitting() {
|
||||||
|
final Timer timer = new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags
|
||||||
|
timer.scheduleAtFixedRate(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!plugin.isEnabled()) { // Plugin was disabled
|
||||||
|
timer.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Nevertheless we want our code to run in the Bukkit main thread, so we have to
|
||||||
|
// use the Bukkit scheduler
|
||||||
|
// Don't be afraid! The connection to the bStats server is still async, only the
|
||||||
|
// stats collection is sync ;)
|
||||||
|
Bukkit.getScheduler().runTask(plugin, () -> submitData());
|
||||||
|
}
|
||||||
|
}, 1000 * 60 * 5, 1000 * 60 * 30);
|
||||||
|
// Submit the data every 30 minutes, first time after 5 minutes to give other
|
||||||
|
// plugins enough time to start
|
||||||
|
// WARNING: Changing the frequency has no effect but your plugin WILL be
|
||||||
|
// blocked/deleted!
|
||||||
|
// WARNING: Just don't do it!
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the plugin specific data. This method is called using Reflection.
|
||||||
|
*
|
||||||
|
* @return The plugin specific data.
|
||||||
|
*/
|
||||||
|
public JsonObject getPluginData() {
|
||||||
|
JsonObject data = new JsonObject();
|
||||||
|
|
||||||
|
String pluginName = plugin.getDescription().getName();
|
||||||
|
String pluginVersion = plugin.getDescription().getVersion();
|
||||||
|
|
||||||
|
data.addProperty("pluginName", pluginName); // Append the name of the plugin
|
||||||
|
data.addProperty("id", pluginId); // Append the id of the plugin
|
||||||
|
data.addProperty("pluginVersion", pluginVersion); // Append the version of the plugin
|
||||||
|
JsonArray customCharts = new JsonArray();
|
||||||
|
for (CustomChart customChart : charts) {
|
||||||
|
// Add the data of the custom charts
|
||||||
|
JsonObject chart = customChart.getRequestJsonObject();
|
||||||
|
if (chart == null) { // If the chart is null, we skip it
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
customCharts.add(chart);
|
||||||
|
}
|
||||||
|
data.add("customCharts", customCharts);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the server specific data.
|
||||||
|
*
|
||||||
|
* @return The server specific data.
|
||||||
|
*/
|
||||||
|
private JsonObject getServerData() {
|
||||||
|
// Minecraft specific data
|
||||||
|
int playerAmount;
|
||||||
|
try {
|
||||||
|
// Around MC 1.8 the return type was changed to a collection from an array,
|
||||||
|
// This fixes java.lang.NoSuchMethodError:
|
||||||
|
// org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
|
||||||
|
Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
|
||||||
|
playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class)
|
||||||
|
? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
|
||||||
|
: ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
|
||||||
|
} catch (Exception e) {
|
||||||
|
playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
|
||||||
|
}
|
||||||
|
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
|
||||||
|
String bukkitVersion = Bukkit.getVersion();
|
||||||
|
String bukkitName = Bukkit.getName();
|
||||||
|
|
||||||
|
// OS/Java specific data
|
||||||
|
String javaVersion = System.getProperty("java.version");
|
||||||
|
String osName = System.getProperty("os.name");
|
||||||
|
String osArch = System.getProperty("os.arch");
|
||||||
|
String osVersion = System.getProperty("os.version");
|
||||||
|
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||||
|
|
||||||
|
JsonObject data = new JsonObject();
|
||||||
|
|
||||||
|
data.addProperty("serverUUID", serverUUID);
|
||||||
|
|
||||||
|
data.addProperty("playerAmount", playerAmount);
|
||||||
|
data.addProperty("onlineMode", onlineMode);
|
||||||
|
data.addProperty("bukkitVersion", bukkitVersion);
|
||||||
|
data.addProperty("bukkitName", bukkitName);
|
||||||
|
|
||||||
|
data.addProperty("javaVersion", javaVersion);
|
||||||
|
data.addProperty("osName", osName);
|
||||||
|
data.addProperty("osArch", osArch);
|
||||||
|
data.addProperty("osVersion", osVersion);
|
||||||
|
data.addProperty("coreCount", coreCount);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects the data and sends it afterwards.
|
||||||
|
*/
|
||||||
|
private void submitData() {
|
||||||
|
final JsonObject data = getServerData();
|
||||||
|
|
||||||
|
JsonArray pluginData = new JsonArray();
|
||||||
|
// Search for all other bStats Metrics classes to get their plugin data
|
||||||
|
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||||
|
try {
|
||||||
|
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||||
|
|
||||||
|
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
|
||||||
|
try {
|
||||||
|
Object plugin = provider.getService().getMethod("getPluginData").invoke(provider.getProvider());
|
||||||
|
if (plugin instanceof JsonObject) {
|
||||||
|
pluginData.add((JsonObject) plugin);
|
||||||
|
} else { // old bstats version compatibility
|
||||||
|
try {
|
||||||
|
Class<?> jsonObjectJsonSimple = Class.forName("org.json.simple.JSONObject");
|
||||||
|
if (plugin.getClass().isAssignableFrom(jsonObjectJsonSimple)) {
|
||||||
|
Method jsonStringGetter = jsonObjectJsonSimple.getDeclaredMethod("toJSONString");
|
||||||
|
jsonStringGetter.setAccessible(true);
|
||||||
|
String jsonString = (String) jsonStringGetter.invoke(plugin);
|
||||||
|
JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject();
|
||||||
|
pluginData.add(object);
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
// minecraft version 1.14+
|
||||||
|
if (logFailedRequests) {
|
||||||
|
this.plugin.getLogger().log(Level.SEVERE, "Encountered unexpected exception", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException
|
||||||
|
| InvocationTargetException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (NoSuchFieldException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.add("plugins", pluginData);
|
||||||
|
|
||||||
|
// Create a new thread for the connection to the bStats server
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
// Send the data
|
||||||
|
sendData(plugin, data);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Something went wrong! :(
|
||||||
|
if (logFailedRequests) {
|
||||||
|
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends the data to the bStats server.
|
||||||
|
*
|
||||||
|
* @param plugin Any plugin. It's just used to get a logger instance.
|
||||||
|
* @param data The data to send.
|
||||||
|
* @throws Exception If the request failed.
|
||||||
|
*/
|
||||||
|
private static void sendData(Plugin plugin, JsonObject data) throws Exception {
|
||||||
|
if (data == null) {
|
||||||
|
throw new IllegalArgumentException("Data cannot be null!");
|
||||||
|
}
|
||||||
|
if (Bukkit.isPrimaryThread()) {
|
||||||
|
throw new IllegalAccessException("This method must not be called from the main thread!");
|
||||||
|
}
|
||||||
|
if (logSentData) {
|
||||||
|
plugin.getLogger().info("Sending data to bStats: " + data);
|
||||||
|
}
|
||||||
|
HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
|
||||||
|
|
||||||
|
// Compress the data to save bandwidth
|
||||||
|
byte[] compressedData = compress(data.toString());
|
||||||
|
|
||||||
|
// Add headers
|
||||||
|
connection.setRequestMethod("POST");
|
||||||
|
connection.addRequestProperty("Accept", "application/json");
|
||||||
|
connection.addRequestProperty("Connection", "close");
|
||||||
|
connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip our request
|
||||||
|
connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
|
||||||
|
connection.setRequestProperty("Content-Type", "application/json"); // We send our data in JSON format
|
||||||
|
connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
|
||||||
|
|
||||||
|
// Send data
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) {
|
||||||
|
outputStream.write(compressedData);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
||||||
|
String line;
|
||||||
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
|
builder.append(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logResponseStatusText) {
|
||||||
|
plugin.getLogger().info("Sent data to bStats and received response: " + builder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gzips the given String.
|
||||||
|
*
|
||||||
|
* @param str The string to gzip.
|
||||||
|
* @return The gzipped String.
|
||||||
|
* @throws IOException If the compression failed.
|
||||||
|
*/
|
||||||
|
private static byte[] compress(final String str) throws IOException {
|
||||||
|
if (str == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
try (GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) {
|
||||||
|
gzip.write(str.getBytes(StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
return outputStream.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a custom chart.
|
||||||
|
*/
|
||||||
|
public static abstract class CustomChart {
|
||||||
|
|
||||||
|
// The id of the chart
|
||||||
|
final String chartId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param chartId The id of the chart.
|
||||||
|
*/
|
||||||
|
CustomChart(String chartId) {
|
||||||
|
if (chartId == null || chartId.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("ChartId cannot be null or empty!");
|
||||||
|
}
|
||||||
|
this.chartId = chartId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JsonObject getRequestJsonObject() {
|
||||||
|
JsonObject chart = new JsonObject();
|
||||||
|
chart.addProperty("chartId", chartId);
|
||||||
|
try {
|
||||||
|
JsonObject data = getChartData();
|
||||||
|
if (data == null) {
|
||||||
|
// If the data is null we don't send the chart.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
chart.add("data", data);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
if (logFailedRequests) {
|
||||||
|
Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return chart;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract JsonObject getChartData() throws Exception;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a custom simple pie.
|
||||||
|
*/
|
||||||
|
public static class SimplePie extends CustomChart {
|
||||||
|
|
||||||
|
private final Callable<String> callable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param chartId The id of the chart.
|
||||||
|
* @param callable The callable which is used to request the chart data.
|
||||||
|
*/
|
||||||
|
public SimplePie(String chartId, Callable<String> callable) {
|
||||||
|
super(chartId);
|
||||||
|
this.callable = callable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JsonObject getChartData() throws Exception {
|
||||||
|
JsonObject data = new JsonObject();
|
||||||
|
String value = callable.call();
|
||||||
|
if (value == null || value.isEmpty()) {
|
||||||
|
// Null = skip the chart
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
data.addProperty("value", value);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a custom advanced pie.
|
||||||
|
*/
|
||||||
|
public static class AdvancedPie extends CustomChart {
|
||||||
|
|
||||||
|
private final Callable<Map<String, Integer>> callable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param chartId The id of the chart.
|
||||||
|
* @param callable The callable which is used to request the chart data.
|
||||||
|
*/
|
||||||
|
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
|
||||||
|
super(chartId);
|
||||||
|
this.callable = callable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JsonObject getChartData() throws Exception {
|
||||||
|
JsonObject data = new JsonObject();
|
||||||
|
JsonObject values = new JsonObject();
|
||||||
|
Map<String, Integer> map = callable.call();
|
||||||
|
if (map == null || map.isEmpty()) {
|
||||||
|
// Null = skip the chart
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
boolean allSkipped = true;
|
||||||
|
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||||
|
if (entry.getValue() == 0) {
|
||||||
|
continue; // Skip this invalid
|
||||||
|
}
|
||||||
|
allSkipped = false;
|
||||||
|
values.addProperty(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
if (allSkipped) {
|
||||||
|
// Null = skip the chart
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
data.add("values", values);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a custom drilldown pie.
|
||||||
|
*/
|
||||||
|
public static class DrilldownPie extends CustomChart {
|
||||||
|
|
||||||
|
private final Callable<Map<String, Map<String, Integer>>> callable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param chartId The id of the chart.
|
||||||
|
* @param callable The callable which is used to request the chart data.
|
||||||
|
*/
|
||||||
|
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
|
||||||
|
super(chartId);
|
||||||
|
this.callable = callable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonObject getChartData() throws Exception {
|
||||||
|
JsonObject data = new JsonObject();
|
||||||
|
JsonObject values = new JsonObject();
|
||||||
|
Map<String, Map<String, Integer>> map = callable.call();
|
||||||
|
if (map == null || map.isEmpty()) {
|
||||||
|
// Null = skip the chart
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
boolean reallyAllSkipped = true;
|
||||||
|
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
|
||||||
|
JsonObject value = new JsonObject();
|
||||||
|
boolean allSkipped = true;
|
||||||
|
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
|
||||||
|
value.addProperty(valueEntry.getKey(), valueEntry.getValue());
|
||||||
|
allSkipped = false;
|
||||||
|
}
|
||||||
|
if (!allSkipped) {
|
||||||
|
reallyAllSkipped = false;
|
||||||
|
values.add(entryValues.getKey(), value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (reallyAllSkipped) {
|
||||||
|
// Null = skip the chart
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
data.add("values", values);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a custom single line chart.
|
||||||
|
*/
|
||||||
|
public static class SingleLineChart extends CustomChart {
|
||||||
|
|
||||||
|
private final Callable<Integer> callable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param chartId The id of the chart.
|
||||||
|
* @param callable The callable which is used to request the chart data.
|
||||||
|
*/
|
||||||
|
public SingleLineChart(String chartId, Callable<Integer> callable) {
|
||||||
|
super(chartId);
|
||||||
|
this.callable = callable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JsonObject getChartData() throws Exception {
|
||||||
|
JsonObject data = new JsonObject();
|
||||||
|
int value = callable.call();
|
||||||
|
if (value == 0) {
|
||||||
|
// Null = skip the chart
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
data.addProperty("value", value);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a custom multi line chart.
|
||||||
|
*/
|
||||||
|
public static class MultiLineChart extends CustomChart {
|
||||||
|
|
||||||
|
private final Callable<Map<String, Integer>> callable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param chartId The id of the chart.
|
||||||
|
* @param callable The callable which is used to request the chart data.
|
||||||
|
*/
|
||||||
|
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||||
|
super(chartId);
|
||||||
|
this.callable = callable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JsonObject getChartData() throws Exception {
|
||||||
|
JsonObject data = new JsonObject();
|
||||||
|
JsonObject values = new JsonObject();
|
||||||
|
Map<String, Integer> map = callable.call();
|
||||||
|
if (map == null || map.isEmpty()) {
|
||||||
|
// Null = skip the chart
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
boolean allSkipped = true;
|
||||||
|
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||||
|
if (entry.getValue() == 0) {
|
||||||
|
continue; // Skip this invalid
|
||||||
|
}
|
||||||
|
allSkipped = false;
|
||||||
|
values.addProperty(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
if (allSkipped) {
|
||||||
|
// Null = skip the chart
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
data.add("values", values);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a custom simple bar chart.
|
||||||
|
*/
|
||||||
|
public static class SimpleBarChart extends CustomChart {
|
||||||
|
|
||||||
|
private final Callable<Map<String, Integer>> callable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param chartId The id of the chart.
|
||||||
|
* @param callable The callable which is used to request the chart data.
|
||||||
|
*/
|
||||||
|
public SimpleBarChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||||
|
super(chartId);
|
||||||
|
this.callable = callable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JsonObject getChartData() throws Exception {
|
||||||
|
JsonObject data = new JsonObject();
|
||||||
|
JsonObject values = new JsonObject();
|
||||||
|
Map<String, Integer> map = callable.call();
|
||||||
|
if (map == null || map.isEmpty()) {
|
||||||
|
// Null = skip the chart
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||||
|
JsonArray categoryValues = new JsonArray();
|
||||||
|
categoryValues.add(new JsonPrimitive(entry.getValue()));
|
||||||
|
values.add(entry.getKey(), categoryValues);
|
||||||
|
}
|
||||||
|
data.add("values", values);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a custom advanced bar chart.
|
||||||
|
*/
|
||||||
|
public static class AdvancedBarChart extends CustomChart {
|
||||||
|
|
||||||
|
private final Callable<Map<String, int[]>> callable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param chartId The id of the chart.
|
||||||
|
* @param callable The callable which is used to request the chart data.
|
||||||
|
*/
|
||||||
|
public AdvancedBarChart(String chartId, Callable<Map<String, int[]>> callable) {
|
||||||
|
super(chartId);
|
||||||
|
this.callable = callable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JsonObject getChartData() throws Exception {
|
||||||
|
JsonObject data = new JsonObject();
|
||||||
|
JsonObject values = new JsonObject();
|
||||||
|
Map<String, int[]> map = callable.call();
|
||||||
|
if (map == null || map.isEmpty()) {
|
||||||
|
// Null = skip the chart
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
boolean allSkipped = true;
|
||||||
|
for (Map.Entry<String, int[]> entry : map.entrySet()) {
|
||||||
|
if (entry.getValue().length == 0) {
|
||||||
|
continue; // Skip this invalid
|
||||||
|
}
|
||||||
|
allSkipped = false;
|
||||||
|
JsonArray categoryValues = new JsonArray();
|
||||||
|
for (int categoryValue : entry.getValue()) {
|
||||||
|
categoryValues.add(new JsonPrimitive(categoryValue));
|
||||||
|
}
|
||||||
|
values.add(entry.getKey(), categoryValues);
|
||||||
|
}
|
||||||
|
if (allSkipped) {
|
||||||
|
// Null = skip the chart
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
data.add("values", values);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* 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.Location;
|
||||||
|
|
||||||
|
public class Distance {
|
||||||
|
private final double l1Y;
|
||||||
|
private final double l2Y;
|
||||||
|
|
||||||
|
private final double XDiff;
|
||||||
|
private final double YDiff;
|
||||||
|
private final double ZDiff;
|
||||||
|
|
||||||
|
private final Location from;
|
||||||
|
private final Location to;
|
||||||
|
|
||||||
|
public Distance(Location from, Location to) {
|
||||||
|
l1Y = to.getY();
|
||||||
|
l2Y = from.getY();
|
||||||
|
|
||||||
|
XDiff = Math.abs(to.getX() - from.getX());
|
||||||
|
ZDiff = Math.abs(to.getZ() - from.getZ());
|
||||||
|
YDiff = Math.abs(l1Y - l2Y);
|
||||||
|
|
||||||
|
this.from = from;
|
||||||
|
this.to = to;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Distance() {
|
||||||
|
l1Y = 0;
|
||||||
|
l2Y = 0;
|
||||||
|
|
||||||
|
XDiff = 0;
|
||||||
|
ZDiff = 0;
|
||||||
|
YDiff = 0;
|
||||||
|
|
||||||
|
this.from = null;
|
||||||
|
this.to = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double fromY() {
|
||||||
|
return l2Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double toY() {
|
||||||
|
return l1Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getXDifference() {
|
||||||
|
return XDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getZDifference() {
|
||||||
|
return ZDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getYDifference() {
|
||||||
|
return YDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getFrom() {
|
||||||
|
return this.from;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getTo() {
|
||||||
|
return this.to;
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-4
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,7 +17,7 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.util;
|
package com.rammelkast.anticheatreloaded.util;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@@ -30,7 +31,9 @@ public class FileFormatter extends Formatter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String format(LogRecord record) {
|
public String format(LogRecord record) {
|
||||||
StringBuilder output = new StringBuilder().append("[").append(record.getLevel()).append('|').append(FORMAT.format(new Date(record.getMillis()))).append("]: ").append(record.getMessage()).append(' ').append(LINE_SEP);
|
StringBuilder output = new StringBuilder().append("[").append(record.getLevel()).append('|')
|
||||||
|
.append(FORMAT.format(new Date(record.getMillis()))).append("]: ").append(record.getMessage())
|
||||||
|
.append(' ').append(LINE_SEP);
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* 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.ChatColor;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Group {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private int level;
|
||||||
|
private ChatColor color = ChatColor.RED;
|
||||||
|
private List<String> actions = new ArrayList<String>();
|
||||||
|
|
||||||
|
public Group(String name, int level, String color, List<String> actions) {
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
this.level = level;
|
||||||
|
this.actions = actions;
|
||||||
|
|
||||||
|
ChatColor c = ChatColor.valueOf(color);
|
||||||
|
if (c == null) {
|
||||||
|
AntiCheatReloaded.getPlugin().getLogger()
|
||||||
|
.warning("Event '" + name + "' was initialized with the color '" + color + "' which is invalid.");
|
||||||
|
AntiCheatReloaded.getPlugin().getLogger().warning(
|
||||||
|
"This event will not run properly. See http://jd.bukkit.org/apidocs/org/bukkit/ChatColor.html#enum_constant_summary for a list of valid colors");
|
||||||
|
} else {
|
||||||
|
this.color = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevel() {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getActions() {
|
||||||
|
return actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Group load(String string) {
|
||||||
|
try {
|
||||||
|
if (string.split(" : ").length == 4) {
|
||||||
|
String name = string.split(" : ")[0];
|
||||||
|
int level = Integer.parseInt(string.split(" : ")[1]);
|
||||||
|
String color = string.split(" : ")[2];
|
||||||
|
List<String> actions = Arrays.asList(string.split(" : ")[3].split(","));
|
||||||
|
return new Group(name, level, color, actions);
|
||||||
|
} else {
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
AntiCheatReloaded.getPlugin().getLogger()
|
||||||
|
.warning("An event was initialized with an invalid string: '" + string + "'");
|
||||||
|
AntiCheatReloaded.getPlugin().getLogger().warning(
|
||||||
|
"The proper format is: 'name : threshold : color : action' such as 'High : 50 : RED : KICK'");
|
||||||
|
AntiCheatReloaded.getPlugin().getLogger().warning("This event will NOT run. (" + ex.getMessage() + ")");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name + " : " + level + " : " + color.name() + " : " + Utilities.listToCommaString(actions);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
/*
|
||||||
|
* 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.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
|
||||||
|
public class MovementManager {
|
||||||
|
|
||||||
|
// Ticks in air
|
||||||
|
public int airTicks = 0;
|
||||||
|
// Ticks on ground
|
||||||
|
public int groundTicks = 0;
|
||||||
|
// Ticks on ice
|
||||||
|
public int iceTicks = 0;
|
||||||
|
// Ticks on slime
|
||||||
|
public int slimeTicks = 0;
|
||||||
|
// Ticks in air before last grounded moment
|
||||||
|
public int airTicksBeforeGrounded = 0;
|
||||||
|
// Ticks influenced by ice
|
||||||
|
public int iceInfluenceTicks = 0;
|
||||||
|
// Ticks influenced by slime
|
||||||
|
public int slimeInfluenceTicks = 0;
|
||||||
|
// Y motion of the movement
|
||||||
|
public double motionY;
|
||||||
|
// Previous Y motion of the movement
|
||||||
|
public double lastMotionY;
|
||||||
|
// Horizontal distance of movement
|
||||||
|
public double distanceXZ;
|
||||||
|
// Horizontal distance on x-axis of movement
|
||||||
|
public double distanceX;
|
||||||
|
// Horizontal distance on z-axis of movement
|
||||||
|
public double distanceZ;
|
||||||
|
// Previous horizontal distance of movement
|
||||||
|
public double lastDistanceXZ;
|
||||||
|
// Previous horizontal distance on x-axis of movement
|
||||||
|
public double lastDistanceX;
|
||||||
|
// Previous horizontal distance on z-axis of movement
|
||||||
|
public double lastDistanceZ;
|
||||||
|
// If the player touched the ground again this tick
|
||||||
|
public boolean touchedGroundThisTick = false;
|
||||||
|
// Last recorded distance
|
||||||
|
public Distance lastDistance = new Distance();
|
||||||
|
// Movement acceleration
|
||||||
|
public double acceleration;
|
||||||
|
// Is the block above solid
|
||||||
|
public boolean topSolid;
|
||||||
|
// Is the block below solid
|
||||||
|
public boolean bottomSolid;
|
||||||
|
// If the current movement is up a slab or stair
|
||||||
|
public boolean halfMovement;
|
||||||
|
// If the player is on the ground (determined clientside!)
|
||||||
|
public boolean onGround;
|
||||||
|
// Ticks counter for last halfMovement
|
||||||
|
public int halfMovementHistoryCounter = 0;
|
||||||
|
// Time of last teleport
|
||||||
|
public long lastTeleport;
|
||||||
|
// Elytra effect ticks
|
||||||
|
public int elytraEffectTicks;
|
||||||
|
// Used by Velocity check, represents the currently expected Y motion
|
||||||
|
public double velocityExpectedMotionY;
|
||||||
|
// Amount of ticks a player is sneaking
|
||||||
|
public int sneakingTicks;
|
||||||
|
// Ticks counter after being near a liquid
|
||||||
|
public int nearLiquidTicks;
|
||||||
|
// Time of last update
|
||||||
|
public long lastUpdate;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public void handle(Player player, Location from, Location to, Distance distance) {
|
||||||
|
// TODO as of now, we "trust" the client to send the right thing
|
||||||
|
// This is checked for spoofing by "GroundFlight"
|
||||||
|
// Also seems to make NoFall cheats flag for speed lmao
|
||||||
|
this.onGround = player.isOnGround();
|
||||||
|
|
||||||
|
double x = distance.getXDifference();
|
||||||
|
double z = distance.getZDifference();
|
||||||
|
this.lastDistanceXZ = this.distanceXZ;
|
||||||
|
this.lastDistanceX = this.distanceX;
|
||||||
|
this.lastDistanceZ = this.distanceZ;
|
||||||
|
this.distanceXZ = Math.sqrt(x * x + z * z);
|
||||||
|
this.distanceX = x;
|
||||||
|
this.distanceZ = z;
|
||||||
|
|
||||||
|
// Account for standing on boat
|
||||||
|
if (Utilities.couldBeOnBoat(player, 0.25, true) && !Utilities.isSubmersed(player))
|
||||||
|
this.onGround = true;
|
||||||
|
|
||||||
|
this.touchedGroundThisTick = false;
|
||||||
|
this.halfMovement = false;
|
||||||
|
if (!this.onGround) {
|
||||||
|
this.groundTicks = 0;
|
||||||
|
this.airTicks++;
|
||||||
|
} else {
|
||||||
|
if (this.airTicks > 0)
|
||||||
|
this.touchedGroundThisTick = true;
|
||||||
|
this.airTicksBeforeGrounded = this.airTicks;
|
||||||
|
this.airTicks = 0;
|
||||||
|
this.groundTicks++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Utilities.couldBeOnIce(to)) {
|
||||||
|
this.iceTicks++;
|
||||||
|
this.iceInfluenceTicks = 60;
|
||||||
|
} else {
|
||||||
|
this.iceTicks = 0;
|
||||||
|
if (this.iceInfluenceTicks > 0)
|
||||||
|
this.iceInfluenceTicks--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Utilities.couldBeOnSlime(to)) {
|
||||||
|
this.slimeTicks++;
|
||||||
|
this.slimeInfluenceTicks = 40;
|
||||||
|
} else {
|
||||||
|
this.slimeTicks = 0;
|
||||||
|
if (this.slimeInfluenceTicks > 0)
|
||||||
|
this.slimeInfluenceTicks--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (VersionUtil.isGliding(player)) {
|
||||||
|
this.elytraEffectTicks = 30;
|
||||||
|
} else {
|
||||||
|
if (this.elytraEffectTicks > 0)
|
||||||
|
this.elytraEffectTicks--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.isSneaking())
|
||||||
|
this.sneakingTicks++;
|
||||||
|
else
|
||||||
|
this.sneakingTicks = 0;
|
||||||
|
|
||||||
|
if (Utilities.isNearWater(player))
|
||||||
|
this.nearLiquidTicks = 8;
|
||||||
|
else {
|
||||||
|
if (this.nearLiquidTicks > 0)
|
||||||
|
this.nearLiquidTicks--;
|
||||||
|
else
|
||||||
|
this.nearLiquidTicks = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double lastDistanceSq = Math.sqrt(this.lastDistance.getXDifference() * this.lastDistance.getXDifference()
|
||||||
|
+ this.lastDistance.getZDifference() * this.lastDistance.getZDifference());
|
||||||
|
double currentDistanceSq = Math.sqrt(distance.getXDifference() * distance.getXDifference()
|
||||||
|
+ distance.getZDifference() * distance.getZDifference());
|
||||||
|
this.acceleration = currentDistanceSq - lastDistanceSq;
|
||||||
|
|
||||||
|
this.lastMotionY = this.motionY;
|
||||||
|
this.motionY = to.getY() - from.getY();
|
||||||
|
|
||||||
|
Location top = to.clone().add(0, 2, 0);
|
||||||
|
this.topSolid = top.getBlock().getType().isSolid();
|
||||||
|
Location bottom = to.clone().add(0, -1, 0);
|
||||||
|
this.bottomSolid = bottom.getBlock().getType().isSolid();
|
||||||
|
|
||||||
|
if ((this.motionY > 0.42D && this.motionY <= 0.5625D)
|
||||||
|
&& (Utilities.couldBeOnHalfblock(to) || Utilities.isNearBed(to))) {
|
||||||
|
this.halfMovement = true;
|
||||||
|
this.halfMovementHistoryCounter = 30;
|
||||||
|
} else {
|
||||||
|
if (this.halfMovementHistoryCounter > 0)
|
||||||
|
this.halfMovementHistoryCounter--;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lastUpdate = System.currentTimeMillis();
|
||||||
|
// Update "good location"
|
||||||
|
AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()).setGoodLocation(from);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* 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,
|
||||||
|
PacketType.Play.Server.POSITION }) {
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPacketSending(PacketEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
// Compensate for teleport
|
||||||
|
MorePacketsCheck.compensate(player);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* 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.command.CommandSender;
|
||||||
|
|
||||||
|
public enum Permission {
|
||||||
|
/* Check Nodes */
|
||||||
|
CHECK_FLIGHT, CHECK_ELYTRAFLY, CHECK_WATERWALK, 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_UNICODE, CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY,
|
||||||
|
CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGALINTERACT, CHECK_FASTLADDER,
|
||||||
|
CHECK_AIMBOT, CHECK_STRAFE,
|
||||||
|
|
||||||
|
/* System Nodes */
|
||||||
|
SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_NOTICE, SYSTEM_CHECK, SYSTEM_RELOAD,
|
||||||
|
SYSTEM_MUTE;
|
||||||
|
|
||||||
|
private static final String PERMISSION_ALL = "anticheat.*";
|
||||||
|
private static final String PERMISSION_SPAM = "anticheat.check.spam";
|
||||||
|
|
||||||
|
public static boolean getCommandExempt(CommandSender cs, String commandLabel) {
|
||||||
|
// Check permission, base, and all will have already been checked
|
||||||
|
return cs.hasPermission(CHECK_COMMANDSPAM.toString() + commandLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean get(CommandSender cs) {
|
||||||
|
if ((this == CHECK_CHATSPAM || this == CHECK_COMMANDSPAM) && cs.hasPermission(PERMISSION_SPAM))
|
||||||
|
return true;
|
||||||
|
return cs.hasPermission(toString()) || cs.hasPermission(getBase()) || cs.hasPermission(PERMISSION_ALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBase() {
|
||||||
|
return "anticheat." + this.name().toLowerCase().split("_")[0] + ".*";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String whichPermission(CommandSender cs) {
|
||||||
|
for (String s : new String[] { PERMISSION_ALL, getBase(), toString() }) {
|
||||||
|
if (cs.hasPermission(s)) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "anticheat." + this.name().toLowerCase().replace("_", ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+5
-9
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,19 +17,14 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.util;
|
package com.rammelkast.anticheatreloaded.util;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
public enum ToolHardness {
|
public enum ToolHardness {
|
||||||
|
|
||||||
// NOTHING(null, 1.5)
|
// NOTHING(null, 1.5)
|
||||||
WOOD(0.75D),
|
WOOD(0.75D), STONE(0.40D), IRON(0.25D), DIAMOND(0.20D), SHEARS(0.55D), GOLD(0.15D);
|
||||||
STONE(0.40D),
|
|
||||||
IRON(0.25D),
|
|
||||||
DIAMOND(0.20D),
|
|
||||||
SHEARS(0.55D),
|
|
||||||
GOLD(0.15D);
|
|
||||||
|
|
||||||
double hardness;
|
double hardness;
|
||||||
|
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
/*
|
||||||
|
* 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 java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
|
||||||
|
public class UpdateManager {
|
||||||
|
|
||||||
|
public static final int RESOURCE_ID = 23799;
|
||||||
|
public static final String SPIGOT_VERSION_URL = "https://api.spigotmc.org/legacy/update.php?resource="
|
||||||
|
+ RESOURCE_ID;
|
||||||
|
|
||||||
|
private final String latestVersion;
|
||||||
|
private final boolean isLatest;
|
||||||
|
private final boolean isAhead;
|
||||||
|
|
||||||
|
public UpdateManager() {
|
||||||
|
this.latestVersion = this.getOnlineData(SPIGOT_VERSION_URL);
|
||||||
|
if (this.latestVersion == null) {
|
||||||
|
this.isLatest = true;
|
||||||
|
this.isAhead = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int splitCompare = 0;
|
||||||
|
try {
|
||||||
|
VersionSplit currentSplit = new VersionSplit(AntiCheatReloaded.getVersion());
|
||||||
|
VersionSplit newSplit = new VersionSplit(this.latestVersion);
|
||||||
|
splitCompare = currentSplit.compareTo(newSplit);
|
||||||
|
} catch (Exception e) {}
|
||||||
|
this.isLatest = splitCompare >= 0;
|
||||||
|
this.isAhead = splitCompare > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getOnlineData(String url) {
|
||||||
|
String data = null;
|
||||||
|
InputStream stream = null;
|
||||||
|
try {
|
||||||
|
stream = new URL(url).openStream();
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(stream, Charset.forName("UTF-8")));
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
int readChar;
|
||||||
|
while ((readChar = reader.read()) != -1) {
|
||||||
|
builder.append((char) readChar);
|
||||||
|
}
|
||||||
|
data = builder.toString();
|
||||||
|
reader.close();
|
||||||
|
} catch (IOException exception) {}
|
||||||
|
finally {
|
||||||
|
if (stream != null) {
|
||||||
|
try {
|
||||||
|
stream.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLatest() {
|
||||||
|
return this.isLatest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAhead() {
|
||||||
|
return this.isAhead;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCurrentVersion() {
|
||||||
|
return AntiCheatReloaded.getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLatestVersion() {
|
||||||
|
return this.latestVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class VersionSplit implements Comparable<VersionSplit> {
|
||||||
|
private final int major, minor, build;
|
||||||
|
|
||||||
|
public VersionSplit(String version) throws Exception {
|
||||||
|
if (version.endsWith("-ALPHA")) {
|
||||||
|
version = version.substring(0, version.length() - 6);
|
||||||
|
} else if (version.endsWith("-PRE")) {
|
||||||
|
version = version.substring(0, version.length() - 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] versionSplit = version.split("\\.");
|
||||||
|
if (versionSplit.length != 3) {
|
||||||
|
// Illegal version
|
||||||
|
throw new Exception("Version " + version + " is illegal!");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
int major = Integer.parseInt(versionSplit[0]);
|
||||||
|
int minor = Integer.parseInt(versionSplit[1]);
|
||||||
|
int build = Integer.parseInt(versionSplit[2]);
|
||||||
|
if (major <= 0) {
|
||||||
|
throw new Exception("Illegal version!");
|
||||||
|
}
|
||||||
|
this.major = major;
|
||||||
|
this.minor = minor;
|
||||||
|
this.build = build;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new Exception("Illegal version!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(VersionSplit other) {
|
||||||
|
if (other.major == this.major) {
|
||||||
|
if (other.minor == this.minor) {
|
||||||
|
if (other.build == this.build) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (other.build > this.build) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (other.minor > this.minor) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (other.major > this.major) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMajor() {
|
||||||
|
return major;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinor() {
|
||||||
|
return minor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBuild() {
|
||||||
|
return build;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,474 @@
|
|||||||
|
/*
|
||||||
|
* 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 java.sql.Timestamp;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.rule.Rule;
|
||||||
|
|
||||||
|
public class User {
|
||||||
|
private final UUID uuid;
|
||||||
|
private final String name;
|
||||||
|
private final int id;
|
||||||
|
private int level = 0;
|
||||||
|
private Location goodLocation;
|
||||||
|
private List<ItemStack> inventorySnapshot = null;
|
||||||
|
private Configuration config = AntiCheatReloaded.getManager().getConfiguration();
|
||||||
|
private int toX, toY, toZ;
|
||||||
|
private String[] messages = new String[2];
|
||||||
|
private Long[] messageTimes = new Long[2];
|
||||||
|
private String[] commands = new String[2];
|
||||||
|
private Long[] commandTimes = new Long[2];
|
||||||
|
|
||||||
|
private boolean isWaitingOnLevelSync;
|
||||||
|
private Timestamp levelSyncTimestamp;
|
||||||
|
|
||||||
|
private long lastServerPing, lastClientPong;
|
||||||
|
private int ping = -1;
|
||||||
|
private int lastPing = -1;
|
||||||
|
|
||||||
|
private MovementManager movementManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize an AntiCheat user
|
||||||
|
*
|
||||||
|
* @param uuid Player's UUID
|
||||||
|
*/
|
||||||
|
public User(UUID uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
this.name = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getName() : "";
|
||||||
|
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1;
|
||||||
|
this.movementManager = new MovementManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the player's UUID
|
||||||
|
*
|
||||||
|
* @return Player UUID
|
||||||
|
*/
|
||||||
|
public UUID getUUID() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the player's name
|
||||||
|
*
|
||||||
|
* @return Player name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the player's entity ID
|
||||||
|
*
|
||||||
|
* @return Entity id
|
||||||
|
*/
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Bukkit player
|
||||||
|
*
|
||||||
|
* @return Player
|
||||||
|
*/
|
||||||
|
public Player getPlayer() {
|
||||||
|
return Bukkit.getPlayer(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the user's level value
|
||||||
|
*
|
||||||
|
* @return level
|
||||||
|
*/
|
||||||
|
public int getLevel() {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the user's group
|
||||||
|
*
|
||||||
|
* @return group
|
||||||
|
*/
|
||||||
|
public Group getGroup() {
|
||||||
|
List<Group> groups = config.getGroups().getGroups();
|
||||||
|
for (int i = 0; i < groups.size(); i++) {
|
||||||
|
if (i == 0 && level < groups.get(i).getLevel())
|
||||||
|
break;
|
||||||
|
else if (i == groups.size() - 1)
|
||||||
|
return groups.get(i);
|
||||||
|
else if (level >= groups.get(i).getLevel() && level < groups.get(i + 1).getLevel())
|
||||||
|
return groups.get(i);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increase the player's level (from failing a check)
|
||||||
|
*
|
||||||
|
* @param type The check failed
|
||||||
|
* @return true if the level was increased
|
||||||
|
*/
|
||||||
|
public boolean increaseLevel(CheckType type) {
|
||||||
|
if (getPlayer() != null && getPlayer().isOnline()) {
|
||||||
|
if (silentMode() && type.getUses(uuid) % 4 != 0) {
|
||||||
|
// Prevent silent mode from increasing the level way too fast
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (level < config.getGroups().getHighestLevel()) {
|
||||||
|
level++;
|
||||||
|
|
||||||
|
// Check levels
|
||||||
|
for (Group l : getLevels()) {
|
||||||
|
if (l.getLevel() == level) {
|
||||||
|
AntiCheatReloaded.getManager().getUserManager().alert(this, l, type);
|
||||||
|
if (l.getLevel() == config.getGroups().getHighestLevel()) {
|
||||||
|
level = l.getLevel() - 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute rules
|
||||||
|
for (Rule rule : config.getRules().getRules()) {
|
||||||
|
rule.check(this, type);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrease the player's level by one value
|
||||||
|
*/
|
||||||
|
public void decreaseLevel() {
|
||||||
|
level = level != 0 ? level - 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the users level to a specific value. Must be 0 < level < config-defined
|
||||||
|
* highest level
|
||||||
|
*
|
||||||
|
* @param level level to set
|
||||||
|
* @return true if the level was valid and set properly
|
||||||
|
*/
|
||||||
|
public boolean setLevel(int level) {
|
||||||
|
isWaitingOnLevelSync = false;
|
||||||
|
if (level >= 0) {
|
||||||
|
if (level <= config.getGroups().getHighestLevel()) {
|
||||||
|
this.level = level;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
this.level = config.getGroups().getHighestLevel();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the user's level to zero and clear all check failures
|
||||||
|
*/
|
||||||
|
public void resetLevel() {
|
||||||
|
level = 0;
|
||||||
|
for (CheckType type : CheckType.values()) {
|
||||||
|
type.clearUse(uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the last known valid location of the player for use in resetting
|
||||||
|
*
|
||||||
|
* @param location default value to be returned if no known good location exists
|
||||||
|
* @return last known valid location
|
||||||
|
*/
|
||||||
|
public Location getGoodLocation(Location location) {
|
||||||
|
if (goodLocation == null || !location.getWorld().equals(goodLocation.getWorld())
|
||||||
|
|| location.distance(goodLocation) > config.getConfig().maxSetbackDistance.getValue()) {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location moveTo = goodLocation;
|
||||||
|
if (location != null) {
|
||||||
|
moveTo.setPitch(location.getPitch());
|
||||||
|
moveTo.setYaw(location.getYaw());
|
||||||
|
}
|
||||||
|
return moveTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the last known valid location of the player
|
||||||
|
*
|
||||||
|
* @param location location to be set
|
||||||
|
* @return true if the location was valid and set properly
|
||||||
|
*/
|
||||||
|
public boolean setGoodLocation(Location location) {
|
||||||
|
if (Utilities.cantStandAtExp(location)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
goodLocation = location;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a copy of the player's inventory, for use in resetting
|
||||||
|
*
|
||||||
|
* @param is ItemStack list to store
|
||||||
|
*/
|
||||||
|
public void setInventorySnapshot(ItemStack[] is) {
|
||||||
|
inventorySnapshot = new ArrayList<ItemStack>();
|
||||||
|
for (int i = 0; i < is.length; i++) {
|
||||||
|
if (is[i] != null) {
|
||||||
|
inventorySnapshot.add(is[i].clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the current inventory snapshot
|
||||||
|
*/
|
||||||
|
public void removeInventorySnapshot() {
|
||||||
|
inventorySnapshot = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restore the player's inventory with the current inventory snapshot
|
||||||
|
*
|
||||||
|
* @param inventory Player's inventory
|
||||||
|
*/
|
||||||
|
public void restoreInventory(Inventory inventory) {
|
||||||
|
if (inventorySnapshot != null) {
|
||||||
|
inventory.clear();
|
||||||
|
for (ItemStack is : inventorySnapshot) {
|
||||||
|
if (is != null) {
|
||||||
|
inventory.addItem(is);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the player's to location
|
||||||
|
*
|
||||||
|
* @param x X value
|
||||||
|
* @param y Y value
|
||||||
|
* @param z Z value
|
||||||
|
*/
|
||||||
|
public void setTo(double x, double y, double z) {
|
||||||
|
toX = (int) x;
|
||||||
|
toY = (int) y;
|
||||||
|
toZ = (int) z;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a given to value is the same as the stored value
|
||||||
|
*
|
||||||
|
* @param x X value
|
||||||
|
* @param y Y value
|
||||||
|
* @param z Z value
|
||||||
|
* @return true if coordinates are all equal
|
||||||
|
*/
|
||||||
|
public boolean checkTo(double x, double y, double z) {
|
||||||
|
return (int) x == toX && (int) y == toY && (int) z == toZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a player's chat message
|
||||||
|
*
|
||||||
|
* @param message Message to log
|
||||||
|
*/
|
||||||
|
public void addMessage(String message) {
|
||||||
|
addToSpamLog(message, messages, messageTimes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a player's command
|
||||||
|
*
|
||||||
|
* @param command Command to log
|
||||||
|
*/
|
||||||
|
public void addCommand(String command) {
|
||||||
|
addToSpamLog(command, commands, commandTimes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addToSpamLog(String string, String[] messages, Long[] times) {
|
||||||
|
messages[1] = messages[0];
|
||||||
|
messages[0] = string;
|
||||||
|
|
||||||
|
times[1] = times[0];
|
||||||
|
times[0] = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a stored chat message
|
||||||
|
*
|
||||||
|
* @param index Index of the chat in storage
|
||||||
|
* @return the message
|
||||||
|
*/
|
||||||
|
public String getMessage(int index) {
|
||||||
|
return messages[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a stored command
|
||||||
|
*
|
||||||
|
* @param index Index of the command in storage
|
||||||
|
* @return the command
|
||||||
|
*/
|
||||||
|
public String getCommand(int index) {
|
||||||
|
return commands[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the time a message in storage was sent
|
||||||
|
*
|
||||||
|
* @param index Index of the chat in storage
|
||||||
|
* @return time the message was sent
|
||||||
|
*/
|
||||||
|
public Long getMessageTime(int index) {
|
||||||
|
return messageTimes[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the time a command in storage was sent
|
||||||
|
*
|
||||||
|
* @param index Index of the command in storage
|
||||||
|
* @return time the command was sent
|
||||||
|
*/
|
||||||
|
public Long getCommandTime(int index) {
|
||||||
|
return commandTimes[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear all stored messages
|
||||||
|
*/
|
||||||
|
public void clearMessages() {
|
||||||
|
messages = new String[2];
|
||||||
|
messageTimes = new Long[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear all stored commands
|
||||||
|
*/
|
||||||
|
public void clearCommands() {
|
||||||
|
commands = new String[2];
|
||||||
|
commandTimes = new Long[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the time the very last stored message was sent
|
||||||
|
*
|
||||||
|
* @return the last message's time
|
||||||
|
*/
|
||||||
|
public Long getLastMessageTime() {
|
||||||
|
return getMessageTime(0) == null ? -1 : getMessageTime(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the time the very last stored command was sent
|
||||||
|
*
|
||||||
|
* @return the last command's time
|
||||||
|
*/
|
||||||
|
public Long getLastCommandTime() {
|
||||||
|
return getCommandTime(0) == null ? -1 : getCommandTime(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Group> getLevels() {
|
||||||
|
return config.getGroups().getGroups();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean silentMode() {
|
||||||
|
return config.getConfig().silentMode.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsWaitingOnLevelSync(boolean b) {
|
||||||
|
this.isWaitingOnLevelSync = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWaitingOnLevelSync() {
|
||||||
|
return isWaitingOnLevelSync;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLevelSyncTimestamp(Timestamp timestamp) {
|
||||||
|
levelSyncTimestamp = timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getLevelSyncTimestamp() {
|
||||||
|
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) > config.getMagic().LAG_DETERMINATION()
|
||||||
|
&& this.ping > config.getMagic().LAG_DETERMINATION();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MovementManager getMovementManager() {
|
||||||
|
return this.movementManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "User {name = " + getName() + ", level = " + level + "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,157 @@
|
|||||||
|
/*
|
||||||
|
* 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 java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
|
||||||
|
public class VersionUtil {
|
||||||
|
|
||||||
|
private static final List<String> SUPPORTED_VERSIONS = Arrays
|
||||||
|
.asList(new String[] { "v1_16", "v1_15", "v1_14", "v1_13", "v1_8_R3" });
|
||||||
|
|
||||||
|
public static String getVersion() {
|
||||||
|
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSupported() {
|
||||||
|
for (String versionId : SUPPORTED_VERSIONS) {
|
||||||
|
if (getVersion().startsWith(versionId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isOfVersion(String versionId) {
|
||||||
|
if (getVersion().startsWith(versionId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
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 player) {
|
||||||
|
if (isBountifulUpdate()) {
|
||||||
|
return player.isFlying();
|
||||||
|
}
|
||||||
|
return player.isFlying() || player.isGliding() || player.hasPotionEffect(PotionEffectType.LEVITATION)
|
||||||
|
|| AntiCheatReloaded.getManager().getBackend().justLevitated(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isRiptiding(Player player) {
|
||||||
|
if (isBountifulUpdate()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return player.isRiptiding();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSlowFalling(Player player) {
|
||||||
|
if (isBountifulUpdate()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return player.hasPotionEffect(PotionEffectType.SLOW_FALLING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFrostWalk(Player player) {
|
||||||
|
if (player.getInventory().getBoots() == null || isBountifulUpdate()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return player.getInventory().getBoots().containsEnchantment(Enchantment.FROST_WALKER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static ItemStack getItemInHand(Player player) {
|
||||||
|
if (isBountifulUpdate()) {
|
||||||
|
return player.getItemInHand();
|
||||||
|
}
|
||||||
|
return player.getInventory().getItemInMainHand();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPlayerPing(Player player) {
|
||||||
|
try {
|
||||||
|
Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player);
|
||||||
|
int ping = (int) entityPlayer.getClass().getField("ping").get(entityPlayer);
|
||||||
|
return ping;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Block getTargetBlock(Player player, int distance) {
|
||||||
|
if (isBountifulUpdate()) {
|
||||||
|
return player.getTargetBlock((Set<Material>) null, distance);
|
||||||
|
}
|
||||||
|
return player.getTargetBlockExact(distance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isGliding(Player player) {
|
||||||
|
if (isBountifulUpdate()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return player.isGliding();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isLevitationEffect(PotionEffect effect) {
|
||||||
|
if (isBountifulUpdate()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return effect.getType().equals(PotionEffectType.LEVITATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPotionLevel(Player player, PotionEffectType type) {
|
||||||
|
if (isBountifulUpdate()) {
|
||||||
|
for (PotionEffect effect : player.getActivePotionEffects()) {
|
||||||
|
if (effect.getType().equals(type))
|
||||||
|
return effect.getAmplifier() + 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.hasPotionEffect(type))
|
||||||
|
return player.getPotionEffect(type).getAmplifier() + 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSwimming(Player player) {
|
||||||
|
if (isBountifulUpdate()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return player.isSwimming();
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
+17
-15
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,15 +17,16 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.util.enterprise;
|
package com.rammelkast.anticheatreloaded.util.enterprise;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@@ -136,7 +138,7 @@ public class Database {
|
|||||||
connection.setAutoCommit(false);
|
connection.setAutoCommit(false);
|
||||||
|
|
||||||
if (logInterval != 0) {
|
if (logInterval != 0) {
|
||||||
eventTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheat.getPlugin(), new Runnable() {
|
eventTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
flushEvents();
|
flushEvents();
|
||||||
@@ -145,7 +147,7 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(syncLevels && syncInterval != 0) {
|
if(syncLevels && syncInterval != 0) {
|
||||||
syncTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheat.getPlugin(), new Runnable() {
|
syncTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
syncUsers();
|
syncUsers();
|
||||||
@@ -153,7 +155,7 @@ public class Database {
|
|||||||
}, syncInterval * 20, syncInterval * 20);
|
}, syncInterval * 20, syncInterval * 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getPlugin().verboseLog("Connected to the database.");
|
AntiCheatReloaded.getPlugin().verboseLog("Connected to the database.");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -180,7 +182,7 @@ public class Database {
|
|||||||
public void logEvent(User user, CheckType checkType) {
|
public void logEvent(User user, CheckType checkType) {
|
||||||
try {
|
try {
|
||||||
eventBatch.setString(1, serverName);
|
eventBatch.setString(1, serverName);
|
||||||
eventBatch.setString(2, user.getName());
|
eventBatch.setString(2, user.getUUID().toString());
|
||||||
eventBatch.setString(3, checkType.toString());
|
eventBatch.setString(3, checkType.toString());
|
||||||
|
|
||||||
eventBatch.addBatch();
|
eventBatch.addBatch();
|
||||||
@@ -202,7 +204,7 @@ public class Database {
|
|||||||
|
|
||||||
public void cleanEvents() {
|
public void cleanEvents() {
|
||||||
if (logLife != 0) {
|
if (logLife != 0) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@@ -212,7 +214,7 @@ public class Database {
|
|||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
|
|
||||||
connection.commit();
|
connection.commit();
|
||||||
AntiCheat.getPlugin().verboseLog("Cleaned " + statement.getUpdateCount() + " old events from the database");
|
AntiCheatReloaded.getPlugin().verboseLog("Cleaned " + statement.getUpdateCount() + " old events from the database");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -222,8 +224,8 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void syncUsers() {
|
private void syncUsers() {
|
||||||
for (User user : AntiCheat.getManager().getUserManager().getUsers()) {
|
for (User user : AntiCheatReloaded.getManager().getUserManager().getUsers()) {
|
||||||
AntiCheat.getManager().getConfiguration().getLevels().updateLevelToUser(user);
|
AntiCheatReloaded.getManager().getConfiguration().getLevels().updateLevelToUser(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-7
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,14 +17,15 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.util.rule;
|
package com.rammelkast.anticheatreloaded.util.rule;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
|
||||||
|
|
||||||
import javax.script.ScriptEngine;
|
import javax.script.ScriptEngine;
|
||||||
import javax.script.ScriptEngineManager;
|
import javax.script.ScriptEngineManager;
|
||||||
import javax.script.ScriptException;
|
import javax.script.ScriptException;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,7 +44,7 @@ import java.util.SortedMap;
|
|||||||
* Check_SPIDER > 0 ? Player.KICK : null<br />
|
* Check_SPIDER > 0 ? Player.KICK : null<br />
|
||||||
* <i>The above statement would read 'If the spider check has been failed over zero times, kick the player. Otherwise, do nothing.'</i>
|
* <i>The above statement would read 'If the spider check has been failed over zero times, kick the player. Otherwise, do nothing.'</i>
|
||||||
* <p/>
|
* <p/>
|
||||||
* To see syntax for variables and functions that you may use, see {@link net.gravitydevelopment.anticheat.util.rule.Rule}
|
* To see syntax for variables and functions that you may use, see {@link com.rammelkast.anticheatreloaded.util.rule.Rule}
|
||||||
*/
|
*/
|
||||||
public class ConditionalRule extends Rule {
|
public class ConditionalRule extends Rule {
|
||||||
|
|
||||||
+19
-16
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,15 +17,16 @@
|
|||||||
* 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 net.gravitydevelopment.anticheat.util.rule;
|
package com.rammelkast.anticheatreloaded.util.rule;
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Group;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Group;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -44,7 +46,7 @@ import java.util.TreeMap;
|
|||||||
* <ul>
|
* <ul>
|
||||||
* <li>Check
|
* <li>Check
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Contains all valid checks as listed in {@link net.gravitydevelopment.anticheat.check.CheckType}</li>
|
* <li>Contains all valid checks as listed in {@link com.rammelkast.anticheatreloaded.check.CheckType}</li>
|
||||||
* <li>Will return the number of times this user has failed the given check</li>
|
* <li>Will return the number of times this user has failed the given check</li>
|
||||||
* <li><b>Example:</b> Check_SPRINT</li>
|
* <li><b>Example:</b> Check_SPRINT</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
@@ -70,23 +72,23 @@ import java.util.TreeMap;
|
|||||||
* <p/>
|
* <p/>
|
||||||
* <b>Types of functions:</b><br />
|
* <b>Types of functions:</b><br />
|
||||||
* - Player: RESET, KICK, BAN, COMMAND[command] OR COMMAND[command1;command2]
|
* - Player: RESET, KICK, BAN, COMMAND[command] OR COMMAND[command1;command2]
|
||||||
* <i>- when using commands <b>&player</b> will be replaced by the player name, <b>&world</b> will be replaced by the player's world,
|
* <i>- when using commands <b>%player%</b> will be replaced by the player name, <b>&world</b> will be replaced by the player's world,
|
||||||
* and <b>&check</b> will be replaced by the check that caused this rule to be run</i><br />
|
* and <b>&check</b> will be replaced by the check that caused this rule to be run</i><br />
|
||||||
* <br /><br />
|
* <br /><br />
|
||||||
* <p/>
|
* <p/>
|
||||||
* The Rule class itself is not an functional rule setup,
|
* The Rule class itself is not an functional rule setup,
|
||||||
* it is inherited and made functional by different implementations of the rule parser.<br />
|
* it is inherited and made functional by different implementations of the rule parser.<br />
|
||||||
* The only current Rule implementation is the {@link net.gravitydevelopment.anticheat.util.rule.ConditionalRule}
|
* The only current Rule implementation is the {@link com.rammelkast.anticheatreloaded.util.rule.ConditionalRule}
|
||||||
*/
|
*/
|
||||||
public class Rule {
|
public class Rule {
|
||||||
|
|
||||||
private static String string;
|
|
||||||
private static final String VARIABLE_SET_REGEX = ".*(_).*=.*";
|
private static final String VARIABLE_SET_REGEX = ".*(_).*=.*";
|
||||||
private static final String FUNCTION_REGEX = ".*\\..*";
|
private static final String FUNCTION_REGEX = ".*\\..*";
|
||||||
|
private String string;
|
||||||
private Type type;
|
private Type type;
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
CONDITIONAL(".*[?]*.*:.*", "net.gravitydevelopment.anticheat.util.rule.ConditionalRule");
|
CONDITIONAL(".*[?]*.*:.*", "com.rammelkast.anticheatreloaded.util.rule.ConditionalRule");
|
||||||
|
|
||||||
private String regex;
|
private String regex;
|
||||||
private String c;
|
private String c;
|
||||||
@@ -127,6 +129,7 @@ public class Rule {
|
|||||||
* @param string the string value to load
|
* @param string the string value to load
|
||||||
* @return an instance of Rule if an implementation exists to handle this rule, null if none are found
|
* @return an instance of Rule if an implementation exists to handle this rule, null if none are found
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
public static Rule load(String string) {
|
public static Rule load(String string) {
|
||||||
for (Type type : Type.values()) {
|
for (Type type : Type.values()) {
|
||||||
if (type.matches(string)) {
|
if (type.matches(string)) {
|
||||||
@@ -145,7 +148,7 @@ public class Rule {
|
|||||||
/**
|
/**
|
||||||
* Get the type of rule this is
|
* Get the type of rule this is
|
||||||
*
|
*
|
||||||
* @return a {@link net.gravitydevelopment.anticheat.util.rule.Rule.Type}
|
* @return a {@link com.rammelkast.anticheatreloaded.util.rule.Rule.Type}
|
||||||
*/
|
*/
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return type;
|
return type;
|
||||||
@@ -174,7 +177,7 @@ public class Rule {
|
|||||||
if (variable.equals("player_level") && Utilities.isInt(value)) {
|
if (variable.equals("player_level") && Utilities.isInt(value)) {
|
||||||
user.setLevel(Integer.parseInt(value));
|
user.setLevel(Integer.parseInt(value));
|
||||||
} else if (variable.equals("player_group") && Utilities.isInt(value)) {
|
} else if (variable.equals("player_group") && Utilities.isInt(value)) {
|
||||||
for (Group group : AntiCheat.getManager().getConfiguration().getGroups().getGroups()) {
|
for (Group group : AntiCheatReloaded.getManager().getConfiguration().getGroups().getGroups()) {
|
||||||
if (group.getName().equalsIgnoreCase(value)) {
|
if (group.getName().equalsIgnoreCase(value)) {
|
||||||
user.setLevel(group.getLevel());
|
user.setLevel(group.getLevel());
|
||||||
}
|
}
|
||||||
@@ -195,7 +198,7 @@ public class Rule {
|
|||||||
text = text.split("\\.")[1];
|
text = text.split("\\.")[1];
|
||||||
List<String> action = new ArrayList<String>();
|
List<String> action = new ArrayList<String>();
|
||||||
action.add(text);
|
action.add(text);
|
||||||
AntiCheat.getManager().getUserManager().execute(user, action, type);
|
AntiCheatReloaded.getManager().getUserManager().execute(user, action, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,215 +0,0 @@
|
|||||||
/*
|
|
||||||
* AntiCheat for Bukkit.
|
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
|
||||||
*
|
|
||||||
* 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 net.gravitydevelopment.anticheat;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.check.combat.KillAuraCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.check.movement.BlinkCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.command.CommandHandler;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.event.BlockListener;
|
|
||||||
import net.gravitydevelopment.anticheat.event.EntityListener;
|
|
||||||
import net.gravitydevelopment.anticheat.event.InventoryListener;
|
|
||||||
import net.gravitydevelopment.anticheat.event.PlayerListener;
|
|
||||||
import net.gravitydevelopment.anticheat.event.VehicleListener;
|
|
||||||
import net.gravitydevelopment.anticheat.manage.AntiCheatManager;
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
|
||||||
import net.gravitydevelopment.anticheat.util.VersionUtil;
|
|
||||||
|
|
||||||
public class AntiCheat extends JavaPlugin {
|
|
||||||
|
|
||||||
private static AntiCheatManager manager;
|
|
||||||
private static AntiCheat plugin;
|
|
||||||
private static List<Listener> eventList = new ArrayList<Listener>();
|
|
||||||
private static Configuration config;
|
|
||||||
private static boolean verbose;
|
|
||||||
private static boolean developer;
|
|
||||||
private static final int PROJECT_ID = 100229;
|
|
||||||
private static ProtocolManager protocolManager;
|
|
||||||
private static boolean protocolLib = false;
|
|
||||||
private static Long loadTime;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
plugin = this;
|
|
||||||
loadTime = System.currentTimeMillis();
|
|
||||||
manager = new AntiCheatManager(this, getLogger());
|
|
||||||
eventList.add(new PlayerListener());
|
|
||||||
eventList.add(new BlockListener());
|
|
||||||
eventList.add(new EntityListener());
|
|
||||||
eventList.add(new VehicleListener());
|
|
||||||
eventList.add(new InventoryListener());
|
|
||||||
// Order is important in some cases, don't screw with these unless needed, especially config
|
|
||||||
setupConfig();
|
|
||||||
setupEvents();
|
|
||||||
setupCommands();
|
|
||||||
setupProtocol();
|
|
||||||
// Enterprise must come before levels
|
|
||||||
setupEnterprise();
|
|
||||||
restoreLevels();
|
|
||||||
// Check if NoCheatPlus is installed
|
|
||||||
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
|
|
||||||
getLogger().severe("You are also running NoCheatPlus!");
|
|
||||||
getLogger().severe("Multiple anticheats create false cheat detections.");
|
|
||||||
getLogger().severe("Please remove or disable NoCheatPlus to silence this warning.");
|
|
||||||
}else if (Bukkit.getPluginManager().getPlugin("AAC") != null) {
|
|
||||||
getLogger().severe("You are also running AAC!");
|
|
||||||
getLogger().severe("Multiple anticheats create false cheat detections.");
|
|
||||||
getLogger().severe("Please remove or disable AAC to silence this warning.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 40L);
|
|
||||||
// End tests
|
|
||||||
verboseLog("Finished loading.");
|
|
||||||
getLogger().info("Running version " + VersionUtil.getVersion() + "...");
|
|
||||||
|
|
||||||
// Enable packetlisteners
|
|
||||||
KillAuraCheck.listenPackets();
|
|
||||||
BlinkCheck.startTimer();
|
|
||||||
BlinkCheck.listenPackets();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
verboseLog("Saving user levels...");
|
|
||||||
config.getLevels().saveLevelsFromUsers(getManager().getUserManager().getUsers());
|
|
||||||
|
|
||||||
AntiCheatManager.close();
|
|
||||||
getServer().getScheduler().cancelTasks(this);
|
|
||||||
cleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupProtocol() {
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
|
||||||
protocolLib = true;
|
|
||||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
|
||||||
verboseLog("Hooked into ProtocolLib");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupEvents() {
|
|
||||||
for (Listener listener : eventList) {
|
|
||||||
getServer().getPluginManager().registerEvents(listener, this);
|
|
||||||
verboseLog("Registered events for ".concat(listener.toString().split("@")[0].split(".anticheat.")[1]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupCommands() {
|
|
||||||
getCommand("anticheat").setExecutor(new CommandHandler());
|
|
||||||
verboseLog("Registered commands.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupConfig() {
|
|
||||||
config = manager.getConfiguration();
|
|
||||||
verboseLog("Setup the config.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupEnterprise() {
|
|
||||||
if (config.getConfig().enterprise.getValue()) {
|
|
||||||
if (config.getEnterprise().loggingEnabled.getValue()) {
|
|
||||||
config.getEnterprise().database.cleanEvents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void restoreLevels() {
|
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
|
||||||
UUID uuid = player.getUniqueId();
|
|
||||||
|
|
||||||
User user = new User(uuid);
|
|
||||||
user.setIsWaitingOnLevelSync(true);
|
|
||||||
config.getLevels().loadLevelToUser(user);
|
|
||||||
|
|
||||||
manager.getUserManager().addUser(user);
|
|
||||||
verboseLog("Data for " + uuid + " loaded");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AntiCheat getPlugin() {
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AntiCheatManager getManager() {
|
|
||||||
return manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getVersion() {
|
|
||||||
return manager.getPlugin().getDescription().getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cleanup() {
|
|
||||||
eventList = null;
|
|
||||||
manager = null;
|
|
||||||
config = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean developerMode() {
|
|
||||||
return developer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setDeveloperMode(boolean b) {
|
|
||||||
developer = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isUsingProtocolLib() {
|
|
||||||
return protocolLib;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void debugLog(final String string) {
|
|
||||||
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (developer) {
|
|
||||||
manager.debugLog("[DEBUG] " + string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void verboseLog(final String string) {
|
|
||||||
if (verbose) {
|
|
||||||
getLogger().info(string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVerbose(boolean b) {
|
|
||||||
verbose = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getLoadTime() {
|
|
||||||
return loadTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ProtocolManager getProtocolManager() {
|
|
||||||
return protocolManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,890 +0,0 @@
|
|||||||
/*
|
|
||||||
* AntiCheat for Bukkit.
|
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
|
||||||
*
|
|
||||||
* 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 net.gravitydevelopment.anticheat.check;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.combat.KillAuraCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.check.combat.VelocityCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.check.movement.BlinkCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.check.movement.FlightCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.check.movement.GlideCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.check.movement.SpeedCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.check.movement.WaterWalkCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.check.movement.YAxisCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.config.providers.Lang;
|
|
||||||
import net.gravitydevelopment.anticheat.config.providers.Magic;
|
|
||||||
import net.gravitydevelopment.anticheat.manage.AntiCheatManager;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Distance;
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
|
||||||
import net.gravitydevelopment.anticheat.util.VersionUtil;
|
|
||||||
|
|
||||||
public class Backend {
|
|
||||||
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> commandLevel = new HashMap<UUID, Integer>();
|
|
||||||
private Map<UUID, Integer> nofallViolation = new HashMap<UUID, Integer>();
|
|
||||||
private Map<UUID, Integer> fastBreakViolation = new HashMap<UUID, Integer>();
|
|
||||||
private Map<UUID, Integer> fastBreaks = new HashMap<UUID, Integer>();
|
|
||||||
private Map<UUID, Boolean> blockBreakHolder = new HashMap<UUID, Boolean>();
|
|
||||||
private Map<UUID, Long> lastBlockBroken = new HashMap<UUID, Long>();
|
|
||||||
private Map<UUID, Integer> fastPlaceViolation = new HashMap<UUID, Integer>();
|
|
||||||
private Map<UUID, Long> lastBlockPlaced = 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> 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, Long> startEat = new HashMap<UUID, Long>();
|
|
||||||
private Map<UUID, Long> lastHeal = new HashMap<UUID, Long>();
|
|
||||||
private Map<UUID, Long> projectileTime = new HashMap<UUID, Long>();
|
|
||||||
private Map<UUID, Long> bowWindUp = new HashMap<UUID, Long>();
|
|
||||||
private Map<UUID, Long> instantBreakExempt = new HashMap<UUID, Long>();
|
|
||||||
private Map<UUID, Long> sprinted = new HashMap<UUID, Long>();
|
|
||||||
private Map<UUID, Long> brokenBlock = new HashMap<UUID, Long>();
|
|
||||||
private Map<UUID, Long> placedBlock = new HashMap<UUID, Long>();
|
|
||||||
private Map<UUID, Long> blockTime = new HashMap<UUID, Long>();
|
|
||||||
private Map<UUID, Integer> blocksDropped = new HashMap<UUID, Integer>();
|
|
||||||
private Map<UUID, Long> lastInventoryTime = 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, 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 Map<UUID, Long> lastFallPacket = new HashMap<UUID, Long>();
|
|
||||||
|
|
||||||
private Magic magic;
|
|
||||||
private AntiCheatManager manager = null;
|
|
||||||
private Lang lang = null;
|
|
||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
|
||||||
|
|
||||||
public Backend(AntiCheatManager instance) {
|
|
||||||
magic = instance.getConfiguration().getMagic();
|
|
||||||
manager = instance;
|
|
||||||
lang = manager.getConfiguration().getLang();
|
|
||||||
transparent.add((byte) -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Magic getMagic() {
|
|
||||||
return magic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateConfig(Configuration config) {
|
|
||||||
magic = config.getMagic();
|
|
||||||
lang = config.getLang();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetChatLevel(User user) {
|
|
||||||
chatLevel.put(user.getUUID(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void garbageClean(Player player) {
|
|
||||||
UUID pU = player.getUniqueId();
|
|
||||||
|
|
||||||
VelocityCheck.cleanPlayer(player);
|
|
||||||
KillAuraCheck.cleanPlayer(player);
|
|
||||||
BlinkCheck.MOVE_COUNT.remove(player.getUniqueId());
|
|
||||||
blocksDropped.remove(pU);
|
|
||||||
blockTime.remove(pU);
|
|
||||||
FlightCheck.movingExempt.remove(pU);
|
|
||||||
brokenBlock.remove(pU);
|
|
||||||
placedBlock.remove(pU);
|
|
||||||
bowWindUp.remove(pU);
|
|
||||||
startEat.remove(pU);
|
|
||||||
lastHeal.remove(pU);
|
|
||||||
sprinted.remove(pU);
|
|
||||||
WaterWalkCheck.isInWater.remove(pU);
|
|
||||||
WaterWalkCheck.isInWaterCache.remove(pU);
|
|
||||||
instantBreakExempt.remove(pU);
|
|
||||||
isAscending.remove(player.getUniqueId());
|
|
||||||
ascensionCount.remove(player.getUniqueId());
|
|
||||||
FlightCheck.blocksOverFlight.remove(pU);
|
|
||||||
nofallViolation.remove(pU);
|
|
||||||
fastBreakViolation.remove(pU);
|
|
||||||
YAxisCheck.yAxisViolations.remove(pU);
|
|
||||||
YAxisCheck.yAxisLastViolation.remove(pU);
|
|
||||||
YAxisCheck.lastYcoord.remove(pU);
|
|
||||||
YAxisCheck.lastYtime.remove(pU);
|
|
||||||
fastBreaks.remove(pU);
|
|
||||||
blockBreakHolder.remove(pU);
|
|
||||||
lastBlockBroken.remove(pU);
|
|
||||||
fastPlaceViolation.remove(pU);
|
|
||||||
lastBlockPlaced.remove(pU);
|
|
||||||
lastBlockPlaceTime.remove(pU);
|
|
||||||
blockPunches.remove(pU);
|
|
||||||
WaterWalkCheck.waterAscensionViolation.remove(pU);
|
|
||||||
WaterWalkCheck.waterSpeedViolation.remove(pU);
|
|
||||||
projectilesShot.remove(pU);
|
|
||||||
velocitized.remove(pU);
|
|
||||||
velocitytrack.remove(pU);
|
|
||||||
startEat.remove(pU);
|
|
||||||
lastHeal.remove(pU);
|
|
||||||
projectileTime.remove(pU);
|
|
||||||
bowWindUp.remove(pU);
|
|
||||||
instantBreakExempt.remove(pU);
|
|
||||||
sprinted.remove(pU);
|
|
||||||
brokenBlock.remove(pU);
|
|
||||||
placedBlock.remove(pU);
|
|
||||||
FlightCheck.movingExempt.remove(pU);
|
|
||||||
blockTime.remove(pU);
|
|
||||||
blocksDropped.remove(pU);
|
|
||||||
lastInventoryTime.remove(pU);
|
|
||||||
inventoryTime.remove(pU);
|
|
||||||
inventoryClicks.remove(pU);
|
|
||||||
lastFallPacket.remove(pU);
|
|
||||||
GlideCheck.lastYDelta.remove(pU);
|
|
||||||
GlideCheck.glideBuffer.remove(pU);
|
|
||||||
SpeedCheck.speedViolation.remove(player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkFastBow(Player player, float force) {
|
|
||||||
// Ignore magic numbers here, they are minecrafty vanilla stuff.
|
|
||||||
int ticks = (int) ((((System.currentTimeMillis() - bowWindUp.get(player.getUniqueId())) * 20) / 1000) + 3);
|
|
||||||
bowWindUp.remove(player.getUniqueId());
|
|
||||||
float f = (float) ticks / 20.0F;
|
|
||||||
f = (f * f + f * 2.0F) / 3.0F;
|
|
||||||
f = f > 1.0F ? 1.0F : f;
|
|
||||||
if (Math.abs(force - f) > magic.BOW_ERROR()) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getUniqueId() + " fired their bow too fast (actual force=" + force + ", calculated force=" + f + ")");
|
|
||||||
} else {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkProjectile(Player player) {
|
|
||||||
incrementOld(player, projectilesShot, 10);
|
|
||||||
if (!projectileTime.containsKey(player.getUniqueId())) {
|
|
||||||
projectileTime.put(player.getUniqueId(), System.currentTimeMillis());
|
|
||||||
return new CheckResult(CheckResult.Result.PASSED);
|
|
||||||
} else if (projectilesShot.get(player.getUniqueId()) == magic.PROJECTILE_CHECK()) {
|
|
||||||
long time = System.currentTimeMillis() - projectileTime.get(player.getUniqueId());
|
|
||||||
projectileTime.remove(player.getUniqueId());
|
|
||||||
projectilesShot.remove(player.getUniqueId());
|
|
||||||
if (time < magic.PROJECTILE_TIME_MIN()) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " wound up a bow too fast (actual time=" + time + ", min time=" + magic.PROJECTILE_TIME_MIN() + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkFastDrop(Player player) {
|
|
||||||
incrementOld(player, blocksDropped, 10);
|
|
||||||
if (!blockTime.containsKey(player.getUniqueId())) {
|
|
||||||
blockTime.put(player.getUniqueId(), System.currentTimeMillis());
|
|
||||||
return new CheckResult(CheckResult.Result.PASSED);
|
|
||||||
} else if (blocksDropped.get(player.getUniqueId()) == magic.DROP_CHECK()) {
|
|
||||||
long time = System.currentTimeMillis() - blockTime.get(player.getUniqueId());
|
|
||||||
blockTime.remove(player.getUniqueId());
|
|
||||||
blocksDropped.remove(player.getUniqueId());
|
|
||||||
if (time < magic.DROP_TIME_MIN()) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " dropped an item too fast (actual time=" + time + ", min time=" + magic.DROP_TIME_MIN() + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkLongReachBlock(Player player, double x, double y, double z) {
|
|
||||||
if (isInstantBreakExempt(player)) {
|
|
||||||
return new CheckResult(CheckResult.Result.PASSED);
|
|
||||||
} else {
|
|
||||||
String string = player.getName() + " reached too far for a block";
|
|
||||||
double distance =
|
|
||||||
player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
|
||||||
: player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
|
||||||
: magic.BLOCK_MAX_DISTANCE();
|
|
||||||
double i = x >= distance ? x : y > distance ? y : z > distance ? z : -1;
|
|
||||||
if (i != -1) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, string + " (distance=" + i + ", max=" + magic.BLOCK_MAX_DISTANCE() + ")");
|
|
||||||
} else {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkLongReachDamage(Player player, double x, double y, double z) {
|
|
||||||
String string = player.getName() + " 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;
|
|
||||||
if (i != -1) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, string + " (distance=" + i + ", max=" + magic.ENTITY_MAX_DISTANCE() + ")");
|
|
||||||
} else {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkSpider(Player player, double y) {
|
|
||||||
if (y <= magic.LADDER_Y_MAX() && y >= magic.LADDER_Y_MIN() && !Utilities.isClimbableBlock(player.getLocation().getBlock())) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to climb a non-ladder (" + player.getLocation().getBlock().getType() + ")");
|
|
||||||
} else {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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)) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + "'s y speed was too high (speed=" + y + ", max=" + magic.Y_SPEED_MAX() + ")");
|
|
||||||
} else {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkNoFall(Player player, double y) {
|
|
||||||
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.getFallDistance() == 0) {
|
|
||||||
if (nofallViolation.get(uuid) == null) {
|
|
||||||
nofallViolation.put(uuid, 1);
|
|
||||||
} else {
|
|
||||||
nofallViolation.put(uuid, nofallViolation.get(player.getUniqueId()) + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int i = nofallViolation.get(uuid);
|
|
||||||
if (i >= magic.NOFALL_LIMIT()) {
|
|
||||||
nofallViolation.put(player.getUniqueId(), 1);
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to avoid fall damage (fall distance = 0 " + i + " times in a row, max=" + magic.NOFALL_LIMIT() + ")");
|
|
||||||
} else {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
nofallViolation.put(uuid, 0);
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkSneak(Player player, double x, double z) {
|
|
||||||
if (player.isSneaking() && !player.isFlying() && !isMovingExempt(player) && !player.isInsideVehicle()) {
|
|
||||||
double i = x > magic.XZ_SPEED_MAX_SNEAK() ? x : z > magic.XZ_SPEED_MAX_SNEAK() ? z : -1;
|
|
||||||
if (i != -1) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")");
|
|
||||||
} else {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkSprintHungry(PlayerToggleSprintEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (event.isSprinting() && player.getGameMode() != GameMode.CREATIVE && player.getFoodLevel() <= magic.SPRINT_FOOD_MIN()) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " sprinted while hungry (food=" + player.getFoodLevel() + ", min=" + magic.SPRINT_FOOD_MIN() + ")");
|
|
||||||
} else {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkSprintStill(Player player, Location from, Location to) {
|
|
||||||
/*if(!isMovingExempt(player) && player.isSprinting() && from.getX() == to.getX() && from.getZ() == to.getZ()) {
|
|
||||||
return new CheckResult(Result.FAILED, player.getName()+" sprinted while standing still (xyz = "+(int)from.getX()+","+(int)from.getY()+","+(int)from.getZ()+")");
|
|
||||||
}*/
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkVClip(Player player, Distance distance) {
|
|
||||||
double from = Math.round(distance.fromY());
|
|
||||||
double to = Math.round(distance.toY());
|
|
||||||
|
|
||||||
if (player.isInsideVehicle() || (from == to || from < to) || Math.round(distance.getYDifference()) < 2) {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
if (block.getType() != Material.AIR && block.getType().isSolid()) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to move through a solid block", (int) from + 3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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, player.getName() + " tried to alter their timer, took " + step + " steps in " + time + " ms (min = " + magic.TIMER_TIMEMIN() + " ms)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkSight(Player player, Entity entity) {
|
|
||||||
/*if (entity instanceof LivingEntity) {
|
|
||||||
LivingEntity le = (LivingEntity) entity;
|
|
||||||
// Check to make sure the entity's head is not surrounded
|
|
||||||
Block head = le.getWorld().getBlockAt((int) le.getLocation().getX(), (int) (le.getLocation().getY() + le.getEyeHeight()), (int) le.getLocation().getZ());
|
|
||||||
boolean solid = false;
|
|
||||||
// TODO: This sucks. See if it's possible to not have as many false-positives while still retaining most of the check.
|
|
||||||
for (int x = -2; x <= 2; x++) {
|
|
||||||
for (int z = -2; z <= 2; z++) {
|
|
||||||
for (int y = -1; y < 2; y++) {
|
|
||||||
if (head.getRelative(x, y, z).getTypeId() != 0) {
|
|
||||||
if (head.getRelative(x, y, z).getType().isSolid()) {
|
|
||||||
solid = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (solid) {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
// TODO: Needs proper testing
|
|
||||||
Location mobLocation = le.getEyeLocation();
|
|
||||||
for (Block block : player.getLineOfSight(transparent, 5)) {
|
|
||||||
if (Math.abs(block.getLocation().getX() - mobLocation.getX()) < 2.3 || Math.abs(block.getLocation().getZ() - mobLocation.getZ()) < 2.3) {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new CheckResult(Result.FAILED, player.getName()+" tried to damage an entity ("+le.getType()+") out of sight ");
|
|
||||||
}*/
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logAscension(Player player, double y1, double y2) {
|
|
||||||
UUID name = player.getUniqueId();
|
|
||||||
if (y1 < y2 && !isAscending.contains(name)) {
|
|
||||||
isAscending.add(name);
|
|
||||||
} else {
|
|
||||||
isAscending.remove(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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) && !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, player.getName() + " 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) {
|
|
||||||
UUID uuid = player.getUniqueId();
|
|
||||||
if (!isInstantBreakExempt(player)) {
|
|
||||||
if (!player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES)) {
|
|
||||||
if (blockPunches.get(uuid) != null && player.getGameMode() != GameMode.CREATIVE) {
|
|
||||||
int i = blockPunches.get(uuid);
|
|
||||||
if (i < magic.BLOCK_PUNCH_MIN()) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to break a block of " + block.getType() + " after only " + i + " punches (min=" + magic.BLOCK_PUNCH_MIN() + ")");
|
|
||||||
} else {
|
|
||||||
blockPunches.put(uuid, 0); // it should reset after EACH block break.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkFastBreak(Player player, Block block) {
|
|
||||||
int violations = magic.FASTBREAK_MAXVIOLATIONS();
|
|
||||||
long timemax = isInstantBreakExempt(player) ? 0 : Utilities.calcSurvivalFastBreak(player.getInventory().getItemInHand(), block.getType());
|
|
||||||
if (player.getGameMode() == GameMode.CREATIVE) {
|
|
||||||
violations = magic.FASTBREAK_MAXVIOLATIONS_CREATIVE();
|
|
||||||
timemax = magic.FASTBREAK_TIMEMAX_CREATIVE();
|
|
||||||
}
|
|
||||||
UUID uuid = player.getUniqueId();
|
|
||||||
if (!fastBreakViolation.containsKey(uuid)) {
|
|
||||||
fastBreakViolation.put(uuid, 0);
|
|
||||||
} else {
|
|
||||||
Long math = System.currentTimeMillis() - lastBlockBroken.get(uuid);
|
|
||||||
int i = fastBreakViolation.get(uuid);
|
|
||||||
if (i > violations && math < magic.FASTBREAK_MAXVIOLATIONTIME()) {
|
|
||||||
lastBlockBroken.put(uuid, System.currentTimeMillis());
|
|
||||||
if (!silentMode()) {
|
|
||||||
player.sendMessage(ChatColor.RED + "[AntiCheat] Fastbreaking detected. Please wait 10 seconds before breaking blocks.");
|
|
||||||
}
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " broke blocks too fast " + i + " times in a row (max=" + violations + ")");
|
|
||||||
} else if (fastBreakViolation.get(uuid) > 0 && math > magic.FASTBREAK_MAXVIOLATIONTIME()) {
|
|
||||||
fastBreakViolation.put(uuid, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!fastBreaks.containsKey(uuid) || !lastBlockBroken.containsKey(uuid)) {
|
|
||||||
if (!lastBlockBroken.containsKey(uuid)) {
|
|
||||||
lastBlockBroken.put(uuid, System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
if (!fastBreaks.containsKey(uuid)) {
|
|
||||||
fastBreaks.put(uuid, 0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Long math = System.currentTimeMillis() - lastBlockBroken.get(uuid);
|
|
||||||
if ((math != 0L && timemax != 0L)) {
|
|
||||||
if (math < timemax) {
|
|
||||||
if (fastBreakViolation.containsKey(uuid) && fastBreakViolation.get(uuid) > 0) {
|
|
||||||
fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) + 1);
|
|
||||||
} else {
|
|
||||||
fastBreaks.put(uuid, fastBreaks.get(uuid) + 1);
|
|
||||||
}
|
|
||||||
blockBreakHolder.put(uuid, false);
|
|
||||||
}
|
|
||||||
if (fastBreaks.get(uuid) >= magic.FASTBREAK_LIMIT() && math < timemax) {
|
|
||||||
int i = fastBreaks.get(uuid);
|
|
||||||
fastBreaks.put(uuid, 0);
|
|
||||||
fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) + 1);
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " 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) {
|
|
||||||
if (!blockBreakHolder.containsKey(uuid) || !blockBreakHolder.get(uuid)) {
|
|
||||||
blockBreakHolder.put(uuid, true);
|
|
||||||
} else {
|
|
||||||
fastBreaks.put(uuid, fastBreaks.get(uuid) - 1);
|
|
||||||
if (fastBreakViolation.get(uuid) > 0) {
|
|
||||||
fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) - 1);
|
|
||||||
}
|
|
||||||
blockBreakHolder.put(uuid, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lastBlockBroken.put(uuid, System.currentTimeMillis()); // always keep a log going.
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkFastPlace(Player player) {
|
|
||||||
int violations = player.getGameMode() == GameMode.CREATIVE ? magic.FASTPLACE_MAXVIOLATIONS_CREATIVE() : magic.FASTPLACE_MAXVIOLATIONS();
|
|
||||||
long time = System.currentTimeMillis();
|
|
||||||
UUID uuid = player.getUniqueId();
|
|
||||||
if (!lastBlockPlaceTime.containsKey(uuid) || !fastPlaceViolation.containsKey(uuid)) {
|
|
||||||
lastBlockPlaceTime.put(uuid, 0L);
|
|
||||||
if (!fastPlaceViolation.containsKey(uuid)) {
|
|
||||||
fastPlaceViolation.put(uuid, 0);
|
|
||||||
}
|
|
||||||
} else if (fastPlaceViolation.containsKey(uuid) && fastPlaceViolation.get(uuid) > violations) {
|
|
||||||
AntiCheat.debugLog("Noted that fastPlaceViolation contains key " + uuid + " with value " + fastPlaceViolation.get(uuid));
|
|
||||||
Long math = System.currentTimeMillis() - lastBlockPlaced.get(uuid);
|
|
||||||
AntiCheat.debugLog("Player lastBlockPlaced value = " + lastBlockPlaced + ", diff=" + math);
|
|
||||||
if (lastBlockPlaced.get(uuid) > 0 && math < magic.FASTPLACE_MAXVIOLATIONTIME()) {
|
|
||||||
lastBlockPlaced.put(uuid, time);
|
|
||||||
if (!silentMode()) {
|
|
||||||
player.sendMessage(ChatColor.RED + "[AntiCheat] Fastplacing detected. Please wait 10 seconds before placing blocks.");
|
|
||||||
}
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " placed blocks too fast " + fastBreakViolation.get(uuid) + " times in a row (max=" + violations + ")");
|
|
||||||
} else if (lastBlockPlaced.get(uuid) > 0 && math > magic.FASTPLACE_MAXVIOLATIONTIME()) {
|
|
||||||
AntiCheat.debugLog("Reset facePlaceViolation for " + uuid);
|
|
||||||
fastPlaceViolation.put(uuid, 0);
|
|
||||||
}
|
|
||||||
} else if (lastBlockPlaced.containsKey(uuid)) {
|
|
||||||
long last = lastBlockPlaced.get(uuid);
|
|
||||||
long lastTime = lastBlockPlaceTime.get(uuid);
|
|
||||||
long thisTime = time - last;
|
|
||||||
|
|
||||||
if (lastTime != 0 && thisTime < magic.FASTPLACE_TIMEMIN()) {
|
|
||||||
lastBlockPlaceTime.put(uuid, (time - last));
|
|
||||||
lastBlockPlaced.put(uuid, time);
|
|
||||||
fastPlaceViolation.put(uuid, fastPlaceViolation.get(uuid) + 1);
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to place a block " + thisTime + " ms after the last one (min=" + magic.FASTPLACE_TIMEMIN() + " ms)");
|
|
||||||
}
|
|
||||||
lastBlockPlaceTime.put(uuid, (time - last));
|
|
||||||
}
|
|
||||||
lastBlockPlaced.put(uuid, time);
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logBowWindUp(Player player) {
|
|
||||||
bowWindUp.put(player.getUniqueId(), System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logEatingStart(Player player) {
|
|
||||||
startEat.put(player.getUniqueId(), System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logHeal(Player player) {
|
|
||||||
lastHeal.put(player.getUniqueId(), System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkChatSpam(Player player, String msg) {
|
|
||||||
UUID uuid = player.getUniqueId();
|
|
||||||
User user = manager.getUserManager().getUser(uuid);
|
|
||||||
if (user.getLastMessageTime() != -1) {
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
String m = user.getMessage(i);
|
|
||||||
if (m == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Long l = user.getMessageTime(i);
|
|
||||||
|
|
||||||
if (System.currentTimeMillis() - l > magic.CHAT_REPEAT_MIN() * 100) {
|
|
||||||
user.clearMessages();
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
if (manager.getConfiguration().getConfig().blockChatSpamRepetition.getValue() && m.equalsIgnoreCase(msg) && i == 1) {
|
|
||||||
manager.getLoggingManager().logFineInfo(player.getName() + " spam-repeated \"" + msg + "\"");
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
|
||||||
} else if (manager.getConfiguration().getConfig().blockChatSpamSpeed.getValue() && System.currentTimeMillis() - user.getLastCommandTime() < magic.COMMAND_MIN() * 2) {
|
|
||||||
manager.getLoggingManager().logFineInfo(player.getName() + " spammed quickly \"" + msg + "\"");
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
user.addMessage(msg);
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkCommandSpam(Player player, String cmd) {
|
|
||||||
UUID uuid = player.getUniqueId();
|
|
||||||
User user = manager.getUserManager().getUser(uuid);
|
|
||||||
if (user.getLastCommandTime() != -1) {
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
String m = user.getCommand(i);
|
|
||||||
if (m == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Long l = user.getCommandTime(i);
|
|
||||||
|
|
||||||
if (System.currentTimeMillis() - l > magic.COMMAND_REPEAT_MIN() * 100) {
|
|
||||||
user.clearCommands();
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
if (manager.getConfiguration().getConfig().blockCommandSpamRepetition.getValue() && m.equalsIgnoreCase(cmd) && i == 1) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
|
||||||
} else if (manager.getConfiguration().getConfig().blockCommandSpamSpeed.getValue() && System.currentTimeMillis() - user.getLastCommandTime() < magic.COMMAND_MIN() * 2) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
user.addCommand(cmd);
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkInventoryClicks(Player player) {
|
|
||||||
if (player.getGameMode() == GameMode.CREATIVE) {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
UUID uuid = player.getUniqueId();
|
|
||||||
int clicks = 1;
|
|
||||||
if (inventoryClicks.containsKey(uuid)) {
|
|
||||||
clicks = inventoryClicks.get(uuid) + 1;
|
|
||||||
}
|
|
||||||
inventoryClicks.put(uuid, clicks);
|
|
||||||
if (clicks == 1) {
|
|
||||||
inventoryTime.put(uuid, System.currentTimeMillis());
|
|
||||||
} else if (clicks == magic.INVENTORY_CHECK()) {
|
|
||||||
long time = System.currentTimeMillis() - inventoryTime.get(uuid);
|
|
||||||
inventoryClicks.put(uuid, 0);
|
|
||||||
if (time < magic.INVENTORY_TIMEMIN()) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " clicked inventory slots " + clicks + " times in " + time + " ms (max=" + magic.INVENTORY_CHECK() + " in " + magic.INVENTORY_TIMEMIN() + " ms)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkAutoTool(Player player) {
|
|
||||||
if (itemInHand.containsKey(player.getUniqueId()) && itemInHand.get(player.getUniqueId()) != player.getItemInHand().getType()) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " switched tools too fast (had " + itemInHand.get(player.getName()) + ", has " + player.getItemInHand().getType() + ")");
|
|
||||||
} else {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkSprintDamage(Player player) {
|
|
||||||
if (isDoing(player, sprinted, magic.SPRINT_MIN())) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " sprinted and damaged an entity too fast (min sprint=" + magic.SPRINT_MIN() + " ms)");
|
|
||||||
} else {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkFastHeal(Player player) {
|
|
||||||
if (lastHeal.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it.
|
|
||||||
{
|
|
||||||
long l = lastHeal.get(player.getUniqueId());
|
|
||||||
lastHeal.remove(player.getUniqueId());
|
|
||||||
if ((System.currentTimeMillis() - l) < magic.HEAL_TIME_MIN()) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " healed too quickly (time=" + (System.currentTimeMillis() - l) + " ms, min=" + magic.HEAL_TIME_MIN() + " ms)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkFastEat(Player player) {
|
|
||||||
if (startEat.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it.
|
|
||||||
{
|
|
||||||
long l = startEat.get(player.getUniqueId());
|
|
||||||
startEat.remove(player.getUniqueId());
|
|
||||||
if ((System.currentTimeMillis() - l) < magic.EAT_TIME_MIN()) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " ate too quickly (time=" + (System.currentTimeMillis() - l) + " ms, min=" + magic.EAT_TIME_MIN() + " ms)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logInstantBreak(final Player player) {
|
|
||||||
instantBreakExempt.put(player.getUniqueId(), System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInstantBreakExempt(Player player) {
|
|
||||||
return isDoing(player, instantBreakExempt, magic.INSTANT_BREAK_TIME());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logSprint(final Player player) {
|
|
||||||
sprinted.put(player.getUniqueId(), System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isHoveringOverWaterAfterViolation(Player player) {
|
|
||||||
if (WaterWalkCheck.waterSpeedViolation.containsKey(player.getUniqueId())) {
|
|
||||||
if (WaterWalkCheck.waterSpeedViolation.get(player.getUniqueId()) >= magic.WATER_SPEED_VIOLATION_MAX() && Utilities.isHoveringOverWater(player.getLocation())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logBlockBreak(final Player player) {
|
|
||||||
brokenBlock.put(player.getUniqueId(), System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean justBroke(Player player) {
|
|
||||||
return isDoing(player, brokenBlock, magic.BLOCK_BREAK_MIN());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logVelocity(final Player player) {
|
|
||||||
velocitized.put(player.getUniqueId(), System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean justVelocity(Player player) {
|
|
||||||
return (velocitized.containsKey(player.getUniqueId()) ? (System.currentTimeMillis() - velocitized.get(player.getUniqueId())) < magic.VELOCITY_CHECKTIME() : false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean extendVelocityTime(final Player player) {
|
|
||||||
if (velocitytrack.containsKey(player.getUniqueId())) {
|
|
||||||
velocitytrack.put(player.getUniqueId(), velocitytrack.get(player.getUniqueId()) + 1);
|
|
||||||
if (velocitytrack.get(player.getUniqueId()) > magic.VELOCITY_MAXTIMES()) {
|
|
||||||
velocitized.put(player.getUniqueId(), System.currentTimeMillis() + magic.VELOCITY_PREVENT());
|
|
||||||
manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(manager.getPlugin(), new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
velocitytrack.put(player.getUniqueId(), 0);
|
|
||||||
}
|
|
||||||
}, magic.VELOCITY_SCHETIME() * 20L);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
velocitytrack.put(player.getUniqueId(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logBlockPlace(final Player player) {
|
|
||||||
placedBlock.put(player.getUniqueId(), System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean justPlaced(Player player) {
|
|
||||||
return isDoing(player, placedBlock, magic.BLOCK_PLACE_MIN());
|
|
||||||
}
|
|
||||||
public void logDamage(final Player player, int type) {
|
|
||||||
long time;
|
|
||||||
switch (type) {
|
|
||||||
case 1:
|
|
||||||
time = magic.DAMAGE_TIME();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
time = magic.KNOCKBACK_DAMAGE_TIME();
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
time = magic.EXPLOSION_DAMAGE_TIME();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
time = magic.DAMAGE_TIME();
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
FlightCheck.movingExempt.put(player.getUniqueId(), System.currentTimeMillis() + time);
|
|
||||||
// Only map in which termination time is calculated beforehand.
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logEnterExit(final Player player) {
|
|
||||||
FlightCheck.movingExempt.put(player.getUniqueId(), System.currentTimeMillis() + magic.ENTERED_EXITED_TIME());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logToggleSneak(final Player player) {
|
|
||||||
FlightCheck.movingExempt.put(player.getUniqueId(), System.currentTimeMillis() + magic.SNEAK_TIME());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logTeleport(final Player player) {
|
|
||||||
FlightCheck.movingExempt.put(player.getUniqueId(), System.currentTimeMillis() + magic.TELEPORT_TIME());
|
|
||||||
|
|
||||||
/* Data for fly/speed should be reset */
|
|
||||||
nofallViolation.remove(player.getUniqueId());
|
|
||||||
FlightCheck.blocksOverFlight.remove(player.getUniqueId());
|
|
||||||
YAxisCheck.yAxisViolations.remove(player.getUniqueId());
|
|
||||||
YAxisCheck.yAxisLastViolation.remove(player.getUniqueId());
|
|
||||||
YAxisCheck.lastYcoord.remove(player.getUniqueId());
|
|
||||||
YAxisCheck.lastYtime.remove(player.getUniqueId());
|
|
||||||
GlideCheck.lastYDelta.remove(player.getUniqueId());
|
|
||||||
GlideCheck.glideBuffer.remove(player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logExitFly(final Player player) {
|
|
||||||
FlightCheck.movingExempt.put(player.getUniqueId(), System.currentTimeMillis() + magic.EXIT_FLY_TIME());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logJoin(final Player player) {
|
|
||||||
FlightCheck.movingExempt.put(player.getUniqueId(), System.currentTimeMillis() + magic.JOIN_TIME());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMovingExempt(Player player) {
|
|
||||||
return isDoing(player, FlightCheck.movingExempt, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAscending(Player player) {
|
|
||||||
return isAscending.contains(player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isDoing(Player player, Map<UUID, Long> map, double max) {
|
|
||||||
if (map.containsKey(player.getUniqueId())) {
|
|
||||||
if (max != -1) {
|
|
||||||
if (((System.currentTimeMillis() - map.get(player.getUniqueId())) / 1000) > max) {
|
|
||||||
map.remove(player.getUniqueId());
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Termination time has already been calculated
|
|
||||||
if (map.get(player.getUniqueId()) < System.currentTimeMillis()) {
|
|
||||||
map.remove(player.getUniqueId());
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasJumpPotion(Player player) {
|
|
||||||
return player.hasPotionEffect(PotionEffectType.JUMP);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasSpeedPotion(Player player) {
|
|
||||||
return player.hasPotionEffect(PotionEffectType.SPEED);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void processChatSpammer(Player player) {
|
|
||||||
User user = manager.getUserManager().getUser(player.getUniqueId());
|
|
||||||
int level = chatLevel.containsKey(user.getUUID()) ? chatLevel.get(user.getUUID()) : 0;
|
|
||||||
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();
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void processCommandSpammer(Player player) {
|
|
||||||
User user = manager.getUserManager().getUser(player.getUniqueId());
|
|
||||||
int level = commandLevel.containsKey(user.getUUID()) ? commandLevel.get(user.getUUID()) : 0;
|
|
||||||
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();
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int increment(Player player, Map<UUID, Integer> ascensionCount2, int num) {
|
|
||||||
UUID name = player.getUniqueId();
|
|
||||||
if (ascensionCount2.get(name) == null) {
|
|
||||||
ascensionCount2.put(name, 1);
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
int amount = ascensionCount2.get(name) + 1;
|
|
||||||
if (amount < num + 1) {
|
|
||||||
ascensionCount2.put(name, amount);
|
|
||||||
return amount;
|
|
||||||
} else {
|
|
||||||
ascensionCount2.put(name, num);
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int incrementOld(Player player, Map<UUID, Integer> ascensionCount2, int num) {
|
|
||||||
UUID uuid = player.getUniqueId();
|
|
||||||
if (ascensionCount2.get(uuid) == null) {
|
|
||||||
ascensionCount2.put(uuid, 1);
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
int amount = ascensionCount2.get(uuid) + 1;
|
|
||||||
if (amount < num + 1) {
|
|
||||||
ascensionCount2.put(uuid, amount);
|
|
||||||
return amount;
|
|
||||||
} else {
|
|
||||||
ascensionCount2.put(uuid, num);
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean silentMode() {
|
|
||||||
return manager.getConfiguration().getConfig().silentMode.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package net.gravitydevelopment.anticheat.check.combat;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.event.EventListener;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
|
||||||
|
|
||||||
public class CriticalsCheck {
|
|
||||||
|
|
||||||
public static void doDamageEvent(EntityDamageByEntityEvent e, Player damager) {
|
|
||||||
if (!(e.getDamager() instanceof Player) || e.getCause() != DamageCause.ENTITY_ATTACK)
|
|
||||||
return;
|
|
||||||
Player p = (Player)e.getDamager();
|
|
||||||
if (isCritical(p)) {
|
|
||||||
if ((p.getLocation().getY() % 1.0 == 0 || p.getLocation().getY() % 0.5 == 0) && p.getLocation().clone().subtract(0, 1.0, 0).getBlock().getType().isSolid()) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed Criticals, tried to do a critical without needed conditions").getMessage(), p, CheckType.CRITICALS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isCritical(Player player) {
|
|
||||||
return player.getFallDistance() > 0.0f && !player.isOnGround() && !player.isInsideVehicle() && !player.hasPotionEffect(PotionEffectType.BLINDNESS) && !Utilities.isHoveringOverWater(player.getLocation()) && player.getEyeLocation().getBlock().getType() != Material.LADDER;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
package net.gravitydevelopment.anticheat.check.combat;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.events.ListenerPriority;
|
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.event.EventListener;
|
|
||||||
import net.gravitydevelopment.anticheat.util.NPC_1_10;
|
|
||||||
import net.gravitydevelopment.anticheat.util.VersionUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Rammelkast
|
|
||||||
*/
|
|
||||||
public class KillAuraCheck {
|
|
||||||
|
|
||||||
private static final Map<UUID, NPC_1_10> NPC_LIST = new HashMap<UUID, NPC_1_10>();
|
|
||||||
private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>();
|
|
||||||
|
|
||||||
public static void cleanPlayer(Player p) {
|
|
||||||
if (!VersionUtil.getVersion().equals("v1_10_R1")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
NPC_LIST.remove(p.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void listenPackets() {
|
|
||||||
if (!VersionUtil.getVersion().equals("v1_10_R1")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
AntiCheat.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheat.getPlugin(), ListenerPriority.NORMAL, new PacketType[] {PacketType.Play.Client.USE_ENTITY}) {
|
|
||||||
@Override
|
|
||||||
public void onPacketReceiving(PacketEvent e) {
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
if (!NPC_LIST.containsKey(p.getUniqueId()))
|
|
||||||
return;
|
|
||||||
int id = e.getPacket().getIntegers().read(0);
|
|
||||||
if (NPC_LIST.containsKey(p.getUniqueId())) {
|
|
||||||
if (NPC_LIST.get(p.getUniqueId()).getID() != id) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!VL_COUNT.containsKey(p.getUniqueId())) {
|
|
||||||
VL_COUNT.put(p.getUniqueId(), 1);
|
|
||||||
NPC_LIST.get(p.getUniqueId()).damage();
|
|
||||||
}else {
|
|
||||||
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
|
|
||||||
if (VL_COUNT.get(p.getUniqueId()) >= 5) {
|
|
||||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed KillAura (botcheck), hit the bot " + VL_COUNT.get(p.getUniqueId()) + " times (max=5)").getMessage(), p, CheckType.BLINK);
|
|
||||||
VL_COUNT.remove(p.getUniqueId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void doDamageEvent(EntityDamageByEntityEvent e, Player p) {
|
|
||||||
if (!VersionUtil.getVersion().equals("v1_10_R1")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (NPC_LIST.containsKey(p.getUniqueId()))
|
|
||||||
NPC_LIST.get(p.getUniqueId()).damage(e, p);
|
|
||||||
else {
|
|
||||||
NPC_1_10 npc = new NPC_1_10(p);
|
|
||||||
NPC_LIST.put(p.getUniqueId(), npc);
|
|
||||||
npc.spawn();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void doMove(PlayerMoveEvent e) {
|
|
||||||
if (!VersionUtil.getVersion().equals("v1_10_R1")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (NPC_LIST.containsKey(e.getPlayer().getUniqueId()))
|
|
||||||
NPC_LIST.get(e.getPlayer().getUniqueId()).move(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
package net.gravitydevelopment.anticheat.check.combat;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.event.EventListener;
|
|
||||||
|
|
||||||
public class VelocityCheck {
|
|
||||||
|
|
||||||
private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>();
|
|
||||||
|
|
||||||
public static void cleanPlayer(Player p) {
|
|
||||||
VL_COUNT.remove(p.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void runCheck(EntityDamageByEntityEvent e, final Player p) {
|
|
||||||
if (AntiCheat.getManager().getCheckManager().isOpExempt(p) || AntiCheat.getManager().getCheckManager().isExempt(p, CheckType.VELOCITY))
|
|
||||||
return;
|
|
||||||
final Location then = p.getLocation();
|
|
||||||
new BukkitRunnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!p.isOnline())
|
|
||||||
return;
|
|
||||||
if (then.distance(p.getLocation()) < 0.125) {
|
|
||||||
if (!VL_COUNT.containsKey(p.getUniqueId()))
|
|
||||||
VL_COUNT.put(p.getUniqueId(), 1);
|
|
||||||
else {
|
|
||||||
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
|
|
||||||
if (VL_COUNT.get(p.getUniqueId()) > AntiCheat.getManager().getBackend().getMagic().VELOCITY_AMT()) {
|
|
||||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed Velocity, had zero/low velocity " + VL_COUNT.get(p.getUniqueId()) + " times (max=" + AntiCheat.getManager().getBackend().getMagic().VELOCITY_AMT() + ")").getMessage(), p, CheckType.VELOCITY);
|
|
||||||
VL_COUNT.remove(p.getUniqueId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
VL_COUNT.remove(p.getUniqueId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTaskLater(AntiCheat.getPlugin(), 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
package net.gravitydevelopment.anticheat.check.movement;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.events.ListenerPriority;
|
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.event.EventListener;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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(AntiCheat.getPlugin(), 0, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void listenPackets() {
|
|
||||||
AntiCheat.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheat.getPlugin(), ListenerPriority.NORMAL, 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 (AntiCheat.getManager().getCheckManager().checkInWorld(p) && !AntiCheat.getManager().getCheckManager().isOpExempt(p) && !AntiCheat.getManager().getCheckManager().isExempt(p, CheckType.BLINK))
|
|
||||||
if (MOVE_COUNT.get(p.getUniqueId()) > AntiCheat.getManager().getBackend().getMagic().BLINK_PACKET()) {
|
|
||||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed Blink, sent " + MOVE_COUNT.get(p.getUniqueId()) + " packets in one second (max=" + AntiCheat.getManager().getBackend().getMagic().BLINK_PACKET() + ")").getMessage(), p, CheckType.BLINK);
|
|
||||||
MOVE_COUNT.remove(p.getUniqueId());
|
|
||||||
e.setCancelled(true);
|
|
||||||
e.getPlayer().teleport(cur);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
package net.gravitydevelopment.anticheat.check.movement;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Distance;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Marco
|
|
||||||
* TODO rewrite this check
|
|
||||||
*/
|
|
||||||
public class FlightCheck {
|
|
||||||
|
|
||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
|
||||||
|
|
||||||
public static Map<UUID, Double> blocksOverFlight = new HashMap<UUID, Double>();
|
|
||||||
public static Map<UUID, Long> movingExempt = new HashMap<UUID, Long>();
|
|
||||||
|
|
||||||
public static CheckResult runCheck(Player player, Distance distance) {
|
|
||||||
if (distance.getYDifference() > AntiCheat.getManager().getBackend().getMagic().TELEPORT_MIN()) {
|
|
||||||
// This was a teleport, so we don't care about it.
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
final UUID uuid = player.getUniqueId();
|
|
||||||
final double y1 = distance.fromY();
|
|
||||||
final double y2 = distance.toY();
|
|
||||||
if (!isMovingExempt(player) && !Utilities.isHoveringOverWater(player.getLocation(), 1) && Utilities.cantStandAtExp(player.getLocation()) && Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN), new Material[]{Material.FENCE, Material.FENCE_GATE, Material.COBBLE_WALL})) {
|
|
||||||
|
|
||||||
if (!blocksOverFlight.containsKey(uuid)) {
|
|
||||||
blocksOverFlight.put(uuid, 0D);
|
|
||||||
}
|
|
||||||
|
|
||||||
blocksOverFlight.put(uuid, (blocksOverFlight.get(uuid) + distance.getXDifference() + distance.getYDifference() + distance.getZDifference()));
|
|
||||||
|
|
||||||
if (y1 > y2) {
|
|
||||||
blocksOverFlight.put(uuid, (blocksOverFlight.get(uuid) - distance.getYDifference()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blocksOverFlight.get(uuid) > AntiCheat.getManager().getBackend().getMagic().FLIGHT_BLOCK_LIMIT() && (y1 <= y2)) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " flew over " + blocksOverFlight.get(uuid) + " blocks (max=" + AntiCheat.getManager().getBackend().getMagic().FLIGHT_BLOCK_LIMIT() + ")");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
blocksOverFlight.put(uuid, 0D);
|
|
||||||
}
|
|
||||||
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isMovingExempt(Player player) {
|
|
||||||
return isDoing(player, movingExempt, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isDoing(Player player, Map<UUID, Long> map, double max) {
|
|
||||||
if (map.containsKey(player.getUniqueId())) {
|
|
||||||
if (max != -1) {
|
|
||||||
if (((System.currentTimeMillis() - map.get(player.getUniqueId())) / 1000) > max) {
|
|
||||||
map.remove(player.getUniqueId());
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Termination time has already been calculated
|
|
||||||
if (map.get(player.getUniqueId()) < System.currentTimeMillis()) {
|
|
||||||
map.remove(player.getUniqueId());
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
package net.gravitydevelopment.anticheat.check.movement;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Distance;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Marco STILL IN ALPHA TESTING!
|
|
||||||
* TODO fix false positives
|
|
||||||
*/
|
|
||||||
public class GlideCheck {
|
|
||||||
|
|
||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
|
||||||
|
|
||||||
public static Map<String, Double> lastYDelta = new HashMap<String, Double>();
|
|
||||||
public static Map<String, Integer> glideBuffer = new HashMap<String, Integer>();
|
|
||||||
|
|
||||||
public static CheckResult runCheck(Player player, Distance distance) {
|
|
||||||
String name = player.getName();
|
|
||||||
if(!lastYDelta.containsKey(name))
|
|
||||||
lastYDelta.put(name, 0.0);
|
|
||||||
if(!YAxisCheck.lastYcoord.containsKey(name))
|
|
||||||
YAxisCheck.lastYcoord.put(name, player.getLocation().getY());
|
|
||||||
double currentY = player.getLocation().getY();
|
|
||||||
double math = currentY - YAxisCheck.lastYcoord.get(name);
|
|
||||||
if((math < 0 && math > AntiCheat.getManager().getBackend().getMagic().GLIDE_MAX()) && !AntiCheat.getManager().getBackend().isMovingExempt(player))
|
|
||||||
{
|
|
||||||
if(math <= lastYDelta.get(name) && !(player.getEyeLocation().getBlock().getType() == Material.LADDER)
|
|
||||||
&& !Utilities.isInWater(player) && !Utilities.isInWeb(player)
|
|
||||||
&& Utilities.cantStandAt(player.getLocation().getBlock()) && !Utilities.cantStandAtSingle(player.getLocation().getBlock()) && !!Utilities.cantStandAtSingle(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))
|
|
||||||
{
|
|
||||||
if(!glideBuffer.containsKey(name))
|
|
||||||
glideBuffer.put(name, 0);
|
|
||||||
int currentBuffer = glideBuffer.get(name);
|
|
||||||
glideBuffer.put(name, currentBuffer + 1);
|
|
||||||
if(currentBuffer >= AntiCheat.getManager().getBackend().getMagic().GLIDE_LIMIT())
|
|
||||||
{
|
|
||||||
double fallDist = distanceToFall(player.getLocation());
|
|
||||||
player.teleport(player.getLocation().add(0, -fallDist, 0));
|
|
||||||
player.setFallDistance((float) fallDist);
|
|
||||||
if(!AntiCheat.getManager().getBackend().silentMode())
|
|
||||||
{
|
|
||||||
player.sendMessage(ChatColor.RED + "[AntiCheat] Glide/Fly hacking detected.");
|
|
||||||
}
|
|
||||||
lastYDelta.put(name, math);
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, name + " attempted to fall too slowly!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
glideBuffer.remove(name);
|
|
||||||
}
|
|
||||||
lastYDelta.put(name, math);
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static double distanceToFall(Location location) {
|
|
||||||
double firstY = location.getY();
|
|
||||||
while (location.clone().add(0, -0.1, 0).getBlock().getType() == Material.AIR)
|
|
||||||
location.add(0, -0.1, 0);
|
|
||||||
return firstY - location.getY();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
package net.gravitydevelopment.anticheat.check.movement;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
|
||||||
import net.gravitydevelopment.anticheat.util.VersionUtil;
|
|
||||||
|
|
||||||
public class SpeedCheck {
|
|
||||||
|
|
||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
|
||||||
public static Map<UUID, Integer> speedViolation = new HashMap<UUID, Integer>();
|
|
||||||
|
|
||||||
public static boolean isSpeedExempt(Player player) {
|
|
||||||
return AntiCheat.getManager().getBackend().isMovingExempt(player)
|
|
||||||
|| AntiCheat.getManager().getBackend().justVelocity(player) || VersionUtil.isFlying(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CheckResult checkXZSpeed(Player player, double x, double z) {
|
|
||||||
if (!isSpeedExempt(player) && player.getVehicle() == null) {
|
|
||||||
String reason = "";
|
|
||||||
double max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX();
|
|
||||||
if (player.getLocation().getBlock().getType() == Material.SOUL_SAND) {
|
|
||||||
if (player.isSprinting()) {
|
|
||||||
reason = "on soulsand while sprinting ";
|
|
||||||
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND_SPRINT();
|
|
||||||
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
|
|
||||||
reason = "on soulsand with speed potion ";
|
|
||||||
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND_POTION();
|
|
||||||
} else {
|
|
||||||
reason = "on soulsand ";
|
|
||||||
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND();
|
|
||||||
}
|
|
||||||
} else if (player.isFlying()) {
|
|
||||||
reason = "while flying ";
|
|
||||||
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_FLY();
|
|
||||||
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
|
|
||||||
if (player.isSprinting()) {
|
|
||||||
reason = "with speed potion while sprinting ";
|
|
||||||
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_POTION_SPRINT();
|
|
||||||
} else {
|
|
||||||
reason = "with speed potion ";
|
|
||||||
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_POTION();
|
|
||||||
}
|
|
||||||
} else if (player.isSprinting()) {
|
|
||||||
reason = "while sprinting ";
|
|
||||||
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT();
|
|
||||||
}
|
|
||||||
|
|
||||||
float speed = player.getWalkSpeed();
|
|
||||||
max += speed > 0 ? player.getWalkSpeed() - 0.2f : 0;
|
|
||||||
|
|
||||||
if (x > max || z > max) {
|
|
||||||
int num = AntiCheat.getManager().getBackend().increment(player, speedViolation,
|
|
||||||
AntiCheat.getManager().getBackend().getMagic().SPEED_MAX());
|
|
||||||
if (num >= AntiCheat.getManager().getBackend().getMagic().SPEED_MAX()) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED,
|
|
||||||
player.getName() + "'s speed was too high " + reason + num + " times in a row (max="
|
|
||||||
+ AntiCheat.getManager().getBackend().getMagic().SPEED_MAX() + ", speed="
|
|
||||||
+ (x > z ? x : z) + ", max speed=" + max + ")");
|
|
||||||
} else {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
speedViolation.put(player.getUniqueId(), 0);
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
package net.gravitydevelopment.anticheat.check.movement;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This check seems to be broken/outdated
|
|
||||||
*/
|
|
||||||
public class WaterWalkCheck {
|
|
||||||
|
|
||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
|
||||||
|
|
||||||
public static List<String> isInWater = new ArrayList<String>();
|
|
||||||
public static List<String> isInWaterCache = new ArrayList<String>();
|
|
||||||
public static Map<String, Integer> waterSpeedViolation = new HashMap<String, Integer>();
|
|
||||||
public static Map<String, Integer> waterAscensionViolation = new HashMap<String, Integer>();
|
|
||||||
|
|
||||||
public static CheckResult runCheck(Player player, double x, double y, double z) {
|
|
||||||
Block block = player.getLocation().getBlock();
|
|
||||||
|
|
||||||
if (player.getVehicle() == null && !player.isFlying()) {
|
|
||||||
if (block.isLiquid()) {
|
|
||||||
if (isInWater.contains(player.getName())) {
|
|
||||||
if (isInWaterCache.contains(player.getName())) {
|
|
||||||
if (player.getNearbyEntities(1, 1, 1).isEmpty()) {
|
|
||||||
boolean b;
|
|
||||||
if (!Utilities.sprintFly(player)) {
|
|
||||||
b = x > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER() || z > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER();
|
|
||||||
} else {
|
|
||||||
b = x > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER_SPRINT() || z > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER_SPRINT();
|
|
||||||
}
|
|
||||||
if (!b && !Utilities.isFullyInWater(player.getLocation()) && Utilities.isHoveringOverWater(player.getLocation(), 1) && y == 0D && !block.getType().equals(Material.WATER_LILY)) {
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
if (b) {
|
|
||||||
if (waterSpeedViolation.containsKey(player.getName())) {
|
|
||||||
int v = waterSpeedViolation.get(player.getName());
|
|
||||||
if (v >= AntiCheat.getManager().getBackend().getMagic().WATER_SPEED_VIOLATION_MAX()) {
|
|
||||||
waterSpeedViolation.put(player.getName(), 0);
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " stood on water " + v + " times (can't stand on " + block.getType() + " or " + block.getRelative(BlockFace.DOWN).getType() + ")");
|
|
||||||
} else {
|
|
||||||
waterSpeedViolation.put(player.getName(), v + 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
waterSpeedViolation.put(player.getName(), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
isInWaterCache.add(player.getName());
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
isInWater.add(player.getName());
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
} else if (block.getRelative(BlockFace.DOWN).isLiquid() && !AntiCheat.getManager().getBackend().isAscending(player) && Utilities.cantStandAt(block) && Utilities.cantStandAt(block.getRelative(BlockFace.DOWN))) {
|
|
||||||
if (waterAscensionViolation.containsKey(player.getName())) {
|
|
||||||
int v = waterAscensionViolation.get(player.getName());
|
|
||||||
if (v >= AntiCheat.getManager().getBackend().getMagic().WATER_ASCENSION_VIOLATION_MAX()) {
|
|
||||||
waterAscensionViolation.put(player.getName(), 0);
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " stood on water " + v + " times (can't stand on " + block.getType() + " or " + block.getRelative(BlockFace.DOWN).getType() + ")");
|
|
||||||
} else {
|
|
||||||
waterAscensionViolation.put(player.getName(), v + 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
waterAscensionViolation.put(player.getName(), 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
isInWater.remove(player.getName());
|
|
||||||
isInWaterCache.remove(player.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
package net.gravitydevelopment.anticheat.check.movement;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Distance;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
|
||||||
import net.gravitydevelopment.anticheat.util.VersionUtil;
|
|
||||||
|
|
||||||
public class YAxisCheck {
|
|
||||||
|
|
||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
|
||||||
|
|
||||||
public static Map<String, Double> lastYcoord = new HashMap<String, Double>();
|
|
||||||
public static Map<String, Long> lastYtime = new HashMap<String, Long>();
|
|
||||||
public static Map<String, Integer> yAxisViolations = new HashMap<String, Integer>();
|
|
||||||
public static Map<String, Long> yAxisLastViolation = new HashMap<String, Long>();
|
|
||||||
|
|
||||||
private static boolean hasJumpPotion(Player player) {
|
|
||||||
return player.hasPotionEffect(PotionEffectType.JUMP);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CheckResult runCheck(Player player, Distance distance) {
|
|
||||||
if (distance.getYDifference() > AntiCheat.getManager().getBackend().getMagic().TELEPORT_MIN() || distance.getYDifference() < 0 || VersionUtil.isFlying(player)) {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
if (!FlightCheck.isMovingExempt(player) && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && !Utilities.isClimbableBlock(player.getLocation().add(0, -1, 0).getBlock()) && !player.isInsideVehicle() && !Utilities.isInWater(player) && !hasJumpPotion(player) && !isMoveUpBlock(player.getLocation().add(0, -1, 0).getBlock()) && !isMoveUpBlock(player.getLocation().add(0, -1.5, 0).getBlock())) {
|
|
||||||
double y1 = player.getLocation().getY();
|
|
||||||
String name = player.getName();
|
|
||||||
// Fix Y axis spam.
|
|
||||||
if (!lastYcoord.containsKey(name) || !lastYtime.containsKey(name) || !yAxisLastViolation.containsKey(name) || !yAxisLastViolation.containsKey(name)) {
|
|
||||||
lastYcoord.put(name, y1);
|
|
||||||
yAxisViolations.put(name, 0);
|
|
||||||
yAxisLastViolation.put(name, 0L);
|
|
||||||
lastYtime.put(name, System.currentTimeMillis());
|
|
||||||
} else {
|
|
||||||
if (y1 > lastYcoord.get(name) && yAxisViolations.get(name) > AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOLATIONS() && (System.currentTimeMillis() - yAxisLastViolation.get(name)) < AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOTIME()) {
|
|
||||||
Location g = player.getLocation();
|
|
||||||
yAxisViolations.put(name, yAxisViolations.get(name) + 1);
|
|
||||||
yAxisLastViolation.put(name, System.currentTimeMillis());
|
|
||||||
if (!AntiCheat.getManager().getBackend().silentMode()) {
|
|
||||||
g.setY(lastYcoord.get(name));
|
|
||||||
player.sendMessage(ChatColor.RED + "[AntiCheat] Fly hacking on the y-axis detected. Please wait 5 seconds to prevent getting damage.");
|
|
||||||
if (g.getBlock().getType() == Material.AIR) {
|
|
||||||
player.teleport(g);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to fly on y-axis " + yAxisViolations.get(name) + " times (max =" + AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOLATIONS() + ")");
|
|
||||||
} else {
|
|
||||||
if (yAxisViolations.get(name) > AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOLATIONS() && (System.currentTimeMillis() - yAxisLastViolation.get(name)) > AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOTIME()) {
|
|
||||||
yAxisViolations.put(name, 0);
|
|
||||||
yAxisLastViolation.put(name, 0L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
long i = System.currentTimeMillis() - lastYtime.get(name);
|
|
||||||
double diff = AntiCheat.getManager().getBackend().getMagic().Y_MAXDIFF() + (Utilities.isStair(player.getLocation().add(0, -1, 0).getBlock()) ? 0.5 : 0.0);
|
|
||||||
if ((y1 - lastYcoord.get(name)) > diff && i < AntiCheat.getManager().getBackend().getMagic().Y_TIME()) {
|
|
||||||
Location g = player.getLocation();
|
|
||||||
yAxisViolations.put(name, yAxisViolations.get(name) + 1);
|
|
||||||
yAxisLastViolation.put(name, System.currentTimeMillis());
|
|
||||||
if (!AntiCheat.getManager().getBackend().silentMode()) {
|
|
||||||
g.setY(lastYcoord.get(name));
|
|
||||||
if (g.getBlock().getType() == Material.AIR) {
|
|
||||||
player.teleport(g);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to fly on y-axis in " + i + " ms (min =" + AntiCheat.getManager().getBackend().getMagic().Y_TIME() + ")");
|
|
||||||
} else {
|
|
||||||
if ((y1 - lastYcoord.get(name)) > AntiCheat.getManager().getBackend().getMagic().Y_MAXDIFF() + 1 || (System.currentTimeMillis() - lastYtime.get(name)) > AntiCheat.getManager().getBackend().getMagic().Y_TIME()) {
|
|
||||||
lastYtime.put(name, System.currentTimeMillis());
|
|
||||||
lastYcoord.put(name, y1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Fix Y axis spam
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isMoveUpBlock(Block block) {
|
|
||||||
return MOVE_UP_BLOCKS.contains(block.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final EnumSet<Material> MOVE_UP_BLOCKS = EnumSet.of(
|
|
||||||
Material.ACACIA_STAIRS,
|
|
||||||
Material.BIRCH_WOOD_STAIRS,
|
|
||||||
Material.BRICK_STAIRS,
|
|
||||||
Material.COBBLESTONE_STAIRS,
|
|
||||||
Material.DARK_OAK_STAIRS,
|
|
||||||
Material.JUNGLE_WOOD_STAIRS,
|
|
||||||
Material.NETHER_BRICK_STAIRS,
|
|
||||||
Material.QUARTZ_STAIRS,
|
|
||||||
Material.RED_SANDSTONE_STAIRS,
|
|
||||||
Material.SANDSTONE_STAIRS,
|
|
||||||
Material.SMOOTH_STAIRS,
|
|
||||||
Material.SPRUCE_WOOD_STAIRS,
|
|
||||||
Material.WOOD_STAIRS,
|
|
||||||
Material.PURPUR_STAIRS
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
/*
|
|
||||||
* AntiCheat for Bukkit.
|
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
|
||||||
*
|
|
||||||
* 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 net.gravitydevelopment.anticheat.command.executors;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.command.CommandBase;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Permission;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CommandCheck extends CommandBase {
|
|
||||||
|
|
||||||
private static final String NAME = "AntiCheat Check Management";
|
|
||||||
private static final String COMMAND = "check";
|
|
||||||
private static final String USAGE = "anticheat check [check] [on/off]";
|
|
||||||
private static final Permission PERMISSION = Permission.SYSTEM_CHECK;
|
|
||||||
private static final String[] HELP = new String[3];
|
|
||||||
|
|
||||||
static {
|
|
||||||
HELP[0] = GRAY + "Use: " + AQUA + "/anticheat check [check] on" + GRAY + " to enable a check";
|
|
||||||
HELP[1] = GRAY + "Use: " + AQUA + "/anticheat check [check] off" + GRAY + " to disable a check";
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append(GRAY + "Checks: ");
|
|
||||||
for (int i=0;i<CheckType.values().length;i++) {
|
|
||||||
builder.append(CheckType.values()[i]);
|
|
||||||
if (i<CheckType.values().length-1) {
|
|
||||||
builder.append(", ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HELP[2] = builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CommandCheck() {
|
|
||||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void execute(CommandSender cs, String[] args) {
|
|
||||||
if (args.length == 2) {
|
|
||||||
for (CheckType type : CheckType.values()) {
|
|
||||||
if (type.toString().equalsIgnoreCase(args[0]) || type.toString().replaceAll("_", "").equalsIgnoreCase(args[0])) {
|
|
||||||
boolean value = CHECK_MANAGER.isActive(type);
|
|
||||||
|
|
||||||
boolean newValue;
|
|
||||||
if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("enable")) {
|
|
||||||
newValue = true;
|
|
||||||
} else if (args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("disable")) {
|
|
||||||
newValue = false;
|
|
||||||
} else {
|
|
||||||
sendHelp(cs);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String strValue = (newValue ? " activated" : " deactivated");
|
|
||||||
if (value == newValue) {
|
|
||||||
cs.sendMessage(GREEN + type.toString() + " is already" + strValue + "!");
|
|
||||||
} else {
|
|
||||||
if (newValue) {
|
|
||||||
CHECK_MANAGER.activateCheck(type, cs.getName());
|
|
||||||
List<String> checks = CONFIG.getConfig().disabledChecks.getValue();
|
|
||||||
if (checks.contains(type.toString())) {
|
|
||||||
checks.remove(type.toString());
|
|
||||||
CONFIG.getConfig().disabledChecks.setValue(checks);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
CHECK_MANAGER.deactivateCheck(type, cs.getName());
|
|
||||||
List<String> checks = CONFIG.getConfig().disabledChecks.getValue();
|
|
||||||
checks.add(type.toString());
|
|
||||||
CONFIG.getConfig().disabledChecks.setValue(checks);
|
|
||||||
}
|
|
||||||
cs.sendMessage(GREEN + type.toString() + strValue + ".");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sendHelp(cs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* AntiCheat for Bukkit.
|
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
|
||||||
*
|
|
||||||
* 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 net.gravitydevelopment.anticheat.command.executors;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.command.CommandBase;
|
|
||||||
import net.gravitydevelopment.anticheat.util.PastebinReport;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Permission;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class CommandDebug extends CommandBase {
|
|
||||||
|
|
||||||
private static final String NAME = "AntiCheat Debug Reporting";
|
|
||||||
private static final String COMMAND = "debug";
|
|
||||||
private static final String USAGE = "anticheat debug <user>";
|
|
||||||
private static final Permission PERMISSION = Permission.SYSTEM_DEBUG;
|
|
||||||
private static final String[] HELP = {
|
|
||||||
GRAY + "Use: " + AQUA + "/anticheat debug" + GRAY + " to create a debug report",
|
|
||||||
GRAY + "Use: " + AQUA + "/anticheat debug <user>" + GRAY + " to create a debug report for a user",
|
|
||||||
};
|
|
||||||
|
|
||||||
public CommandDebug() {
|
|
||||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void execute(CommandSender cs, String[] args) {
|
|
||||||
Player player = null;
|
|
||||||
if (args.length == 1) {
|
|
||||||
player = Bukkit.getPlayer(args[0]);
|
|
||||||
} else {
|
|
||||||
if (cs instanceof Player) {
|
|
||||||
player = (Player) cs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cs.sendMessage(GRAY + "Please wait while I collect some data...");
|
|
||||||
PastebinReport report = new PastebinReport(cs, player);
|
|
||||||
cs.sendMessage(GREEN + "Debug information posted to: " + WHITE + report.getURL());
|
|
||||||
cs.sendMessage(GREEN + "Please include this link when making bug reports.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-45
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* AntiCheat for Bukkit.
|
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
|
||||||
*
|
|
||||||
* 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 net.gravitydevelopment.anticheat.command.executors;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.command.CommandBase;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Permission;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
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) {
|
|
||||||
AntiCheat.setDeveloperMode(!AntiCheat.developerMode());
|
|
||||||
cs.sendMessage(GREEN + "Developer mode " + (AntiCheat.developerMode() ? "ON" : "OFF"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,388 +0,0 @@
|
|||||||
/*
|
|
||||||
* AntiCheat for Bukkit.
|
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
|
||||||
*
|
|
||||||
* 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 net.gravitydevelopment.anticheat.config.providers;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic number class. Modifications to values in magic.yml will be accepted here.
|
|
||||||
* <p/>
|
|
||||||
* Note that although each value is documented, changing it may have unintended side-effects. For instance, setting something to 0 that the plugin then uses as a dividend will result in an error. <br>
|
|
||||||
* Also realize that the smaller (more precise) a value is, the less you should change it; it's probably small for a reason. The larger a value is, the safer it is to make larger modifications to it.
|
|
||||||
* <p/>
|
|
||||||
* <b>How to read the value documentation:</b>
|
|
||||||
* <p/>
|
|
||||||
* First, you will see a description of the value. Then, you will see a type: <br>
|
|
||||||
* <b>Type SYSTEM:</b> This is a millisecond value used to compare past and future events with the current SYSTEM time. Remember, 1000 ms = 1 second. <br>
|
|
||||||
* <b>Type INTEGER:</b> This is a regular number. It's typically used as something trivial, such as how many times X event can occur. <br>
|
|
||||||
* <b>Type DOUBLE:</b> This is a number that has a decimal in it. It's typically used to evaluate speed or distance.
|
|
||||||
* <p/>
|
|
||||||
* After the type, you may see a recommendation labeled as 'Leniency'. This means 'In order to add leniency to this value, do X'<br>
|
|
||||||
* The suggestion for adding leniency will either be to INCREASE or DECREASE the variable. Doing what it suggests will cause the SYSTEM to not judge the people being checked so vigorously.<br>
|
|
||||||
* Some values may not have a leniency recommendation because they are internal numbers used for running checks. Values without these recommendations would be best left alone.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public interface Magic {
|
|
||||||
/**
|
|
||||||
* Time to exempt a player from moving because of entering/exiting a vehicle; Type=SYSTEM, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int ENTERED_EXITED_TIME();
|
|
||||||
/**
|
|
||||||
* Time to exempt a player from moving because of entering/exiting sneak mode; Type=SYSTEM, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int SNEAK_TIME();
|
|
||||||
/**
|
|
||||||
* Time to exempt a player from moving because of teleporting; Type=SYSTEM, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int TELEPORT_TIME();
|
|
||||||
/**
|
|
||||||
* Time to exempt a player from moving because of exiting fly mode; Type=SYSTEM, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int EXIT_FLY_TIME();
|
|
||||||
/**
|
|
||||||
* Time to exempt a player from moving because of joining the server; Type=SYSTEM, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int JOIN_TIME();
|
|
||||||
/**
|
|
||||||
* Time to exempt a player from fastbreak check because of using instant break; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int INSTANT_BREAK_TIME();
|
|
||||||
/**
|
|
||||||
* Time to exempt a player from moving because of taking damage; Type=SYSTEM, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int DAMAGE_TIME();
|
|
||||||
/**
|
|
||||||
* Time to exempt a player from moving because of taking damage with knockback effects; Type=SYSTEM, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int KNOCKBACK_DAMAGE_TIME();
|
|
||||||
/**
|
|
||||||
* Time to exempt a player from moving because of taking damage from an explosion; Type=SYSTEM, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int EXPLOSION_DAMAGE_TIME();
|
|
||||||
/**
|
|
||||||
* Minimum time it takes to fire X projectiles; Type=SYSTEM, Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public int PROJECTILE_TIME_MIN();
|
|
||||||
/**
|
|
||||||
* Number of projectiles to wait for before checking how long they took to fire off; Type=INTEGER.
|
|
||||||
*/
|
|
||||||
public int PROJECTILE_CHECK();
|
|
||||||
/**
|
|
||||||
* Minimum time it takes to drop X items; Type=SYSTEM, Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public int DROP_TIME_MIN();
|
|
||||||
/**
|
|
||||||
* Number of item drops to wait for before checking how long they took to drop; Type=INTEGER.
|
|
||||||
*/
|
|
||||||
public int DROP_CHECK();
|
|
||||||
/**
|
|
||||||
* Max number of blocks that can be broken in a given time; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int FASTBREAK_LIMIT();
|
|
||||||
/**
|
|
||||||
* Time to wait before checking block breaks; Type=SYSTEM, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int FASTBREAK_TIMEMAX();
|
|
||||||
/**
|
|
||||||
* Time to wait before checking block breaks in creative mode; Type=SYSTEM, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int FASTBREAK_TIMEMAX_CREATIVE();
|
|
||||||
/**
|
|
||||||
* Number of times fastbreak can be observed before taking action; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int FASTBREAK_MAXVIOLATIONS();
|
|
||||||
/**
|
|
||||||
* Number of times fastbreak can be observed before taking action in creative mode; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int FASTBREAK_MAXVIOLATIONS_CREATIVE();
|
|
||||||
/**
|
|
||||||
* Time a player is forced to wait after fastbreak has been detected; Type=SYSTEM, Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public int FASTBREAK_MAXVIOLATIONTIME();
|
|
||||||
/**
|
|
||||||
* Number of blocks that can be broken without being hit before taking action; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int FASTPLACE_ZEROLIMIT();
|
|
||||||
/**
|
|
||||||
* Minimum time in between block places; Type=SYSTEM, Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public int FASTPLACE_TIMEMIN();
|
|
||||||
/**
|
|
||||||
* Number of times fastplace can be observed before taking action; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int FASTPLACE_MAXVIOLATIONS();
|
|
||||||
/**
|
|
||||||
* Number of times fastplace can be observed before taking action in creative mode; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int FASTPLACE_MAXVIOLATIONS_CREATIVE();
|
|
||||||
/**
|
|
||||||
* Time a player is forced to wait after fastplace has been detected; Type=SYSTEM, Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public int FASTPLACE_MAXVIOLATIONTIME();
|
|
||||||
/**
|
|
||||||
* Number of times required to punch a block before it breaks; Type=INTEGER, Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public int BLOCK_PUNCH_MIN();
|
|
||||||
/**
|
|
||||||
* Number of command spam violations before action one is executed; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int COMMAND_ACTION_ONE_LEVEL();
|
|
||||||
/**
|
|
||||||
* Number of command spam violations before action two is executed; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int COMMAND_ACTION_TWO_LEVEL();
|
|
||||||
/**
|
|
||||||
* Number of chat spam violations before action one is executed; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int CHAT_ACTION_ONE_LEVEL();
|
|
||||||
/**
|
|
||||||
* Number of chat spam violations before action two is executed; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int CHAT_ACTION_TWO_LEVEL();
|
|
||||||
/**
|
|
||||||
* Number of times a player can be caught in-flight before action is taken; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int FLIGHT_LIMIT();
|
|
||||||
/**
|
|
||||||
* Number of times a player can be caught in-glide before action is taken; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int GLIDE_LIMIT();
|
|
||||||
/**
|
|
||||||
* The max fallspeed after which glide check is disabled; Type=DOUBLE
|
|
||||||
*/
|
|
||||||
public double GLIDE_MAX();
|
|
||||||
/**
|
|
||||||
* How many blocks you can travel before action is taken; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double FLIGHT_BLOCK_LIMIT();
|
|
||||||
/**
|
|
||||||
* Maximum speed that a player can climb a waterfall; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double WATER_CLIMB_MAX();
|
|
||||||
/**
|
|
||||||
* Number of times a player can fly on the y-axis before action is taken; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int Y_MAXVIOLATIONS();
|
|
||||||
/**
|
|
||||||
* Time a player is forced to wait after flying on the y-axis; Type=SYSTEM, Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public int Y_MAXVIOTIME();
|
|
||||||
/**
|
|
||||||
* Number of times a player can fail a velocity check before action is taken; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int VELOCITY_TIME();
|
|
||||||
/**
|
|
||||||
* Time used to schedule increasing a players velocity count - probably not touching this would be good; Type=INTEGER.
|
|
||||||
*/
|
|
||||||
public int VELOCITY_SCHETIME();
|
|
||||||
/**
|
|
||||||
* Maximum time a player is considered to have a change in velocity; Type=SYSTEM, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int VELOCITY_CHECKTIME();
|
|
||||||
/**
|
|
||||||
* Time to extend a player's velocity count by; Type=SYSTEM, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int VELOCITY_PREVENT();
|
|
||||||
/**
|
|
||||||
* Number of times a player can fail the velocity check before action is taken; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int VELOCITY_MAXTIMES();
|
|
||||||
/**
|
|
||||||
* Number of times a player can fail the nofall check before action is taken; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int NOFALL_LIMIT();
|
|
||||||
/**
|
|
||||||
* Number of times a player can fail the ascension check before action is taken; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int ASCENSION_COUNT_MAX();
|
|
||||||
/**
|
|
||||||
* Number of times a player can fail the ascension check while in water before action is taken; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int WATER_ASCENSION_VIOLATION_MAX();
|
|
||||||
/**
|
|
||||||
* Number of times a player can be caught speeding in water before action is taken; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int WATER_SPEED_VIOLATION_MAX();
|
|
||||||
/**
|
|
||||||
* Number of times a player can sprint without proper food level before action is taken; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int SPRINT_FOOD_MIN();
|
|
||||||
/**
|
|
||||||
* Maximum times a player can interact between animations; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int ANIMATION_INTERACT_MAX();
|
|
||||||
/**
|
|
||||||
* Minimum time between animations; Type=SYSTEM, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int ANIMATION_MIN();
|
|
||||||
/**
|
|
||||||
* Minimum time between commands; Type=SYSTEM, Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public int COMMAND_MIN();
|
|
||||||
/**
|
|
||||||
* Minimum time before repeating a command is ignored; Type=SYSTEM, Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public int COMMAND_REPEAT_MIN();
|
|
||||||
/**
|
|
||||||
* Minimum time between chats; Type=SYSTEM, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int CHAT_MIN();
|
|
||||||
/**
|
|
||||||
* Time before repeating yourself in chat is ignored; Type=SYSTEM, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int CHAT_REPEAT_MIN();
|
|
||||||
/**
|
|
||||||
* Maximum speed you can travel while sprinting; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double SPRINT_MIN();
|
|
||||||
/**
|
|
||||||
* Minimum time in between block breaks; Type=INTEGER, Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public double BLOCK_BREAK_MIN();
|
|
||||||
/**
|
|
||||||
* Minimum time in between block placing; Type=INTEGER, Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public double BLOCK_PLACE_MIN();
|
|
||||||
/**
|
|
||||||
* Minimum time in between healing; Type=SYSTEM, Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public int HEAL_TIME_MIN();
|
|
||||||
/**
|
|
||||||
* Minimum time in between eating; Type=SYSTEM, Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public int EAT_TIME_MIN();
|
|
||||||
/**
|
|
||||||
* Maximum percent error between predicted bow force and actual bow force; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double BOW_ERROR();
|
|
||||||
/**
|
|
||||||
* Minimum distance a player can break a block from; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double BLOCK_MAX_DISTANCE();
|
|
||||||
/**
|
|
||||||
* Minimum distance a player can break a block from in creative mode; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double BLOCK_MAX_DISTANCE_CREATIVE();
|
|
||||||
/**
|
|
||||||
* Minimum distance a player can damage an entity from; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double ENTITY_MAX_DISTANCE();
|
|
||||||
/**
|
|
||||||
* Minimum distance a player can damage an entity from in creative mode; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double ENTITY_MAX_DISTANCE_CREATIVE();
|
|
||||||
/**
|
|
||||||
* Maximum speed a player on a ladder can travel; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double LADDER_Y_MAX();
|
|
||||||
/**
|
|
||||||
* Minimum speed a player on a ladder can travel; Type=DOUBLE, Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public double LADDER_Y_MIN();
|
|
||||||
/**
|
|
||||||
* Maximum speed a player can travel up; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double Y_SPEED_MAX();
|
|
||||||
/**
|
|
||||||
* Maximum difference between the player's last 2 Y values when traveling up; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double Y_MAXDIFF();
|
|
||||||
/**
|
|
||||||
* Time in between Y difference measures; Type=SYSTEM, Leniency=DECREASE.
|
|
||||||
*/
|
|
||||||
public int Y_TIME();
|
|
||||||
/**
|
|
||||||
* Maximum speed a player can travel forwards or backwards; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double XZ_SPEED_MAX();
|
|
||||||
/**
|
|
||||||
* Maximum speed a player can travel forwards or backwards while sprinting; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double XZ_SPEED_MAX_SPRINT();
|
|
||||||
/**
|
|
||||||
* Maximum speed a player can travel forwards or backwards while flying; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double XZ_SPEED_MAX_FLY();
|
|
||||||
/**
|
|
||||||
* Maximum speed a player can travel forwards or backwards while under the influence; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double XZ_SPEED_MAX_POTION();
|
|
||||||
/**
|
|
||||||
* Maximum speed a player can travel forwards or backwards while sprinting while under the influence; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double XZ_SPEED_MAX_POTION_SPRINT();
|
|
||||||
/**
|
|
||||||
* Maximum speed a player can travel forwards or backwards while sneaking; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double XZ_SPEED_MAX_SNEAK();
|
|
||||||
/**
|
|
||||||
* Maximum speed a player can travel forwards or backwards in water; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double XZ_SPEED_MAX_WATER();
|
|
||||||
/**
|
|
||||||
* Maximum speed a player can travel forwards or backwards in water while sprinting; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double XZ_SPEED_MAX_WATER_SPRINT();
|
|
||||||
/**
|
|
||||||
* Maximum speed a player can travel forwards or backwards on soul sand; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double XZ_SPEED_MAX_SOULSAND();
|
|
||||||
/**
|
|
||||||
* Maximum speed a player can travel forwards or backwards on soul sand while sprinting; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double XZ_SPEED_MAX_SOULSAND_SPRINT();
|
|
||||||
/**
|
|
||||||
* Maximum speed a player can travel forwards or backwards on soul sand while under the influence; Type=DOUBLE, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public double XZ_SPEED_MAX_SOULSAND_POTION();
|
|
||||||
/**
|
|
||||||
* Maximum times a player can fail the speed check before action is taken; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int SPEED_MAX();
|
|
||||||
/**
|
|
||||||
* The number of clicks we should wait before checking if the player has used fast inventory; Type=INTEGER; Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int INVENTORY_CHECK();
|
|
||||||
/**
|
|
||||||
* The minimum time it should have taken for the player to click X times; Type=INTEGER; Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
public int TELEPORT_MIN();
|
|
||||||
/**
|
|
||||||
* Maximum amount of times a player can hit a killaura bot; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int KILLAURA_BOTHITS();
|
|
||||||
/**
|
|
||||||
* Maximum amount of packets a player can send in a second; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int BLINK_PACKET();
|
|
||||||
/**
|
|
||||||
* Maximum amount of low/zero velocity before flagging; Type=INTEGER, Leniency=INCREASE.
|
|
||||||
*/
|
|
||||||
public int VELOCITY_AMT();
|
|
||||||
}
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
/*
|
|
||||||
* AntiCheat for Bukkit.
|
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
|
||||||
*
|
|
||||||
* 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 net.gravitydevelopment.anticheat.event;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Distance;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
|
|
||||||
public class BlockListener extends EventListener {
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onBlockDamage(BlockDamageEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (event.getInstaBreak() || Utilities.isInstantBreak(event.getBlock().getType())) {
|
|
||||||
getBackend().logInstantBreak(player);
|
|
||||||
}
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.AUTOTOOL)) {
|
|
||||||
CheckResult result = getBackend().checkAutoTool(player);
|
|
||||||
if (result.failed()) {
|
|
||||||
event.setCancelled(!silentMode());
|
|
||||||
log(result.getMessage(), player, CheckType.AUTOTOOL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
if (player != null && getCheckManager().willCheck(player, CheckType.FAST_PLACE)) {
|
|
||||||
CheckResult result = getBackend().checkFastPlace(player);
|
|
||||||
if (result.failed()) {
|
|
||||||
event.setCancelled(!silentMode());
|
|
||||||
log(result.getMessage(), player, CheckType.FAST_PLACE);
|
|
||||||
} else {
|
|
||||||
decrease(player);
|
|
||||||
getBackend().logBlockPlace(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
final Block block = event.getBlock();
|
|
||||||
boolean noHack = true;
|
|
||||||
if (player != null) {
|
|
||||||
CheckResult result;
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.FAST_BREAK)) {
|
|
||||||
result = getBackend().checkFastBreak(player, block);
|
|
||||||
if (result.failed()) {
|
|
||||||
event.setCancelled(!silentMode());
|
|
||||||
log(result.getMessage(), player, CheckType.FAST_BREAK);
|
|
||||||
noHack = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.NO_SWING)) {
|
|
||||||
result = getBackend().checkSwing(player, block);
|
|
||||||
if (result.failed()) {
|
|
||||||
event.setCancelled(!silentMode());
|
|
||||||
log(result.getMessage(), player, CheckType.NO_SWING);
|
|
||||||
noHack = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.LONG_REACH)) {
|
|
||||||
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
|
||||||
result = getBackend().checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
|
||||||
if (result.failed()) {
|
|
||||||
event.setCancelled(!silentMode());
|
|
||||||
log(result.getMessage(), player, CheckType.LONG_REACH);
|
|
||||||
noHack = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (noHack) {
|
|
||||||
decrease(player);
|
|
||||||
}
|
|
||||||
getBackend().logBlockBreak(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
/*
|
|
||||||
* AntiCheat for Bukkit.
|
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
|
||||||
*
|
|
||||||
* 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 net.gravitydevelopment.anticheat.event;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.Backend;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
|
||||||
import net.gravitydevelopment.anticheat.manage.*;
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class EventListener implements Listener {
|
|
||||||
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
|
|
||||||
private static final Map<UUID, Integer> DECREASE_LIST = new HashMap<UUID, Integer>();
|
|
||||||
private static final CheckManager CHECK_MANAGER = AntiCheat.getManager().getCheckManager();
|
|
||||||
private static final Backend BACKEND = AntiCheat.getManager().getBackend();
|
|
||||||
private static final AntiCheat PLUGIN = AntiCheat.getManager().getPlugin();
|
|
||||||
private static final UserManager USER_MANAGER = AntiCheat.getManager().getUserManager();
|
|
||||||
private static final Configuration CONFIG = AntiCheat.getManager().getConfiguration();
|
|
||||||
|
|
||||||
public static void log(String message, Player player, CheckType type) {
|
|
||||||
User user = getUserManager().getUser(player.getUniqueId());
|
|
||||||
if (user != null) { // npc
|
|
||||||
logCheat(type, user);
|
|
||||||
if (user.increaseLevel(type) && message != null) {
|
|
||||||
AntiCheat.getManager().log(message);
|
|
||||||
}
|
|
||||||
removeDecrease(user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void logCheat(CheckType type, User user) {
|
|
||||||
USAGE_LIST.put(type, getCheats(type) + 1);
|
|
||||||
// Ignore plugins that are creating NPCs with no names (why the hell)
|
|
||||||
if (user != null && user.getUUID() != null) {
|
|
||||||
type.logUse(user);
|
|
||||||
if (CONFIG.getConfig().enterprise.getValue() && CONFIG.getEnterprise().loggingEnabled.getValue()) {
|
|
||||||
CONFIG.getEnterprise().database.logEvent(user, type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetCheck(CheckType type) {
|
|
||||||
USAGE_LIST.put(type, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getCheats(CheckType type) {
|
|
||||||
int x = 0;
|
|
||||||
if (USAGE_LIST.get(type) != null) {
|
|
||||||
x = USAGE_LIST.get(type);
|
|
||||||
}
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void removeDecrease(User user) {
|
|
||||||
int x = 0;
|
|
||||||
// Ignore plugins that are creating NPCs with no names
|
|
||||||
if (user.getUUID() != null) {
|
|
||||||
if (DECREASE_LIST.get(user.getUUID()) != null) {
|
|
||||||
x = DECREASE_LIST.get(user.getUUID());
|
|
||||||
x -= 2;
|
|
||||||
if (x < 0) {
|
|
||||||
x = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DECREASE_LIST.put(user.getUUID(), x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void decrease(Player player) {
|
|
||||||
User user = getUserManager().getUser(player.getUniqueId());
|
|
||||||
// Ignore plugins that are creating NPCs with no names
|
|
||||||
if (user.getUUID() != null) {
|
|
||||||
int x = 0;
|
|
||||||
|
|
||||||
if (DECREASE_LIST.get(user.getUUID()) != null) {
|
|
||||||
x = DECREASE_LIST.get(user.getUUID());
|
|
||||||
}
|
|
||||||
|
|
||||||
x += 1;
|
|
||||||
DECREASE_LIST.put(user.getUUID(), x);
|
|
||||||
|
|
||||||
if (x >= 10) {
|
|
||||||
user.decreaseLevel();
|
|
||||||
DECREASE_LIST.put(user.getUUID(), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CheckManager getCheckManager() {
|
|
||||||
return CHECK_MANAGER;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AntiCheatManager getManager() {
|
|
||||||
return AntiCheat.getManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Backend getBackend() {
|
|
||||||
return BACKEND;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UserManager getUserManager() {
|
|
||||||
return USER_MANAGER;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AntiCheat getPlugin() {
|
|
||||||
return PLUGIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Configuration getConfig() {
|
|
||||||
return CONFIG;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean silentMode() {
|
|
||||||
return CONFIG.getConfig().silentMode.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,469 +0,0 @@
|
|||||||
/*
|
|
||||||
* AntiCheat for Bukkit.
|
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
|
||||||
*
|
|
||||||
* 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 net.gravitydevelopment.anticheat.event;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Arrow;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.block.Action;
|
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
||||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
|
||||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
|
||||||
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
|
||||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
|
||||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerKickEvent;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
|
||||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
|
||||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
|
||||||
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
|
||||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
|
||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
|
||||||
import net.gravitydevelopment.anticheat.check.combat.KillAuraCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.check.movement.FlightCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.check.movement.GlideCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.check.movement.SpeedCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.check.movement.WaterWalkCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.check.movement.YAxisCheck;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Distance;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Permission;
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
|
||||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
|
||||||
import net.gravitydevelopment.anticheat.util.VersionUtil;
|
|
||||||
|
|
||||||
public class PlayerListener extends EventListener {
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.COMMAND_SPAM) && !Permission.getCommandExempt(player, event.getMessage().split(" ")[0])) {
|
|
||||||
CheckResult result = getBackend().checkCommandSpam(player, event.getMessage());
|
|
||||||
if (result.failed()) {
|
|
||||||
event.setCancelled(!silentMode());
|
|
||||||
if (!silentMode()) player.sendMessage(ChatColor.RED + result.getMessage());
|
|
||||||
getBackend().processCommandSpammer(player);
|
|
||||||
log(null, player, CheckType.COMMAND_SPAM);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
|
|
||||||
if (!event.isFlying()) {
|
|
||||||
getBackend().logEnterExit(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
|
||||||
if (event.getNewGameMode() != GameMode.CREATIVE) {
|
|
||||||
getBackend().logEnterExit(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
|
||||||
if (event.getEntity().getShooter() instanceof Player) {
|
|
||||||
Player player = (Player) event.getEntity().getShooter();
|
|
||||||
|
|
||||||
if (event.getEntity() instanceof Arrow) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.FAST_PROJECTILE)) {
|
|
||||||
CheckResult result = getBackend().checkProjectile(player);
|
|
||||||
if (result.failed()) {
|
|
||||||
event.setCancelled(!silentMode());
|
|
||||||
log(result.getMessage(), player, CheckType.FAST_PROJECTILE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
|
||||||
if (event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.PLUGIN) {
|
|
||||||
getBackend().logTeleport(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerChangeWorlds(PlayerChangedWorldEvent event) {
|
|
||||||
getBackend().logTeleport(event.getPlayer());
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
|
|
||||||
if (event.isSneaking()) {
|
|
||||||
getBackend().logToggleSneak(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerVelocity(PlayerVelocityEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.FLY)) {
|
|
||||||
if (getBackend().justVelocity(player) && getBackend().extendVelocityTime(player)) {
|
|
||||||
event.setCancelled(!silentMode());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
getBackend().logVelocity(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
|
||||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.CHAT_SPAM)) {
|
|
||||||
CheckResult result = getBackend().checkChatSpam(player, event.getMessage());
|
|
||||||
if (result.failed()) {
|
|
||||||
event.setCancelled(!silentMode());
|
|
||||||
if (!result.getMessage().equals("") && !silentMode()) {
|
|
||||||
player.sendMessage(ChatColor.RED + result.getMessage());
|
|
||||||
}
|
|
||||||
getBackend().processChatSpammer(player);
|
|
||||||
log(null, player, CheckType.CHAT_SPAM);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerKick(PlayerKickEvent event) {
|
|
||||||
getBackend().garbageClean(event.getPlayer());
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
getBackend().garbageClean(event.getPlayer());
|
|
||||||
|
|
||||||
User user = getUserManager().getUser(event.getPlayer().getUniqueId());
|
|
||||||
|
|
||||||
getConfig().getLevels().saveLevelFromUser(user);
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerToggleSprint(PlayerToggleSprintEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (!event.isSprinting()) {
|
|
||||||
getBackend().logEnterExit(player);
|
|
||||||
}
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.SPRINT)) {
|
|
||||||
CheckResult result = getBackend().checkSprintHungry(event);
|
|
||||||
if (result.failed()) {
|
|
||||||
event.setCancelled(!silentMode());
|
|
||||||
log(result.getMessage(), player, CheckType.SPRINT);
|
|
||||||
} else {
|
|
||||||
decrease(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
PlayerInventory inv = player.getInventory();
|
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
|
||||||
Material m = inv.getItemInHand().getType();
|
|
||||||
if (m == Material.BOW) {
|
|
||||||
getBackend().logBowWindUp(player);
|
|
||||||
} else if (Utilities.isFood(m)) {
|
|
||||||
getBackend().logEatingStart(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Block block = event.getClickedBlock();
|
|
||||||
|
|
||||||
if (block != null) {
|
|
||||||
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
|
||||||
getBackend().checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.ITEM_SPAM)) {
|
|
||||||
CheckResult result = getBackend().checkFastDrop(player);
|
|
||||||
if (result.failed()) {
|
|
||||||
event.setCancelled(!silentMode());
|
|
||||||
log(result.getMessage(), player, CheckType.ITEM_SPAM);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
|
||||||
public void onPlayerEnterBed(PlayerBedEnterEvent event) {
|
|
||||||
if (event.getBed().getType() != Material.BED) return;
|
|
||||||
getBackend().logEnterExit(event.getPlayer());
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
|
||||||
public void onPlayerExitBed(PlayerBedLeaveEvent event) {
|
|
||||||
if (event.getBed().getType() != Material.BED) return;
|
|
||||||
getBackend().logEnterExit(event.getPlayer());
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerAnimation(PlayerAnimationEvent event) {
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
String section = "\u00a7";
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.ZOMBE_FLY)) {
|
|
||||||
player.sendMessage(section + "f " + section + "f " + section + "1 " + section + "0 " + section + "2 " + section + "4");
|
|
||||||
}
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.ZOMBE_CHEAT)) {
|
|
||||||
player.sendMessage(section + "f " + section + "f " + section + "2 " + section + "0 " + section + "4 " + section + "8");
|
|
||||||
}
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.ZOMBE_NOCLIP)) {
|
|
||||||
player.sendMessage(section + "f " + section + "f " + section + "4 " + section + "0 " + section + "9 " + section + "6");
|
|
||||||
}
|
|
||||||
|
|
||||||
getBackend().logJoin(player);
|
|
||||||
|
|
||||||
User user = new User(player.getUniqueId());
|
|
||||||
user.setIsWaitingOnLevelSync(true);
|
|
||||||
getConfig().getLevels().loadLevelToUser(user);
|
|
||||||
getUserManager().addUser(user);
|
|
||||||
|
|
||||||
if (player.hasMetadata(Utilities.SPY_METADATA)) {
|
|
||||||
for (Player p : player.getServer().getOnlinePlayers()) {
|
|
||||||
if (!Permission.SYSTEM_SPY.get(p)) {
|
|
||||||
p.hidePlayer(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
if (getCheckManager().checkInWorld(player) && !getCheckManager().isOpExempt(player)) {
|
|
||||||
final Location from = event.getFrom();
|
|
||||||
final Location to = event.getTo();
|
|
||||||
|
|
||||||
final Distance distance = new Distance(from, to);
|
|
||||||
final double y = distance.getYDifference();
|
|
||||||
getBackend().logAscension(player, from.getY(), to.getY());
|
|
||||||
|
|
||||||
final User user = getUserManager().getUser(player.getUniqueId());
|
|
||||||
user.setTo(to.getX(), to.getY(), to.getZ());
|
|
||||||
|
|
||||||
KillAuraCheck.doMove(event);
|
|
||||||
|
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.SPRINT)) {
|
|
||||||
CheckResult result = getBackend().checkSprintStill(player, from, to);
|
|
||||||
if (result.failed()) {
|
|
||||||
event.setCancelled(!silentMode());
|
|
||||||
log(result.getMessage(), player, CheckType.SPRINT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.FLY) && !VersionUtil.isFlying(player)) {
|
|
||||||
CheckResult result = FlightCheck.runCheck(player, distance);
|
|
||||||
if (result.failed()) {
|
|
||||||
if (!silentMode()) {
|
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
|
||||||
}
|
|
||||||
log(result.getMessage(), player, CheckType.FLY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.FLY) && !VersionUtil.isFlying(player)) {
|
|
||||||
CheckResult result = GlideCheck.runCheck(player, distance);
|
|
||||||
if (result.failed()) {
|
|
||||||
// NO TELEPORT NEEDED HERE, HANDLED BY CHECK ITSELF
|
|
||||||
log(result.getMessage(), player, CheckType.FLY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.VCLIP) && event.getFrom().getY() > event.getTo().getY()) {
|
|
||||||
CheckResult result = getBackend().checkVClip(player, new Distance(event.getFrom(), event.getTo()));
|
|
||||||
if (result.failed()) {
|
|
||||||
if (!silentMode()) {
|
|
||||||
int data = result.getData() > 3 ? 3 : result.getData();
|
|
||||||
Location newloc = new Location(player.getWorld(), event.getFrom().getX(), event.getFrom().getY() + data, event.getFrom().getZ());
|
|
||||||
if (newloc.getBlock().getType() == Material.AIR) {
|
|
||||||
event.setTo(newloc);
|
|
||||||
} else {
|
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
|
||||||
}
|
|
||||||
player.damage(3);
|
|
||||||
}
|
|
||||||
log(result.getMessage(), player, CheckType.VCLIP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.NOFALL) && getCheckManager().willCheck(player, CheckType.FLY) && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && event.getFrom().getY() > event.getTo().getY()) {
|
|
||||||
CheckResult result = getBackend().checkNoFall(player, y);
|
|
||||||
if (result.failed()) {
|
|
||||||
if (!silentMode()) {
|
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
|
||||||
/*TODO: player.damage(1); better system for this, too exploitable*/
|
|
||||||
}
|
|
||||||
log(result.getMessage(), player, CheckType.NOFALL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean changed = false;
|
|
||||||
if (event.getTo() != event.getFrom()) {
|
|
||||||
double x = distance.getXDifference();
|
|
||||||
double z = distance.getZDifference();
|
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.SPEED) && getCheckManager().willCheck(player, CheckType.FLY)) {
|
|
||||||
if (event.getFrom().getY() < event.getTo().getY()) {
|
|
||||||
CheckResult result = getBackend().checkYSpeed(player, y);
|
|
||||||
if (result.failed()) {
|
|
||||||
if (!silentMode()) {
|
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
|
||||||
}
|
|
||||||
log(result.getMessage(), player, CheckType.SPEED);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CheckResult result = SpeedCheck.checkXZSpeed(player, x, z);
|
|
||||||
if (result.failed()) {
|
|
||||||
if (!silentMode()) {
|
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
|
||||||
}
|
|
||||||
log(result.getMessage(), player, CheckType.SPEED);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) {
|
|
||||||
CheckResult result = WaterWalkCheck.runCheck(player, x, y, z);
|
|
||||||
if (result.failed()) {
|
|
||||||
if (!silentMode()) {
|
|
||||||
player.teleport(user.getGoodLocation(player.getLocation().add(0, -1.5, 0)));
|
|
||||||
}
|
|
||||||
log(result.getMessage(), player, CheckType.WATER_WALK);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.SNEAK)) {
|
|
||||||
CheckResult result = getBackend().checkSneak(player, x, z);
|
|
||||||
if (result.failed()) {
|
|
||||||
if (!silentMode()) {
|
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
|
||||||
player.setSneaking(false);
|
|
||||||
}
|
|
||||||
log(result.getMessage(), player, CheckType.SNEAK);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.SPIDER)) {
|
|
||||||
CheckResult result = getBackend().checkSpider(player, y);
|
|
||||||
if (result.failed()) {
|
|
||||||
if (!silentMode()) {
|
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
|
||||||
}
|
|
||||||
log(result.getMessage(), player, CheckType.SPIDER);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!changed) {
|
|
||||||
user.setGoodLocation(event.getFrom());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.HIGHEST)
|
|
||||||
public void onDeath(PlayerDeathEvent e) {
|
|
||||||
KillAuraCheck.cleanPlayer(e.getEntity()); // Remove bots on death to reduce lag
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
|
||||||
public void checkFly(PlayerMoveEvent event) {
|
|
||||||
// Check flight on highest to make sure other plugins have a chance to change the values first.
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
final User user = getUserManager().getUser(player.getUniqueId());
|
|
||||||
final Location from = event.getFrom();
|
|
||||||
final Location to = event.getTo();
|
|
||||||
|
|
||||||
if (!user.checkTo(to.getX(), to.getY(), to.getZ())) {
|
|
||||||
// The to value has been modified by another plugin
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.FLY) && !player.isFlying()) {
|
|
||||||
CheckResult result1 = YAxisCheck.runCheck(player, new Distance(from, to));
|
|
||||||
CheckResult result2 = getBackend().checkAscension(player, from.getY(), to.getY());
|
|
||||||
String log = result1.failed() ? result1.getMessage() : result2.failed() ? result2.getMessage() : "";
|
|
||||||
if (!log.equals("")) {
|
|
||||||
if (!silentMode()) {
|
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
|
||||||
}
|
|
||||||
log(log, player, CheckType.FLY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* AntiCheat for Bukkit.
|
|
||||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
|
||||||
*
|
|
||||||
* 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 net.gravitydevelopment.anticheat.event;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
|
||||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
|
||||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
|
||||||
|
|
||||||
public class VehicleListener extends EventListener {
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
|
||||||
public void onVehicleEnter(VehicleEnterEvent event) {
|
|
||||||
if (event.getEntered() instanceof Player) {
|
|
||||||
getBackend().logEnterExit((Player) event.getEntered());
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
|
||||||
public void onVehicleExit(VehicleExitEvent event) {
|
|
||||||
if (event.getExited() instanceof Player) {
|
|
||||||
getBackend().logEnterExit((Player) event.getExited());
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
|
||||||
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
|
||||||
if (event.getVehicle().getPassenger() != null && event.getVehicle().getPassenger() instanceof Player) {
|
|
||||||
getBackend().logEnterExit((Player) event.getVehicle().getPassenger());
|
|
||||||
}
|
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package net.gravitydevelopment.anticheat.manage;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.Packets;
|
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
|
||||||
import com.comphenix.protocol.events.*;
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
|
||||||
|
|
||||||
public class PacketManager {
|
|
||||||
|
|
||||||
private ProtocolManager protocolManager;
|
|
||||||
private AntiCheat plugin;
|
|
||||||
private AntiCheatManager manager;
|
|
||||||
|
|
||||||
public PacketManager(ProtocolManager protocolManager, AntiCheat plugin, AntiCheatManager manager) {
|
|
||||||
this.protocolManager = protocolManager;
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.manager = manager;
|
|
||||||
addListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addListeners() {
|
|
||||||
// Arm Animation
|
|
||||||
protocolManager.addPacketListener(new PacketAdapter(plugin,
|
|
||||||
ConnectionSide.CLIENT_SIDE,
|
|
||||||
ListenerPriority.NORMAL,
|
|
||||||
Packets.Client.ARM_ANIMATION) {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPacketReceiving(PacketEvent event) {
|
|
||||||
if (event.getPacketID() == Packets.Client.ARM_ANIMATION) {
|
|
||||||
PacketContainer packet = event.getPacket();
|
|
||||||
//System.out.println("Arm animation from "+packet.getIntegers().read(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loaded 100 of 118 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user