Compare commits

..
113 Commits
Author SHA1 Message Date
Rammelkast 9473781a26 Fix multiversion issues with levitation, fix more stacktraces 2020-10-22 21:28:14 +02:00
Rammelkast 6497891e43 Use integrated copy of latest MinecraftVersion to fix compatibility issues 2020-10-22 21:05:54 +02:00
Rammelkast 0dc3a8053d Merge pull request #118 from Rammelkast/funding
Create FUNDING.yml
2020-10-22 18:58:38 +02:00
Rammelkast 1b5f2dcaa1 Create FUNDING.yml 2020-10-22 18:58:27 +02:00
Rammelkast b232026644 Fix #116 2020-10-21 14:46:48 +02:00
Rammelkast 0c91ec7ba4 Prepare for release 2020-10-19 18:31:21 +02:00
Rammelkast abff433510 Fix Speed bypass 2020-10-19 16:55:43 +02:00
Rammelkast fad298086c Fix speed false positive 2020-10-19 16:10:00 +02:00
Rammelkast 8b413a382a Fixes for 1.12.2 support 2020-10-18 12:15:25 +02:00
Rammelkast 1428b55591 Added 1.12.x compatibility, not tested yet (#90) 2020-10-18 12:05:54 +02:00
Rammelkast a84b573fa8 Allow /acr report for offline players & small multiversion improvements 2020-10-17 18:46:07 +02:00
Rammelkast 9211003d6d Added #78, magic.yml changes 2020-10-17 14:24:37 +02:00
Rammelkast 01df416236 Fix #112 2020-10-17 14:00:50 +02:00
Rammelkast 619c8efae1 Add BoatFly check, fix WaterWalk false positive 2020-10-17 13:46:54 +02:00
Rammelkast ab2fcc5521 Update to 1.16.3, update dependencies & plugins 2020-10-16 13:57:21 +02:00
Rammelkast 8843725ede Update README 2020-10-16 13:49:44 +02:00
Rammelkast 0d9b8707dd Merge pull request #109 from gcurtiss/master
Add disable broadcast
2020-09-15 13:34:58 +02:00
Gabriel Curtiss 6e2eae7d1e Fix logic error and remove unnecessary line 2020-09-14 16:34:52 -05:00
Gabriel Curtiss ef5b4069ce Add disable broadcast
Prevents public embarassment. Some anarchy server owners like myself want to kick those who have certain hacks but don't want their kick to be publicly known.
2020-09-13 23:39:01 -05:00
Rammelkast 3b9b39c49a Fix error with temporary players, continue work on BoatFly 2020-09-13 20:30:34 +02:00
Rammelkast 09c42905d0 Fixed falses with sweet berry bushes 2020-08-27 14:38:21 +02:00
Rammelkast 8de7ae1c59 Fix #108, update XMaterial, start BoatFly 2020-08-27 11:11:47 +02:00
Rammelkast 768331011e Update to 1.16.2, fix #102, fix #104, fix strafe & reach false positives 2020-08-27 11:05:28 +02:00
Rammelkast 1f48785d1d Changes to update checking, add subcheck in alerts 2020-08-09 17:24:51 +02:00
Rammelkast 7cd90cfb61 Add NoSlow check, fix broken strafe check, fix false positives with speed check, fix BadPackets false positive. 2020-08-06 15:45:25 +02:00
Rammelkast 5f181c556e Fix #101, small change to lag determination and fix 1.8.8 combat checks not working 2020-08-06 13:48:38 +02:00
Rammelkast 16c778c17f Fix WaterWalk false positive 2020-08-04 16:27:31 +02:00
Rammelkast 97534e5df0 Fix false positive with weeping vines 2020-08-04 16:22:00 +02:00
Rammelkast e770d0e01c Fix 1.8.8 support, fix false positive with scaffolding 2020-08-04 10:52:23 +02:00
Rammelkast a59a4baf28 Unchecked attempt at fixing 1.8 compat issues 2020-08-04 10:16:21 +02:00
Rammelkast 7caf7376ba Fix riptide false, small change to lag determination 2020-08-03 20:04:11 +02:00
Rammelkast a6a39e352a Add Strafe check, improve KillAura, fix Elytra false positive, fix BadPackets false positive, 2020-08-03 19:50:18 +02:00
Rammelkast 700c0145f3 Fix #97 and fix #87 2020-08-02 13:08:09 +02:00
Rammelkast c74fc92da9 Fix #96, introduce Strafe check and fix flight, speed false positives 2020-08-01 22:35:51 +02:00
Rammelkast 3bc49141fc Change default velocity minimum percentage, seems to act weird in 1.8.8? 2020-07-30 16:59:09 +02:00
Rammelkast cffd6d07ae Gamebreaking flight false hotfix for 1.8.8 2020-07-30 13:39:02 +02:00
Rammelkast e9a99f0463 False positive fixes: Nofall false with shulkers, flight false positive with snow, speed false positive with snow, waterwalk false positive with boats and KillAura false positive with thorns 2020-07-30 13:26:46 +02:00
Rammelkast 4deb8ae0fb Fixed two WaterWalk falses 2020-07-29 14:26:08 +02:00
Rammelkast 07f957cf35 Fix false positive with horse and jump boost, added "max-setback-distance". 2020-07-29 14:06:49 +02:00
Rammelkast 9850f48a4e Small change to checks.yml, prepare for release 2020-07-28 14:04:44 +02:00
Rammelkast 656841b046 Fixed config issues, enabled/disabled info in /acr checks 2020-07-28 11:12:50 +02:00
Rammelkast fc006c39f2 Fixe false positive when coming out of water 2020-07-27 15:54:26 +02:00
Rammelkast f4ca2ea8bf Fixed issue with config reloading and false positives 2020-07-22 11:16:01 +02:00
Rammelkast 6966582e4c Fixed 3 false positives in water, one with beds and returned to old "getGoodLocation" 2020-07-21 13:19:35 +02:00
Rammelkast 168c25e5d2 Ready for pre-release; Removed broken code, finished config migrations and fixed false positive 2020-07-20 21:39:53 +02:00
Rammelkast 07f3c3abce Remove broken FastBreak and NoSwing, fixed false positives and more config migrations 2020-07-19 12:32:43 +02:00
Rammelkast 128a668e6c Recoded Velocity & WaterWalk 2020-07-16 16:49:05 +02:00
Rammelkast ad618ffaf0 Glide -> Gravity, more migration towards new config, expanded illegalinteract, fix false positives 2020-07-13 18:24:25 +02:00
Rammelkast 2086a01f80 Added NoSlowdown, migrations to new config 2020-07-12 14:04:18 +02:00
Rammelkast add3fe5eae Update to 1.16, migrate config and more movement changes 2020-07-03 17:00:32 +02:00
Rammelkast 20635a2acb Replaced broken reach check, continued work on movement check update 2020-06-13 14:49:35 +02:00
Rammelkast 636f94b408 Started on movement check recode. First up: speed check! 2020-06-10 20:29:49 +02:00
Rammelkast 610d53550f Fixed false positives with boats, changes to MorePackets 2020-06-09 14:33:54 +02:00
Rammelkast db9aa97ca1 Fix broken IllegalInteract permission, fix false positive in sneak check 2020-06-09 14:05:32 +02:00
Rammelkast 992c67d894 Fixed Aimbot and MorePackets false positives, staff notifications are now every x violations and not spammy. Removed broken part of glide check and fixed all permission issues. 2020-06-04 16:41:13 +02:00
Rammelkast 12c85b3939 Fix missing permissions 2020-06-02 20:56:03 +02:00
Rammelkast 37d580a4ba Remove old magic.yml contents, fix riptide false positive 2020-05-19 13:20:39 +02:00
Rammelkast f94a430d41 Recoded MorePackets, fixed false positive. This commit is a release candidate. 2020-05-13 17:16:04 +02:00
Rammelkast 918549bc11 Fixed bug in version check, fixed water-related false positive and fixed wrong permission 2020-05-13 15:56:07 +02:00
Rammelkast c6e4ce091a Fix #83, fix BadPackets false positive added packet sneak check. 2020-05-13 15:43:54 +02:00
Rammelkast 7d13aae057 Replaced falsing GCD check, started aimbot check. Added "symbiosis" metric. 2020-05-13 14:52:36 +02:00
Rammelkast 3538b8934c Cleaned up and changed some comments 2020-05-04 17:24:47 +02:00
Rammelkast b2701fa057 Fixed #81, removed POS optifine check code that won't work & fixed console messaging 2020-05-04 17:18:22 +02:00
Rammelkast 8cf2702708 Bleeding fix for #81, added #76 and started working on OF zoom support 2020-05-04 15:40:14 +02:00
Rammelkast cd3184f17b Merge pull request #77 from BlazingAsher/master
make getHandlers() static
2020-04-28 14:23:08 +02:00
David Hui 9078846511 make getHandlers() static 2020-04-25 15:03:10 -04:00
Rammelkast 50247f28c9 Fixed false positive with slow falling potion and upped default teleport protection 2020-04-24 18:54:15 +02:00
Rammelkast cc51e9307f Added FastLadder check, fixed glide false positive 2020-04-24 13:59:06 +02:00
Rammelkast 0288a9734a Found possible 1.8.8 compat issue with BadPackets 2020-04-23 19:57:18 +02:00
Rammelkast a7419e3968 Code cleanup, prepare for release 2020-04-23 19:46:58 +02:00
Rammelkast df3c410436 Tightened velocity check, fixed issues with slime block 2020-04-23 19:37:47 +02:00
Rammelkast 27bb684736 Added #66 and fixed issue with Velocity check 2020-04-23 19:24:20 +02:00
Rammelkast aa9fa9b290 Fix #63 2020-04-23 19:00:22 +02:00
Rammelkast da4a61e228 Fixed false positives in glide check, removed broken figtspeed check. 2020-04-23 18:30:36 +02:00
Rammelkast 9771387909 Fixed YAxis false positive, added BadPackets check and cleaned up code and README . 2020-04-23 16:47:25 +02:00
Rammelkast 76c595e255 Removed unused timer check 2020-04-20 15:34:45 +02:00
Rammelkast 91f5fcd31c Blink is now MorePackets, fix #67 2020-04-19 17:19:07 +02:00
Rammelkast 80b5e64924 Blink is now MorePackets, fix #67 2020-04-19 17:18:51 +02:00
BuildTools 67e824ef28 Added support for 1.8.8 2020-04-19 17:09:30 +02:00
Rammelkast 661718d001 Fixes for #63, #62, #55
Also added extra KillAura check and fixed compatibility issues
2020-04-07 20:40:04 +02:00
Rammelkast 7c9a05ff92 UnicodeChat fix for other European languages (possible more?) as described in #59.
Also added more default leniancy for blink check.
2020-04-06 17:28:22 +02:00
Rammelkast 3af7bde9db Prepare for release 2020-04-01 13:07:06 +02:00
Rammelkast 7e37e8558b Introduced version command, fixed #58 2020-04-01 12:53:25 +02:00
Rammelkast d41d08ccc6 Added heuristic KillAura check 2020-03-31 14:59:10 +02:00
Rammelkast f88c31051b Code cleanup 2020-03-31 13:15:59 +02:00
Rammelkast 6afe0049c5 Added and tested backwards compatibility for 1.13 and 1.14. 2020-03-31 13:10:14 +02:00
Rammelkast f77d45a78d Changes loggig, renamed GhostHand to IllegalInteract. 2020-03-30 23:24:28 +02:00
Rammelkast 2ba98f9f9c Sort of fixed badly broken and untested GhostHand check, added update messaging.
Check will still need to be improved, but seems to work without false positives for now.
2020-03-30 22:55:18 +02:00
Rammelkast e89a6cfd88 Merge pull request #54 from EncryptSL/master
Clean Solution for sendToStaff (thanks @EncryptSL)
2020-03-26 10:48:13 +01:00
EncryptSL 07bf56cc93 Clean Solution for sendToStaff
Added clean solution for sendToStaff sendMessage
2020-03-25 20:40:35 +01:00
Rammelkast 773900594d Forgot to commit class 2020-03-25 18:25:57 +01:00
Rammelkast 27ca12aec3 Massive messaging and config changes.
Furthermore:
+ Added basic KillAura angle check (a start to #52)
+ Fixed sneak false positives
+ Added staff alert messaging (anticheat.system.alert permission, see #28)
+ Language file now support color coding
+ Added debug-mode for testservers
+ Insignificant pom.xml and README.md updates
2020-03-25 17:41:44 +01:00
Rammelkast fec1286c8d Added GhostHand and Unicode chat check and fixed broken fly check.
Furthermore:
+ Updated and documented magic.yml
+ Added support for missing CAVE_AIR material
+ Average ping for blink check can now be configured
+ Removed /acr update from help command
+ Added UpdateManager.java to be used in future update messages
+ Better MainHand/OffHand support

I've been busy :)
2020-03-24 20:15:31 +01:00
Rammelkast acea36929b Nevermind 2020-02-28 12:57:24 +01:00
Rammelkast 8da9d7f365 Add Travis CI 2020-02-28 12:55:18 +01:00
Rammelkast c9c3b2397f Updated Metrics, made small code changes 2020-02-28 12:40:27 +01:00
Rammelkast a140afe33e Update copyright 2020-02-27 21:01:10 +01:00
Rammelkast 08c484bfb1 Merge branch 'master' of https://github.com/Rammelkast/AntiCheatReloaded 2020-02-27 20:48:11 +01:00
Rammelkast ae66b0ed3c Changes 2020-02-27 20:47:46 +01:00
Rammelkast 0963458be5 Updated to 1.15, fixed issues and made changes to some checks 2020-02-27 20:46:20 +01:00
BuildTools d9639c81d9 Updated to 1.15, fixed issues and made changes to some checks 2020-02-27 20:44:47 +01:00
Rammelkast 0428c4796a Merge branch 'master' of https://github.com/Rammelkast/AntiCheatReloaded 2018-08-15 20:29:14 +02:00
Rammelkast 8e92077bb6 More small changes 2018-08-15 20:28:52 +02:00
Rammelkast 9d32c8f2de Create CNAME 2018-08-14 22:55:01 +02:00
Rammelkast d6917b81f7 Set theme jekyll-theme-cayman 2018-08-14 22:54:16 +02:00
Rammelkast 1a64403223 Update copyright & big fixes 2018-08-14 22:42:46 +02:00
Rammelkast 7ae3f010a3 Fixes regarding 1.9+ support 2018-08-14 11:37:17 +02:00
marcomoesman 06c1eab2e6 Fixed a lot of things. Plugin should work a lot better on 1.12 now. 2018-08-13 14:36:05 +02:00
Rammelkast f609758d28 Ready for Minecraft 1.12 2017-11-20 19:34:51 +01:00
Rammelkast 2d064ee849 1.12 fixes 2017-11-18 17:04:03 +01:00
Rammelkast 717b7acb67 Quick metrics fix 2017-11-18 16:55:20 +01:00
Rammelkast 2617aa1225 Cleanup 2017-05-06 16:00:08 +02:00
Rammelkast dd8c495ee6 Modify Metrics data & fix 2017-03-03 12:40:30 +01:00
106 changed files with 8223 additions and 4327 deletions

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [Rammelkast]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
+38 -33
View File
@@ -1,11 +1,11 @@
AntiCheatReloaded AntiCheatReloaded ![Latest Release](https://img.shields.io/github/v/release/Rammelkast/AntiCheatReloaded) ![Downloads](https://img.shields.io/github/downloads/Rammelkast/AntiCheatReloaded/total) ![Last Commit](https://img.shields.io/github/last-commit/Rammelkast/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.
Bug Reporting Bug Reporting
------------ ------------
@@ -13,36 +13,41 @@ Bug Reporting
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.
Please include the following information with your issue, this allows me to fix it quicker; Please include the following information with your issue, this allows me to fix it quicker;
* The `/anticheat debug` log
* Your AntiCheatReloaded version * Your AntiCheatReloaded version
* Your server software (Bukkit/Spigot/Paper/Taco) and it's version * Your server implementation (Craftbukkit/Spigot/Other) and it's version
* When using protocollib, your protocollib version * Your ProtocolLib version
* If you use protocolhacks (ViaVersion etc.) * Whether or not you are using protocol hacks (ViaVersion etc.)
* Any logs relating to the issue
Usage Hacks blocked
------- -------
Simply drag and drop the plugin and the ProtoclLib into your Plugins folder. * Flight/Glide
* ElytraFly
###Hacks blocked * WaterWalk/Jesus
-------
* Blink
* Flight
* Glide
* Jesus
* Step
* Criticals
* KillAura
* Anti-Knockback
* FastBow
* FastDrop
* Reach
* Spider
* Speed
* NoFall
* Sneak
* vClip
* Timer
* FastBreak * FastBreak
* FastPlace * FastPlace
* Spam * Chat spam
* Command spam
* Sprint
* (Packet)Sneak
* Speed
* Vclip
* Spider
* NoFall
* FastBow
* FastEat * FastEat
* FastHeal
* KillAura
* Aimbot
* Reach
* Unicode chat
* FastProjectile
* ItemSpam
* FastInventory
* Timer
* Blink
* Anti-Knockback
* Scaffold
* FastLadder
* Strafe
* NoSlow
+18 -32
View File
@@ -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>com.rammelkast.anticheatreloaded</groupId> <groupId>com.rammelkast.anticheatreloaded</groupId>
<artifactId>AntiCheatReloaded</artifactId> <artifactId>AntiCheatReloaded</artifactId>
<version>1.6.1-ALPHA</version> <version>1.9.5</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,7 +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>
</repositories> </repositories>
<build> <build>
@@ -22,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.8.1</version>
<configuration> <configuration>
<source>1.7</source> <source>1.8</source>
<target>1.7</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.2.4</version>
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
@@ -54,7 +54,7 @@
<extension> <extension>
<groupId>org.apache.maven.wagon</groupId> <groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId> <artifactId>wagon-file</artifactId>
<version>2.2</version> <version>3.4.1</version>
</extension> </extension>
</extensions> </extensions>
<resources> <resources>
@@ -64,36 +64,22 @@
</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.2.1-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.11.2-R0.1-SNAPSHOT</version> <version>1.16.3-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@@ -1,282 +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 com.rammelkast.anticheatreloaded;
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 com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
import com.rammelkast.anticheatreloaded.check.movement.BlinkCheck;
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.User;
import com.rammelkast.anticheatreloaded.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 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();
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
getLogger().info("Found ProtocolLib, enabling checks that use ProtcolLib...");
// Enable packetlisteners
KillAuraCheck.listenPackets();
BlinkCheck.startTimer();
BlinkCheck.listenPackets();
}
// Check if other AC's are installed
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
public void run() {
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
getLogger().severe("*----------------------------------------------*");
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.");
getLogger().severe("*----------------------------------------------*");
}
if (Bukkit.getPluginManager().getPlugin("AAC") != null) {
getLogger().severe("*----------------------------------------------*");
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.");
getLogger().severe("*----------------------------------------------*");
}
if (Bukkit.getPluginManager().getPlugin("AntiCheat") != null) {
getLogger().severe("*----------------------------------------------*");
getLogger().severe("You are also running AntiCheat!");
getLogger().severe("Multiple anticheats create false cheat detections.");
getLogger().severe("Please remove or disable AntiCheat to silence this warning.");
getLogger().severe("*----------------------------------------------*");
}
}
}, 60L);
// End tests
verboseLog("Finished loading.");
getLogger().info("Running NMS version " + VersionUtil.getVersion() + "...");
// Metrics
try {
Metrics metrics = new Metrics(this);
metrics.addCustomChart(new Metrics.SingleLineChart("cheaters_kicked") {
@Override
public int getValue() {
return playersKicked;
}
});
metrics.addCustomChart(new Metrics.SingleLineChart("killaura_violations") {
@Override
public int getValue() {
return killauraViolations;
}
});
metrics.addCustomChart(new Metrics.SingleLineChart("glide_violations") {
@Override
public int getValue() {
return glideViolations;
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
@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;
}
/**
* Amount of players kicked since start
*/
private int playersKicked = 0;
/**
* Amount of killaura violations since start
*/
private int killauraViolations = 0;
/**
* Amount of glide violations since start
*/
private int glideViolations = 0;
public void onPlayerKicked() {
this.playersKicked++;
}
public void onKillAuraViolation() {
this.killauraViolations++;
}
public void onGlideViolation() {
this.killauraViolations++;
}
}
@@ -0,0 +1,356 @@
/*
* 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.listenMovementPackets();
PacketListener.listenKeepAlivePackets();
PacketListener.listenUseItemPackets();
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;
}
// Check for updates every 12 hours
if (ticks % 864000 == 0)
updateManager.update();
}
}.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;
}
}
@@ -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
@@ -22,7 +23,7 @@ import java.util.List;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager; import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
import com.rammelkast.anticheatreloaded.manage.CheckManager; import com.rammelkast.anticheatreloaded.manage.CheckManager;
@@ -34,8 +35,8 @@ import com.rammelkast.anticheatreloaded.util.Group;
*/ */
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
* *
@@ -173,8 +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();
} }
} }
@@ -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
@@ -62,4 +63,8 @@ public class CheckFailEvent extends Event {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }
File diff suppressed because it is too large. Load diff
@@ -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
@@ -25,6 +26,7 @@ public class CheckResult {
} }
private Result result; private Result result;
private String subCheck;
private String message; private String message;
private int data; private int data;
@@ -33,6 +35,12 @@ public class CheckResult {
this.data = data; this.data = data;
} }
public CheckResult(Result result, String subcheck, String message) {
this(result);
this.subCheck = subcheck;
this.message = message;
}
public CheckResult(Result result, String message) { public CheckResult(Result result, String message) {
this(result); this(result);
this.message = message; this.message = message;
@@ -46,6 +54,10 @@ public class CheckResult {
return result == Result.FAILED; return result == Result.FAILED;
} }
public String getSubCheck() {
return subCheck;
}
public String getMessage() { public String getMessage() {
return message; return message;
} }
@@ -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
@@ -35,46 +36,50 @@ 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); NOSLOW(Permission.CHECK_NOSLOW, "NoSlow"),
BOATFLY(Permission.CHECK_BOATFLY, "BoatFly");
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;
} }
/** /**
@@ -120,12 +125,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);
} }
} }
@@ -1,3 +1,21 @@
/*
* 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; package com.rammelkast.anticheatreloaded.check.combat;
import org.bukkit.Material; import org.bukkit.Material;
@@ -13,20 +31,27 @@ import com.rammelkast.anticheatreloaded.util.Utilities;
public class CriticalsCheck { public class CriticalsCheck {
public static void doDamageEvent(EntityDamageByEntityEvent e, Player damager) { public static void doDamageEvent(EntityDamageByEntityEvent event, Player damager) {
if (!(e.getDamager() instanceof Player) || e.getCause() != DamageCause.ENTITY_ATTACK) if (!(event.getDamager() instanceof Player) || event.getCause() != DamageCause.ENTITY_ATTACK)
return; return;
Player p = (Player)e.getDamager(); Player player = (Player) event.getDamager();
if (isCritical(p)) { if (isCritical(player)) {
if ((p.getLocation().getY() % 1.0 == 0 || p.getLocation().getY() % 0.5 == 0) && p.getLocation().clone().subtract(0, 1.0, 0).getBlock().getType().isSolid()) { if ((player.getLocation().getY() % 1.0 == 0 || player.getLocation().getY() % 0.5 == 0)
e.setCancelled(true); && player.getLocation().clone().subtract(0, 1.0, 0).getBlock().getType().isSolid()) {
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed Criticals, tried to do a critical without needed conditions").getMessage(), p, CheckType.CRITICALS); event.setCancelled(true);
EventListener.log(new CheckResult(CheckResult.Result.FAILED, "tried to do a critical without needed conditions")
.getMessage(),
player, CheckType.CRITICALS, null);
} }
} }
} }
@SuppressWarnings("deprecation")
private static boolean isCritical(Player player) { 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; 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 +1,169 @@
/*
* 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; package com.rammelkast.anticheatreloaded.check.combat;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.util.Vector;
import com.comphenix.protocol.PacketType; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.event.EventListener; import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
import com.rammelkast.anticheatreloaded.util.NPC_1_11; import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.MovementManager;
import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities;
/**
* @author Rammelkast
*/
public class KillAuraCheck { public class KillAuraCheck {
private static final Map<UUID, NPC_1_11> NPC_LIST = new HashMap<UUID, NPC_1_11>(); // Angle check
private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>(); 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 void cleanPlayer(Player p) { public static CheckResult checkReach(Player player, Entity target) {
if (!VersionUtil.getVersion().equals("v1_11_R1")) { if (!(target instanceof LivingEntity))
return; 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");
if (player.getGameMode() == GameMode.CREATIVE)
allowedReach += 1.5D;
// 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;
} }
NPC_LIST.remove(p.getUniqueId()); // 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, "Reach",
"reached too far (distance=" + Utilities.roundDouble(reachedDistance, 6) + ", max=" + Utilities.roundDouble(allowedReach, 6) + ")");
return PASS;
} }
public static void listenPackets() { public static CheckResult checkAngle(Player player, EntityDamageEvent event) {
if (!VersionUtil.getVersion().equals("v1_11_R1")) { UUID uuid = player.getUniqueId();
return; Entity entity = event.getEntity();
} Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
AntiCheat.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheat.getPlugin(), ListenerPriority.NORMAL, new PacketType[] {PacketType.Play.Client.USE_ENTITY}) {
@Override // Check if enabled
public void onPacketReceiving(PacketEvent e) { if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "angle"))
Player p = e.getPlayer(); return PASS;
if (!NPC_LIST.containsKey(p.getUniqueId()))
return; if (entity instanceof LivingEntity) {
int id = e.getPacket().getIntegers().read(0); LivingEntity living = (LivingEntity) entity;
if (NPC_LIST.containsKey(p.getUniqueId())) { Location eyeLocation = player.getEyeLocation();
if (NPC_LIST.get(p.getUniqueId()).getID() != id) {
return; double yawDifference = calculateYawDifference(eyeLocation, living.getLocation());
} double playerYaw = player.getEyeLocation().getYaw();
}
if (!VL_COUNT.containsKey(p.getUniqueId())) { double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
VL_COUNT.put(p.getUniqueId(), 1); int maxDifference = checksConfig.getInteger(CheckType.KILLAURA, "angle", "maxDifference");
NPC_LIST.get(p.getUniqueId()).damage(); if (Math.round(angleDifference) > maxDifference) {
}else { if (!ANGLE_FLAGS.containsKey(uuid)) {
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1); ANGLE_FLAGS.put(uuid, 1);
if (VL_COUNT.get(p.getUniqueId()) >= 5) { return PASS;
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.KILLAURA);
AntiCheat.getPlugin().onKillAuraViolation();
VL_COUNT.remove(p.getUniqueId());
}
}
}
});
} }
public static void doDamageEvent(EntityDamageByEntityEvent e, Player p) { int flags = ANGLE_FLAGS.get(uuid);
if (!VersionUtil.getVersion().equals("v1_11_R1")) { int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "angle", "vlBeforeFlag");
return; if (flags >= vlBeforeFlag) {
ANGLE_FLAGS.remove(uuid);
return new CheckResult(CheckResult.Result.FAILED, "Angle",
"tried to attack from an illegal angle (angle=" + Math.round(angleDifference) + ")");
} }
if (NPC_LIST.containsKey(p.getUniqueId()))
NPC_LIST.get(p.getUniqueId()).damage(e, p); ANGLE_FLAGS.put(uuid, flags + 1);
else {
NPC_1_11 npc = new NPC_1_11(p);
NPC_LIST.put(p.getUniqueId(), npc);
npc.spawn();
} }
} }
public static void doMove(PlayerMoveEvent e) { return PASS;
if (!VersionUtil.getVersion().equals("v1_11_R1")) {
return;
} }
if (NPC_LIST.containsKey(e.getPlayer().getUniqueId())) {
NPC_LIST.get(e.getPlayer().getUniqueId()).move(e); 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, "PacketOrder", "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();
} }
} }
@@ -1,51 +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; package com.rammelkast.anticheatreloaded.check.combat;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.scheduler.BukkitRunnable;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.event.EventListener; 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 class VelocityCheck {
private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>(); public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static void cleanPlayer(Player p) { public static CheckResult runCheck(Player player, Distance distance) {
VL_COUNT.remove(p.getUniqueId()); 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");
public static void runCheck(EntityDamageByEntityEvent e, final Player p) { if (movementManager.velocityExpectedMotionY > 0 && !movementManager.onGround) {
if (AntiCheat.getManager().getCheckManager().isOpExempt(p) || AntiCheat.getManager().getCheckManager().isExempt(p, CheckType.VELOCITY)) double percentage = (movementManager.motionY / movementManager.velocityExpectedMotionY) * 100;
return; if (percentage < 0)
final Location then = p.getLocation(); percentage = 0;
new BukkitRunnable() { // Reset expected Y motion
@Override movementManager.velocityExpectedMotionY = 0;
public void run() { if (percentage < minimumPercentage) {
if (!p.isOnline()) int vl = VIOLATIONS.getOrDefault(player.getUniqueId(), 0) + 1;
return; VIOLATIONS.put(player.getUniqueId(), vl);
if (then.distance(p.getLocation()) < 0.125) { if (vl >= vlBeforeFlag)
if (!VL_COUNT.containsKey(p.getUniqueId())) return new CheckResult(Result.FAILED, "ignored server velocity (pct=" + Utilities.roundDouble(percentage, 2) + ")");
VL_COUNT.put(p.getUniqueId(), 1); } else {
else { VIOLATIONS.remove(player.getUniqueId());
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() + ", dist=" + then.distance(p.getLocation()) + ")").getMessage(), p, CheckType.VELOCITY);
VL_COUNT.remove(p.getUniqueId());
} }
} } else if (movementManager.airTicks > 5 && movementManager.velocityExpectedMotionY > 0)
}else { movementManager.velocityExpectedMotionY = 0;
VL_COUNT.remove(p.getUniqueId()); return PASS;
}
}
}.runTaskLater(AntiCheat.getPlugin(), 4);
} }
} }
@@ -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;
}
}
@@ -1,59 +0,0 @@
package com.rammelkast.anticheatreloaded.check.movement;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.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(), 20, 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);
}
}
}
}
});
}
}
@@ -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 java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
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.MovementManager;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class BoatFlyCheck {
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, MovementManager movementManager, Location to) {
if (movementManager.distanceXZ <= 0 || movementManager.motionY <= 1E-3
|| (System.currentTimeMillis() - movementManager.lastTeleport <= 50) || VersionUtil.isFlying(player)
|| !player.isInsideVehicle())
return PASS;
UUID uuid = player.getUniqueId();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
if (player.getVehicle().getType() == EntityType.BOAT) {
Block bottom = player.getWorld().getBlockAt(to.getBlockX(), to.getBlockY() - 1, to.getBlockZ());
if (!Utilities.cantStandAt(bottom))
return PASS;
int violations = VIOLATIONS.getOrDefault(uuid, 1);
if (violations++ >= checksConfig.getInteger(CheckType.BOATFLY, "vlBeforeFlag")) {
violations = 0;
return new CheckResult(Result.FAILED, "tried to fly in a boat (mY=" + movementManager.motionY
+ ", bottom=" + bottom.getType().name().toLowerCase() + ")");
}
VIOLATIONS.put(uuid, violations);
}
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;
}
}
@@ -1,19 +0,0 @@
package com.rammelkast.anticheatreloaded.check.movement;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Distance;
/**
* TODO
*/
public class ElytraFly {
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static CheckResult runCheck(Player player, Distance distance) {
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;
}
}
@@ -1,94 +1,179 @@
/*
* 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; package com.rammelkast.anticheatreloaded.check.movement;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.Backend;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.util.Distance; 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.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.VersionUtil;
/** /**
* * @author Rammelkast
* @author Marco TODO rewrite this check
*/ */
public class FlightCheck { 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 CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
private static final double GRAVITY_FRICTION = 0.9800000190734863D;
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) { public static CheckResult runCheck(Player player, Distance distance) {
if (distance.getYDifference() > AntiCheat.getManager().getBackend().getMagic().TELEPORT_MIN() if (distance.getYDifference() >= AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|| VersionUtil.isFlying(player)) { || VersionUtil.isFlying(player) || player.getVehicle() != null
// This was a teleport or user is flying/elyta'ing, so we don't care || 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. // about it.
return PASS; 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)) { User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
blocksOverFlight.put(uuid, 0D); 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, "AirFlight",
"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.isNearWeb(player)
&& movementManager.elytraEffectTicks <= 25)
return new CheckResult(CheckResult.Result.FAILED, "AirFlight", "had too little Y dropoff (diff="
+ Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")");
} }
// End AirFlight
blocksOverFlight.put(uuid, (blocksOverFlight.get(uuid) + distance.getXDifference() // Start AirClimb
+ distance.getYDifference() + distance.getZDifference())); // 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, "AirClimb",
"tried to climb air (mY=" + movementManager.motionY + ")");
if (y1 > y2) { // TODO hardcoded value against false again..
blocksOverFlight.put(uuid, (blocksOverFlight.get(uuid) - distance.getYDifference())); 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, "AirClimb",
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
} }
// End AirClimb
if (blocksOverFlight.get(uuid) > AntiCheat.getManager().getBackend().getMagic().FLIGHT_BLOCK_LIMIT() // Start GroundFlight
&& (y1 <= y2)) { if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "groundFlight") && movementManager.onGround
return new CheckResult(CheckResult.Result.FAILED, && Utilities.cantStandAt(distance.getTo().getBlock().getRelative(BlockFace.DOWN))
player.getName() + " flew over " + blocksOverFlight.get(uuid) + " blocks (max=" && Utilities.cantStandAt(distance.getFrom().getBlock().getRelative(BlockFace.DOWN))
+ AntiCheat.getManager().getBackend().getMagic().FLIGHT_BLOCK_LIMIT() + ")"); && Utilities.cantStandAt(distance.getTo().getBlock())) {
return new CheckResult(CheckResult.Result.FAILED, "GroundFlight",
"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.isNearWeb(player) && movementManager.elytraEffectTicks <= 25
&& !VersionUtil.isSlowFalling(player)) {
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, "Gravity",
"ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")");
} else { } else {
blocksOverFlight.put(uuid, 0D); GRAVITY_VIOLATIONS.remove(player.getUniqueId());
} }
}
// End Gravity
return PASS; 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,72 +0,0 @@
package com.rammelkast.anticheatreloaded.check.movement;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.check.Backend;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class GlideCheck {
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static Map<UUID, Double> lastDiff = new HashMap<UUID, Double>();
public static Map<UUID, Float> lastFallDistance = new HashMap<UUID, Float>();
public static Map<UUID, Integer> violations = new HashMap<UUID, Integer>();
public static CheckResult runCheck(Player player, Distance distance) {
if (VersionUtil.isFlying(player)) {
return PASS;
}
if (!lastDiff.containsKey(player.getUniqueId())) {
lastDiff.put(player.getUniqueId(), distance.getYDifference());
return PASS;
}
if (!lastFallDistance.containsKey(player.getUniqueId())) {
lastFallDistance.put(player.getUniqueId(), player.getFallDistance());
return PASS;
}
double yDiff = distance.getYDifference();
float fallDistance = player.getFallDistance();
if (yDiff == lastDiff.get(player.getUniqueId()) && fallDistance > lastFallDistance.get(player.getUniqueId())) {
if (!violations.containsKey(player.getUniqueId())) {
violations.put(player.getUniqueId(), 1);
} else {
if (violations.get(player.getUniqueId()) + 1 >= AntiCheat.getManager().getBackend().getMagic().GLIDE_LIMIT()) {
violations.remove(player.getUniqueId());
Location to = player.getLocation();
to.setY(to.getY() - distanceToFall(to));
player.teleport(to);
return new CheckResult(CheckResult.Result.FAILED,
player.getName() + " was set back for gliding (yDiff=" + new BigDecimal(yDiff).setScale(2, BigDecimal.ROUND_UP) + ")");
} else {
violations.put(player.getUniqueId(), violations.get(player.getUniqueId()) + 1);
}
}
}
lastDiff.put(player.getUniqueId(), distance.getYDifference());
lastFallDistance.put(player.getUniqueId(), player.getFallDistance());
return PASS;
}
private static double distanceToFall(Location location) {
location = location.clone();
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();
}
}
@@ -0,0 +1,81 @@
/*
* 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.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.MovementManager;
import com.rammelkast.anticheatreloaded.util.User;
public class NoSlowCheck {
public static final Map<UUID, Long> LAST_RELEASE = new HashMap<UUID, Long>();
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
public static void runCheck(Player player, PacketEvent event) {
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.NOSLOW))
return;
UUID uuid = player.getUniqueId();
User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
MovementManager movementManager = user.getMovementManager();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
final long time = System.currentTimeMillis();
final long lastRelease = LAST_RELEASE.getOrDefault(uuid, 0L);
LAST_RELEASE.put(uuid, time);
if (lastRelease == 0L)
return;
long difference = time - lastRelease;
long minimumDifference = checksConfig.getInteger(CheckType.NOSLOW, "minimumDifference");
if (difference < minimumDifference
&& movementManager.distanceXZ >= checksConfig.getDouble(CheckType.NOSLOW, "minimumDistXZ")) {
int violations = VIOLATIONS.getOrDefault(uuid, 1);
if (violations++ >= checksConfig.getInteger(CheckType.NOSLOW, "vlBeforeFlag")) {
violations = 0;
flag(player, event,
"toggled use item too fast (diff=" + difference + ", min=" + minimumDifference + ")");
}
VIOLATIONS.put(uuid, violations);
}
}
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.NOSLOW, null);
player.teleport(player.getLocation());
}
});
}
}
@@ -1,79 +1,288 @@
/*
* 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; package com.rammelkast.anticheatreloaded.check.movement;
import java.util.HashMap; import org.bukkit.Location;
import java.util.Map; import org.bukkit.block.BlockFace;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.Backend;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.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; import com.rammelkast.anticheatreloaded.util.VersionUtil;
/**
* @author Rammelkast TODO soulsand speed
*/
public class SpeedCheck { public class SpeedCheck {
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); 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) { public static boolean isSpeedExempt(Player player, Backend backend) {
return AntiCheat.getManager().getBackend().isMovingExempt(player) return backend.isMovingExempt(player) || backend.justVelocity(player) || VersionUtil.isFlying(player);
|| AntiCheat.getManager().getBackend().justVelocity(player) || VersionUtil.isFlying(player);
} }
public static CheckResult checkXZSpeed(Player player, double x, double z) { public static CheckResult checkXZSpeed(Player player, double x, double z, Location movingTowards) {
if (!isSpeedExempt(player) && player.getVehicle() == null) { Backend backend = AntiCheatReloaded.getManager().getBackend();
String reason = ""; if (isSpeedExempt(player, backend) || player.getVehicle() != null || Utilities.isInWater(player))
double max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX(); return PASS;
if (player.getLocation().getBlock().getType() == Material.SOUL_SAND) {
if (player.isSprinting()) { MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
reason = "on soulsand while sprinting "; .getMovementManager();
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND_SPRINT(); Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) { double distanceXZ = movementManager.distanceXZ;
reason = "on soulsand with speed potion "; boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid;
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND_POTION();
} else { // AirSpeed
reason = "on soulsand "; if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airSpeed") && movementManager.airTicks > 1
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND(); && 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;
} }
} else if (VersionUtil.isFlying(player)) { // Leniency when boxed in
reason = "while flying "; if (boxedIn && movementManager.airTicks < 3)
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_FLY(); predict *= 1.2D;
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) { // Adjust for slime
if (player.isSprinting()) { if (movementManager.slimeInfluenceTicks > 0) {
reason = "with speed potion while sprinting "; double slimeIncrement = 0.022 * Math.pow(1.0375, movementManager.slimeInfluenceTicks);
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_POTION_SPRINT(); // Clamp to max value
} else { if (slimeIncrement > 0.12D)
reason = "with speed potion "; slimeIncrement = 0.12D;
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_POTION(); predict += slimeIncrement;
}
// Adjust for speed effects
if (movementManager.hasSpeedEffect)
predict += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect)
limit *= 1.2D;
// 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.08) || movementManager.airTicks >= 40
&& (movingTowards.getBlockY() - player.getWorld().getHighestBlockYAt(movingTowards)) <= 1.5)
predict *= (movementManager.airTicks > 60 ? 4.0D : (movementManager.airTicks > 30 ? 3.0D : 2.0D));
// Players can move faster in air with slow falling
if (VersionUtil.isSlowFalling(player))
predict *= 1.25D;
// Prevent NoSlow
if (movementManager.blockingTicks > 3 && movementManager.airTicks > 2)
predict *= 0.8D;
if (movementManager.blockingTicks > 10 && movementManager.airTicks > 2)
predict *= 0.5D;
// 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, "AirSpeed",
"moved too fast in air (speed=" + distanceXZ + ", limit=" + predict + ", block="
+ movementManager.blockingTicks + ", box=" + boxedIn + ", at="
+ movementManager.airTicks + ")");
} }
} else if (player.isSprinting()) {
reason = "while sprinting ";
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT();
} }
float speed = player.getWalkSpeed(); // AirAcceleration
max += speed > 0 ? player.getWalkSpeed() - 0.2f : 0; // 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.08D;
// 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, "AirAcceleration",
"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
if (distanceXZ >= minimumDistXZ || movementManager.lastDistanceXZ >= minimumDistXZ) {
return new CheckResult(CheckResult.Result.FAILED, "JumpBehaviour",
"had unexpected jumping behaviour (dXZ=" + Utilities.roundDouble(distanceXZ, 4) + ", lXZ="
+ Utilities.roundDouble(movementManager.lastDistanceXZ, 4) + ")");
}
}
}
// 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 (movementManager.hasSpeedEffect)
limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.06D;
if (movementManager.hasSpeedEffect && movementManager.groundTicks > 3)
limit *= 1.4D;
if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect)
limit *= 1.2D;
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, "GroundSpeed",
"moved too fast on ground (speed=" + distanceXZ + ", limit=" + limit + ", blocking="
+ player.isBlocking() + ", gt=" + movementManager.groundTicks + ")");
}
}
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; return PASS;
} }
} else {
speedViolation.put(player.getUniqueId(), 0); 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; 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, "VerticalSpeed",
"exceeded vertical speed limit (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")");
} }
} else {
return PASS; 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,71 @@
/*
* 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.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;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
/**
*
* @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) || VersionUtil.isFlying(player) || player.isDead()
|| Utilities.isHalfblock(to.getBlock().getRelative(BlockFace.DOWN)))
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
|| movementManager.halfMovementHistoryCounter >= 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;
}
}
@@ -1,105 +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; package com.rammelkast.anticheatreloaded.check.movement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; 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.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
/**
* This check seems to be broken/outdated
*/
public class WaterWalkCheck { public class WaterWalkCheck {
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static List<UUID> isInWater = new ArrayList<UUID>();
public static List<UUID> isInWaterCache = new ArrayList<UUID>();
public static Map<UUID, Integer> waterSpeedViolation = new HashMap<UUID, Integer>();
public static Map<UUID, Integer> waterAscensionViolation = new HashMap<UUID, Integer>();
/**
* TODO check & fix for 1.11? (see #25)
*/
public static CheckResult runCheck(Player player, double x, double y, double z) { public static CheckResult runCheck(Player player, double x, double y, double z) {
Block block = player.getLocation().getBlock();
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
MovementManager movementManager = user.getMovementManager();
if (player.getVehicle() == null && !player.isFlying()) { if (movementManager.distanceXZ <= 0 || player.getVehicle() != null || Utilities.isOnLilyPad(player)
if (block.isLiquid()) { || VersionUtil.isRiptiding(player) || VersionUtil.isSwimming(player) || VersionUtil.isFlying(player))
if (isInWater.contains(uuid)) {
if (isInWaterCache.contains(uuid)) {
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(uuid)) {
int v = waterSpeedViolation.get(uuid);
if (v >= AntiCheat.getManager().getBackend().getMagic()
.WATER_SPEED_VIOLATION_MAX()) {
waterSpeedViolation.put(uuid, 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(uuid, v + 1);
}
} else {
waterSpeedViolation.put(uuid, 1);
}
}
}
} else {
isInWaterCache.add(uuid);
return PASS; return PASS;
}
} else { Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
isInWater.add(uuid); Block blockBeneath = player.getLocation().clone().subtract(0, 0.1, 0).getBlock();
return PASS; if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "walk") && blockBeneath.isLiquid()
} && Utilities.isSurroundedByWater(player)
} else if (block.getRelative(BlockFace.DOWN).isLiquid() && ((movementManager.motionY == 0 && movementManager.lastMotionY == 0)
&& !AntiCheat.getManager().getBackend().isAscending(player) && Utilities.cantStandAt(block) || movementManager.motionY == Utilities.JUMP_MOTION_Y)
&& Utilities.cantStandAt(block.getRelative(BlockFace.DOWN))) { && movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "walk", "minimumDistXZ")
if (waterAscensionViolation.containsKey(uuid)) { && !movementManager.topSolid && !Utilities.couldBeOnBoat(player, 3, false))
int v = waterAscensionViolation.get(uuid); return new CheckResult(Result.FAILED, "Walk",
if (v >= AntiCheat.getManager().getBackend().getMagic().WATER_ASCENSION_VIOLATION_MAX()) { "tried to walk on water (xz=" + Utilities.roundDouble(movementManager.distanceXZ, 5) + ")");
waterAscensionViolation.put(uuid, 0);
return new CheckResult(CheckResult.Result.FAILED, if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "hop") && blockBeneath.isLiquid()
player.getName() + " stood on water " + v + " times (can't stand on " + block.getType() && Utilities.isSurroundedByWater(player) && movementManager.onGround
+ " or " + block.getRelative(BlockFace.DOWN).getType() + ")"); && Math.abs(movementManager.motionY) < checksConfig.getDouble(CheckType.WATER_WALK, "hop", "maxMotionY")
} else { && !Utilities.couldBeOnBoat(player, 0.3, false))
waterAscensionViolation.put(uuid, v + 1); return new CheckResult(Result.FAILED, "Hop",
} "tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")");
} else {
waterAscensionViolation.put(uuid, 1); double minAbsMotionY = 0.12D;
} if (player.hasPotionEffect(PotionEffectType.SPEED))
} else { minAbsMotionY += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
isInWater.remove(uuid); if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && blockBeneath.isLiquid()
isInWaterCache.remove(uuid); && Utilities.isSurroundedByWater(player)
} && Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY
} && movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "lunge", "minimumDistXZ")
&& movementManager.lastMotionY > -0.25
&& !Utilities.couldBeOnBoat(player, 0.3, false))
return new CheckResult(Result.FAILED, "Lunge", "tried to lunge in water (xz="
+ Utilities.roundDouble(movementManager.distanceXZ, 5) + ", absMotionY="
+ Utilities.roundDouble(Math.abs(movementManager.lastMotionY - movementManager.motionY), 5) + ")");
return PASS; return PASS;
} }
@@ -1,111 +0,0 @@
package com.rammelkast.anticheatreloaded.check.movement;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import com.rammelkast.anticheatreloaded.AntiCheat;
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 YAxisCheck {
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static Map<UUID, Double> lastYcoord = new HashMap<UUID, Double>();
public static Map<UUID, Long> lastYtime = new HashMap<UUID, Long>();
public static Map<UUID, Integer> yAxisViolations = new HashMap<UUID, Integer>();
public static Map<UUID, Long> yAxisLastViolation = new HashMap<UUID, 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();
UUID uuid = player.getUniqueId();
// Fix Y axis spam.
if (!lastYcoord.containsKey(uuid) || !lastYtime.containsKey(uuid)
|| !yAxisLastViolation.containsKey(uuid)) {
lastYcoord.put(uuid, y1);
yAxisViolations.put(uuid, 0);
yAxisLastViolation.put(uuid, 0L);
lastYtime.put(uuid, System.currentTimeMillis());
} else {
if (y1 > lastYcoord.get(uuid)
&& yAxisViolations.get(uuid) > AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOLATIONS()
&& (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) < AntiCheat.getManager()
.getBackend().getMagic().Y_MAXVIOTIME()) {
Location g = player.getLocation();
yAxisViolations.put(uuid, yAxisViolations.get(uuid) + 1);
yAxisLastViolation.put(uuid, System.currentTimeMillis());
if (!AntiCheat.getManager().getBackend().silentMode()) {
g.setY(lastYcoord.get(uuid));
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(uuid) + " times (max ="
+ AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOLATIONS() + ")");
} else {
if (yAxisViolations.get(uuid) > AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOLATIONS()
&& (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) > AntiCheat.getManager()
.getBackend().getMagic().Y_MAXVIOTIME()) {
yAxisViolations.put(uuid, 0);
yAxisLastViolation.put(uuid, 0L);
}
}
long i = System.currentTimeMillis() - lastYtime.get(uuid);
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(uuid)) > diff && i < AntiCheat.getManager().getBackend().getMagic().Y_TIME()) {
Location g = player.getLocation();
yAxisViolations.put(uuid, yAxisViolations.get(uuid) + 1);
yAxisLastViolation.put(uuid, System.currentTimeMillis());
if (!AntiCheat.getManager().getBackend().silentMode()) {
g.setY(lastYcoord.get(uuid));
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(uuid)) > AntiCheat.getManager().getBackend().getMagic().Y_MAXDIFF() + 1
|| (System.currentTimeMillis() - lastYtime.get(uuid)) > AntiCheat.getManager().getBackend()
.getMagic().Y_TIME()) {
lastYtime.put(uuid, System.currentTimeMillis());
lastYcoord.put(uuid, y1);
}
}
}
}
// Fix Y axis spam
return PASS;
}
public static boolean isMoveUpBlock(Block block) {
return VersionUtil.getMoveUpBlocks().contains(block.getType());
}
}
@@ -0,0 +1,102 @@
/*
* 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 <= 150))
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");
// Fix falling false
if (movementManager.airTicks >= 40 && movementManager.motionY < 0 && movementManager.lastMotionY < 0)
maxDistance *= 1.5D;
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 + ", at=" + movementManager.airTicks + ")");
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, null);
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, null);
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,121 @@
/*
* 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, "Interact",
"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, "Break", "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, "Place", "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;
}
}
@@ -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
@@ -24,7 +25,7 @@ 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 com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.manage.CheckManager; import com.rammelkast.anticheatreloaded.manage.CheckManager;
import com.rammelkast.anticheatreloaded.manage.UserManager; import com.rammelkast.anticheatreloaded.manage.UserManager;
@@ -32,9 +33,9 @@ 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);
} }
@@ -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
@@ -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 com.rammelkast.anticheatreloaded.command.executors.CommandCheck; import com.rammelkast.anticheatreloaded.command.executors.CommandChecks;
import com.rammelkast.anticheatreloaded.command.executors.CommandDebug;
import com.rammelkast.anticheatreloaded.command.executors.CommandDeveloper;
import com.rammelkast.anticheatreloaded.command.executors.CommandHelp; import com.rammelkast.anticheatreloaded.command.executors.CommandHelp;
import com.rammelkast.anticheatreloaded.command.executors.CommandLog; import com.rammelkast.anticheatreloaded.command.executors.CommandLog;
import com.rammelkast.anticheatreloaded.command.executors.CommandMute;
import com.rammelkast.anticheatreloaded.command.executors.CommandReload; import com.rammelkast.anticheatreloaded.command.executors.CommandReload;
import com.rammelkast.anticheatreloaded.command.executors.CommandReport; import com.rammelkast.anticheatreloaded.command.executors.CommandReport;
import com.rammelkast.anticheatreloaded.command.executors.CommandReset; import com.rammelkast.anticheatreloaded.command.executors.CommandReset;
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
@@ -1,97 +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 com.rammelkast.anticheatreloaded.command.executors;
import org.bukkit.command.CommandSender;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.Permission;
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);
}
}
@@ -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);
}
}
@@ -1,60 +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 com.rammelkast.anticheatreloaded.command.executors;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.PastebinReport;
import com.rammelkast.anticheatreloaded.util.Permission;
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.");
}
}
@@ -1,46 +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 com.rammelkast.anticheatreloaded.command.executors;
import org.bukkit.command.CommandSender;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandDeveloper extends CommandBase {
private static final String NAME = "AntiCheat Developer Mode";
private static final String COMMAND = "developer";
private static final String USAGE = "anticheat developer";
private static final Permission PERMISSION = Permission.SYSTEM_DEBUG;
private static final String[] HELP = {
GRAY + "Use: " + AQUA + "/anticheat developer" + GRAY + " to turn on developer mode",
};
public CommandDeveloper() {
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
}
@Override
protected void execute(CommandSender cs, String[] args) {
AntiCheat.setDeveloperMode(!AntiCheat.developerMode());
cs.sendMessage(GREEN + "Developer mode " + (AntiCheat.developerMode() ? "ON" : "OFF"));
}
}
@@ -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
@@ -30,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() {
@@ -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
@@ -26,7 +27,7 @@ import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandLog extends CommandBase { public class CommandLog extends CommandBase {
private static final String NAME = "AntiCheat Logging"; private static final String NAME = "AntiCheatReloaded Logging";
private static final String COMMAND = "log"; private static final String COMMAND = "log";
private static final String USAGE = "anticheat log [file/console] [on/off]"; private static final String USAGE = "anticheat log [file/console] [on/off]";
private static final Permission PERMISSION = Permission.SYSTEM_LOG; private static final Permission PERMISSION = Permission.SYSTEM_LOG;
@@ -0,0 +1,61 @@
/*
* AntiCheatReloaded for Bukkit and Spigot.
* Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.rammelkast.anticheatreloaded.command.executors;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandMute extends CommandBase {
private static final String NAME = "AntiCheatReloaded Mute";
private static final String COMMAND = "mute";
private static final String USAGE = "anticheat 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;
}
}
}
@@ -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
@@ -18,6 +19,7 @@
package com.rammelkast.anticheatreloaded.command.executors; package com.rammelkast.anticheatreloaded.command.executors;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.rammelkast.anticheatreloaded.command.CommandBase; import com.rammelkast.anticheatreloaded.command.CommandBase;
@@ -25,7 +27,7 @@ import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandReload extends CommandBase { public class CommandReload extends CommandBase {
private static final String NAME = "AntiCheat Reload"; private static final String NAME = "AntiCheatReloaded Reload";
private static final String COMMAND = "reload"; private static final String COMMAND = "reload";
private static final String USAGE = "anticheat reload"; private static final String USAGE = "anticheat reload";
private static final Permission PERMISSION = Permission.SYSTEM_RELOAD; private static final Permission PERMISSION = Permission.SYSTEM_RELOAD;
@@ -40,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");
} }
} }
@@ -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
@@ -15,35 +16,35 @@
* 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.command.executors; package com.rammelkast.anticheatreloaded.command.executors;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.manage.CheckManager;
import com.rammelkast.anticheatreloaded.util.*;
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.OfflinePlayer;
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.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() {
super(NAME, COMMAND, USAGE, HELP, PERMISSION); super(NAME, COMMAND, USAGE, HELP, PERMISSION);
@@ -63,33 +64,37 @@ public class CommandReport extends CommandBase {
if ("low".equalsIgnoreCase(args[0])) { if ("low".equalsIgnoreCase(args[0])) {
groupReport(cs, null, page); groupReport(cs, null, page);
} } else if ("all".equalsIgnoreCase(args[0])) {
else if ("all".equalsIgnoreCase(args[0])) {
cs.sendMessage(GREEN + "Low: " + WHITE + USER_MANAGER.getUsersInGroup(null).size() + " players"); cs.sendMessage(GREEN + "Low: " + WHITE + USER_MANAGER.getUsersInGroup(null).size() + " players");
for (Group g : CONFIG.getGroups().getGroups()) { for (Group g : CONFIG.getGroups().getGroups()) {
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()) {
if (group.getName().equalsIgnoreCase(args[0]) || "low".equalsIgnoreCase(args[0]) || "all".equalsIgnoreCase(args[0])) { if (group.getName().equalsIgnoreCase(args[0]) || "low".equalsIgnoreCase(args[0])
|| "all".equalsIgnoreCase(args[0])) {
groupReport(cs, group, page); groupReport(cs, group, page);
return; return;
} }
} }
// Test users @SuppressWarnings("deprecation")
for (Player player : Bukkit.getOnlinePlayers()) { OfflinePlayer targetPlayer = Bukkit.getOfflinePlayer(args[0]);
if (player.getUniqueId().equals(Bukkit.getPlayer(args[0]).getUniqueId())) { if (targetPlayer == null) {
User user = AntiCheat.getManager().getUserManager().getUser(player.getUniqueId()); cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
return;
}
User user = AntiCheatReloaded.getManager().getUserManager().getUser(targetPlayer.getUniqueId());
if (user != null) {
playerReport(cs, user, page); playerReport(cs, user, page);
return; return;
} }
}
// Neither of these
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]); cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
} }
} else { } else {
@@ -103,7 +108,8 @@ 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));
@@ -115,7 +121,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);
@@ -146,8 +152,13 @@ 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);
int ping = user.getPing();
cs.sendMessage(GRAY + "Ping: " + ((ping == -1) ? (RED + "Offline")
: (WHITE + "" + ping + "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)));
@@ -160,14 +171,18 @@ 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);
int ping = user.getPing();
cs.sendMessage(GRAY + "Ping: " + ((ping == -1) ? (RED + "Offline")
: (WHITE + "" + ping + "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);
@@ -175,19 +190,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");
}
} }
} }
@@ -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
@@ -20,16 +21,15 @@ package com.rammelkast.anticheatreloaded.command.executors;
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.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.command.CommandBase; import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.util.Permission; import com.rammelkast.anticheatreloaded.util.Permission;
import com.rammelkast.anticheatreloaded.util.User; 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 + ".");
}
}
@@ -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
@@ -18,21 +19,35 @@
package com.rammelkast.anticheatreloaded.config; package com.rammelkast.anticheatreloaded.config;
import org.bukkit.configuration.file.YamlConfiguration;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.config.files.Config;
import com.rammelkast.anticheatreloaded.config.files.Enterprise;
import com.rammelkast.anticheatreloaded.config.holders.mysql.*;
import com.rammelkast.anticheatreloaded.config.holders.yaml.*;
import com.rammelkast.anticheatreloaded.config.providers.*;
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
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;
@@ -44,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);
@@ -56,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>();
@@ -80,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);
@@ -129,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) {
@@ -146,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);
} }
} }
} }
@@ -191,4 +216,8 @@ public class Configuration {
public Magic getMagic() { public Magic getMagic() {
return magic; return magic;
} }
public Checks getChecks() {
return checks;
}
} }
@@ -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
@@ -21,11 +22,12 @@ package com.rammelkast.anticheatreloaded.config;
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.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.yaml.CommentedConfiguration; 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 {
@@ -36,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;
@@ -59,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();
} }
@@ -162,6 +170,7 @@ public class ConfigurationFile {
return path; return path;
} }
@SuppressWarnings("unchecked")
public T getValue() { public T getValue() {
return (T) value; return (T) value;
} }
@@ -172,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);
} }
@@ -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
@@ -20,7 +21,7 @@ package com.rammelkast.anticheatreloaded.config;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.util.enterprise.Database; import com.rammelkast.anticheatreloaded.util.enterprise.Database;
import java.sql.Connection; import java.sql.Connection;
@@ -59,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();
@@ -103,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 + " = ?";
@@ -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
@@ -20,7 +21,7 @@ package com.rammelkast.anticheatreloaded.config.files;
import java.util.List; import java.util.List;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile; import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
@@ -29,13 +30,13 @@ 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> disableBroadcast;
public ConfigValue<Boolean> blockChatSpamSpeed; public ConfigValue<Boolean> blockChatSpamSpeed;
public ConfigValue<Boolean> blockCommandSpamSpeed; public ConfigValue<Boolean> blockCommandSpamSpeed;
@@ -49,9 +50,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 +62,13 @@ 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");
disableBroadcast = new ConfigValue<Boolean>("system.disable-broadcast");
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 +83,14 @@ 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);
}
} }
} }
@@ -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
@@ -18,7 +19,7 @@
package com.rammelkast.anticheatreloaded.config.files; package com.rammelkast.anticheatreloaded.config.files;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile; import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.util.enterprise.Database; import com.rammelkast.anticheatreloaded.util.enterprise.Database;
@@ -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);
} }
@@ -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
@@ -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
@@ -21,11 +22,13 @@ package com.rammelkast.anticheatreloaded.config.holders.mysql;
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.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable; import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Lang; 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;
@@ -50,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>>();
@@ -142,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.";
} }
@@ -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
@@ -20,7 +21,7 @@ package com.rammelkast.anticheatreloaded.config.holders.mysql;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable; import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Levels; import com.rammelkast.anticheatreloaded.config.providers.Levels;
@@ -81,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());
@@ -101,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 {
@@ -120,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"));
} }
@@ -162,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 {
@@ -174,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"));
} }
@@ -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
@@ -21,11 +22,13 @@ package com.rammelkast.anticheatreloaded.config.holders.mysql;
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.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable; import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Magic; 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;
@@ -47,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>();
@@ -94,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)) {
@@ -141,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;
} }
} }
@@ -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
@@ -23,7 +24,7 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable; import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Rules; import com.rammelkast.anticheatreloaded.config.providers.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) {
@@ -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");
}
}
@@ -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
@@ -20,7 +21,7 @@ package com.rammelkast.anticheatreloaded.config.holders.yaml;
import java.util.*; import java.util.*;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile; import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.config.providers.Groups; import com.rammelkast.anticheatreloaded.config.providers.Groups;
@@ -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);
} }
@@ -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
@@ -22,7 +23,7 @@ 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.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile; import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
@@ -30,7 +31,7 @@ public class YamlLangHolder extends ConfigurationFile implements InvocationHandl
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.";
} }
} }
@@ -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
@@ -21,7 +22,7 @@ package com.rammelkast.anticheatreloaded.config.holders.yaml;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile; import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.config.providers.Levels; import com.rammelkast.anticheatreloaded.config.providers.Levels;
@@ -31,7 +32,7 @@ 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);
} }
} }
@@ -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
@@ -21,7 +22,7 @@ package com.rammelkast.anticheatreloaded.config.holders.yaml;
import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile; import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
@@ -29,7 +30,7 @@ public class YamlMagicHolder extends ConfigurationFile implements InvocationHand
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;
} }
} }
@@ -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
@@ -21,7 +22,7 @@ package com.rammelkast.anticheatreloaded.config.holders.yaml;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile; import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.config.providers.Rules; import com.rammelkast.anticheatreloaded.config.providers.Rules;
@@ -33,7 +34,7 @@ public class YamlRulesHolder extends ConfigurationFile implements Rules {
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);
}
@@ -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
@@ -1,3 +1,22 @@
/*
* 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; package com.rammelkast.anticheatreloaded.config.providers;
import java.util.List; import java.util.List;
@@ -80,4 +99,12 @@ public interface Lang {
* @return Kicking broadcast. * @return Kicking broadcast.
*/ */
public String KICK_BROADCAST(); public String KICK_BROADCAST();
/**
* Get the alert prefix for staff and debug.
*
* @return Alert prefix.
*/
public String ALERT_PREFIX();
} }
@@ -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
@@ -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
@@ -41,26 +42,14 @@ public interface Magic {
* Time to exempt a player from moving because of entering/exiting a vehicle; Type=SYSTEM, Leniency=INCREASE. * Time to exempt a player from moving because of entering/exiting a vehicle; Type=SYSTEM, Leniency=INCREASE.
*/ */
public int ENTERED_EXITED_TIME(); 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. * Time to exempt a player from moving because of teleporting; Type=SYSTEM, Leniency=INCREASE.
*/ */
public int TELEPORT_TIME(); 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. * Time to exempt a player from moving because of joining the server; Type=SYSTEM, Leniency=INCREASE.
*/ */
public int JOIN_TIME(); 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. * Time to exempt a player from moving because of taking damage; Type=SYSTEM, Leniency=INCREASE.
*/ */
@@ -73,308 +62,28 @@ public interface Magic {
* Time to exempt a player from moving because of taking damage from an explosion; Type=SYSTEM, Leniency=INCREASE. * Time to exempt a player from moving because of taking damage from an explosion; Type=SYSTEM, Leniency=INCREASE.
*/ */
public int EXPLOSION_DAMAGE_TIME(); 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();
/**
* 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. * Time used to schedule increasing a players velocity count - probably not touching this would be good; Type=INTEGER.
*/ */
public int VELOCITY_SCHETIME(); public int VELOCITY_EXTENSION();
/** /**
* Maximum time a player is considered to have a change in velocity; Type=SYSTEM, Leniency=INCREASE. * Time a player is considered to have a change in velocity; Type=SYSTEM, Leniency=INCREASE.
*/ */
public int VELOCITY_CHECKTIME(); public int VELOCITY_TIME();
/** /**
* Time to extend a player's velocity count by; Type=SYSTEM, Leniency=INCREASE. * Time to extend a player's velocity count by; Type=SYSTEM, Leniency=INCREASE.
*/ */
public int VELOCITY_PREVENT(); public int VELOCITY_PREVENT();
/** /**
* Number of times a player can fail the velocity check before action is taken; Type=INTEGER, Leniency=INCREASE. * Maximum amount of velocity tracks; Type=INTEGER, Leniency=INCREASE.
*/ */
public int VELOCITY_MAXTIMES(); 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 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. * Minimum travel distance for move to be considered a teleport and subsequently be ignored; Type=INTEGER, Leniency=INCREASE.
*/ */
public int TELEPORT_MIN(); public int TELEPORT_MIN();
/** /**
* Maximum amount of times a player can hit a killaura bot; Type=INTEGER, Leniency=INCREASE. * The change milliseconds between two keepalives before considering a player to be lagging; TYPE=INTEGER, Leniency=DECREASE
*/ */
public int KILLAURA_BOTHITS(); public int LAG_DETERMINATION();
/**
* 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,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,6 @@
* 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 com.rammelkast.anticheatreloaded.config.providers;
import java.util.List; import java.util.List;
@@ -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
@@ -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) {
@@ -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
@@ -15,92 +16,61 @@
* 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.event; package com.rammelkast.anticheatreloaded.event;
import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.Distance; import com.rammelkast.anticheatreloaded.check.player.IllegalInteract;
import com.rammelkast.anticheatreloaded.util.Utilities;
public class BlockListener extends EventListener { 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) @EventHandler(ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
if (player != null && getCheckManager().willCheck(player, CheckType.FAST_PLACE)) { boolean noHack = true;
if (getCheckManager().willCheck(player, CheckType.FAST_PLACE)) {
CheckResult result = getBackend().checkFastPlace(player); CheckResult result = getBackend().checkFastPlace(player);
if (result.failed()) { if (result.failed()) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.FAST_PLACE); log(result.getMessage(), player, CheckType.FAST_PLACE, result.getSubCheck());
} else { noHack = false;
decrease(player);
getBackend().logBlockPlace(player);
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); 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, result.getSubCheck());
noHack = false;
}
}
if (noHack) {
decrease(player);
getBackend().logBlockPlace(player);
}
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final Block block = event.getBlock();
boolean noHack = true; boolean noHack = true;
if (player != null) {
CheckResult result; CheckResult result;
if (getCheckManager().willCheck(player, CheckType.FAST_BREAK)) { if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) {
result = getBackend().checkFastBreak(player, block); result = IllegalInteract.performCheck(player, event);
if (result.failed()) { if (result.failed()) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.FAST_BREAK); log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck());
noHack = false; 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) { if (noHack) {
decrease(player); decrease(player);
} }
@@ -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
@@ -26,19 +27,18 @@ 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.EntityDamageEvent.DamageCause;
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.FoodLevelChangeEvent;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.check.combat.CriticalsCheck; import com.rammelkast.anticheatreloaded.check.combat.CriticalsCheck;
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck; import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck; import com.rammelkast.anticheatreloaded.util.VersionUtil;
import com.rammelkast.anticheatreloaded.util.Distance;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
public class EntityListener extends EventListener { public class EntityListener extends EventListener {
@@ -50,14 +50,14 @@ public class EntityListener extends EventListener {
CheckResult result = getBackend().checkFastBow(player, event.getForce()); CheckResult result = getBackend().checkFastBow(player, event.getForce());
if (result.failed()) { if (result.failed()) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.FAST_BOW); log(result.getMessage(), player, CheckType.FAST_BOW, result.getSubCheck());
} else { } else {
decrease(player); decrease(player);
} }
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -68,7 +68,7 @@ public class EntityListener extends EventListener {
CheckResult result = getBackend().checkFastHeal(player); CheckResult result = getBackend().checkFastHeal(player);
if (result.failed()) { if (result.failed()) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.FAST_HEAL); log(result.getMessage(), player, CheckType.FAST_HEAL, result.getSubCheck());
} else { } else {
decrease(player); decrease(player);
getBackend().logHeal(player); getBackend().logHeal(player);
@@ -76,7 +76,7 @@ public class EntityListener extends EventListener {
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -88,14 +88,14 @@ public class EntityListener extends EventListener {
CheckResult result = getBackend().checkFastEat(player); CheckResult result = getBackend().checkFastEat(player);
if (result.failed()) { if (result.failed()) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.FAST_EAT); log(result.getMessage(), player, CheckType.FAST_EAT, result.getSubCheck());
} else { } else {
decrease(player); decrease(player);
} }
} }
} }
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)
@@ -104,30 +104,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);
@@ -136,30 +123,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, result.getSubCheck());
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, result.getSubCheck());
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, result.getSubCheck());
noHack = false; noHack = false;
} }
} }
@@ -169,6 +155,6 @@ public class EntityListener extends EventListener {
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
} }
@@ -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
@@ -15,41 +16,82 @@
* 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.event; package com.rammelkast.anticheatreloaded.event;
import org.bukkit.entity.Player; import java.text.DecimalFormat;
import org.bukkit.event.Listener;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.check.Backend;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.manage.*;
import com.rammelkast.anticheatreloaded.util.User;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; 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 { public class EventListener implements Listener {
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class); private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
private static final Map<UUID, Integer> DECREASE_LIST = new HashMap<UUID, Integer>(); private static final Map<UUID, Integer> DECREASE_LIST = new HashMap<UUID, Integer>();
private static final CheckManager CHECK_MANAGER = AntiCheat.getManager().getCheckManager(); private static final CheckManager CHECK_MANAGER = AntiCheatReloaded.getManager().getCheckManager();
private static final Backend BACKEND = AntiCheat.getManager().getBackend(); private static final Backend BACKEND = AntiCheatReloaded.getManager().getBackend();
private static final AntiCheat PLUGIN = AntiCheat.getManager().getPlugin(); private static final AntiCheatReloaded PLUGIN = AntiCheatReloaded.getManager().getPlugin();
private static final UserManager USER_MANAGER = AntiCheat.getManager().getUserManager(); private static final UserManager USER_MANAGER = AntiCheatReloaded.getManager().getUserManager();
private static final Configuration CONFIG = AntiCheat.getManager().getConfiguration(); private static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration();
private static final DecimalFormat TPS_FORMAT = new DecimalFormat("##.##");
public static void log(String message, Player player, CheckType type) { public static void log(String message, Player player, CheckType type, String subcheck) {
User user = getUserManager().getUser(player.getUniqueId()); User user = getUserManager().getUser(player.getUniqueId());
if (user != null) { // npc if (user == null)
return;
boolean debugMode = CONFIG.getConfig().debugMode.getValue();
int vlForType = type.getUses(player.getUniqueId()) + 1;
int notifyEveryVl = CONFIG.getConfig().notifyEveryVl.getValue();
String prefix = ChatColor.translateAlternateColorCodes('&', CONFIG.getLang().ALERT_PREFIX());
if (message == null || message.equals("")) {
if (debugMode) {
message = prefix + player.getName() + " failed "
+ type.getName();
} else {
message = prefix + player.getName() + " failed "
+ type.getName() + ChatColor.GOLD + " (x" + vlForType + ")";
}
} else {
if (debugMode) {
message = prefix + 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 = prefix
+ player.getName() + " failed " + type.getName() + ChatColor.GOLD + " (x" + vlForType + ")"
+ ChatColor.DARK_GRAY + " | " + ChatColor.GRAY
+ (subcheck != null ? ("type: " + subcheck.toLowerCase() + ", ") : "") + "ping: " + user.getPing() + "ms"
+ ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS());
}
}
logCheat(type, user); logCheat(type, user);
if (user.increaseLevel(type) && message != null) { if (user.increaseLevel(type) && (!debugMode && vlForType % notifyEveryVl == 0)) {
AntiCheat.getManager().log(message); AntiCheatReloaded.getManager().log(message);
} }
removeDecrease(user); removeDecrease(user);
if (debugMode) {
player.sendMessage(message);
return;
}
if (vlForType % notifyEveryVl == 0) {
AntiCheatReloaded.getPlugin().sendToStaff(message);
} }
} }
@@ -116,7 +158,7 @@ public class EventListener implements Listener {
} }
public static AntiCheatManager getManager() { public static AntiCheatManager getManager() {
return AntiCheat.getManager(); return AntiCheatReloaded.getManager();
} }
public static Backend getBackend() { public static Backend getBackend() {
@@ -127,7 +169,7 @@ public class EventListener implements Listener {
return USER_MANAGER; return USER_MANAGER;
} }
public static AntiCheat getPlugin() { public static AntiCheatReloaded getPlugin() {
return PLUGIN; return PLUGIN;
} }
@@ -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
@@ -25,7 +26,7 @@ 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.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.User;
@@ -44,14 +45,14 @@ public class InventoryListener extends EventListener {
player.getInventory().clear(); player.getInventory().clear();
event.setCancelled(true); event.setCancelled(true);
} }
log(result.getMessage(), player, CheckType.FAST_INVENTORY); log(result.getMessage(), player, CheckType.FAST_INVENTORY, result.getSubCheck());
} else { } else {
decrease(player); decrease(player);
} }
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -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
@@ -24,11 +25,11 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.event.player.PlayerAnimationEvent;
@@ -43,46 +44,55 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.event.player.PlayerToggleSprintEvent; import org.bukkit.event.player.PlayerToggleSprintEvent;
import org.bukkit.event.player.PlayerVelocityEvent; 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 org.bukkit.inventory.PlayerInventory;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck; import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
import com.rammelkast.anticheatreloaded.check.movement.ElytraFly; import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
import com.rammelkast.anticheatreloaded.check.movement.BoatFlyCheck;
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.FlightCheck;
import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck; import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck;
import com.rammelkast.anticheatreloaded.check.movement.StrafeCheck;
import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck; import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck;
import com.rammelkast.anticheatreloaded.check.movement.YAxisCheck; import com.rammelkast.anticheatreloaded.check.player.IllegalInteract;
import com.rammelkast.anticheatreloaded.util.Distance; import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.Permission; import com.rammelkast.anticheatreloaded.util.Permission;
import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.VersionUtil;
import com.rammelkast.anticheatreloaded.util.XMaterial;
public class PlayerListener extends EventListener { public class PlayerListener extends EventListener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (getCheckManager().willCheck(player, CheckType.COMMAND_SPAM) && !Permission.getCommandExempt(player, event.getMessage().split(" ")[0])) { if (getCheckManager().willCheck(player, CheckType.COMMAND_SPAM)
&& !Permission.getCommandExempt(player, event.getMessage().split(" ")[0])) {
CheckResult result = getBackend().checkCommandSpam(player, event.getMessage()); CheckResult result = getBackend().checkCommandSpam(player, event.getMessage());
if (result.failed()) { if (result.failed()) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
if (!silentMode()) player.sendMessage(ChatColor.RED + result.getMessage()); if (!silentMode())
player.sendMessage(ChatColor.translateAlternateColorCodes('&', result.getMessage()));
getBackend().processCommandSpammer(player); getBackend().processCommandSpammer(player);
log(null, player, CheckType.COMMAND_SPAM); log(null, player, CheckType.COMMAND_SPAM, result.getSubCheck());
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -91,7 +101,7 @@ public class PlayerListener extends EventListener {
getBackend().logEnterExit(event.getPlayer()); getBackend().logEnterExit(event.getPlayer());
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -100,7 +110,7 @@ public class PlayerListener extends EventListener {
getBackend().logEnterExit(event.getPlayer()); getBackend().logEnterExit(event.getPlayer());
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -116,43 +126,48 @@ public class PlayerListener extends EventListener {
CheckResult result = getBackend().checkProjectile(player); CheckResult result = getBackend().checkProjectile(player);
if (result.failed()) { if (result.failed()) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.FAST_PROJECTILE); log(result.getMessage(), player, CheckType.FAST_PROJECTILE, result.getSubCheck());
} }
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event) { public void onPlayerTeleport(PlayerTeleportEvent event) {
if (event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.PLUGIN) {
getBackend().logTeleport(event.getPlayer()); getBackend().logTeleport(event.getPlayer());
} AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
public void onPlayerChangeWorlds(PlayerChangedWorldEvent event) { public void onPlayerChangeWorlds(PlayerChangedWorldEvent event) {
getBackend().logTeleport(event.getPlayer()); getBackend().logTeleport(event.getPlayer());
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) { public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
Player player = event.getPlayer();
if (event.isSneaking()) { if (event.isSneaking()) {
getBackend().logToggleSneak(event.getPlayer()); if (getCheckManager().willCheck(player, CheckType.SNEAK)) {
CheckResult result = getBackend().checkSneakToggle(player);
if (result.failed()) {
event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.SNEAK, result.getSubCheck());
}
}
// getBackend().logToggleSneak(event.getPlayer());
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
public void onPlayerVelocity(PlayerVelocityEvent event) { public void onPlayerVelocity(PlayerVelocityEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (getCheckManager().willCheck(player, CheckType.FLY)) { if (getCheckManager().willCheck(player, CheckType.FLIGHT)) {
if (getBackend().justVelocity(player) && getBackend().extendVelocityTime(player)) { if (getBackend().justVelocity(player) && getBackend().extendVelocityTime(player)) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
return; return;
@@ -160,7 +175,16 @@ public class PlayerListener extends EventListener {
getBackend().logVelocity(player); getBackend().logVelocity(player);
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); // 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) @EventHandler(ignoreCancelled = true)
@@ -172,21 +196,40 @@ public class PlayerListener extends EventListener {
if (result.failed()) { if (result.failed()) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
if (!result.getMessage().equals("") && !silentMode()) { if (!result.getMessage().equals("") && !silentMode()) {
player.sendMessage(ChatColor.RED + result.getMessage()); player.sendMessage(ChatColor.translateAlternateColorCodes('&', result.getMessage()));
} }
getBackend().processChatSpammer(player); getBackend().processChatSpammer(player);
log(null, player, CheckType.CHAT_SPAM); AntiCheatReloaded.sendToMainThread(new Runnable() {
@Override
public void run() {
log(null, player, CheckType.CHAT_SPAM, result.getSubCheck());
}
});
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); 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, result.getSubCheck());
}
});
}
}
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
public void onPlayerKick(PlayerKickEvent event) { public void onPlayerKick(PlayerKickEvent event) {
getBackend().garbageClean(event.getPlayer()); getBackend().garbageClean(event.getPlayer());
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -197,26 +240,32 @@ public class PlayerListener extends EventListener {
getConfig().getLevels().saveLevelFromUser(user); getConfig().getLevels().saveLevelFromUser(user);
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); 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 @EventHandler
public void onPlayerToggleSprint(PlayerToggleSprintEvent event) { public void onPlayerToggleSprint(PlayerToggleSprintEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!event.isSprinting()) {
getBackend().logEnterExit(player);
}
if (getCheckManager().willCheck(player, CheckType.SPRINT)) { if (getCheckManager().willCheck(player, CheckType.SPRINT)) {
CheckResult result = getBackend().checkSprintHungry(event); CheckResult result = getBackend().checkSprintHungry(event);
if (result.failed()) { if (result.failed()) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.SPRINT); log(result.getMessage(), player, CheckType.SPRINT, result.getSubCheck());
} else { } else {
decrease(player); decrease(player);
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
@@ -224,21 +273,44 @@ public class PlayerListener extends EventListener {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlayerInventory inv = player.getInventory(); PlayerInventory inv = player.getInventory();
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Material m = inv.getItemInHand().getType(); ItemStack itemInHand;
if (m == Material.BOW) { 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); getBackend().logBowWindUp(player);
} else if (Utilities.isFood(m)) { } else if (Utilities.isFood(itemInHand.getType()) || Utilities.isFood(itemInHand.getType())) {
getBackend().logEatingStart(player); getBackend().logEatingStart(player);
} }
if (!VersionUtil.isBountifulUpdate()) {
if (itemInHand.getType() == XMaterial.FIREWORK_ROCKET.parseMaterial()) {
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(); Block block = event.getClickedBlock();
if (block != null
if (block != null) { && (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)) {
Distance distance = new Distance(player.getLocation(), block.getLocation()); if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) {
getBackend().checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference()); CheckResult result = IllegalInteract.performCheck(player, event);
if (result.failed()) {
event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck());
}
}
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
@@ -248,48 +320,39 @@ public class PlayerListener extends EventListener {
CheckResult result = getBackend().checkFastDrop(player); CheckResult result = getBackend().checkFastDrop(player);
if (result.failed()) { if (result.failed()) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.ITEM_SPAM); log(result.getMessage(), player, CheckType.ITEM_SPAM, result.getSubCheck());
} }
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onPlayerEnterBed(PlayerBedEnterEvent event) { public void onPlayerEnterBed(PlayerBedEnterEvent event) {
if (event.getBed().getType() != Material.BED) return; if (event.getBed().getType().name().endsWith("BED"))
return;
getBackend().logEnterExit(event.getPlayer()); getBackend().logEnterExit(event.getPlayer());
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onPlayerExitBed(PlayerBedLeaveEvent event) { public void onPlayerExitBed(PlayerBedLeaveEvent event) {
if (event.getBed().getType() != Material.BED) return; if (event.getBed().getType().name().endsWith("BED"))
return;
getBackend().logEnterExit(event.getPlayer()); getBackend().logEnterExit(event.getPlayer());
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
public void onPlayerAnimation(PlayerAnimationEvent event) { public void onPlayerAnimation(PlayerAnimationEvent event) {
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); 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); getBackend().logJoin(player);
User user = new User(player.getUniqueId()); User user = new User(player.getUniqueId());
@@ -297,15 +360,14 @@ public class PlayerListener extends EventListener {
getConfig().getLevels().loadLevelToUser(user); getConfig().getLevels().loadLevelToUser(user);
getUserManager().addUser(user); getUserManager().addUser(user);
if (player.hasMetadata(Utilities.SPY_METADATA)) { AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
for (Player p : player.getServer().getOnlinePlayers()) {
if (!Permission.SYSTEM_SPY.get(p)) {
p.hidePlayer(player);
}
}
}
AntiCheat.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) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
@@ -317,48 +379,44 @@ public class PlayerListener extends EventListener {
final Distance distance = new Distance(from, to); final Distance distance = new Distance(from, to);
final double y = distance.getYDifference(); final double y = distance.getYDifference();
getBackend().logAscension(player, from.getY(), to.getY());
final User user = getUserManager().getUser(player.getUniqueId()); final User user = getUserManager().getUser(player.getUniqueId());
user.setTo(to.getX(), to.getY(), to.getZ()); user.setTo(to.getX(), to.getY(), to.getZ());
user.getMovementManager().handle(player, from, to, distance);
KillAuraCheck.doMove(event); if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) {
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); CheckResult result = FlightCheck.runCheck(player, distance);
if (result.failed()) { if (result.failed()) {
if (!silentMode()) { if (!silentMode()) {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
} }
log(result.getMessage(), player, CheckType.FLY); log(result.getMessage(), player, CheckType.FLIGHT, result.getSubCheck());
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.FLY) && !VersionUtil.isFlying(player)) { if (getCheckManager().willCheckQuick(player, CheckType.ELYTRAFLY)) {
CheckResult result = GlideCheck.runCheck(player, distance); CheckResult result = ElytraCheck.runCheck(player, distance);
if (result.failed()) { if (result.failed()) {
// NO TELEPORT NEEDED HERE, HANDLED BY CHECK ITSELF log(result.getMessage(), player, CheckType.ELYTRAFLY, result.getSubCheck());
log(result.getMessage(), player, CheckType.FLY);
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.FLY)) { if (getCheckManager().willCheckQuick(player, CheckType.BOATFLY)) {
CheckResult result = ElytraFly.runCheck(player, distance); CheckResult result = BoatFlyCheck.runCheck(player, user.getMovementManager(), to);
if (result.failed()) { if (result.failed()) {
log(result.getMessage(), player, CheckType.FLY); if (!silentMode()) {
player.eject();
event.setTo(user.getGoodLocation(from.clone()));
}
log(result.getMessage(), player, CheckType.BOATFLY, result.getSubCheck());
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.VCLIP) && event.getFrom().getY() > event.getTo().getY()) { if (getCheckManager().willCheckQuick(player, CheckType.VCLIP)
&& event.getFrom().getY() > event.getTo().getY()) {
CheckResult result = getBackend().checkVClip(player, new Distance(event.getFrom(), event.getTo())); CheckResult result = getBackend().checkVClip(player, new Distance(event.getFrom(), event.getTo()));
if (result.failed()) { if (result.failed()) {
if (!silentMode()) { if (!silentMode()) {
int data = result.getData() > 3 ? 3 : result.getData(); int data = result.getData() > 3 ? 3 : result.getData();
Location newloc = new Location(player.getWorld(), event.getFrom().getX(), event.getFrom().getY() + data, event.getFrom().getZ()); Location newloc = new Location(player.getWorld(), event.getFrom().getX(),
event.getFrom().getY() + data, event.getFrom().getZ());
if (newloc.getBlock().getType() == Material.AIR) { if (newloc.getBlock().getType() == Material.AIR) {
event.setTo(newloc); event.setTo(newloc);
} else { } else {
@@ -366,63 +424,53 @@ public class PlayerListener extends EventListener {
} }
player.damage(3); player.damage(3);
} }
log(result.getMessage(), player, CheckType.VCLIP); log(result.getMessage(), player, CheckType.VCLIP, result.getSubCheck());
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.NOFALL) && getCheckManager().willCheck(player, CheckType.FLY) && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && event.getFrom().getY() > event.getTo().getY()) { 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); CheckResult result = getBackend().checkNoFall(player, y);
if (result.failed()) { if (result.failed()) {
if (!silentMode()) { if (!silentMode()) {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
/*TODO: player.damage(1); better system for this, too exploitable*/ // TODO better handling of this
} }
log(result.getMessage(), player, CheckType.NOFALL); log(result.getMessage(), player, CheckType.NOFALL, result.getSubCheck());
} }
} }
boolean changed = false;
if (event.getTo() != event.getFrom()) { if (event.getTo() != event.getFrom()) {
double x = distance.getXDifference(); double x = distance.getXDifference();
double z = distance.getZDifference(); double z = distance.getZDifference();
if (getCheckManager().willCheckQuick(player, CheckType.SPEED) && getCheckManager().willCheck(player, CheckType.FLY)) { if (getCheckManager().willCheckQuick(player, CheckType.SPEED)
&& getCheckManager().willCheck(player, CheckType.FLIGHT)) {
if (event.getFrom().getY() < event.getTo().getY()) { if (event.getFrom().getY() < event.getTo().getY()) {
CheckResult result = getBackend().checkYSpeed(player, y); CheckResult result = SpeedCheck.checkVerticalSpeed(player, distance);
if (result.failed()) { if (result.failed()) {
if (!silentMode()) { if (!silentMode()) {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
} }
log(result.getMessage(), player, CheckType.SPEED); log(result.getMessage(), player, CheckType.SPEED, result.getSubCheck());
changed = true;
} }
} }
CheckResult result = SpeedCheck.checkXZSpeed(player, x, z); CheckResult result = SpeedCheck.checkXZSpeed(player, x, z, event.getTo());
if (result.failed()) { if (result.failed()) {
if (!silentMode()) { if (!silentMode()) {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
} }
log(result.getMessage(), player, CheckType.SPEED); log(result.getMessage(), player, CheckType.SPEED, result.getSubCheck());
changed = true;
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) { if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) {
CheckResult result = WaterWalkCheck.runCheck(player, x, y, z); CheckResult result = WaterWalkCheck.runCheck(player, x, y, z);
if (result.failed()) { if (result.failed()) {
if (!silentMode()) { if (!silentMode()) {
player.teleport(user.getGoodLocation(player.getLocation().add(0, -1.5, 0))); // TODO check this
player.teleport(player.getLocation().clone().subtract(0, 0.52, 0));
} }
log(result.getMessage(), player, CheckType.WATER_WALK); log(result.getMessage(), player, CheckType.WATER_WALK, result.getSubCheck());
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)) { if (getCheckManager().willCheckQuick(player, CheckType.SPIDER)) {
@@ -431,46 +479,50 @@ public class PlayerListener extends EventListener {
if (!silentMode()) { if (!silentMode()) {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
} }
log(result.getMessage(), player, CheckType.SPIDER); log(result.getMessage(), player, CheckType.SPIDER, result.getSubCheck());
changed = true;
} }
} }
if (!changed) { if (getCheckManager().willCheckQuick(player, CheckType.FASTLADDER)) {
user.setGoodLocation(event.getFrom()); // 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()) {
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()) { if (!silentMode()) {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
} }
log(log, player, CheckType.FLY); log(result.getMessage(), player, CheckType.FASTLADDER, result.getSubCheck());
}
}
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, result.getSubCheck());
} }
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.AIMBOT)) {
CheckResult result = AimbotCheck.runCheck(player, event);
if (result.failed()) {
log(result.getMessage(), player, CheckType.AIMBOT, result.getSubCheck());
}
}
if (getCheckManager().willCheckQuick(player, CheckType.VELOCITY)) {
CheckResult result = VelocityCheck.runCheck(player, distance);
if (result.failed()) {
log(result.getMessage(), player, CheckType.VELOCITY, result.getSubCheck());
}
}
}
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onRespawn(PlayerRespawnEvent event) {
getBackend().logTeleport(event.getPlayer());
}
} }
@@ -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
@@ -18,13 +19,15 @@
package com.rammelkast.anticheatreloaded.event; package com.rammelkast.anticheatreloaded.event;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.event.vehicle.VehicleDestroyEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent; import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.event.vehicle.VehicleExitEvent; import org.bukkit.event.vehicle.VehicleExitEvent;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class VehicleListener extends EventListener { public class VehicleListener extends EventListener {
@@ -34,7 +37,7 @@ public class VehicleListener extends EventListener {
getBackend().logEnterExit((Player) event.getEntered()); getBackend().logEnterExit((Player) event.getEntered());
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
@@ -43,16 +46,29 @@ public class VehicleListener extends EventListener {
getBackend().logEnterExit((Player) event.getExited()); getBackend().logEnterExit((Player) event.getExited());
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@SuppressWarnings("deprecation")
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onVehicleDestroy(VehicleDestroyEvent event) { public void onVehicleDestroy(VehicleDestroyEvent event) {
if (event.getVehicle().getPassenger() != null && event.getVehicle().getPassenger() instanceof Player) { if (VersionUtil.isBountifulUpdate()) {
getBackend().logEnterExit((Player) event.getVehicle().getPassenger()); 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);
}
}
}
} }
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
} }
@@ -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,12 +11,11 @@
* 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 com.rammelkast.anticheatreloaded.manage;
import java.util.Map; import java.util.Map;
@@ -25,16 +25,15 @@ import java.util.logging.Logger;
import org.bukkit.plugin.RegisteredListener; import org.bukkit.plugin.RegisteredListener;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.Backend; import com.rammelkast.anticheatreloaded.check.Backend;
import com.rammelkast.anticheatreloaded.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;
} }
@@ -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
@@ -18,19 +19,20 @@
package com.rammelkast.anticheatreloaded.manage; package com.rammelkast.anticheatreloaded.manage;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.Configuration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.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/>
* The manager that AntiCheat will check with to see if it should watch certain checks and certain players. * The manager that AntiCheat will check with to see if it should watch certain checks and certain players.
@@ -45,14 +47,20 @@ public class CheckManager {
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");
} }
} }
@@ -175,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;
} }
@@ -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
@@ -22,7 +23,7 @@ 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.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.util.FileFormatter; import com.rammelkast.anticheatreloaded.util.FileFormatter;
import com.rammelkast.anticheatreloaded.util.Permission; import com.rammelkast.anticheatreloaded.util.Permission;
@@ -42,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");
@@ -70,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) {
@@ -88,6 +89,7 @@ public class LoggingManager {
} }
public void logToPlayers(String message) { public void logToPlayers(String message) {
if(config.getConfig().disableBroadcast.getValue()) return;
for(Player player : Bukkit.getOnlinePlayers()) { for(Player player : Bukkit.getOnlinePlayers()) {
if (Permission.SYSTEM_NOTICE.get(player)) { if (Permission.SYSTEM_NOTICE.get(player)) {
player.sendMessage(message); player.sendMessage(message);
@@ -95,7 +97,7 @@ public class LoggingManager {
} }
} }
private void logToLogs(String message) { // Yo dawg private void logToLogs(String message) { // Yo dawg, you like logs?
logs.add(ChatColor.stripColor(message)); logs.add(ChatColor.stripColor(message));
} }
@@ -1,37 +0,0 @@
package com.rammelkast.anticheatreloaded.manage;
import com.comphenix.protocol.Packets;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.*;
import com.rammelkast.anticheatreloaded.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));
}
}
});
}
}
@@ -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
@@ -18,28 +19,25 @@
package com.rammelkast.anticheatreloaded.manage; package com.rammelkast.anticheatreloaded.manage;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.BanList.Type;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.util.Group; import com.rammelkast.anticheatreloaded.util.Group;
import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.Utilities;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
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
* *
@@ -160,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
* *
@@ -177,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);
} }
@@ -216,21 +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));
AntiCheat.getPlugin().onPlayerKicked(); AntiCheatReloaded.getPlugin().onPlayerKicked();
String msg = RED + config.getLang().KICK_BROADCAST().replaceAll("&player", name) + " (" + CheckType.getName(type) + ")"; 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);
@@ -239,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);
File diff suppressed because it is too large. Load diff
@@ -1,225 +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 com.rammelkast.anticheatreloaded.util;
import org.bukkit.Material;
public enum BlockHardness {
STONE(1.50D),
GRASS(0.60D),
DIRT(0.50D),
COBBLESTONE(2.00D),
WOOD(2.00D),
SAPLING(0.00D),
WATER(100.00D),
STATIONARY_WATER(100.00D),
LAVA(0.00D),
STATIONARY_LAVA(100.00D),
SAND(0.50D),
GRAVEL(0.60D),
GOLD_ORE(3.00D),
IRON_ORE(3.00D),
COAL_ORE(3.00D),
LOG(2.00D),
LOG_2(2.00D),
LEAVES(0.20D),
LEAVES_2(0.20D),
SPONGE(0.60D),
GLASS(0.30D),
LAPIS_ORE(3.00D),
LAPIS_BLOCK(3.00D),
DISPENSER(3.50D),
DROPPER(3.50D),
SANDSTONE(0.80D),
NOTE_BLOCK(0.80D),
BED(0.20D),
RAILS(0.70D),
DETECTOR_RAIL(0.70D),
POWERED_RAIL(0.70D),
ACTIVATOR_RAIL(0.70D),
WEB(4.00D),
LONG_GRASS(0.00D),
DOUBLE_PLANT(0.00D),
DEAD_BUSH(0.00D),
WOOL(0.80D),
YELLOW_FLOWER(0.00D),
RED_ROSE(0.00D),
BROWN_MUSHROOM(0.00D),
RED_MUSHROOM(0.00D),
GOLD_BLOCK(3.00D),
IRON_BLOCK(5.00D),
DOUBLE_STEP(2.00D),
STEP(2.00D),
BRICK(2.00D),
TNT(0.00D),
BOOKSHELF(1.50D),
MOSSY_COBBLESTONE(2.00D),
OBSIDIAN(50.00D),
TORCH(0.00D),
FIRE(0.00D),
MOB_SPAWNER(5.00D),
CHEST(2.50D),
TRAPPED_CHEST(2.50D),
REDSTONE_WIRE(0.00D),
DIAMOND_ORE(3.00D),
DIAMOND_BLOCK(5.00D),
WORKBENCH(2.50D),
SOIL(0.60D),
FURNACE(3.50D),
BURNING_FURNACE(3.50D),
WOODEN_DOOR(3.00D),
LADDER(0.40D),
LEVER(0.50D),
IRON_DOOR_BLOCK(5.00D),
HOPPER(2.00D),
STONE_PLATE(0.50D),
WOOD_PLATE(0.50D),
GOLD_PLATE(0.50D),
IRON_PLATE(0.50D),
QUARTZ_BLOCK(0.80D),
QUARTZ_ORE(3.00D),
REDSTONE_BLOCK(5.00D),
REDSTONE_ORE(3.00D),
GLOWING_REDSTONE_ORE(3.00D),
REDSTONE_TORCH_OFF(0.00D),
REDSTONE_TORCH_ON(0.00D),
REDSTONE_COMPARATOR_OFF(0.00D),
REDSTONE_COMPARATOR_ON(0.00D),
DAYLIGHT_DETECTOR(0.20D),
STONE_BUTTON(0.50D),
SNOW(0.10D),
ICE(0.50D),
PACKED_ICE(0.50D),
SNOW_BLOCK(0.20D),
CACTUS(0.40D),
CLAY(0.60D),
HARD_CLAY(1.25D),
STAINED_CLAY(1.25D),
SUGAR_CANE_BLOCK(0.00D),
JUKEBOX(2.00D),
FENCE(2.00D),
NETHERRACK(0.40D),
SOUL_SAND(0.50D),
GLOWSTONE(0.30D),
PORTAL(-1.00D),
CAKE_BLOCK(0.50D),
LOCKED_CHEST(0.00D),
TRAP_DOOR(3.00D),
MONSTER_EGGS(0.750D),
SMOOTH_BRICK(1.50D),
IRON_FENCE(5.00D),
THIN_GLASS(0.30D),
STAINED_GLASS(0.30D),
STAINED_GLASS_PANE(0.30D),
PUMPKIN_STEM(0.00D),
MELON_STEM(0.00D),
VINE(0.20D),
FENCE_GATE(2.00D),
MYCEL(0.60D),
WATER_LILY(0.00D),
NETHER_BRICK(2.00D),
NETHER_FENCE(2.00D),
ENCHANTMENT_TABLE(5.00D),
BREWING_STAND(0.50D),
CAULDRON(2.00D),
ENDER_PORTAL(-1.00D),
ENDER_PORTAL_FRAME(-1.00D),
DRAGON_EGG(3.00D),
REDSTONE_LAMP_OFF(0.30D),
REDSTONE_LAMP_ON(0.30D),
WOOD_DOUBLE_STEP(2.00D),
WOOD_STEP(2.00D),
COCOA(0.20D),
EMERALD_ORE(3.00D),
ENDER_CHEST(22.50D),
EMERALD_BLOCK(5.00D),
FLOWER_POT(0.00D),
WOOD_BUTTON(0.50D),
ANVIL(5.00D),
HUGE_MUSHROOM_1(0.20D),
HUGE_MUSHROOM_2(0.20D),
BED_BLOCK(0.20D),
WOOD_STAIRS(2.00D),
COBBLESTONE_STAIRS(2.00D),
BRICK_STAIRS(2.00D),
SMOOTH_STAIRS(1.50D),
NETHER_BRICK_STAIRS(2.00D),
SPRUCE_WOOD_STAIRS(2.00D),
BIRCH_WOOD_STAIRS(2.00D),
JUNGLE_WOOD_STAIRS(2.00D),
DARK_OAK_STAIRS(2.00D),
ACACIA_STAIRS(2.00D),
QUARTZ_STAIRS(0.80D),
SANDSTONE_STAIRS(0.80D),
COMMAND(0.00D),
BEACON(3.00D),
COBBLE_WALL(2.00D),
CROPS(0.00D),
CARROT(0.00D),
POTATO(0.00D),
SKULL(1.00D),
NETHER_WARTS(0.00D),
SIGN_POST(1.00D),
WALL_SIGN(1.00D),
PUMPKIN(1.00D),
JACK_O_LANTERN(1.00D),
DIODE_BLOCK_ON(0.00D),
DIODE_BLOCK_OFF(0.00D),
MELON_BLOCK(1.00D),
ENDER_STONE(3.00D),
TRIPWIRE(0.00D),
TRIPWIRE_HOOK(0.00D),
HAY_BLOCK(0.50D),
CARPET(0.10D),
COAL_BLOCK(5.00D),
PISTON_BASE(0.70D),
PISTON_EXTENSION(0.70D),
PISTON_MOVING_PIECE(0.70D),
PISTON_STICKY_BASE(0.70D);
Material mat;
double hardness;
BlockHardness(double hard) {
mat = Material.getMaterial(name());
hardness = hard;
}
public static double getBlockHardness(Material m) {
try {
BlockHardness h = getHardness(m);
return h == null ? 0D : h.hardness;
}catch(Exception e) {
return 0D;
}
}
public static boolean hasBlockHardness(Material m) {
return getHardness(m) != null;
}
public static BlockHardness getHardness(Material m) {
for (BlockHardness e : BlockHardness.values()) {
if (e.mat.equals(m)) {
return e;
}
}
return null;
}
}
@@ -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
@@ -28,6 +29,9 @@ public class Distance {
private final double YDiff; private final double YDiff;
private final double ZDiff; private final double ZDiff;
private final Location from;
private final Location to;
public Distance(Location from, Location to) { public Distance(Location from, Location to) {
l1Y = to.getY(); l1Y = to.getY();
l2Y = from.getY(); l2Y = from.getY();
@@ -35,6 +39,21 @@ public class Distance {
XDiff = Math.abs(to.getX() - from.getX()); XDiff = Math.abs(to.getX() - from.getX());
ZDiff = Math.abs(to.getZ() - from.getZ()); ZDiff = Math.abs(to.getZ() - from.getZ());
YDiff = Math.abs(l1Y - l2Y); 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() { public double fromY() {
@@ -56,4 +75,12 @@ public class Distance {
public double getYDifference() { public double getYDifference() {
return YDiff; return YDiff;
} }
public Location getFrom() {
return this.from;
}
public Location getTo() {
return this.to;
}
} }
@@ -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
@@ -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();
} }
} }
@@ -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
@@ -20,7 +21,7 @@ package com.rammelkast.anticheatreloaded.util;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -41,12 +42,15 @@ public class Group {
ChatColor c = ChatColor.valueOf(color); ChatColor c = ChatColor.valueOf(color);
if (c == null) { if (c == null) {
AntiCheat.getPlugin().getLogger().warning("Event '" + name + "' was initialized with the color '" + color + "' which is invalid."); AntiCheatReloaded.getPlugin().getLogger()
AntiCheat.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"); .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 { } else {
this.color = c; this.color = c;
} }
} }
public String getName() { public String getName() {
return name; return name;
} }
@@ -75,9 +79,11 @@ public class Group {
throw new Exception(); throw new Exception();
} }
} catch (Exception ex) { } catch (Exception ex) {
AntiCheat.getPlugin().getLogger().warning("An event was initialized with an invalid string: '" + string + "'"); AntiCheatReloaded.getPlugin().getLogger()
AntiCheat.getPlugin().getLogger().warning("The proper format is: 'name : threshold : color : action' such as 'High : 50 : RED : KICK'"); .warning("An event was initialized with an invalid string: '" + string + "'");
AntiCheat.getPlugin().getLogger().warning("This event will NOT run. (" + ex.getMessage() + ")"); 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; return null;
} }
} }
@@ -0,0 +1,393 @@
/*
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
* Copyright (C) 2012 Kristian S. Stangeland
*
* 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*/
package com.rammelkast.anticheatreloaded.util;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.utility.SnapshotVersion;
import com.google.common.base.Objects;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.Ordering;
/**
* Determine the current Minecraft version.
*
* @author Kristian
*/
public class MinecraftVersion implements Comparable<MinecraftVersion>, Serializable {
private static final long serialVersionUID = 1L;
/**
* Regular expression used to parse version strings.
*/
private static final Pattern VERSION_PATTERN = Pattern.compile(".*\\(.*MC.\\s*([a-zA-z0-9\\-.]+).*");
/**
* Version 1.16.2 - breaking change to the nether update
*/
public static final MinecraftVersion NETHER_UPDATE_2 = new MinecraftVersion("1.16.2");
/**
* Version 1.16.0 - the nether update
*/
public static final MinecraftVersion NETHER_UPDATE = new MinecraftVersion("1.16");
/**
* Version 1.15 - the bee update
*/
public static final MinecraftVersion BEE_UPDATE = new MinecraftVersion("1.15");
/**
* Version 1.14 - village and pillage update.
*/
public static final MinecraftVersion VILLAGE_UPDATE = new MinecraftVersion("1.14");
/**
* Version 1.13 - update aquatic.
*/
public static final MinecraftVersion AQUATIC_UPDATE = new MinecraftVersion("1.13");
/**
* Version 1.12 - the world of color update.
*/
public static final MinecraftVersion COLOR_UPDATE = new MinecraftVersion("1.12");
/**
* Version 1.11 - the exploration update.
*/
public static final MinecraftVersion EXPLORATION_UPDATE = new MinecraftVersion("1.11");
/**
* Version 1.10 - the frostburn update.
*/
public static final MinecraftVersion FROSTBURN_UPDATE = new MinecraftVersion("1.10");
/**
* Version 1.9 - the combat update.
*/
public static final MinecraftVersion COMBAT_UPDATE = new MinecraftVersion("1.9");
/**
* Version 1.8 - the "bountiful" update.
*/
public static final MinecraftVersion BOUNTIFUL_UPDATE = new MinecraftVersion("1.8");
/**
* Version 1.7.8 - the update that changed the skin format (and distribution - R.I.P. player disguise)
*/
public static final MinecraftVersion SKIN_UPDATE = new MinecraftVersion("1.7.8");
/**
* Version 1.7.2 - the update that changed the world.
*/
public static final MinecraftVersion WORLD_UPDATE = new MinecraftVersion("1.7.2");
/**
* Version 1.6.1 - the horse update.
*/
public static final MinecraftVersion HORSE_UPDATE = new MinecraftVersion("1.6.1");
/**
* Version 1.5.0 - the redstone update.
*/
public static final MinecraftVersion REDSTONE_UPDATE = new MinecraftVersion("1.5.0");
/**
* Version 1.4.2 - the scary update (Wither Boss).
*/
public static final MinecraftVersion SCARY_UPDATE = new MinecraftVersion("1.4.2");
private final int major;
private final int minor;
private final int build;
private Boolean atLeast;
// The development stage
private final String development;
// Snapshot?
private final SnapshotVersion snapshot;
/**
* Determine the current Minecraft version.
* @param server - the Bukkit server that will be used to examine the MC version.
*/
public MinecraftVersion(Server server) {
this(extractVersion(server.getVersion()));
}
/**
* Construct a version object from the format major.minor.build, or the snapshot format.
* @param versionOnly - the version in text form.
*/
public MinecraftVersion(String versionOnly) {
this(versionOnly, true);
}
/**
* Construct a version format from the standard release version or the snapshot verison.
* @param versionOnly - the version.
* @param parseSnapshot - TRUE to parse the snapshot, FALSE otherwise.
*/
private MinecraftVersion(String versionOnly, boolean parseSnapshot) {
String[] section = versionOnly.split("-");
SnapshotVersion snapshot = null;
int[] numbers = new int[3];
try {
numbers = parseVersion(section[0]);
} catch (NumberFormatException cause) {
// Skip snapshot parsing
if (!parseSnapshot)
throw cause;
try {
// Determine if the snapshot is newer than the current release version
snapshot = new SnapshotVersion(section[0]);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
MinecraftVersion latest = new MinecraftVersion(ProtocolLibrary.MAXIMUM_MINECRAFT_VERSION, false);
boolean newer = snapshot.getSnapshotDate().compareTo(
format.parse(ProtocolLibrary.MINECRAFT_LAST_RELEASE_DATE)) > 0;
numbers[0] = latest.getMajor();
numbers[1] = latest.getMinor() + (newer ? 1 : -1);
numbers[2] = 0;
} catch (Exception e) {
throw new IllegalStateException("Cannot parse " + section[0], e);
}
}
this.major = numbers[0];
this.minor = numbers[1];
this.build = numbers[2];
this.development = section.length > 1 ? section[1] : (snapshot != null ? "snapshot" : null);
this.snapshot = snapshot;
}
/**
* Construct a version object directly.
* @param major - major version number.
* @param minor - minor version number.
* @param build - build version number.
*/
public MinecraftVersion(int major, int minor, int build) {
this(major, minor, build, null);
}
/**
* Construct a version object directly.
* @param major - major version number.
* @param minor - minor version number.
* @param build - build version number.
* @param development - development stage.
*/
public MinecraftVersion(int major, int minor, int build, String development) {
this.major = major;
this.minor = minor;
this.build = build;
this.development = development;
this.snapshot = null;
}
private int[] parseVersion(String version) {
String[] elements = version.split("\\.");
int[] numbers = new int[3];
// Make sure it's even a valid version
if (elements.length < 1)
throw new IllegalStateException("Corrupt MC version: " + version);
// The String 1 or 1.2 is interpreted as 1.0.0 and 1.2.0 respectively.
for (int i = 0; i < Math.min(numbers.length, elements.length); i++)
numbers[i] = Integer.parseInt(elements[i].trim());
return numbers;
}
/**
* Major version number
* @return Current major version number.
*/
public int getMajor() {
return major;
}
/**
* Minor version number
* @return Current minor version number.
*/
public int getMinor() {
return minor;
}
/**
* Build version number
* @return Current build version number.
*/
public int getBuild() {
return build;
}
/**
* Retrieve the development stage.
* @return Development stage, or NULL if this is a release.
*/
public String getDevelopmentStage() {
return development;
}
/**
* Retrieve the snapshot version, or NULL if this is a release.
* @return The snapshot version.
*/
public SnapshotVersion getSnapshot() {
return snapshot;
}
/**
* Determine if this version is a snapshot.
* @return The snapshot version.
*/
public boolean isSnapshot() {
return snapshot != null;
}
public boolean atOrAbove() {
if (atLeast == null) {
atLeast = MinecraftVersion.atOrAbove(this);
}
return atLeast;
}
/**
* Retrieve the version String (major.minor.build) only.
* @return A normal version string.
*/
public String getVersion() {
if (getDevelopmentStage() == null)
return String.format("%s.%s.%s", getMajor(), getMinor(), getBuild());
else
return String.format("%s.%s.%s-%s%s", getMajor(), getMinor(), getBuild(),
getDevelopmentStage(), isSnapshot() ? snapshot : "");
}
@Override
public int compareTo(MinecraftVersion o) {
if (o == null)
return 1;
return ComparisonChain.start().
compare(getMajor(), o.getMajor()).
compare(getMinor(), o.getMinor()).
compare(getBuild(), o.getBuild()).
// No development String means it's a release
compare(getDevelopmentStage(), o.getDevelopmentStage(), Ordering.natural().nullsLast()).
compare(getSnapshot(), o.getSnapshot(), Ordering.natural().nullsFirst()).
result();
}
public boolean isAtLeast(MinecraftVersion other) {
if (other == null)
return false;
return compareTo(other) >= 0;
}
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
if (obj == this)
return true;
if (obj instanceof MinecraftVersion) {
MinecraftVersion other = (MinecraftVersion) obj;
return getMajor() == other.getMajor() &&
getMinor() == other.getMinor() &&
getBuild() == other.getBuild() &&
Objects.equal(getDevelopmentStage(), other.getDevelopmentStage());
}
return false;
}
@Override
public int hashCode() {
return Objects.hashCode(getMajor(), getMinor(), getBuild());
}
@Override
public String toString() {
// Convert to a String that we can parse back again
return String.format("(MC: %s)", getVersion());
}
/**
* Extract the Minecraft version from CraftBukkit itself.
* @param text - the server version in text form.
* @return The underlying MC version.
* @throws IllegalStateException If we could not parse the version string.
*/
public static String extractVersion(String text) {
Matcher version = VERSION_PATTERN.matcher(text);
if (version.matches() && version.group(1) != null) {
return version.group(1);
} else {
throw new IllegalStateException("Cannot parse version String '" + text + "'");
}
}
/**
* Parse the given server version into a Minecraft version.
* @param serverVersion - the server version.
* @return The resulting Minecraft version.
*/
public static MinecraftVersion fromServerVersion(String serverVersion) {
return new MinecraftVersion(extractVersion(serverVersion));
}
private static MinecraftVersion currentVersion;
public static void setCurrentVersion(MinecraftVersion version) {
currentVersion = version;
}
public static MinecraftVersion getCurrentVersion() {
if (currentVersion == null) {
currentVersion = fromServerVersion(Bukkit.getVersion());
}
return currentVersion;
}
public static boolean atOrAbove(MinecraftVersion version) {
return getCurrentVersion().isAtLeast(version);
}
}
@@ -0,0 +1,211 @@
/*
* 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 org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
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;
// Ticks of player blocking
public int blockingTicks;
// If the player has a speed effect
public boolean hasSpeedEffect = false;
// If the player had speed effect previous tick
public boolean hadSpeedEffect = false;
// 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;
// Handle 1.9+ potion effects
if (MinecraftVersion.atOrAbove(MinecraftVersion.COMBAT_UPDATE)) {
for (PotionEffect effect : player.getActivePotionEffects()) {
if (!VersionUtil.isLevitationEffect(effect))
return;
AntiCheatReloaded.getManager().getBackend().logLevitating(player, 1);
}
}
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 (player.isBlocking())
this.blockingTicks++;
else
this.blockingTicks = 0;
if (Utilities.isNearWater(player))
this.nearLiquidTicks = 8;
else {
if (this.nearLiquidTicks > 0)
this.nearLiquidTicks--;
else
this.nearLiquidTicks = 0;
}
this.hadSpeedEffect = this.hasSpeedEffect;
this.hasSpeedEffect = player.hasPotionEffect(PotionEffectType.SPEED);
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);
}
}
@@ -1,18 +0,0 @@
package com.rammelkast.anticheatreloaded.util;
import java.util.EnumSet;
import org.bukkit.Material;
import org.bukkit.potion.PotionEffectType;
public class NMS_1_9_PLUS {
static final EnumSet<Material> MOVE_UP_BLOCKS_1_9 = 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);
static final PotionEffectType LEVITATION = PotionEffectType.LEVITATION;
}
@@ -1,186 +0,0 @@
package com.rammelkast.anticheatreloaded.util;
import java.util.Random;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_11_R1.CraftServer;
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import com.mojang.authlib.GameProfile;
import com.rammelkast.anticheatreloaded.AntiCheat;
import net.minecraft.server.v1_11_R1.EntityHuman;
import net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.MinecraftServer;
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_11_R1.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_11_R1.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_11_R1.PlayerConnection;
import net.minecraft.server.v1_11_R1.PlayerInteractManager;
import net.minecraft.server.v1_11_R1.World;
import net.minecraft.server.v1_11_R1.WorldServer;
public class NPC_1_11 {
private final UUID owner;
private final String name;
private UUID uuid;
private EntityPlayer npc;
private int entityId;
private Location location;
public int getID() {
return this.entityId;
}
public NPC_1_11(Player owner) {
this.owner = owner.getUniqueId();
this.name = NameGenerator.generateName();
Location eyelocation = owner.getEyeLocation();
Vector vec = owner.getLocation().getDirection();
vec.setX(-3 * vec.getX());
vec.setZ(-3 * vec.getZ());
Location back = eyelocation.add(vec);
this.location = back; // TODO
}
public void spawn() {
final MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
final WorldServer nmsWorld = ((CraftWorld) this.getOwner().getWorld()).getHandle();
this.uuid = UUID.randomUUID();
(this.npc = new EntityPlayer(nmsServer, nmsWorld, new GameProfile(this.uuid, this.name),
new PlayerInteractManager((World) nmsWorld))).setLocation(this.location.getX(), this.location.getY(),
this.location.getZ(), 0.0f, 0.0f);
this.npc.collides = false;
this.npc.setInvisible(true);
this.entityId = this.npc.getId();
final PlayerConnection connection = ((CraftPlayer) this.getOwner()).getHandle().playerConnection;
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER,
new EntityPlayer[] { this.npc }));
connection.sendPacket(new PacketPlayOutNamedEntitySpawn((EntityHuman) this.npc));
}
public boolean up = true;
public void move(PlayerMoveEvent e) {
if (e.getTo().getPitch() <= -32.5) {
if (e.getTo().getPitch() <= -82.5) {
Location eyelocation = e.getPlayer().getEyeLocation();
Vector vec = e.getPlayer().getLocation().getDirection();
vec.setX(-3 * vec.getX());
vec.setY(e.getPlayer().getLocation().getY() - 8.25);
vec.setZ(-3 * vec.getZ());
Location back = eyelocation.add(vec);
this.location = back; // TODO
this.npc.setPositionRotation(back.getX(), back.getY(), back.getZ(), (float)new Random().nextFloat() * 20, (float)new Random().nextFloat() * 20);
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityTeleport(npc));
if (new Random().nextInt(50) == 25 && this.npc.isInvisible()) {
this.npc.setInvisible(false);
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
new BukkitRunnable() {
@Override
public void run() {
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(AntiCheat.getPlugin(), 4);
}
}else {
Location eyelocation = e.getPlayer().getEyeLocation();
Vector vec = e.getPlayer().getLocation().getDirection();
vec.setX(-3 * vec.getX());
vec.setY(e.getPlayer().getLocation().getY());
vec.setZ(-3 * vec.getZ());
Location back = eyelocation.add(vec);
this.location = back; // TODO
this.npc.setPositionRotation(back.getX(), back.getY(), back.getZ(), (float)new Random().nextFloat() * 20, (float)new Random().nextFloat() * 20);
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityTeleport(npc));
}
} else if (e.getTo().getPitch() >= 22) {
Location eyelocation = e.getPlayer().getEyeLocation();
Vector vec = e.getPlayer().getLocation().getDirection();
vec.setX(-3 * vec.getX());
vec.setY(e.getPlayer().getLocation().getY() - 0.4);
vec.setZ(-3 * vec.getZ());
Location back = eyelocation.add(vec);
this.location = back; // TODO
this.npc.setPositionRotation(back.getX(), back.getY(), back.getZ(), (float)new Random().nextFloat() * 20, (float)new Random().nextFloat() * 20);
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityTeleport(npc));
} else {
Location eyelocation = e.getPlayer().getEyeLocation();
Vector vec = e.getPlayer().getLocation().getDirection();
vec.setX(-1.95 * vec.getX());
if (up)
vec.setY(vec.getY() + 0.5);
else
vec.setY(vec.getY() - 0.25);
if (new Random().nextInt(10) == 5)
up = !up;
vec.setZ(-1.95 * vec.getZ());
Location back = eyelocation.add(vec);
this.location = back; // TODO
this.npc.setPositionRotation(back.getX(), back.getY(), back.getZ(), (float)new Random().nextFloat() * 20, (float)new Random().nextFloat() * 20);
((CraftPlayer) this.getOwner()).getHandle().playerConnection
.sendPacket(new PacketPlayOutEntityTeleport(npc));
if (new Random().nextInt(1000) == 500 && this.npc.isInvisible()) {
this.npc.setInvisible(false);
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
new BukkitRunnable() {
@Override
public void run() {
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(AntiCheat.getPlugin(), 6);
}
}
}
public Player getOwner() {
return Bukkit.getPlayer(owner);
}
public void damage(EntityDamageByEntityEvent e, Player p) {
if (p != getOwner() || this.npc == null) {
return;
}
if (new Random().nextBoolean() && this.npc.isInvisible()) {
this.npc.setInvisible(false);
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
new BukkitRunnable() {
@Override
public void run() {
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(AntiCheat.getPlugin(), 6 + new Random().nextInt(7));
}
}
public void damage() {
if (this.npc == null || this.getOwner() == null) {
return;
}
if (new Random().nextBoolean() && this.npc.isInvisible()) {
this.npc.setInvisible(false);
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
new BukkitRunnable() {
@Override
public void run() {
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(AntiCheat.getPlugin(), 6 + new Random().nextInt(8));
}
}
}
@@ -1,45 +0,0 @@
package com.rammelkast.anticheatreloaded.util;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
public class NameGenerator {
private static final List<String> BEGIN = Arrays.asList(new String[]{
"Pixel",
"Pro",
"NoHax",
"Just",
"That",
"New",
"Ultra",
"Killer",
"Swift"
});
private static final List<String> END = Arrays.asList(new String[]{
"Gamer",
"PvP",
"JustYolo",
"Gaming",
"Minecraft",
"Games",
"Bawz",
"1",
"51",
"99",
"" + new Random().nextInt(100)
});
public static String generateName() {
Random r = new Random();
String begin = BEGIN.get(r.nextInt(BEGIN.size() - 1));
String end = END.get(r.nextInt(END.size() - 1));
if (r.nextBoolean())
return begin + end + r.nextInt(9);
else
return begin + end;
}
}
@@ -1,37 +0,0 @@
package com.rammelkast.anticheatreloaded.util;
import java.util.Random;
public class NameUtil {
private static String[] firstParts = new String[] {
"Gamer",
"Pixel",
"Derp",
"Random",
"That",
"NoHaxJust",
"Derp",
"Fun",
"Luigi"
};
private static String[] secondParts = new String[] {
"01",
"Boy",
"Guy",
"Mario",
"Plain",
"Simple",
"NotHacking",
"Random",
"11",
"06"
};
private static Random theRandom = new Random();
public static String getRandomName() {
return firstParts[theRandom.nextInt(firstParts.length - 1)] + secondParts[theRandom.nextInt(secondParts.length - 1)];
}
}
@@ -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.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.comphenix.protocol.injector.server.TemporaryPlayer;
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerDigType;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.movement.NoSlowCheck;
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();
if (player == null || !player.isOnline())
return;
// 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();
// Check if we have an actual player object
if (player instanceof TemporaryPlayer)
return;
// 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();
}
});
}
public static void listenUseItemPackets() {
AntiCheatReloaded.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(),
ListenerPriority.LOWEST, new PacketType[] { PacketType.Play.Client.BLOCK_DIG }) {
@Override
public void onPacketReceiving(PacketEvent event) {
if (event.getPacket().getPlayerDigTypes().read(0) == PlayerDigType.RELEASE_USE_ITEM)
NoSlowCheck.runCheck(event.getPlayer(), event);
}
});
}
}
@@ -1,228 +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 com.rammelkast.anticheatreloaded.util;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
import java.io.*;
import java.lang.reflect.Field;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
public class PastebinReport {
private static final String DATE = new SimpleDateFormat("yyyy-MM-dd kk:mm Z").format(new Date());
private static final String API_KEY = "d5ac92da966edb97a97860e6a052784f";
private StringBuilder report = new StringBuilder();
private String url = "";
public PastebinReport(CommandSender cs) {
Player player = null;
if (cs instanceof Player) {
player = (Player) cs;
}
createReport(player);
try {
writeReport();
} catch (IOException e) {
}
postReport();
}
public PastebinReport(CommandSender cs, Player tp) {
createReport(tp);
try {
writeReport();
} catch (IOException e) {
}
postReport();
}
public String getURL() {
return url;
}
private void appendPermissionsTester(Player player) {
if (player == null) {
append("No player defined.");
return;
}
for (Permission node : Permission.values()) {
report.append(player.getName() + ": " + node.toString() + " " + node.get(player));
if (node.get(player) && !node.whichPermission(player).equals(node.toString())) {
report.append(" (Applied by " + node.whichPermission(player) + ")");
}
report.append('\n');
}
}
private void createReport(Player player) {
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
append("------------ WARNING! ------------");
append("This report was run with NoCheatPlus enabled. Results may be inaccurate." + '\n');
}
append("------------ AntiCheat Report - " + DATE + " ------------");
appendSystemInfo();
append("------------Last 30 logs------------");
appendLogs();
append("------------Permission Tester------------");
appendPermissionsTester(player);
append("------------Event Chains------------");
appendEventHandlers();
append("------------Magic Diff------------");
appendMagicDiff();
append("-----------End Of Report------------");
}
private void appendLogs() {
List<String> logs = AntiCheat.getManager().getLoggingManager().getLastLogs();
if (logs.size() == 0) {
append("No recent logs.");
return;
}
for (String log : logs) {
append(log);
}
}
private void appendSystemInfo() {
Runtime runtime = Runtime.getRuntime();
Configuration config = AntiCheat.getManager().getConfiguration();
append("AntiCheat Version: " + AntiCheat.getVersion());
append("Server Version: " + Bukkit.getVersion());
append("Server Implementation: " + Bukkit.getName());
append("Server ID: " + Bukkit.getServerId());
append("NMS Version: " + VersionUtil.getVersion());
append("Java Version: " + System.getProperty("java.vendor") + " " + System.getProperty("java.version"));
append("OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version"));
append("Free Memory: " + runtime.freeMemory() / 1024 / 1024 + "MB");
append("Max Memory: " + runtime.maxMemory() / 1024 / 1024 + "MB");
append("Total Memory: " + runtime.totalMemory() / 1024 / 1024 + "MB");
append("Online Mode: " + Bukkit.getOnlineMode());
append("Players: " + Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers());
append("Plugin Count: " + Bukkit.getPluginManager().getPlugins().length);
append("Plugin Uptime: " + ((System.currentTimeMillis() - AntiCheat.getPlugin().getLoadTime()) / 1000) / 60 + " minutes");
append("Enterprise: " + config.getConfig().enterprise.getValue());
if (config.getConfig().enterprise.getValue()) {
append("- Server name: " + config.getEnterprise().serverName.getValue());
append("- Database type: " + config.getEnterprise().database.getType());
append("- Groups source: " + (config.getEnterprise().configGroups.getValue() ? "Database" : "Flatfile"));
append("- Rules source: " + (config.getEnterprise().configRules.getValue() ? "Database" : "Flatfile"));
append("- Levels source: " + (config.getEnterprise().syncLevels.getValue() ? "Database" : "Flatfile"));
}
}
private void appendMagicDiff() {
// This is hacky, and I like it
Magic magic = AntiCheat.getManager().getConfiguration().getMagic();
FileConfiguration file = YamlConfiguration.loadConfiguration(new File(AntiCheat.getPlugin().getDataFolder(), "magic.yml"));
boolean changed = false;
for (Field field : Magic.class.getFields()) {
Object defaultValue = file.get(field.getName());
try {
Field value = magic.getClass().getDeclaredField(field.getName());
String s1 = value.get(magic).toString();
String s2 = defaultValue.toString();
if (!s1.equals(s2) && !s1.equals(s2 + ".0")) {
changed = true;
append(field.getName() + ": " + s1 + " (Default: " + s2 + ")");
} else {
}
} catch (NoSuchFieldException ex) {
} catch (IllegalAccessException ex) {
}
}
if (!changed) {
append("No changes from default.");
}
}
private void appendEventHandlers() {
report.append(AntiCheat.getManager().getEventChainReport());
}
private void writeReport() throws IOException {
File f = new File(AntiCheat.getPlugin().getDataFolder() + "/report.txt");
FileWriter r = new FileWriter(f);
BufferedWriter writer = new BufferedWriter(r);
writer.write(report.toString());
writer.close();
}
private void postReport() {
try {
URL urls = new URL("http://pastebin.com/api/api_post.php");
HttpURLConnection conn = (HttpURLConnection) urls.openConnection();
conn.setConnectTimeout(5000);
conn.setReadTimeout(5000);
conn.setRequestMethod("POST");
conn.addRequestProperty("Content-type", "application/x-www-form-urlencoded");
conn.setInstanceFollowRedirects(false);
conn.setDoOutput(true);
OutputStream out = conn.getOutputStream();
out.write(("api_option=paste" + "&api_dev_key=" + URLEncoder.encode(API_KEY, "utf-8") + "&api_paste_code=" + URLEncoder.encode(report.toString(), "utf-8") + "&api_paste_private=" + URLEncoder.encode("1", "utf-8") + "&api_paste_name=" + URLEncoder.encode("", "utf-8") + "&api_paste_expire_date=" + URLEncoder.encode("1M", "utf-8") + "&api_paste_format=" + URLEncoder.encode("text", "utf-8") + "&api_user_key=" + URLEncoder.encode("", "utf-8")).getBytes());
out.flush();
out.close();
if (conn.getResponseCode() == 200) {
InputStream receive = conn.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(receive));
String line;
StringBuffer response = new StringBuffer();
while ((line = reader.readLine()) != null) {
response.append(line);
response.append("\r\n");
}
reader.close();
String result = response.toString().trim();
if (!result.contains("http://")) {
url = "Failed to post. Check report.txt";
} else {
url = result.trim();
}
} else {
url = "Failed to post. Check report.txt";
}
} catch (Exception e) {
url = "Failed to post. Check report.txt";
}
}
private void append(String s) {
report.append(s + '\n');
}
}
@@ -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
@@ -22,46 +23,15 @@ import org.bukkit.command.CommandSender;
public enum Permission { public enum Permission {
/* Check Nodes */ /* Check Nodes */
CHECK_ZOMBE_FLY, CHECK_FLIGHT, CHECK_ELYTRAFLY, CHECK_WATERWALK, CHECK_FASTPLACE, CHECK_CHATSPAM, CHECK_COMMANDSPAM, CHECK_SPRINT,
CHECK_ZOMBE_NOCLIP, CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP, CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL,
CHECK_ZOMBE_CHEAT, CHECK_KILLAURA, CHECK_UNICODE, CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY,
CHECK_FLY, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGALINTERACT, CHECK_FASTLADDER,
CHECK_WATERWALK, CHECK_AIMBOT, CHECK_STRAFE, CHECK_NOSLOW, CHECK_BOATFLY,
CHECK_NOSWING,
CHECK_FASTBREAK,
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_FORCEFIELD,
CHECK_LONGREACH,
CHECK_FASTPROJECTILE,
CHECK_ITEMSPAM,
CHECK_VISUAL,
CHECK_FASTINVENTORY,
CHECK_AUTOTOOL,
/* System Nodes */ /* System Nodes */
SYSTEM_LOG, SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_NOTICE, SYSTEM_CHECK, SYSTEM_RELOAD,
SYSTEM_RESET, SYSTEM_MUTE;
SYSTEM_SPY,
SYSTEM_HELP,
SYSTEM_UPDATE,
SYSTEM_REPORT,
SYSTEM_ALERT,
SYSTEM_NOTICE,
SYSTEM_CALIBRATE,
SYSTEM_CHECK,
SYSTEM_DEBUG,
SYSTEM_RELOAD, CHECK_KILLAURA, CHECK_BLINK, VELOCITY, CRITICALS;
private static final String PERMISSION_ALL = "anticheat.*"; private static final String PERMISSION_ALL = "anticheat.*";
private static final String PERMISSION_SPAM = "anticheat.check.spam"; private static final String PERMISSION_SPAM = "anticheat.check.spam";
@@ -72,7 +42,8 @@ public enum Permission {
} }
public boolean get(CommandSender cs) { public boolean get(CommandSender cs) {
if ((this == CHECK_CHATSPAM || this == CHECK_COMMANDSPAM) && cs.hasPermission(PERMISSION_SPAM)) return true; if ((this == CHECK_CHATSPAM || this == CHECK_COMMANDSPAM) && cs.hasPermission(PERMISSION_SPAM))
return true;
return cs.hasPermission(toString()) || cs.hasPermission(getBase()) || cs.hasPermission(PERMISSION_ALL); return cs.hasPermission(toString()) || cs.hasPermission(getBase()) || cs.hasPermission(PERMISSION_ALL);
} }
@@ -81,7 +52,7 @@ public enum Permission {
} }
public String whichPermission(CommandSender cs) { public String whichPermission(CommandSender cs) {
for (String s : new String[]{PERMISSION_ALL, getBase(), toString()}) { for (String s : new String[] { PERMISSION_ALL, getBase(), toString() }) {
if (cs.hasPermission(s)) { if (cs.hasPermission(s)) {
return s; return s;
} }
@@ -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
@@ -23,12 +24,7 @@ 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,170 @@
/*
* 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 String latestVersion;
private boolean isLatest;
private boolean isAhead;
public UpdateManager() {
this.update();
}
public void update() {
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;
}
}
}
@@ -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
@@ -18,22 +19,22 @@
package com.rammelkast.anticheatreloaded.util; 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.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.util.rule.Rule; import com.rammelkast.anticheatreloaded.util.rule.Rule;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class User { public class User {
private final UUID uuid; private final UUID uuid;
private final String name; private final String name;
@@ -41,7 +42,7 @@ public class User {
private int level = 0; private int level = 0;
private Location goodLocation; private Location goodLocation;
private List<ItemStack> inventorySnapshot = null; private List<ItemStack> inventorySnapshot = null;
private Configuration config = AntiCheat.getManager().getConfiguration(); private Configuration config = AntiCheatReloaded.getManager().getConfiguration();
private int toX, toY, toZ; private int toX, toY, toZ;
private String[] messages = new String[2]; private String[] messages = new String[2];
private Long[] messageTimes = new Long[2]; private Long[] messageTimes = new Long[2];
@@ -51,6 +52,12 @@ public class User {
private boolean isWaitingOnLevelSync; private boolean isWaitingOnLevelSync;
private Timestamp levelSyncTimestamp; private Timestamp levelSyncTimestamp;
private long lastServerPing, lastClientPong;
private int ping = -1;
private int lastPing = -1;
private MovementManager movementManager;
/** /**
* Initialize an AntiCheat user * Initialize an AntiCheat user
* *
@@ -60,19 +67,10 @@ public class User {
this.uuid = uuid; this.uuid = uuid;
this.name = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getName() : ""; this.name = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getName() : "";
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1; this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1;
this.movementManager = new MovementManager();
this.ping = getPlayer() != null && getPlayer().isOnline() ? VersionUtil.getPlayerPing(getPlayer()) : -1;
} }
/**
* Initialize an AntiCheat user
*
* @param name Player's name
*/
/* public User(String name) {
this.uuid = Bukkit.getPlayer(name).getUniqueId();
this.name = name;
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1;
}
*/
/** /**
* Get the player's UUID * Get the player's UUID
* *
@@ -126,9 +124,12 @@ public class User {
public Group getGroup() { public Group getGroup() {
List<Group> groups = config.getGroups().getGroups(); List<Group> groups = config.getGroups().getGroups();
for (int i = 0; i < groups.size(); i++) { for (int i = 0; i < groups.size(); i++) {
if (i == 0 && level < groups.get(i).getLevel()) break; if (i == 0 && level < groups.get(i).getLevel())
else if (i == groups.size() - 1) return groups.get(i); break;
else if (level >= groups.get(i).getLevel() && level < groups.get(i + 1).getLevel()) return groups.get(i); 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; return null;
} }
@@ -151,7 +152,7 @@ public class User {
// Check levels // Check levels
for (Group l : getLevels()) { for (Group l : getLevels()) {
if (l.getLevel() == level) { if (l.getLevel() == level) {
AntiCheat.getManager().getUserManager().alert(this, l, type); AntiCheatReloaded.getManager().getUserManager().alert(this, l, type);
if (l.getLevel() == config.getGroups().getHighestLevel()) { if (l.getLevel() == config.getGroups().getHighestLevel()) {
level = l.getLevel() - 10; level = l.getLevel() - 10;
} }
@@ -179,7 +180,8 @@ public class User {
} }
/** /**
* Set the users level to a specific value. Must be 0 < level < config-defined highest level * Set the users level to a specific value. Must be 0 < level < config-defined
* highest level
* *
* @param level level to set * @param level level to set
* @return true if the level was valid and set properly * @return true if the level was valid and set properly
@@ -216,11 +218,17 @@ public class User {
* @return last known valid location * @return last known valid location
*/ */
public Location getGoodLocation(Location location) { public Location getGoodLocation(Location location) {
if (goodLocation == null) { if (goodLocation == null || !location.getWorld().equals(goodLocation.getWorld())
|| location.distance(goodLocation) > config.getConfig().maxSetbackDistance.getValue()) {
return location; return location;
} }
return goodLocation; Location moveTo = goodLocation;
if (location != null) {
moveTo.setPitch(location.getPitch());
moveTo.setYaw(location.getYaw());
}
return moveTo;
} }
/** /**
@@ -230,7 +238,7 @@ public class User {
* @return true if the location was valid and set properly * @return true if the location was valid and set properly
*/ */
public boolean setGoodLocation(Location location) { public boolean setGoodLocation(Location location) {
if (Utilities.cantStandAtExp(location) || (location.getBlock().isLiquid() && !Utilities.isFullyInWater(location))) { if (Utilities.cantStandAtExp(location)) {
return false; return false;
} }
@@ -424,8 +432,44 @@ public class User {
return levelSyncTimestamp; return levelSyncTimestamp;
} }
public void onServerPing() {
this.lastServerPing = System.currentTimeMillis();
}
public void onClientPong() {
this.lastClientPong = System.currentTimeMillis();
this.lastPing = this.ping;
this.ping = (int) (this.lastClientPong - this.lastServerPing);
}
public int getPing() {
int ping = this.ping;
if (ping < 0) {
return VersionUtil.getPlayerPing(this.getPlayer());
}
return ping;
}
public int getLastPing() {
int lastPing = this.lastPing;
if (lastPing < 0) {
return this.getPing();
}
return lastPing;
}
public boolean isLagging() {
return Math.abs(this.ping - this.lastPing) > config.getMagic().LAG_DETERMINATION()
&& this.ping > config.getMagic().LAG_DETERMINATION();
}
public MovementManager getMovementManager() {
return this.movementManager;
}
@Override @Override
public String toString() { public String toString() {
return "User {name = " + getName() + ", level = " + level + "}"; return "User {name = " + getName() + ", level = " + level + "}";
} }
} }
@@ -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
@@ -18,18 +19,8 @@
package com.rammelkast.anticheatreloaded.util; package com.rammelkast.anticheatreloaded.util;
import org.bukkit.Bukkit; import java.math.BigDecimal;
import org.bukkit.Location; import java.math.RoundingMode;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.NumberConversions;
import com.rammelkast.anticheatreloaded.AntiCheat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -37,40 +28,33 @@ import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
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.Boat;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.BoundingBox;
import org.bukkit.util.NumberConversions;
public final class Utilities { public final class Utilities {
private static final List<Material> INSTANT_BREAK = new ArrayList<Material>(); private static final List<Material> INSTANT_BREAK = new ArrayList<Material>();
private static final List<Material> FOOD = new ArrayList<Material>(); private static final List<Material> FOOD = new ArrayList<Material>();
private static final List<Material> INTERACTABLE = new ArrayList<Material>(); private static final List<Material> CLIMBABLE = new ArrayList<Material>();
private static final Map<Material, Material> COMBO = new HashMap<Material, Material>(); private static final Map<Material, Material> COMBO = new HashMap<Material, Material>();
public static final String SPY_METADATA = "ac-spydata"; public static final double JUMP_MOTION_Y = 0.41999998688697815;
/**
* Send a hack level alert to players and console
*
* @param message List of strings to send as the alert
*/
public static void alert(List<String> message) {
for (Player player : Bukkit.getOnlinePlayers()) {
if (Permission.SYSTEM_ALERT.get(player)) {
for (String msg : message) {
player.sendMessage(msg);
}
}
}
for (String msg : message) {
AntiCheat.getManager().log(msg);
}
}
/** /**
* Check if only the block beneath them is standable (includes water + lava) * Check if only the block beneath them is standable (includes water + lava)
*
* @param block the block to check (under) * @param block the block to check (under)
* @return true if they cannot stand there * @return true if they cannot stand there
*/ */
public static boolean cantStandAtSingle(Block block) public static boolean cantStandAtSingle(Block block) {
{
// TODO: Implement Better to reduce false positives (done? lets test...)
Block otherBlock = block.getLocation().add(0, -0.5, 0).getBlock(); Block otherBlock = block.getLocation().add(0, -0.5, 0).getBlock();
boolean center = otherBlock.getType() == Material.AIR; boolean center = otherBlock.getType() == Material.AIR;
return center; return center;
@@ -93,17 +77,20 @@ public final class Utilities {
* @return true if the player should be unable to stand here * @return true if the player should be unable to stand here
*/ */
public static boolean cantStandAtExp(Location location) { public static boolean cantStandAtExp(Location location) {
return cantStandAt(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D, location.getBlockZ()).getBlock()); return cantStandAt(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D,
location.getBlockZ()).getBlock());
} }
/** /**
* Determine whether cannot stand on the block's immediately surroundings (North, East, South, West) * Determine whether cannot stand on the block's immediately surroundings
* (North, East, South, West)
* *
* @param block the block to check * @param block the block to check
* @return true if a player cannot stand in the immediate vicinity * @return true if a player cannot stand in the immediate vicinity
*/ */
public static boolean cantStandClose(Block block) { public static boolean cantStandClose(Block block) {
return !canStand(block.getRelative(BlockFace.NORTH)) && !canStand(block.getRelative(BlockFace.EAST)) && !canStand(block.getRelative(BlockFace.SOUTH)) && !canStand(block.getRelative(BlockFace.WEST)); return !canStand(block.getRelative(BlockFace.NORTH)) && !canStand(block.getRelative(BlockFace.EAST))
&& !canStand(block.getRelative(BlockFace.SOUTH)) && !canStand(block.getRelative(BlockFace.WEST));
} }
/** /**
@@ -113,7 +100,9 @@ public final class Utilities {
* @return true if a player cannot stand in areas further away from the block * @return true if a player cannot stand in areas further away from the block
*/ */
public static boolean cantStandFar(Block block) { public static boolean cantStandFar(Block block) {
return !canStand(block.getRelative(BlockFace.NORTH_WEST)) && !canStand(block.getRelative(BlockFace.NORTH_EAST)) && !canStand(block.getRelative(BlockFace.SOUTH_WEST)) && !canStand(block.getRelative(BlockFace.SOUTH_EAST)); return !canStand(block.getRelative(BlockFace.NORTH_WEST)) && !canStand(block.getRelative(BlockFace.NORTH_EAST))
&& !canStand(block.getRelative(BlockFace.SOUTH_WEST))
&& !canStand(block.getRelative(BlockFace.SOUTH_EAST));
} }
/** /**
@@ -126,6 +115,161 @@ public final class Utilities {
return !(block.isLiquid() || block.getType() == Material.AIR); return !(block.isLiquid() || block.getType() == Material.AIR);
} }
public static boolean isNotNearSlime(Block block) {
return !isSlime(block.getRelative(BlockFace.NORTH)) && !isSlime(block.getRelative(BlockFace.EAST))
&& !isSlime(block.getRelative(BlockFace.SOUTH)) && !isSlime(block.getRelative(BlockFace.WEST))
&& !isSlime(block.getRelative(BlockFace.DOWN));
}
public static boolean couldBeOnBoat(Player player) {
return couldBeOnBoat(player, 0.35, false);
}
public static boolean couldBeOnBoat(Player player, double range, boolean checkY) {
for (Entity entity : player.getNearbyEntities(range, range, range)) {
if (entity instanceof Boat) {
if (((Boat) entity).getLocation().getY() < player.getLocation().getY() + 0.25) {
return true;
} else if (!checkY) {
return true;
}
}
}
return false;
}
/**
* Determine whether a player could be standing on ice
*
* @param location the location to check
* @return true if the player could be standing on ice
*/
public static boolean couldBeOnIce(Location location) {
return isNearIce(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D,
location.getBlockZ()))
|| isNearIce(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.26D,
location.getBlockZ()));
}
/**
* Determine whether a block is a type of ice
*
* @param block block to check
* @return true if block is a type of ice
*/
public static boolean isIce(Block block) {
Material type = block.getType();
return type.name().endsWith("ICE");
}
public static boolean isNearIce(Location location) {
return isIce(location.getBlock()) || isIce(location.getBlock().getRelative(BlockFace.NORTH))
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH))
|| isIce(location.getBlock().getRelative(BlockFace.EAST))
|| isIce(location.getBlock().getRelative(BlockFace.WEST))
|| isIce(location.getBlock().getRelative(BlockFace.NORTH_EAST))
|| isIce(location.getBlock().getRelative(BlockFace.NORTH_WEST))
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
}
/**
* Determine whether a block is a shulker box
*
* @param block block to check
* @return true if block is a shulker box
*/
public static boolean isShulkerBox(Block block) {
Material type = block.getType();
return type.name().endsWith("SHULKER_BOX");
}
public static boolean isNearShulkerBox(Location location) {
// Shulkers are 1.12+
if (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.COLOR_UPDATE)) {
return false;
}
return isShulkerBox(location.getBlock()) || isShulkerBox(location.getBlock().getRelative(BlockFace.NORTH))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.SOUTH))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.EAST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.WEST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.NORTH_EAST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.NORTH_WEST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
}
/**
* Determine whether a player could be standing on a halfblock
*
* @param location the location to check
* @return true if the player could be standing on a halfblock
*/
public static boolean couldBeOnHalfblock(Location location) {
return isNearHalfblock(
new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, location.getBlockZ()))
|| isNearHalfblock(new Location(location.getWorld(), location.getX(), location.getY() - 0.51D,
location.getBlockZ()));
}
public static boolean isNearHalfblock(Location location) {
return isHalfblock(location.getBlock()) || isHalfblock(location.getBlock().getRelative(BlockFace.NORTH))
|| isHalfblock(location.getBlock().getRelative(BlockFace.SOUTH))
|| isHalfblock(location.getBlock().getRelative(BlockFace.EAST))
|| isHalfblock(location.getBlock().getRelative(BlockFace.WEST))
|| isHalfblock(location.getBlock().getRelative(BlockFace.NORTH_EAST))
|| isHalfblock(location.getBlock().getRelative(BlockFace.NORTH_WEST))
|| isHalfblock(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|| isHalfblock(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
}
public static boolean isHalfblock(Block block) {
// getBoundingBox() is only available on 1.14+
if (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
BoundingBox box = block.getBoundingBox();
double height = box.getMaxY() - box.getMinY();
if (height > 0.42 && height <= 0.6 && block.getType().isSolid())
return true;
}
return isSlab(block) || isStair(block) || isWall(block) || block.getType() == Material.SNOW
|| block.getType().name().endsWith("HEAD");
}
/**
* Determine whether a player could be standing on slime
*
* @param location the location to check
* @return true if the player could be standing on slime
*/
public static boolean couldBeOnSlime(Location location) {
return isNearSlime(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D,
location.getBlockZ()))
|| isNearSlime(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.51D,
location.getBlockZ()));
}
/**
* Determine whether a block is a type of slime
*
* @param block block to check
* @return true if block is a type of slime
*/
public static boolean isSlime(Block block) {
Material type = block.getType();
return type.equals(XMaterial.SLIME_BLOCK.parseMaterial());
}
public static boolean isNearSlime(Location location) {
return isSlime(location.getBlock()) || isSlime(location.getBlock().getRelative(BlockFace.NORTH))
|| isSlime(location.getBlock().getRelative(BlockFace.SOUTH))
|| isSlime(location.getBlock().getRelative(BlockFace.EAST))
|| isSlime(location.getBlock().getRelative(BlockFace.WEST))
|| isSlime(location.getBlock().getRelative(BlockFace.NORTH_EAST))
|| isSlime(location.getBlock().getRelative(BlockFace.NORTH_WEST))
|| isSlime(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|| isSlime(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
}
/** /**
* Determine whether a player is fully submerged in water * Determine whether a player is fully submerged in water
* *
@@ -135,17 +279,23 @@ public final class Utilities {
public static boolean isFullyInWater(Location player) { public static boolean isFullyInWater(Location player) {
double touchedX = fixXAxis(player.getX()); double touchedX = fixXAxis(player.getX());
// Yes, this doesn't make sense, but it's supposed to fix some false positives in water walk. // Yes, this doesn't make sense, but it's supposed to fix some false positives
// in water walk.
// Think of it as 2 negatives = a positive :) // Think of it as 2 negatives = a positive :)
if (!(new Location(player.getWorld(), touchedX, player.getY(), player.getBlockZ()).getBlock()).isLiquid() && !(new Location(player.getWorld(), touchedX, Math.round(player.getY()), player.getBlockZ()).getBlock()).isLiquid()) { if (!(new Location(player.getWorld(), touchedX, player.getY(), player.getBlockZ()).getBlock()).isLiquid()
&& !(new Location(player.getWorld(), touchedX, Math.round(player.getY()), player.getBlockZ())
.getBlock()).isLiquid()) {
return true; return true;
} }
return (new Location(player.getWorld(), touchedX, player.getY(), player.getBlockZ()).getBlock()).isLiquid() && (new Location(player.getWorld(), touchedX, Math.round(player.getY()), player.getBlockZ()).getBlock()).isLiquid(); return (new Location(player.getWorld(), touchedX, player.getY(), player.getBlockZ()).getBlock()).isLiquid()
&& (new Location(player.getWorld(), touchedX, Math.round(player.getY()), player.getBlockZ()).getBlock())
.isLiquid();
} }
/** /**
* Fixes a player's X position to determine the block they are on, even if they're on the edge * Fixes a player's X position to determine the block they are on, even if
* they're on the edge
* *
* @param x player's x position * @param x player's x position
* @return fixed x position * @return fixed x position
@@ -216,15 +366,29 @@ public final class Utilities {
*/ */
public static boolean isSlab(Block block) { public static boolean isSlab(Block block) {
Material type = block.getType(); Material type = block.getType();
switch (type) { return type.name().endsWith("SLAB");
case STEP:
case DOUBLE_STEP:
case WOOD_STEP:
case WOOD_DOUBLE_STEP:
return true;
default:
return false;
} }
/**
* Determine whether a block is a bed
*
* @param block block to bed
* @return true if bed
*/
public static boolean isBed(Block block) {
Material type = block.getType();
return type.name().endsWith("BED");
}
public static boolean isNearBed(Location location) {
return isBed(location.getBlock()) || isBed(location.getBlock().getRelative(BlockFace.NORTH))
|| isBed(location.getBlock().getRelative(BlockFace.SOUTH))
|| isBed(location.getBlock().getRelative(BlockFace.EAST))
|| isBed(location.getBlock().getRelative(BlockFace.WEST))
|| isBed(location.getBlock().getRelative(BlockFace.NORTH_EAST))
|| isBed(location.getBlock().getRelative(BlockFace.NORTH_WEST))
|| isBed(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|| isBed(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
} }
/** /**
@@ -235,30 +399,18 @@ public final class Utilities {
*/ */
public static boolean isStair(Block block) { public static boolean isStair(Block block) {
Material type = block.getType(); Material type = block.getType();
switch (type) { return type.name().endsWith("STAIRS");
case WOOD_STAIRS:
case SPRUCE_WOOD_STAIRS:
case SMOOTH_STAIRS:
case SANDSTONE_STAIRS:
case QUARTZ_STAIRS:
case JUNGLE_WOOD_STAIRS:
case NETHER_BRICK_STAIRS:
case BIRCH_WOOD_STAIRS:
case COBBLESTONE_STAIRS:
return true;
default:
return false;
}
} }
/** /**
* Determine whether a player can interact with this material * Determine whether a block is a wall
* *
* @param m material to check * @param block block to check
* @return true if interactable * @return true if wall
*/ */
public static boolean isInteractable(Material m) { public static boolean isWall(Block block) {
return INTERACTABLE.contains(m); Material type = block.getType();
return type.name().endsWith("WALL") || type.name().endsWith("FENCE");
} }
/** /**
@@ -279,9 +431,11 @@ public final class Utilities {
*/ */
public static boolean isOnLilyPad(Player player) { public static boolean isOnLilyPad(Player player) {
Block block = player.getLocation().getBlock(); Block block = player.getLocation().getBlock();
Material lily = Material.WATER_LILY; return block.getType() == XMaterial.LILY_PAD.parseMaterial()
// TODO: Can we fix X this? || block.getRelative(BlockFace.NORTH).getType() == XMaterial.LILY_PAD.parseMaterial()
return block.getType() == lily || block.getRelative(BlockFace.NORTH).getType() == lily || block.getRelative(BlockFace.SOUTH).getType() == lily || block.getRelative(BlockFace.EAST).getType() == lily || block.getRelative(BlockFace.WEST).getType() == lily; || block.getRelative(BlockFace.SOUTH).getType() == XMaterial.LILY_PAD.parseMaterial()
|| block.getRelative(BlockFace.EAST).getType() == XMaterial.LILY_PAD.parseMaterial()
|| block.getRelative(BlockFace.WEST).getType() == XMaterial.LILY_PAD.parseMaterial();
} }
/** /**
@@ -291,7 +445,8 @@ public final class Utilities {
* @return true if submersed * @return true if submersed
*/ */
public static boolean isSubmersed(Player player) { public static boolean isSubmersed(Player player) {
return player.getLocation().getBlock().isLiquid() && player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid(); return player.getLocation().getBlock().isLiquid()
&& player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
} }
/** /**
@@ -301,7 +456,80 @@ public final class Utilities {
* @return true if in water * @return true if in water
*/ */
public static boolean isInWater(Player player) { public static boolean isInWater(Player player) {
return player.getLocation().getBlock().isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid(); return player.getLocation().getBlock().isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid()
|| (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.AQUATIC_UPDATE)
&& (player.getLocation().getBlock().getType() == XMaterial.KELP_PLANT.parseMaterial()
|| player.getLocation().getBlock().getRelative(BlockFace.UP)
.getType() == XMaterial.KELP_PLANT.parseMaterial()
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN)
.getType() == XMaterial.KELP_PLANT.parseMaterial())
&& isNearWater(player));
}
/**
* Determine whether a player is near a liquid block
*
* @param player player to check
* @return true if near liquid block
*/
public static boolean isNearWater(Player player) {
return player.getLocation().getBlock().isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.NORTH).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.SOUTH).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.EAST).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.WEST).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.NORTH_EAST).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.NORTH_WEST).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.SOUTH_EAST).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.SOUTH_WEST).isLiquid();
}
/**
* Determine whether a player is surrounded by liquid blocks
*
* @param player player to check
* @return true if surrounded by liquid blocks
*/
public static boolean isSurroundedByWater(Player player) {
Location location = player.getLocation().clone().subtract(0, 0.1, 0);
return location.getBlock().isLiquid() && location.getBlock().getRelative(BlockFace.NORTH).isLiquid()
&& location.getBlock().getRelative(BlockFace.SOUTH).isLiquid()
&& location.getBlock().getRelative(BlockFace.EAST).isLiquid()
&& location.getBlock().getRelative(BlockFace.WEST).isLiquid()
&& location.getBlock().getRelative(BlockFace.NORTH_EAST).isLiquid()
&& location.getBlock().getRelative(BlockFace.NORTH_WEST).isLiquid()
&& location.getBlock().getRelative(BlockFace.SOUTH_EAST).isLiquid()
&& location.getBlock().getRelative(BlockFace.SOUTH_WEST).isLiquid();
}
/**
* Determine whether a player is near a web
*
* @param player player to check
* @return true if near a web
*/
public static boolean isNearWeb(Player player) {
return isWeb(player.getLocation().getBlock())
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.DOWN))
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.UP))
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.NORTH))
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.SOUTH))
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.EAST))
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.WEST));
}
/**
* Determine whether a block is a web
*
* @param block block to check
* @return true if web
*/
public static boolean isWeb(Block block) {
return block.getType() == XMaterial.COBWEB.parseMaterial();
} }
/** /**
@@ -311,7 +539,43 @@ public final class Utilities {
* @return true if in web * @return true if in web
*/ */
public static boolean isInWeb(Player player) { public static boolean isInWeb(Player player) {
return player.getLocation().getBlock().getType() == Material.WEB || player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.WEB || player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == Material.WEB; return player.getLocation().getBlock().getType() == XMaterial.COBWEB.parseMaterial()
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == XMaterial.COBWEB
.parseMaterial()
|| player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == XMaterial.COBWEB
.parseMaterial();
}
/**
* Determine whether a player is near a climbable block
*
* @param player player to check
* @return true if near climbable block
*/
public static boolean isNearClimbable(Player player) {
return isClimbableBlock(player.getLocation().getBlock())
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.DOWN))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.UP))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.NORTH))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.SOUTH))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.EAST))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.WEST));
}
/**
* Determine whether a location is near a climbable block
*
* @param location location to check
* @return true if near climbable block
*/
public static boolean isNearClimbable(Location location) {
return isClimbableBlock(location.getBlock())
|| isClimbableBlock(location.getBlock().getRelative(BlockFace.DOWN))
|| isClimbableBlock(location.getBlock().getRelative(BlockFace.UP))
|| isClimbableBlock(location.getBlock().getRelative(BlockFace.NORTH))
|| isClimbableBlock(location.getBlock().getRelative(BlockFace.SOUTH))
|| isClimbableBlock(location.getBlock().getRelative(BlockFace.EAST))
|| isClimbableBlock(location.getBlock().getRelative(BlockFace.WEST));
} }
/** /**
@@ -321,7 +585,7 @@ public final class Utilities {
* @return true if climbable * @return true if climbable
*/ */
public static boolean isClimbableBlock(Block block) { public static boolean isClimbableBlock(Block block) {
return block.getType() == Material.VINE || block.getType() == Material.LADDER || block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER; return CLIMBABLE.contains(block.getType());
} }
/** /**
@@ -331,7 +595,7 @@ public final class Utilities {
* @return true if on vine * @return true if on vine
*/ */
public static boolean isOnVine(Player player) { public static boolean isOnVine(Player player) {
return player.getLocation().getBlock().getType() == Material.VINE; return player.getLocation().getBlock().getType() == XMaterial.VINE.parseMaterial();
} }
/** /**
@@ -364,52 +628,6 @@ public final class Utilities {
} }
} }
/**
* Calculate the time in milliseconds that it should take to break the given block with the given tool
*
* @param tool tool to check
* @param block block to check
* @return time in milliseconds to break
*/
public static long calcSurvivalFastBreak(ItemStack tool, Material block) {
if (isInstantBreak(block) || (tool.getType() == Material.SHEARS && block == Material.LEAVES)) {
return 0;
}
double bhardness = BlockHardness.getBlockHardness(block);
double thardness = ToolHardness.getToolHardness(tool.getType());
long enchantlvl = (long) tool.getEnchantmentLevel(Enchantment.DIG_SPEED);
long result = Math.round((bhardness * thardness) * 0.10 * 10000);
if (enchantlvl > 0) {
result /= enchantlvl * enchantlvl + 1L;
}
result = result > 25000 ? 25000 : result < 0 ? 0 : result;
if (isQuickCombo(tool, block)) {
result = result / 2;
}
return result;
}
/**
* Determine whether the given tool is a combination that makes the breaking of this block faster
*
* @param tool tool to check
* @param block block to check
* @return true if quick combo
*/
private static boolean isQuickCombo(ItemStack tool, Material block) {
for (Material t : COMBO.keySet()) {
if (tool.getType() == t && COMBO.get(t) == block) {
return true;
}
}
return false;
}
/** /**
* Determine if a block ISN'T one of the specified types * Determine if a block ISN'T one of the specified types
* *
@@ -424,8 +642,25 @@ public final class Utilities {
return false; return false;
} }
} }
return true;
}
/**
* Determine if a block ISN'T one of the specified types
*
* @param block block to check
* @param endTypes array of possible name endings
* @return true if the block isn't any of the materials
*/
public static boolean blockIsnt(Block block, String[] endTypes) {
Material type = block.getType();
for (String s : endTypes) {
if (type.name().endsWith(s)) {
return false; return false;
} }
}
return true;
}
/** /**
* Parse a COMMAND[] input to a set of commands to execute * Parse a COMMAND[] input to a set of commands to execute
@@ -470,7 +705,12 @@ public final class Utilities {
* @return ArrayList with string * @return ArrayList with string
*/ */
public static ArrayList<String> stringToList(final String string) { public static ArrayList<String> stringToList(final String string) {
return new ArrayList<String>() {{ add(string); }}; return new ArrayList<String>() {
private static final long serialVersionUID = 364115444874638230L;
{
add(string);
}
};
} }
/** /**
@@ -492,16 +732,18 @@ public final class Utilities {
/** /**
* Parse a string in the format of "XdXhXmXs" to seconds * Parse a string in the format of "XdXhXmXs" to seconds
*
* @param string The string to parse * @param string The string to parse
* @return seconds * @return seconds
*/ */
public static long lifeToSeconds(String string) { public static long lifeToSeconds(String string) {
if (string.equals("0") || string.equals("")) return 0; if (string.equals("0") || string.equals(""))
String[] lifeMatch = new String[]{ "d", "h", "m", "s" }; return 0;
int[] lifeInterval = new int[]{ 86400, 3600, 60, 1 }; String[] lifeMatch = new String[] { "d", "h", "m", "s" };
int[] lifeInterval = new int[] { 86400, 3600, 60, 1 };
long seconds = 0L; long seconds = 0L;
for (int i=0;i<lifeMatch.length;i++) { for (int i = 0; i < lifeMatch.length; i++) {
Matcher matcher = Pattern.compile("([0-9]*)" + lifeMatch[i]).matcher(string); Matcher matcher = Pattern.compile("([0-9]*)" + lifeMatch[i]).matcher(string);
while (matcher.find()) { while (matcher.find()) {
seconds += Integer.parseInt(matcher.group(1)) * lifeInterval[i]; seconds += Integer.parseInt(matcher.group(1)) * lifeInterval[i];
@@ -511,66 +753,278 @@ public final class Utilities {
return seconds; return seconds;
} }
/**
* Rounds a float value to a scale
*
* @param value Value to round
* @param scale Scale
* @return rounded value
*/
public static float roundFloat(float value, int scale) {
return new BigDecimal(value).setScale(scale, RoundingMode.HALF_UP).floatValue();
}
/**
* Rounds a double value to a scale
*
* @param value Value to round
* @param scale Scale
* @return rounded value
*/
public static double roundDouble(double value, int scale) {
return new BigDecimal(value).setScale(scale, RoundingMode.HALF_UP).doubleValue();
}
public static int floor(double value) {
int rounded = (int) value;
return value < rounded ? rounded - 1 : rounded;
}
public static boolean isHoneyBlock(Block block) {
if (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.BEE_UPDATE)) {
return false;
}
return block.getType() == XMaterial.HONEY_BLOCK.parseMaterial();
}
static { static {
// START INSTANT BREAK MATERIALS // Start 1.8.8
INSTANT_BREAK.add(Material.RED_MUSHROOM); if (VersionUtil.isBountifulUpdate()) {
INSTANT_BREAK.add(Material.RED_ROSE); // Start instant break materials
INSTANT_BREAK.add(Material.BROWN_MUSHROOM); INSTANT_BREAK.add(XMaterial.COMPARATOR.parseMaterial());
INSTANT_BREAK.add(Material.YELLOW_FLOWER); INSTANT_BREAK.add(XMaterial.REPEATER.parseMaterial());
INSTANT_BREAK.add(Material.REDSTONE); INSTANT_BREAK.add(XMaterial.TORCH.parseMaterial());
INSTANT_BREAK.add(Material.REDSTONE_TORCH_OFF); INSTANT_BREAK.add(XMaterial.REDSTONE_TORCH.parseMaterial());
INSTANT_BREAK.add(Material.REDSTONE_TORCH_ON); INSTANT_BREAK.add(XMaterial.REDSTONE_WIRE.parseMaterial());
INSTANT_BREAK.add(Material.REDSTONE_WIRE); INSTANT_BREAK.add(XMaterial.TRIPWIRE.parseMaterial());
INSTANT_BREAK.add(Material.LONG_GRASS); INSTANT_BREAK.add(XMaterial.TRIPWIRE_HOOK.parseMaterial());
INSTANT_BREAK.add(Material.PAINTING); INSTANT_BREAK.add(XMaterial.FIRE.parseMaterial());
INSTANT_BREAK.add(Material.WHEAT); INSTANT_BREAK.add(XMaterial.FLOWER_POT.parseMaterial());
INSTANT_BREAK.add(Material.SUGAR_CANE); INSTANT_BREAK.add(XMaterial.TNT.parseMaterial());
INSTANT_BREAK.add(Material.SUGAR_CANE_BLOCK); INSTANT_BREAK.add(XMaterial.SLIME_BLOCK.parseMaterial());
INSTANT_BREAK.add(Material.DIODE); INSTANT_BREAK.add(XMaterial.CARROT.parseMaterial());
INSTANT_BREAK.add(Material.DIODE_BLOCK_OFF); INSTANT_BREAK.add(XMaterial.DEAD_BUSH.parseMaterial());
INSTANT_BREAK.add(Material.DIODE_BLOCK_ON); INSTANT_BREAK.add(XMaterial.GRASS.parseMaterial());
INSTANT_BREAK.add(Material.SAPLING); INSTANT_BREAK.add(XMaterial.TALL_GRASS.parseMaterial());
INSTANT_BREAK.add(Material.TORCH); INSTANT_BREAK.add(XMaterial.LILY_PAD.parseMaterial());
INSTANT_BREAK.add(Material.CROPS); INSTANT_BREAK.add(XMaterial.MELON_STEM.parseMaterial());
INSTANT_BREAK.add(Material.SNOW); INSTANT_BREAK.add(XMaterial.MELON_STEM.parseMaterial());
INSTANT_BREAK.add(Material.TNT); INSTANT_BREAK.add(XMaterial.BROWN_MUSHROOM.parseMaterial());
INSTANT_BREAK.add(Material.POTATO); INSTANT_BREAK.add(XMaterial.RED_MUSHROOM.parseMaterial());
INSTANT_BREAK.add(Material.CARROT); INSTANT_BREAK.add(XMaterial.NETHER_WART.parseMaterial());
// END INSTANT BREAK MATERIALS INSTANT_BREAK.add(XMaterial.POTATO.parseMaterial());
INSTANT_BREAK.add(XMaterial.PUMPKIN_STEM.parseMaterial());
INSTANT_BREAK.add(XMaterial.PUMPKIN_STEM.parseMaterial());
INSTANT_BREAK.add(XMaterial.OAK_SAPLING.parseMaterial());
INSTANT_BREAK.add(XMaterial.SUGAR_CANE.parseMaterial());
INSTANT_BREAK.add(XMaterial.WHEAT.parseMaterial());
// End instant break materials
// START INTERACTABLE MATERIALS // Start food
INTERACTABLE.add(Material.STONE_BUTTON); FOOD.add(XMaterial.APPLE.parseMaterial());
INTERACTABLE.add(Material.LEVER); FOOD.add(XMaterial.BAKED_POTATO.parseMaterial());
INTERACTABLE.add(Material.CHEST); FOOD.add(XMaterial.BREAD.parseMaterial());
// END INTERACTABLE MATERIALS FOOD.add(XMaterial.CAKE.parseMaterial());
FOOD.add(XMaterial.CARROT.parseMaterial());
FOOD.add(XMaterial.COOKED_CHICKEN.parseMaterial());
FOOD.add(XMaterial.COOKED_COD.parseMaterial());
FOOD.add(XMaterial.COD.parseMaterial());
FOOD.add(XMaterial.COOKED_MUTTON.parseMaterial());
FOOD.add(XMaterial.COOKED_PORKCHOP.parseMaterial());
FOOD.add(XMaterial.COOKED_RABBIT.parseMaterial());
FOOD.add(XMaterial.COOKIE.parseMaterial());
FOOD.add(XMaterial.GOLDEN_APPLE.parseMaterial());
FOOD.add(XMaterial.GOLDEN_CARROT.parseMaterial());
FOOD.add(XMaterial.GLISTERING_MELON_SLICE.parseMaterial());
FOOD.add(XMaterial.MUSHROOM_STEM.parseMaterial());
FOOD.add(XMaterial.POISONOUS_POTATO.parseMaterial());
FOOD.add(XMaterial.POTATO.parseMaterial());
FOOD.add(XMaterial.PUMPKIN_PIE.parseMaterial());
FOOD.add(XMaterial.RABBIT_STEW.parseMaterial());
FOOD.add(XMaterial.COOKED_BEEF.parseMaterial());
FOOD.add(XMaterial.BEEF.parseMaterial());
FOOD.add(XMaterial.COOKED_CHICKEN.parseMaterial());
FOOD.add(XMaterial.CHICKEN.parseMaterial());
FOOD.add(XMaterial.MUTTON.parseMaterial());
FOOD.add(XMaterial.PORKCHOP.parseMaterial());
FOOD.add(XMaterial.RABBIT.parseMaterial());
FOOD.add(XMaterial.COOKED_RABBIT.parseMaterial());
FOOD.add(XMaterial.ROTTEN_FLESH.parseMaterial());
FOOD.add(XMaterial.SPIDER_EYE.parseMaterial());
// START FOOD // Start combos
FOOD.add(Material.COOKED_BEEF); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.WHITE_WOOL.parseMaterial());
FOOD.add(Material.COOKED_CHICKEN);
FOOD.add(Material.COOKED_FISH);
FOOD.add(Material.GRILLED_PORK);
FOOD.add(Material.PORK);
FOOD.add(Material.MUSHROOM_SOUP);
FOOD.add(Material.RAW_BEEF);
FOOD.add(Material.RAW_CHICKEN);
FOOD.add(Material.RAW_FISH);
FOOD.add(Material.APPLE);
FOOD.add(Material.GOLDEN_APPLE);
FOOD.add(Material.MELON);
FOOD.add(Material.COOKIE);
FOOD.add(Material.BREAD);
FOOD.add(Material.SPIDER_EYE);
FOOD.add(Material.ROTTEN_FLESH);
FOOD.add(Material.POTATO_ITEM);
// END FOOD
// START COMBOS COMBO.put(XMaterial.IRON_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
COMBO.put(Material.SHEARS, Material.WOOL); COMBO.put(XMaterial.DIAMOND_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
COMBO.put(Material.IRON_SWORD, Material.WEB); COMBO.put(XMaterial.STONE_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
COMBO.put(Material.DIAMOND_SWORD, Material.WEB); COMBO.put(XMaterial.WOODEN_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
COMBO.put(Material.STONE_SWORD, Material.WEB); // End combos
COMBO.put(Material.WOOD_SWORD, Material.WEB);
// END COMBOS // Start climbable
CLIMBABLE.add(XMaterial.VINE.parseMaterial());
CLIMBABLE.add(XMaterial.LADDER.parseMaterial());
CLIMBABLE.add(XMaterial.WATER.parseMaterial());
// End climbable
}
// End 1.8.8
// Start other version
else {
MinecraftVersion currentVersion = MinecraftVersion.getCurrentVersion();
// Start instant break materials
INSTANT_BREAK.add(XMaterial.COMPARATOR.parseMaterial());
INSTANT_BREAK.add(XMaterial.REPEATER.parseMaterial());
INSTANT_BREAK.add(XMaterial.TORCH.parseMaterial());
INSTANT_BREAK.add(XMaterial.REDSTONE_TORCH.parseMaterial());
INSTANT_BREAK.add(XMaterial.REDSTONE_WIRE.parseMaterial());
INSTANT_BREAK.add(XMaterial.TRIPWIRE.parseMaterial());
INSTANT_BREAK.add(XMaterial.TRIPWIRE_HOOK.parseMaterial());
INSTANT_BREAK.add(XMaterial.FIRE.parseMaterial());
INSTANT_BREAK.add(XMaterial.FLOWER_POT.parseMaterial());
INSTANT_BREAK.add(XMaterial.INFESTED_CHISELED_STONE_BRICKS.parseMaterial());
INSTANT_BREAK.add(XMaterial.INFESTED_COBBLESTONE.parseMaterial());
INSTANT_BREAK.add(XMaterial.INFESTED_CRACKED_STONE_BRICKS.parseMaterial());
INSTANT_BREAK.add(XMaterial.INFESTED_MOSSY_STONE_BRICKS.parseMaterial());
INSTANT_BREAK.add(XMaterial.INFESTED_STONE.parseMaterial());
INSTANT_BREAK.add(XMaterial.INFESTED_STONE_BRICKS.parseMaterial());
INSTANT_BREAK.add(XMaterial.TNT.parseMaterial());
INSTANT_BREAK.add(XMaterial.SLIME_BLOCK.parseMaterial());
INSTANT_BREAK.add(XMaterial.CARROTS.parseMaterial());
INSTANT_BREAK.add(XMaterial.DEAD_BUSH.parseMaterial());
INSTANT_BREAK.add(XMaterial.FERN.parseMaterial());
INSTANT_BREAK.add(XMaterial.LARGE_FERN.parseMaterial());
INSTANT_BREAK.add(XMaterial.CHORUS_FLOWER.parseMaterial());
INSTANT_BREAK.add(XMaterial.SUNFLOWER.parseMaterial());
INSTANT_BREAK.add(XMaterial.LILY_PAD.parseMaterial());
INSTANT_BREAK.add(XMaterial.MELON_STEM.parseMaterial());
INSTANT_BREAK.add(XMaterial.ATTACHED_MELON_STEM.parseMaterial());
INSTANT_BREAK.add(XMaterial.BROWN_MUSHROOM.parseMaterial());
INSTANT_BREAK.add(XMaterial.RED_MUSHROOM.parseMaterial());
INSTANT_BREAK.add(XMaterial.NETHER_WART.parseMaterial());
INSTANT_BREAK.add(XMaterial.POTATOES.parseMaterial());
INSTANT_BREAK.add(XMaterial.PUMPKIN_STEM.parseMaterial());
INSTANT_BREAK.add(XMaterial.ATTACHED_PUMPKIN_STEM.parseMaterial());
INSTANT_BREAK.add(XMaterial.ACACIA_SAPLING.parseMaterial());
INSTANT_BREAK.add(XMaterial.BIRCH_SAPLING.parseMaterial());
INSTANT_BREAK.add(XMaterial.DARK_OAK_SAPLING.parseMaterial());
INSTANT_BREAK.add(XMaterial.JUNGLE_SAPLING.parseMaterial());
INSTANT_BREAK.add(XMaterial.OAK_SAPLING.parseMaterial());
INSTANT_BREAK.add(XMaterial.SPRUCE_SAPLING.parseMaterial());
INSTANT_BREAK.add(XMaterial.SUGAR_CANE.parseMaterial());
INSTANT_BREAK.add(XMaterial.TALL_GRASS.parseMaterial());
INSTANT_BREAK.add(XMaterial.TALL_SEAGRASS.parseMaterial());
INSTANT_BREAK.add(XMaterial.WHEAT.parseMaterial());
// Start 1.14 objects
if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
INSTANT_BREAK.add(XMaterial.BAMBOO_SAPLING.parseMaterial());
INSTANT_BREAK.add(XMaterial.CORNFLOWER.parseMaterial());
}
// End 1.14 objects
// Start 1.15 objects
if (currentVersion.isAtLeast(MinecraftVersion.BEE_UPDATE)) {
INSTANT_BREAK.add(XMaterial.HONEY_BLOCK.parseMaterial());
}
// End 1.15 objects
// End instant break materials
// Start food
FOOD.add(XMaterial.APPLE.parseMaterial());
FOOD.add(XMaterial.BAKED_POTATO.parseMaterial());
FOOD.add(XMaterial.BEETROOT.parseMaterial());
FOOD.add(XMaterial.BEETROOT_SOUP.parseMaterial());
FOOD.add(XMaterial.BREAD.parseMaterial());
FOOD.add(XMaterial.CAKE.parseMaterial());
FOOD.add(XMaterial.CARROT.parseMaterial());
FOOD.add(XMaterial.CHORUS_FRUIT.parseMaterial());
FOOD.add(XMaterial.COOKED_BEEF.parseMaterial());
FOOD.add(XMaterial.COOKED_CHICKEN.parseMaterial());
FOOD.add(XMaterial.COOKED_COD.parseMaterial());
FOOD.add(XMaterial.COOKED_MUTTON.parseMaterial());
FOOD.add(XMaterial.COOKED_PORKCHOP.parseMaterial());
FOOD.add(XMaterial.COOKED_RABBIT.parseMaterial());
FOOD.add(XMaterial.COOKED_SALMON.parseMaterial());
FOOD.add(XMaterial.COOKIE.parseMaterial());
FOOD.add(XMaterial.DRIED_KELP.parseMaterial());
FOOD.add(XMaterial.ENCHANTED_GOLDEN_APPLE.parseMaterial());
FOOD.add(XMaterial.GOLDEN_APPLE.parseMaterial());
FOOD.add(XMaterial.GOLDEN_CARROT.parseMaterial());
FOOD.add(XMaterial.MELON_SLICE.parseMaterial());
FOOD.add(XMaterial.MUSHROOM_STEW.parseMaterial());
FOOD.add(XMaterial.POISONOUS_POTATO.parseMaterial());
FOOD.add(XMaterial.POTATO.parseMaterial());
FOOD.add(XMaterial.PUFFERFISH.parseMaterial());
FOOD.add(XMaterial.PUMPKIN_PIE.parseMaterial());
FOOD.add(XMaterial.RABBIT_STEW.parseMaterial());
FOOD.add(XMaterial.BEEF.parseMaterial());
FOOD.add(XMaterial.CHICKEN.parseMaterial());
FOOD.add(XMaterial.COD.parseMaterial());
FOOD.add(XMaterial.MUTTON.parseMaterial());
FOOD.add(XMaterial.PORKCHOP.parseMaterial());
FOOD.add(XMaterial.RABBIT.parseMaterial());
FOOD.add(XMaterial.SALMON.parseMaterial());
FOOD.add(XMaterial.ROTTEN_FLESH.parseMaterial());
FOOD.add(XMaterial.SPIDER_EYE.parseMaterial());
FOOD.add(XMaterial.TROPICAL_FISH.parseMaterial());
// Start 1.14 objects
if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
FOOD.add(XMaterial.SUSPICIOUS_STEW.parseMaterial());
FOOD.add(XMaterial.SWEET_BERRIES.parseMaterial());
}
// End 1.14 objects
// Start 1.15 objects
if (currentVersion.isAtLeast(MinecraftVersion.BEE_UPDATE)) {
FOOD.add(XMaterial.HONEY_BOTTLE.parseMaterial());
}
// End 1.15 objects
// End food
// Start combos
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.BLACK_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.BLUE_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.BROWN_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.CYAN_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.GRAY_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.GREEN_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.LIGHT_BLUE_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.LIGHT_GRAY_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.LIME_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.MAGENTA_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.MAGENTA_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.ORANGE_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.PINK_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.PURPLE_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.RED_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.WHITE_WOOL.parseMaterial());
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.YELLOW_WOOL.parseMaterial());
COMBO.put(XMaterial.IRON_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
COMBO.put(XMaterial.DIAMOND_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
COMBO.put(XMaterial.STONE_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
COMBO.put(XMaterial.WOODEN_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
// End combos
// Start climbable
CLIMBABLE.add(XMaterial.VINE.parseMaterial());
CLIMBABLE.add(XMaterial.LADDER.parseMaterial());
CLIMBABLE.add(XMaterial.WATER.parseMaterial());
// Start 1.14 objects
if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
CLIMBABLE.add(XMaterial.SCAFFOLDING.parseMaterial());
CLIMBABLE.add(XMaterial.SWEET_BERRY_BUSH.parseMaterial());
}
// End 1.14 objects
// Start 1.16 objects
if (currentVersion.isAtLeast(MinecraftVersion.NETHER_UPDATE)) {
CLIMBABLE.add(XMaterial.TWISTING_VINES.parseMaterial());
CLIMBABLE.add(XMaterial.TWISTING_VINES_PLANT.parseMaterial());
CLIMBABLE.add(XMaterial.WEEPING_VINES.parseMaterial());
CLIMBABLE.add(XMaterial.WEEPING_VINES_PLANT.parseMaterial());
}
// End 1.16 objects
// End climbable
}
// End other versions
} }
} }
@@ -1,53 +1,161 @@
/*
* 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; package com.rammelkast.anticheatreloaded.util;
import java.util.EnumSet; import java.util.Arrays;
import java.util.List;
import java.util.Set;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; 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 { public class VersionUtil {
private static final List<String> SUPPORTED_VERSIONS;
private static final MinecraftVersion CURRENT_VERSION;
public static String getVersion() { public static String getVersion() {
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
} }
private static final EnumSet<Material> MOVE_UP_BLOCKS_1_8 = EnumSet.of(Material.ACACIA_STAIRS, public static boolean isSupported() {
Material.BIRCH_WOOD_STAIRS, Material.BRICK_STAIRS, Material.COBBLESTONE_STAIRS, Material.DARK_OAK_STAIRS, for (String versionId : SUPPORTED_VERSIONS) {
Material.JUNGLE_WOOD_STAIRS, Material.NETHER_BRICK_STAIRS, Material.QUARTZ_STAIRS, if (getVersion().startsWith(versionId)) {
Material.RED_SANDSTONE_STAIRS, Material.SANDSTONE_STAIRS, Material.SMOOTH_STAIRS,
Material.SPRUCE_WOOD_STAIRS, Material.WOOD_STAIRS);
public static boolean isFlying(Player p) {
if (getVersion().equals("v1_9_R1") || getVersion().equals("v1_10_R1") || getVersion().equals("v1_11_R1")) {
return p.isFlying() || p.isGliding() || p.hasPotionEffect(NMS_1_9_PLUS.LEVITATION);
} else {
return p.isFlying();
}
}
public static EnumSet<Material> getMoveUpBlocks() {
if (getVersion().equals("v1_9_R1") || getVersion().equals("v1_10_R1") || getVersion().equals("v1_11_R1")) {
return NMS_1_9_PLUS.MOVE_UP_BLOCKS_1_9;
} else {
return MOVE_UP_BLOCKS_1_8;
}
}
public static boolean isNewYSpeed() {
if (getVersion().equals("v1_9_R1") || getVersion().equals("v1_10_R1") || getVersion().equals("v1_11_R1")) {
return true; return true;
} else { }
}
return false; return false;
} }
public static boolean isOfVersion(String versionId) {
if (getVersion().startsWith(versionId)) {
return true;
}
return false;
} }
public static long getHealTime() { /**
if (getVersion().equals("v1_9_R1") || getVersion().equals("v1_10_R1") || getVersion().equals("v1_11_R1")) { * @return the if server is running Bountiful Update (1.8)
return 495; */
} else { public static boolean isBountifulUpdate() {
return 1995; 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 (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
return false;
}
return player.isRiptiding();
}
public static boolean isSlowFalling(Player player) {
if (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
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 (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
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 (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
return false;
}
return player.isSwimming();
}
static {
SUPPORTED_VERSIONS = Arrays.asList(new String[] { "v1_16", "v1_15", "v1_14", "v1_13", "v1_12", "v1_8_R3" });
CURRENT_VERSION = MinecraftVersion.getCurrentVersion();
}
} }
File diff suppressed because it is too large. Load diff
@@ -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
@@ -21,7 +22,7 @@ package com.rammelkast.anticheatreloaded.util.enterprise;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.Utilities;
@@ -137,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();
@@ -146,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();
@@ -154,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();
} }
@@ -203,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 {
@@ -213,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();
} }
@@ -223,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);
} }
} }
} }
@@ -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
@@ -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
@@ -20,7 +21,7 @@ package com.rammelkast.anticheatreloaded.util.rule;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import com.rammelkast.anticheatreloaded.AntiCheat; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.Group; import com.rammelkast.anticheatreloaded.util.Group;
import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.User;
@@ -71,7 +72,7 @@ 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/>
@@ -81,13 +82,13 @@ import java.util.TreeMap;
*/ */
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;
@@ -128,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)) {
@@ -175,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());
} }
@@ -196,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);
} }
} }
+450
View File
@@ -0,0 +1,450 @@
# AntiCheatReloaded checks configuration file
# Checks that have multiple modules need to be disabled on a per-module basis
# If you have a false positive and can't determine what subcheck it's from,
# enable debug-mode in config.yml and compare the results against the commented values
# Flight check settings
# Checks if a player moves wrongly in the air
flight:
# Checks for prolonged air movement
# Debugs as 'tried to fly on the Y-axis' or 'had too little Y dropoff'
airFlight:
# Should this part of the check be enabled?
enabled: true
# How many milliseconds to account for block placement
# Increase this if you get false positives when building a tower
accountForBlockPlacement: 1200
# How many milliseconds to account for TPS drops
# Increase this if you get false positives when building a tower during TPS drops
accountForTpsDrops: 250
# How many milliseconds to account for teleports
# Increase this is you debug 'had too little Y dropoff' after teleports
accountForTeleports: 150
# Checks for climbing behaviour in air
# Debugs as 'tried to climb air'
airClimb:
# Should this part of the check be enabled?
enabled: true
# How many milliseconds to account for teleports
# Increase this is you debug 'tried to climb air' after teleports
accountForTeleports: 50
# Checks if a player is faking it's ground status to fly
# Debugs as 'faked ground to fly'
groundFlight:
# Should this part of the check be enabled?
enabled: true
# Checks if a player ignores gravity
# Debugs as 'ignored gravity'
gravity:
# Should this part of the check be enabled?
enabled: true
# Maximum offset between predicted and actual gravity
maxOffset: 0.005
# How many milliseconds to account for teleports
# Increase this is you debug 'ignored gravity' after teleports
accountForTeleports: 100
# Amount of illegal moves before flagging
vlBeforeFlag: 5
# ElytraFly check settings
# Checks for illegal upward elytra movement
elytrafly:
# Should this check be enabled?
enabled: true
# Speed check settings
# Checks if a player moves too fast
speed:
# Checks movement speed in the air
# Debugs as 'moved too fast in air'
airSpeed:
# Should this part of the check be enabled?
enabled: true
# Base unadjusted air speed limit
baseLimit: 0.03125
# Prediction multiplier for custom walk speeds
walkSpeedMultiplier: 1.4
# Checks movement acceleration in the air
# Debugs as 'exceeded acceleration limits'
airAcceleration:
# Should this part of the check be enabled?
enabled: true
# Base unadjusted air acceleration limit
baseLimit: 0.3725
# Limit multiplier for custom walk speeds
walkSpeedMultiplier: 1.4
# Checks movement acceleration in the air
# Debugs as 'had unexpected jumping behaviour'
jumpBehaviour:
# Should this part of the check be enabled?
enabled: true
# Minimum movement distance needed to flag
minimumDistXZ: 0.42
# Checks movement speed on the ground
# Debugs as 'moved too fast on ground'
groundSpeed:
# Should this part of the check be enabled?
enabled: true
# Initial speed limit value
initialLimit: 0.34
# Checks movement acceleration in the air
# Debugs as 'exceeded vertical speed limit'
verticalSpeed:
# Should this part of the check be enabled?
enabled: true
# Extra compensation when moving off a ladder up a slab
climbableCompensation: 0.04
# Strafe check settings
# Checks if a player switches movement angle in air
strafe:
# Should this check be enabled?
enabled: true
# How many milliseconds to account for teleports
accountForTeleports: 100
# Maximum angle change when moving in air
maxAngleChange: 0.50
# Minimum movement distance for the strafe check to be active
minActivationDistance: 0.025
# WaterWalk check settings
# Checks if a player is walking on water
waterwalk:
# Checks for vanilla water walking/jumping
# Debugs as 'tried to walk on water'
walk:
# Should this part of the check be enabled?
enabled: true
# Minimum xz distance before flagging
# This combats false positives, while giving hackers not much leniency
minimumDistXZ: 0.092
# Checks for small hops on top of water
# Debugs as 'tried to hop on water'
hop:
# Should this part of the check be enabled?
enabled: true
# Maximum lunge Y motion to flag
maxMotionY: 0.10
# Checks for small lunges in water
# Debugs as 'tried to lunge in water'
lunge:
# Should this part of the check be enabled?
enabled: true
# Minimum xz distance before flagging
# This combats false positives, while giving hackers not much leniency
minimumDistXZ: 0.098
# FastLadder check settings
# Checks if a player moves too fast on a ladder
fastladder:
# Should this check be enabled?
enabled: true
# Maximum speed a player on a ladder can travel upwards
speedUpMax: 0.11761
# Maximum speed a player on a ladder can travel downwards
speedDownMax: 0.15
# Amount of illegal ladder moves before flagging
vlBeforeFlag: 3
# BoatFly check settings
# Checks if the player is flying in a boat
boatfly:
# Should this check be enabled?
enabled: true
# Amount of in-boat airborne moments before flagging
vlBeforeFlag: 2
# KillAura check settings
# Checks if the player uses a form of kill aura
killaura:
# Checks reach distance in fights
# Debugs as 'reached too far'
reach:
# Should this part of the check be enabled?
enabled: true
# Maximum base reach distances
baseMaxValue:
# Maximum base reach value
normal: 3.6
# Maximum base reach value when a player has velocity
velocitized: 4.0
# Settings for lag compensation
lagCompensation:
# Basic extra allowed reach when a player is lagging
lagExtraReach: 0.2
# Extra allowed reach distance per millisecond of ping
pingCompensation: 0.0025
# The multiplier of extra compensation for velocity
velocityMultiplier: 1.2
# Checks if the target it within a players viewing angle
# Debugs as 'tried to attack from an illegal angle'
angle:
# Should this part of the check be enabled?
enabled: true
# Maximum difference in angle from the players view
maxDifference: 50
# Amount of illegally angled hits before flagging
vlBeforeFlag: 3
# Checks if the player has a suspicious packet order
# Debugs as 'suspicious packet order'
packetOrder:
# Should this part of the check be enabled?
enabled: true
# Minimum server TPS needed for BadPackets to be active
minimumTps: 17.5
# Minimum elapsed time in milliseconds between a movement packet and a combat packet
minElapsedTime: 5
# Amount of suspicious combat packet situations before flagging
vlBeforeFlag: 3
# Aimbot check settings
# Checks if the player is sending aimbot-like movements
aimbot:
# Should this check be enabled?
enabled: true
# Minimum yaw difference when repeated
minYaw: 30
# Maximum yaw difference when repeated
maxYaw: 355
# Criticals check settings
# Checks if the player tries to do a crit without needed conditions
criticals:
# Should this check be enabled?
enabled: true
# Velocity check settings
# Checks if the player ignores knockback
velocity:
# Should this check be enabled?
enabled: true
# Minimum percentage of the given knockback a player has to meet
minimumPercentage: 75
# Amount of low-velocity moments before flagging
vlBeforeFlag: 2
# FastPlace check settings
# Checks if the player places blocks too fast
fastplace:
# Should this check be enabled?
enabled: true
# Minimum time in milliseconds between block places
minimumTime: 50
# Amount of fastplace-moments before flagging a survival player
vlBeforeFlagSurvival: 2
# Amount of fastplace-moments before flagging a creative player
vlBeforeFlagCreative: 3
# Amount of time in milliseconds to prevent a player from placing blocks after flagging
blockPlacementTime: 1000
# IllegalInteract check settings
# Checks if the player is using, placing or breaking blocks from illegal angles
illegalinteract:
# Maximum difference in angle from the players view
maxAngleDifference: 90
# Checks angle when breaking a block
# Debugs as 'tried to break a block which was out of view'
break:
# Should this part of the check be enabled?
enabled: true
# Checks angle when placing a block
# Debugs as 'tried to place a block which was out of view'
place:
# Should this part of the check be enabled?
enabled: true
# Checks angle when placing a block
# Debugs as 'tried to interact out of range' or 'tried to interact out of view'
interact:
# Should this part of the check be enabled?
enabled: true
# Default survival interact range
survivalRange: 5.8
# Default creative interact range
creativeRange: 6.8
# Extra allowed reach distance per millisecond of ping
pingCompensation: 0.0045
# The multiplier of extra compensation for velocity
velocityMultiplier: 1.5
# BadPackets check settings
# Checks for illegal packets
badpackets:
# Should this check be enabled?
enabled: true
# Minimum server TPS needed for BadPackets to be active
minimumTps: 17.5
# Maximum distance a player can move between packets
maxDistance: 25.0
# MorePackets check settings
# Checks for an extra amount of packets and modified game timers
morepackets:
# Should this check be enabled?
enabled: true
# Minimum server TPS needed for MorePackets to be active
minimumTps: 17.5
# Maximum amount of lag compensation a player can acquire (50ms = 1 tick)
minimumClamp: 500
# The amount of milliseconds offset between packets before flagging (50ms = 1 tick)
triggerBalance: 100
# The amount of milliseconds to compensate for a teleport (50ms = 1 tick)
teleportCompensation: 150
# Should MorePackets be disabled for 'lagging' players?
# This can easily be spoofed by clients!
disableForLagging: false
# Maximum ping value before MorePackets stops checking a player (-1 to disable)
# This can easily be spoofed by clients!
maxPing: -1
# Sneak check settings
# Checks if the player toggles sneak too fast
sneak:
# Should this check be enabled?
enabled: true
# Should MorePackets be disabled for 'lagging' players?
# This can easily be spoofed by clients!
disableForLagging: false
# Minimum server TPS needed for sneak
minimumTps: 12
# Minimum time in milliseconds between sneak toggles
minToggleTime: 75
# NoSlow check settings
# Checks if the player moves too fast while blocking
noslow:
# Should this check be enabled?
enabled: true
# Minimum time difference in milliseconds between toggling use item state
minimumDifference: 75
# Minimum movement distance needed to flag
minimumDistXZ: 0.15
# Amount of no slowdown moments before flagging
vlBeforeFlag: 3
# Spider check settings
# Checks if the player tries to climb a non-climbable block
spider:
# Should this check be enabled?
enabled: true
# NoFall check settings
# Checks if the player tries to ignore fall damage
nofall:
# Should this check be enabled?
enabled: true
# Amount of moves with a modified fall distance before flagging
vlBeforeFlag: 6
# Sprint check settings
# Checks if the player tries to sprint without the needed conditions
sprint:
# Should this check be enabled?
enabled: true
# Minimum food level needed to sprint
sprintFoodMin: 6
# FastBow check settings
# Checks if the player fires a bow too fast
fastbow:
# Should this check be enabled?
enabled: true
# Maximum percent error between predicted bow force and actual bow force
bowError: 0.25
# FastEat check settings
# Checks if the player consumes food too fast
fasteat:
# Should this check be enabled?
enabled: true
# Minimum time in milliseconds it takes to consume food
eatTimeMin: 1000
# FastHeal check settings
# Checks if the player regains health too fast
fastheal:
# Should this check be enabled?
enabled: true
# Minimum server TPS needed for FastHeal to be active
minimumTps: 17.5
# Should FastHeal be disabled for 'lagging' players?
# This can easily be spoofed by clients!
disableForLagging: false
# The minimum time it takes to regenerate health in milliseconds
minHealTime: 495
# Amount of milliseconds a player can heal faster per millisecond of ping
pingCompensation: 0.15
# FastProjectile check settings
# Checks if the player fires a projectile too fast
fastprojectile:
# Should this check be enabled?
enabled: true
# Number of projectiles to wait for before checking how long they took to fire off
projectilesToWait: 10
# The minimum time in milliseconds it should have taken for the player fire 'projectilesToWait' projectiles
minimumTime: 1500
# ItemSpam check settings
# Checks if the player drops items too fast
itemspam:
# Should this check be enabled?
enabled: true
# The number of item drops we should wait before checking if the player has used item spam
dropsToWait: 10
# The minimum time in milliseconds it should have taken for the player to drop items 'dropsToWait' times
minimumTime: 800
# FastInventory check settings
# Checks if the player moves items in the inventory too fast
fastinventory:
# Should this check be enabled?
enabled: true
# The number of clicks we should wait before checking if the player has used fast inventory
clicksToWait: 10
# The minimum time in milliseconds it should have taken for the player to click 'clicksToWait' times
minimumTime: 50
# vClip check settings
# Checks if the player is clipping
vclip:
# Should this check be enabled?
enabled: true
# ChatUnicode check settings
# Checks for illegal unicode characters in the chat
chatunicode:
# Should this check be enabled?
enabled: true
# ChatSpam check settings
# Checks for a spam of chat messages
chatspam:
# Should this check be enabled?
enabled: true
# Minimum time between chats
timeMin: 500
# Time in milliseconds after which repeating yourself in chat is ignored
repeatIgnore: 600
# Number of chat spam violations before action one (see config.yml) is executed
levelActionOne: 5
# Number of chat spam violations before action two (see config.yml) is executed
levelActionTwo: 10
# CommandSpam check settings
# Checks for a spam of commands
commandspam:
# Should this check be enabled?
enabled: true
# Minimum time between commands
timeMin: 400
# Time in milliseconds after which repeating a command is ignored
repeatIgnore: 500
# Number of command spam violations before action one (see config.yml) is executed
levelActionOne: 5
# Number of command spam violations before action two (see config.yml) is executed
levelActionTwo: 10
Loaded 100 of 106 files, more files were not shown because too many files have changed in this diff. Show more