Compare commits

...
46 Commits
Author SHA1 Message Date
Rammelkast e5c8c5dc8a Prepare for release 2020-12-15 13:25:11 +01:00
Rammelkast 15c61fac67 Fixed WaterWalk false positive with carpets 2020-11-26 17:00:27 +01:00
Rammelkast 7e1f0d83ce Fix riptide false positives, improved performance 2020-11-25 19:08:55 +01:00
Rammelkast bd1db83a98 Fix #123, fix elytrafly false positive, fix flight false positive when falling, fix speed false positive with slabs, fixed strafe false positive with slabs, fixed TPS formatting issue, improved default config 2020-11-25 11:43:49 +01:00
Rammelkast 646e906ada Fix FastLadder false with elytra, fix speed & flight false positive with trident, fix #122 and fix #119, fix illegalinteract false positive with torches 2020-11-07 17:06:50 +01:00
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
49 changed files with 1992 additions and 966 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']
+10 -8
View File
@@ -1,4 +1,4 @@
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 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. 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.
@@ -14,7 +14,7 @@ Issues should be filed by hitting the [issues](https://github.com/Rammelkast/Ant
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;
* Your AntiCheatReloaded version * Your AntiCheatReloaded version
* Your server software (Bukkit/Spigot/Other) and it's version * Your server implementation (Craftbukkit/Spigot/Other) and it's version
* Your ProtocolLib version * Your ProtocolLib version
* Whether or not you are using protocol hacks (ViaVersion etc.) * Whether or not you are using protocol hacks (ViaVersion etc.)
* Any logs relating to the issue * Any logs relating to the issue
@@ -24,7 +24,6 @@ Hacks blocked
* Flight/Glide * Flight/Glide
* ElytraFly * ElytraFly
* WaterWalk/Jesus * WaterWalk/Jesus
* NoSwing
* FastBreak * FastBreak
* FastPlace * FastPlace
* Chat spam * Chat spam
@@ -38,14 +37,17 @@ Hacks blocked
* FastBow * FastBow
* FastEat * FastEat
* FastHeal * FastHeal
* KillAura (Aimbot) * KillAura
* Aimbot
* Reach * Reach
* Unicode chat * Unicode chat
* FastProjectile * FastProjectile
* ItemSpam * ItemSpam
* FastInventory * FastInventory
* MorePackets/Timer * Timer
* BadPackets * Blink
* Velocity/Anti-Knockback * Anti-Knockback
* IllegalInteract (Scaffold) * Scaffold
* FastLadder * FastLadder
* Strafe
* NoSlow
+6 -6
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.rammelkast.anticheatreloaded</groupId> <groupId>com.rammelkast.anticheatreloaded</groupId>
<artifactId>AntiCheatReloaded</artifactId> <artifactId>AntiCheatReloaded</artifactId>
<version>1.9.0-PRE</version> <version>1.9.6</version>
<name>AntiCheatReloaded</name> <name>AntiCheatReloaded</name>
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url> <url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
<properties> <properties>
@@ -22,7 +22,7 @@
<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.5</version> <version>3.8.1</version>
<configuration> <configuration>
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>
@@ -31,7 +31,7 @@
<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>3.1.1</version> <version>3.2.4</version>
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
@@ -44,7 +44,6 @@
<artifactSet> <artifactSet>
<includes> <includes>
<include>com.rammelkast.*</include> <include>com.rammelkast.*</include>
<include>com.cryptomorin.*</include>
</includes> </includes>
</artifactSet> </artifactSet>
</configuration> </configuration>
@@ -55,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>
@@ -70,6 +69,7 @@
<groupId>com.comphenix.protocol</groupId> <groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId> <artifactId>ProtocolLib</artifactId>
<version>4.6.0-SNAPSHOT</version> <version>4.6.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
@@ -80,7 +80,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version> <version>1.16.4-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@@ -101,8 +101,9 @@ public class AntiCheatReloaded extends JavaPlugin {
: (ChatColor.RED + "(NOT SUPPORTED!)"))); : (ChatColor.RED + "(NOT SUPPORTED!)")));
getLogger().info("Enabling packet listeners"); getLogger().info("Enabling packet listeners");
PacketListener.listenKeepAlivePackets();
PacketListener.listenMovementPackets(); PacketListener.listenMovementPackets();
PacketListener.listenKeepAlivePackets();
PacketListener.listenUseItemPackets();
updateManager = new UpdateManager(); updateManager = new UpdateManager();
@@ -164,6 +165,10 @@ public class AntiCheatReloaded extends JavaPlugin {
tps = (tps == 0.0D ? ticks : (tps + ticks) / 2.0D); tps = (tps == 0.0D ? ticks : (tps + ticks) / 2.0D);
ticks = 1; ticks = 1;
} }
// Check for updates every 12 hours
if (ticks % 864000 == 0)
updateManager.update();
} }
}.runTaskTimer(this, 40L, 1L); }.runTaskTimer(this, 40L, 1L);
} }
@@ -152,5 +152,4 @@ public class AntiCheatAPI {
return AntiCheatReloaded.getManager(); return AntiCheatReloaded.getManager();
} }
} }
@@ -18,10 +18,8 @@
*/ */
package com.rammelkast.anticheatreloaded.check; package com.rammelkast.anticheatreloaded.check;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@@ -29,6 +27,7 @@ import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerToggleSprintEvent; import org.bukkit.event.player.PlayerToggleSprintEvent;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@@ -40,6 +39,7 @@ import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck; import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck; import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck; import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
import com.rammelkast.anticheatreloaded.check.movement.NoSlowCheck;
import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck; import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck;
import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.providers.Checks; import com.rammelkast.anticheatreloaded.config.providers.Checks;
@@ -54,7 +54,6 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class Backend { public class Backend {
public Map<UUID, Long> velocitized = new HashMap<UUID, Long>(); public Map<UUID, Long> velocitized = new HashMap<UUID, Long>();
private Map<UUID, Long> levitatingEnd = new HashMap<UUID, Long>(); private Map<UUID, Long> levitatingEnd = new HashMap<UUID, Long>();
private List<UUID> isAscending = new ArrayList<UUID>();
private Map<UUID, Integer> chatLevel = new HashMap<UUID, Integer>(); private Map<UUID, Integer> chatLevel = new HashMap<UUID, Integer>();
private Map<UUID, Integer> commandLevel = new HashMap<UUID, Integer>(); private Map<UUID, Integer> commandLevel = new HashMap<UUID, Integer>();
private Map<UUID, Integer> nofallViolation = new HashMap<UUID, Integer>(); private Map<UUID, Integer> nofallViolation = new HashMap<UUID, Integer>();
@@ -120,7 +119,6 @@ public class Backend {
startEat.remove(uuid); startEat.remove(uuid);
lastHeal.remove(uuid); lastHeal.remove(uuid);
sprinted.remove(uuid); sprinted.remove(uuid);
isAscending.remove(uuid);
nofallViolation.remove(uuid); nofallViolation.remove(uuid);
blockBreakHolder.remove(uuid); blockBreakHolder.remove(uuid);
fastPlaceViolation.remove(uuid); fastPlaceViolation.remove(uuid);
@@ -153,7 +151,10 @@ public class Backend {
MorePacketsCheck.EXEMPT_TIMINGS.remove(uuid); MorePacketsCheck.EXEMPT_TIMINGS.remove(uuid);
ElytraCheck.JUMP_Y_VALUE.remove(uuid); ElytraCheck.JUMP_Y_VALUE.remove(uuid);
KillAuraCheck.ANGLE_FLAGS.remove(uuid); KillAuraCheck.ANGLE_FLAGS.remove(uuid);
KillAuraCheck.PACKETORDER_FLAGS.remove(uuid);
FlightCheck.MOVING_EXEMPT.remove(uuid); FlightCheck.MOVING_EXEMPT.remove(uuid);
NoSlowCheck.LAST_RELEASE.remove(uuid);
NoSlowCheck.VIOLATIONS.remove(uuid);
} }
public CheckResult checkFastBow(Player player, float force) { public CheckResult checkFastBow(Player player, float force) {
@@ -216,7 +217,8 @@ public class Backend {
public CheckResult checkSpider(Player player, double y) { public CheckResult checkSpider(Player player, double y) {
if (y <= 0.11761 && y >= 0.11759 && !Utilities.isClimbableBlock(player.getLocation().getBlock()) if (y <= 0.11761 && y >= 0.11759 && !Utilities.isClimbableBlock(player.getLocation().getBlock())
&& !Utilities.isClimbableBlock(player.getEyeLocation().getBlock()) && !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
&& !Utilities.isClimbableBlock(player.getLocation().clone().add(0, -0.98, 0).getBlock())) { && !Utilities.isClimbableBlock(player.getLocation().clone().add(0, -0.98, 0).getBlock())
&& !Utilities.isNearClimbable(player)) {
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED,
"tried to climb a non-climbable block (" + player.getLocation().getBlock().getType() + ")"); "tried to climb a non-climbable block (" + player.getLocation().getBlock().getType() + ")");
} else { } else {
@@ -229,7 +231,11 @@ public class Backend {
if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping() if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping()
&& !isMovingExempt(player) && !justPlaced(player) && !Utilities.isNearWater(player) && !isMovingExempt(player) && !justPlaced(player) && !Utilities.isNearWater(player)
&& !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR") && !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")
&& !VersionUtil.isSlowFalling(player)) { && !VersionUtil.isSlowFalling(player)
&& !Utilities
.isNearShulkerBox(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation())
&& !Utilities.isNearClimbable(player)
&& !Utilities.isNearWater(player.getLocation().clone().subtract(0, 1.5, 0))) {
if (player.getFallDistance() == 0) { if (player.getFallDistance() == 0) {
if (nofallViolation.get(uuid) == null) { if (nofallViolation.get(uuid) == null) {
nofallViolation.put(uuid, 1); nofallViolation.put(uuid, 1);
@@ -241,8 +247,8 @@ public class Backend {
int vlBeforeFlag = checksConfig.getInteger(CheckType.NOFALL, "vlBeforeFlag"); int vlBeforeFlag = checksConfig.getInteger(CheckType.NOFALL, "vlBeforeFlag");
if (i >= vlBeforeFlag) { if (i >= vlBeforeFlag) {
nofallViolation.put(player.getUniqueId(), 1); nofallViolation.put(player.getUniqueId(), 1);
return new CheckResult(CheckResult.Result.FAILED, "tried to avoid fall damage (fall distance = 0 " return new CheckResult(CheckResult.Result.FAILED,
+ i + " times in a row, max=" + vlBeforeFlag + ")"); "tried to avoid fall damage (" + i + " times in a row, max=" + vlBeforeFlag + ")");
} else { } else {
return PASS; return PASS;
} }
@@ -304,15 +310,6 @@ public class Backend {
return PASS; return PASS;
} }
public void logAscension(Player player, double y1, double y2) {
UUID name = player.getUniqueId();
if (y1 < y2 && !isAscending.contains(name)) {
isAscending.add(name);
} else {
isAscending.remove(name);
}
}
public CheckResult checkFastPlace(Player player) { public CheckResult checkFastPlace(Player player) {
int vlBeforeFlagSurvival = checksConfig.getInteger(CheckType.FAST_PLACE, "vlBeforeFlagSurvival"); int vlBeforeFlagSurvival = checksConfig.getInteger(CheckType.FAST_PLACE, "vlBeforeFlagSurvival");
int vlBeforeFlagCreative = checksConfig.getInteger(CheckType.FAST_PLACE, "vlBeforeFlagCreative"); int vlBeforeFlagCreative = checksConfig.getInteger(CheckType.FAST_PLACE, "vlBeforeFlagCreative");
@@ -613,10 +610,6 @@ public class Backend {
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId()); ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
} }
public void logExitFly(final Player player) {
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.EXIT_FLY_TIME());
}
public void logBoatCollision(final Player player) { public void logBoatCollision(final Player player) {
// TODO config?? // TODO config??
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + 100 /* 2 ticks */); FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + 100 /* 2 ticks */);
@@ -631,10 +624,6 @@ public class Backend {
return isDoing(player, FlightCheck.MOVING_EXEMPT, -1); return isDoing(player, FlightCheck.MOVING_EXEMPT, -1);
} }
public boolean isAscending(Player player) {
return isAscending.contains(player.getUniqueId());
}
public boolean isDoing(Player player, Map<UUID, Long> map, double max) { public boolean isDoing(Player player, Map<UUID, Long> map, double max) {
if (map.containsKey(player.getUniqueId())) { if (map.containsKey(player.getUniqueId())) {
if (max != -1) { if (max != -1) {
@@ -26,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;
@@ -34,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;
@@ -47,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;
} }
@@ -62,7 +62,10 @@ public enum CheckType {
CHAT_UNICODE(Permission.CHECK_UNICODE, "ChatUnicode"), CHAT_UNICODE(Permission.CHECK_UNICODE, "ChatUnicode"),
ILLEGAL_INTERACT(Permission.CHECK_ILLEGALINTERACT, "IllegalInteract"), ILLEGAL_INTERACT(Permission.CHECK_ILLEGALINTERACT, "IllegalInteract"),
FASTLADDER(Permission.CHECK_FASTLADDER, "FastLadder"), FASTLADDER(Permission.CHECK_FASTLADDER, "FastLadder"),
AIMBOT(Permission.CHECK_AIMBOT, "Aimbot"); AIMBOT(Permission.CHECK_AIMBOT, "Aimbot"),
STRAFE(Permission.CHECK_STRAFE, "Strafe"),
NOSLOW(Permission.CHECK_NOSLOW, "NoSlow"),
BOATFLY(Permission.CHECK_BOATFLY, "BoatFly");
private final Permission permission; private final Permission permission;
private final String displayName; private final String displayName;
@@ -41,7 +41,7 @@ public class CriticalsCheck {
event.setCancelled(true); event.setCancelled(true);
EventListener.log(new CheckResult(CheckResult.Result.FAILED, "tried to do a critical without needed conditions") EventListener.log(new CheckResult(CheckResult.Result.FAILED, "tried to do a critical without needed conditions")
.getMessage(), .getMessage(),
player, CheckType.CRITICALS); player, CheckType.CRITICALS, null);
} }
} }
} }
@@ -22,6 +22,7 @@ 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.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@@ -32,7 +33,9 @@ import org.bukkit.util.Vector;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
import com.rammelkast.anticheatreloaded.config.providers.Checks; import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.util.MovementManager;
import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.Utilities;
@@ -40,6 +43,8 @@ public class KillAuraCheck {
// Angle check // Angle check
public static final Map<UUID, Integer> ANGLE_FLAGS = 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); private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static CheckResult checkReach(Player player, Entity target) { public static CheckResult checkReach(Player player, Entity target) {
@@ -55,6 +60,8 @@ public class KillAuraCheck {
double allowedReach = target.getVelocity().length() < 0.08 double allowedReach = target.getVelocity().length() < 0.08
? checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.normal") ? checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.normal")
: checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.velocitized"); : checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.velocitized");
if (player.getGameMode() == GameMode.CREATIVE)
allowedReach += 1.5D;
// Lag compensation // Lag compensation
double lagExtraReach = checksConfig.getDouble(CheckType.KILLAURA, "reach", "lagCompensation.lagExtraReach"); double lagExtraReach = checksConfig.getDouble(CheckType.KILLAURA, "reach", "lagCompensation.lagExtraReach");
double pingCompensation = checksConfig.getDouble(CheckType.KILLAURA, "reach", double pingCompensation = checksConfig.getDouble(CheckType.KILLAURA, "reach",
@@ -74,7 +81,7 @@ public class KillAuraCheck {
double reachedDistance = ((LivingEntity) target).getLocation().toVector() double reachedDistance = ((LivingEntity) target).getLocation().toVector()
.distance(player.getLocation().toVector()); .distance(player.getLocation().toVector());
if (reachedDistance > allowedReach) if (reachedDistance > allowedReach)
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED, "Reach",
"reached too far (distance=" + Utilities.roundDouble(reachedDistance, 6) + ", max=" + Utilities.roundDouble(allowedReach, 6) + ")"); "reached too far (distance=" + Utilities.roundDouble(reachedDistance, 6) + ", max=" + Utilities.roundDouble(allowedReach, 6) + ")");
return PASS; return PASS;
} }
@@ -107,7 +114,7 @@ public class KillAuraCheck {
int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "angle", "vlBeforeFlag"); int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "angle", "vlBeforeFlag");
if (flags >= vlBeforeFlag) { if (flags >= vlBeforeFlag) {
ANGLE_FLAGS.remove(uuid); ANGLE_FLAGS.remove(uuid);
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED, "Angle",
"tried to attack from an illegal angle (angle=" + Math.round(angleDifference) + ")"); "tried to attack from an illegal angle (angle=" + Math.round(angleDifference) + ")");
} }
@@ -118,6 +125,39 @@ public class KillAuraCheck {
return PASS; return PASS;
} }
public static CheckResult checkPacketOrder(Player player, Entity entity) {
UUID uuid = player.getUniqueId();
User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
MovementManager movementManager = user.getMovementManager();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
// Check if enabled
if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "packetOrder"))
return PASS;
if (user.isLagging() || (System.currentTimeMillis() - movementManager.lastTeleport) <= 100
|| AntiCheatReloaded.getPlugin().getTPS() < checksConfig.getDouble(CheckType.KILLAURA, "packetOrder", "minimumTps"))
return PASS;
long elapsed = System.currentTimeMillis() - movementManager.lastUpdate;
if (elapsed < checksConfig.getInteger(CheckType.KILLAURA, "packetOrder", "minElapsedTime")) {
if (!PACKETORDER_FLAGS.containsKey(uuid)) {
PACKETORDER_FLAGS.put(uuid, 1);
return PASS;
}
int flags = PACKETORDER_FLAGS.get(uuid);
int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "packetOrder", "vlBeforeFlag");
if (flags >= vlBeforeFlag) {
PACKETORDER_FLAGS.remove(uuid);
return new CheckResult(Result.FAILED, "PacketOrder", "suspicious packet order (elapsed=" + elapsed + ")");
}
PACKETORDER_FLAGS.put(uuid, flags + 1);
}
return PASS;
}
public static double calculateYawDifference(Location from, Location to) { public static double calculateYawDifference(Location from, Location to) {
Location clonedFrom = from.clone(); Location clonedFrom = from.clone();
Vector startVector = clonedFrom.toVector(); Vector startVector = clonedFrom.toVector();
@@ -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;
}
}
@@ -30,6 +30,7 @@ import org.bukkit.potion.PotionEffectType;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Distance; import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class ElytraCheck { public class ElytraCheck {
@@ -38,10 +39,9 @@ public class ElytraCheck {
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static CheckResult runCheck(Player player, Distance distance) { public static CheckResult runCheck(Player player, Distance distance) {
// No elytra in server version // No elytra in server version or not relevant
if (VersionUtil.isBountifulUpdate()) { if (VersionUtil.isBountifulUpdate() || Utilities.isNearWater(player))
return PASS; return PASS;
}
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()) { if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()) {
@@ -71,9 +71,11 @@ public class ElytraCheck {
} }
if (!JUMP_Y_VALUE.containsKey(uuid)) { if (!JUMP_Y_VALUE.containsKey(uuid)) {
JUMP_Y_VALUE.put(uuid, distance.toY()); // Distance + player height
JUMP_Y_VALUE.put(uuid, distance.toY() + 1.8D);
return PASS; return PASS;
} }
double lastY = JUMP_Y_VALUE.get(uuid); double lastY = JUMP_Y_VALUE.get(uuid);
if (lastY < distance.toY()) { if (lastY < distance.toY()) {
double diff = distance.toY() - lastY; double diff = distance.toY() - lastY;
@@ -16,7 +16,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.rammelkast.anticheatreloaded.check.movement; package com.rammelkast.anticheatreloaded.check.movement;
import java.util.HashMap; import java.util.HashMap;
@@ -31,6 +30,7 @@ import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.providers.Checks; import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class FastLadderCheck { public class FastLadderCheck {
@@ -38,11 +38,11 @@ public class FastLadderCheck {
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static CheckResult runCheck(Player player, double y) { public static CheckResult runCheck(Player player, double y) {
// Only check if fully on ladder // Only check if fully on ladder and not flying
// Liquids are climbable blocks, so we have to add a seperate check // Liquids are climbable blocks, so we have to add a seperate check
if (!Utilities.isClimbableBlock(player.getLocation().getBlock()) if (!Utilities.isClimbableBlock(player.getLocation().getBlock())
|| !Utilities.isClimbableBlock(player.getEyeLocation().getBlock()) || !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
|| player.getLocation().getBlock().isLiquid()) { || player.getLocation().getBlock().isLiquid() || VersionUtil.isFlying(player)) {
return PASS; return PASS;
} }
@@ -22,6 +22,7 @@ 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 org.bukkit.potion.PotionEffectType;
@@ -49,8 +50,10 @@ public class FlightCheck {
public static CheckResult runCheck(Player player, Distance distance) { public static CheckResult runCheck(Player player, Distance distance) {
if (distance.getYDifference() >= AntiCheatReloaded.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/using elytra, 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;
} }
@@ -60,23 +63,20 @@ public class FlightCheck {
Backend backend = AntiCheatReloaded.getManager().getBackend(); Backend backend = AntiCheatReloaded.getManager().getBackend();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
if (movementManager.nearLiquidTicks > 0 || movementManager.halfMovement if (movementManager.nearLiquidTicks > 0 || movementManager.halfMovement || Utilities.isNearClimbable(player)
|| Utilities.isClimbableBlock(distance.getFrom().getBlock()) || movementManager.riptideTicks > 0)
|| Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN))
|| Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.UP)))
return PASS; return PASS;
int minAirTicks = 13; int minAirTicks = 13;
if (player.hasPotionEffect(PotionEffectType.JUMP)) { if (player.hasPotionEffect(PotionEffectType.JUMP))
minAirTicks += player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() * 3; minAirTicks += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 3;
}
if (movementManager.halfMovementHistoryCounter > 25) if (movementManager.halfMovementHistoryCounter > 25)
minAirTicks += 5; minAirTicks += 5;
// Start AirFlight // Start AirFlight
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airFlight") && movementManager.airTicks > minAirTicks if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airFlight") && movementManager.airTicks > minAirTicks
&& !backend.justVelocity(player)) { && !backend.justVelocity(player) && movementManager.elytraEffectTicks <= 25) {
// Config default base is 1200ms // Config default base is 1200ms
// Ping clamped to max. 1000 to prevent spoofing for an advantage // Ping clamped to max. 1000 to prevent spoofing for an advantage
int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight", int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
@@ -90,52 +90,74 @@ public class FlightCheck {
? AntiCheatReloaded.getManager().getBackend().placedBlock.get(player.getUniqueId()) ? AntiCheatReloaded.getManager().getBackend().placedBlock.get(player.getUniqueId())
: (blockPlaceAccountingTime + 1); : (blockPlaceAccountingTime + 1);
double maxMotionY = System.currentTimeMillis() - lastPlacedBlock > blockPlaceAccountingTime ? 0 : 0.42; double maxMotionY = System.currentTimeMillis() - lastPlacedBlock > blockPlaceAccountingTime ? 0 : 0.42;
if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0) // Fixes snow false positive
return new CheckResult(CheckResult.Result.FAILED, if (movementManager.motionY < 0.004 && Utilities
.isNearHalfblock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN).getLocation()))
maxMotionY += 0.004D;
if (Utilities.isNearWater(player) || Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0)))
maxMotionY += 0.05;
if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0
&& !Utilities.isNearClimbable(distance.getTo().clone().subtract(0, 1.25, 0))
&& !Utilities.isNearClimbable(distance.getTo().clone().subtract(0, 0.75, 0))
&& (!Utilities.isNearWater(distance.getTo().clone().subtract(0, 1.5, 0))
&& distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR))
return new CheckResult(CheckResult.Result.FAILED, "AirFlight",
"tried to fly on the Y-axis (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")"); "tried to fly on the Y-axis (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")");
if (Math.abs(movementManager.motionY - movementManager.lastMotionY) < 0.01 if (Math.abs(movementManager.motionY
- movementManager.lastMotionY) < (movementManager.airTicks >= 115 ? 1E-3 : 5E-3)
&& !Utilities.couldBeOnBoat(player) && !Utilities.couldBeOnBoat(player)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports")) .getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports"))
&& !VersionUtil.isSlowFalling(player) && !Utilities.isInWeb(player)) && !VersionUtil.isSlowFalling(player) && !Utilities.isNearWeb(player)
return new CheckResult(CheckResult.Result.FAILED, "had too little Y dropoff (diff=" && movementManager.elytraEffectTicks <= 25
&& !Utilities.isNearClimbable(distance.getFrom().clone().subtract(0, 0.51D, 0))
&& !Utilities.isNearWater(player)
&& !Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0)))
return new CheckResult(CheckResult.Result.FAILED, "AirFlight", "had too little Y dropoff (diff="
+ Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")"); + Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")");
} }
// End AirFlight // End AirFlight
// Start AirClimb // Start AirClimb
// TODO two hardcoded values here shouldn't be there, temp against false // TODO three hardcoded values here shouldn't be there, temp against false
// positive // positive
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.lastMotionY > 0 if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.lastMotionY > 0
&& movementManager.motionY > 0 && movementManager.airTicks == 2 && movementManager.motionY > 0 && movementManager.airTicks == 2
&& Math.round(movementManager.lastMotionY * 1000) != 420 && Math.round(movementManager.lastMotionY * 1000) != 420
&& Math.round(movementManager.motionY * 1000) != 248
&& !(Math.round(movementManager.motionY * 1000) == 333 && !(Math.round(movementManager.motionY * 1000) == 333
&& Math.round(movementManager.lastMotionY * 1000) != 333) && Math.round(movementManager.lastMotionY * 1000) != 333)
&& !AntiCheatReloaded.getManager().getBackend().justVelocity(player) && !AntiCheatReloaded.getManager().getBackend().justVelocity(player)
&& !player.hasPotionEffect(PotionEffectType.JUMP) && !player.hasPotionEffect(PotionEffectType.JUMP)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports")) .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
&& (!Utilities.isNearBed(distance.getTo()) && (!Utilities.isNearBed(distance.getTo()) || ((Utilities.isNearBed(distance.getTo())
|| (Utilities.isNearBed(distance.getTo()) && movementManager.motionY > 0.12675))) || Utilities.isNearBed(distance.getTo().clone().add(0, -0.51, 0)))
return new CheckResult(CheckResult.Result.FAILED, && movementManager.motionY > 0.15))
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25)
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
"tried to climb air (mY=" + movementManager.motionY + ")"); "tried to climb air (mY=" + movementManager.motionY + ")");
// TODO hardcoded value against false again..
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.motionY > 0.42 if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.motionY > 0.42
&& movementManager.airTicks > 2 && !AntiCheatReloaded.getManager().getBackend().justVelocity(player) && movementManager.airTicks > 2 && !AntiCheatReloaded.getManager().getBackend().justVelocity(player)
&& !player.hasPotionEffect(PotionEffectType.JUMP) && !player.hasPotionEffect(PotionEffectType.JUMP)
&& !(Math.round(movementManager.motionY * 1000) == 425 && movementManager.airTicks == 11)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))) .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
return new CheckResult(CheckResult.Result.FAILED, && movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25) {
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")"); "tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
}
// End AirClimb // End AirClimb
// Start GroundFlight // Start GroundFlight
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "groundFlight") && movementManager.onGround if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "groundFlight") && movementManager.onGround
&& Utilities.cantStandAt(distance.getTo().getBlock().getRelative(BlockFace.DOWN)) && Utilities.cantStandAt(distance.getTo().getBlock().getRelative(BlockFace.DOWN))
&& Utilities.cantStandAt(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)) && Utilities.cantStandAt(distance.getFrom().getBlock().getRelative(BlockFace.DOWN))
&& movementManager.groundTicks > 2) { && Utilities.cantStandAt(distance.getTo().getBlock())) {
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED, "GroundFlight",
"faked ground to fly (mY=" + movementManager.motionY + ", gt=" + movementManager.groundTicks + ")"); "faked ground to fly (mY=" + movementManager.motionY + ", gt=" + movementManager.groundTicks + ")");
} }
// End GroundFlight // End GroundFlight
@@ -145,17 +167,25 @@ public class FlightCheck {
&& movementManager.motionY < 0 && !backend.justVelocity(player) && movementManager.motionY < 0 && !backend.justVelocity(player)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports")) .getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports"))
&& !Utilities.isInWeb(player)) { && !Utilities.isNearWeb(player) && movementManager.elytraEffectTicks <= 25
&& !VersionUtil.isSlowFalling(player)) {
double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION; double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION;
double offset = Math.abs(gravitatedY - movementManager.motionY); double offset = Math.abs(gravitatedY - movementManager.motionY);
double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset"); double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset");
if (Utilities.isNearClimbable(distance.getFrom().clone().subtract(0, 0.51D, 0))
|| Utilities.isNearClimbable(distance.getFrom()) || Utilities.isNearWater(player)
|| (!Utilities.isNearWater(distance.getTo().clone().subtract(0, 1.5, 0))
&& distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR))
maxOffset += 0.15D;
if (offset > maxOffset && movementManager.airTicks > 2) { if (offset > maxOffset && movementManager.airTicks > 2) {
int vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0) + 1; int vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0) + 1;
GRAVITY_VIOLATIONS.put(player.getUniqueId(), vl); GRAVITY_VIOLATIONS.put(player.getUniqueId(), vl);
int vlBeforeFlag = checksConfig.getInteger(CheckType.FLIGHT, "gravity", "vlBeforeFlag"); int vlBeforeFlag = checksConfig.getInteger(CheckType.FLIGHT, "gravity", "vlBeforeFlag");
if (vl >= vlBeforeFlag) if (vl >= vlBeforeFlag) {
return new CheckResult(CheckResult.Result.FAILED, GRAVITY_VIOLATIONS.put(player.getUniqueId(), Math.max(0, vl - 2));
return new CheckResult(CheckResult.Result.FAILED, "Gravity",
"ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")"); "ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")");
}
} else { } else {
GRAVITY_VIOLATIONS.remove(player.getUniqueId()); GRAVITY_VIOLATIONS.remove(player.getUniqueId());
} }
@@ -165,31 +195,4 @@ public class FlightCheck {
return PASS; return PASS;
} }
public static boolean isMovingExempt(Player player) {
return isDoing(player, MOVING_EXEMPT, -1) || player.isInsideVehicle();
}
private static boolean isDoing(Player player, Map<UUID, Long> map, double max) {
if (map.containsKey(player.getUniqueId())) {
if (max != -1) {
if (((System.currentTimeMillis() - map.get(player.getUniqueId())) / 1000) > max) {
map.remove(player.getUniqueId());
return false;
} else {
return true;
}
} else {
// Termination time has already been calculated
if (map.get(player.getUniqueId()) < System.currentTimeMillis()) {
map.remove(player.getUniqueId());
return false;
} else {
return true;
}
}
} else {
return false;
}
}
} }
@@ -0,0 +1,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());
}
});
}
}
@@ -34,9 +34,7 @@ import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.VersionUtil;
/** /**
* @author Rammelkast * @author Rammelkast TODO soulsand speed TODO buffer system
* TODO soulsand speed
* TODO fix false positive with water weeds
*/ */
public class SpeedCheck { public class SpeedCheck {
@@ -53,14 +51,21 @@ public class SpeedCheck {
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()) MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
.getMovementManager(); .getMovementManager();
// Riptiding exemption
if (movementManager.riptideTicks > 0)
return PASS;
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
double distanceXZ = movementManager.distanceXZ; double distanceXZ = movementManager.distanceXZ;
boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid; boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid;
// AirSpeed // AirSpeed
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airSpeed") && movementManager.airTicks > 1 && movementManager.elytraEffectTicks <= 0) { if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airSpeed") && movementManager.airTicks > 1
&& movementManager.elytraEffectTicks <= 0 && !Utilities.isNearClimbable(player)) {
double multiplier = 0.985D; double multiplier = 0.985D;
double predict = 0.36 * Math.pow(multiplier, movementManager.airTicks + 1); double predict = 0.36 * Math.pow(multiplier, movementManager.airTicks + 1);
// Prevents false when falling from great heights
if (movementManager.airTicks >= 115)
predict = Math.max(0.08, predict);
double limit = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "baseLimit"); // Default 0.03125 double limit = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "baseLimit"); // Default 0.03125
// Adjust for ice // Adjust for ice
if (movementManager.iceInfluenceTicks > 0) { if (movementManager.iceInfluenceTicks > 0) {
@@ -71,12 +76,12 @@ public class SpeedCheck {
if (boxedIn) if (boxedIn)
iceIncrement += 0.45D; iceIncrement += 0.45D;
if (!Utilities.couldBeOnIce(movingTowards)) if (!Utilities.couldBeOnIce(movingTowards))
iceIncrement *= 2.5D; iceIncrement *= 2.5D;
predict += iceIncrement; predict += iceIncrement;
} }
// Leniency when boxed in // Leniency when boxed in
if (boxedIn && movementManager.airTicks < 3) if (boxedIn && movementManager.airTicks < 3)
limit *= 1.2D; predict *= 1.2D;
// Adjust for slime // Adjust for slime
if (movementManager.slimeInfluenceTicks > 0) { if (movementManager.slimeInfluenceTicks > 0) {
double slimeIncrement = 0.022 * Math.pow(1.0375, movementManager.slimeInfluenceTicks); double slimeIncrement = 0.022 * Math.pow(1.0375, movementManager.slimeInfluenceTicks);
@@ -86,13 +91,16 @@ public class SpeedCheck {
predict += slimeIncrement; predict += slimeIncrement;
} }
// Adjust for speed effects // Adjust for speed effects
if (player.hasPotionEffect(PotionEffectType.SPEED)) if (movementManager.hasSpeedEffect)
predict += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.05D; predict += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect)
limit *= 1.2D;
// Adjust for jump boost effects // Adjust for jump boost effects
if (player.hasPotionEffect(PotionEffectType.JUMP)) if (player.hasPotionEffect(PotionEffectType.JUMP))
predict += (player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() + 1) * 0.05D; predict += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.05D;
// Adjust for custom walking speed // Adjust for custom walking speed
double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "walkSpeedMultiplier"); // Default 1.4 double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "walkSpeedMultiplier"); // Default
// 1.4
predict += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1); predict += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1);
// Slabs sometimes allow for a slight boost after jump // Slabs sometimes allow for a slight boost after jump
if (movementManager.halfMovementHistoryCounter > 0) if (movementManager.halfMovementHistoryCounter > 0)
@@ -100,28 +108,33 @@ public class SpeedCheck {
if (Utilities.couldBeOnHalfblock(movingTowards) && movementManager.halfMovementHistoryCounter == 0) if (Utilities.couldBeOnHalfblock(movingTowards) && movementManager.halfMovementHistoryCounter == 0)
predict *= 1.25D; predict *= 1.25D;
// Boats sometimes give a false positive // Boats sometimes give a false positive
if (Utilities.couldBeOnBoat(player, 0.5)) if (Utilities.couldBeOnBoat(player, 0.5, true))
predict *= 1.25D; predict *= 1.25D;
// Strafing in air when nearing terminal velocity gives false positives // 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 // This fixes the issue but gives hackers some leniency which means we need
// another check for this
double deltaMotionY = movementManager.motionY - movementManager.lastMotionY; double deltaMotionY = movementManager.motionY - movementManager.lastMotionY;
if (deltaMotionY < 0 && deltaMotionY >= -0.06) if ((deltaMotionY < 0 && deltaMotionY >= -0.08) || movementManager.airTicks >= 40
predict *= 1.5D; && (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 // Players can move faster in air with slow falling
if (VersionUtil.isSlowFalling(player)) if (VersionUtil.isSlowFalling(player))
predict *= 1.25D; predict *= 1.25D;
// Prevent NoSlow // Prevent NoSlow
// TODO better way for this if (movementManager.blockingTicks > 3 && movementManager.airTicks > 2)
if (player.isBlocking() && movementManager.airTicks > 2)
predict *= 0.8D; predict *= 0.8D;
if (movementManager.blockingTicks > 10 && movementManager.airTicks > 2)
predict *= 0.5D;
// Fixes false positive when coming out of water // Fixes false positive when coming out of water
if (movementManager.nearLiquidTicks >= 7 && movementManager.airTicks >= 14 if (movementManager.nearLiquidTicks >= 7 && movementManager.airTicks >= 14
&& movementManager.motionY < -0.18 && movementManager.motionY > -0.182) && movementManager.motionY < -0.18 && movementManager.motionY > -0.182)
predict += Math.abs(movementManager.motionY); predict += Math.abs(movementManager.motionY);
if (distanceXZ - predict > limit) { if (distanceXZ - predict > limit) {
return new CheckResult(CheckResult.Result.FAILED, "moved too fast in air (speed=" + distanceXZ return new CheckResult(CheckResult.Result.FAILED, "AirSpeed",
+ ", limit=" + predict + ", block=" + player.isBlocking() + ", box=" + boxedIn + ", at=" + movementManager.airTicks + ")"); "moved too fast in air (speed=" + distanceXZ + ", limit=" + predict + ", block="
+ movementManager.blockingTicks + ", box=" + boxedIn + ", at="
+ movementManager.airTicks + ")");
} }
} }
@@ -134,21 +147,22 @@ public class SpeedCheck {
double limit = checksConfig.getDouble(CheckType.SPEED, "airAcceleration", "baseLimit"); // Default 0.3725 double limit = checksConfig.getDouble(CheckType.SPEED, "airAcceleration", "baseLimit"); // Default 0.3725
// Slight increase when boxed in // Slight increase when boxed in
if (boxedIn) if (boxedIn)
limit *= 1.05D; limit *= 1.08D;
// Adjust for speed effects // Adjust for speed effects
if (player.hasPotionEffect(PotionEffectType.SPEED)) if (player.hasPotionEffect(PotionEffectType.SPEED))
limit += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.0225D; limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.0225D;
// Adjust for slabs // Adjust for slabs
if (movementManager.halfMovementHistoryCounter > 15) if (movementManager.halfMovementHistoryCounter > 15)
limit *= 2.0D; limit *= 2.05D;
// Adjust for custom walking speed // Adjust for custom walking speed
double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airAcceleration", "walkSpeedMultiplier"); // Default 1.4 double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airAcceleration",
"walkSpeedMultiplier"); // Default 1.4
limit += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1); limit += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1);
// Boats sometimes give a false positive // Boats sometimes give a false positive
if (Utilities.couldBeOnBoat(player)) if (Utilities.couldBeOnBoat(player))
limit *= 1.25D; limit *= 1.25D;
if (initialAcceleration > limit) { if (initialAcceleration > limit) {
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED, "AirAcceleration",
"exceeded acceleration limits (acceleration=" + initialAcceleration + ", max=" + limit + ")"); "exceeded acceleration limits (acceleration=" + initialAcceleration + ", max=" + limit + ")");
} }
} }
@@ -156,19 +170,24 @@ public class SpeedCheck {
// JumpBehaviour // JumpBehaviour
// Works against YPorts and mini jumps // Works against YPorts and mini jumps
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "jumpBehaviour") && movementManager.touchedGroundThisTick if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "jumpBehaviour") && movementManager.touchedGroundThisTick
&& !boxedIn && movementManager.slimeInfluenceTicks <= 10) { && !boxedIn && movementManager.slimeInfluenceTicks <= 10 && !Utilities.isNearHalfblock(movingTowards)
&& !Utilities.isNearHalfblock(movingTowards.clone().subtract(0, 0.51, 0))) {
// This happens naturally // This happens naturally
if (movementManager.airTicksBeforeGrounded == movementManager.groundTicks) { if (movementManager.airTicksBeforeGrounded == movementManager.groundTicks) {
double minimumDistXZ = checksConfig.getDouble(CheckType.SPEED, "jumpBehaviour", "minimumDistXZ"); // Default 0.42 double minimumDistXZ = checksConfig.getDouble(CheckType.SPEED, "jumpBehaviour", "minimumDistXZ"); // Default
if (distanceXZ >= minimumDistXZ) {
return new CheckResult(CheckResult.Result.FAILED, "had unexpected jumping behaviour"); 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 // GroundSpeed
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "groundSpeed") && movementManager.groundTicks > 1) { if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "groundSpeed") && movementManager.groundTicks > 1) {
double initialLimit = checksConfig.getDouble(CheckType.SPEED, "groundSpeed", "initialLimit"); // Default 0.34 double initialLimit = checksConfig.getDouble(CheckType.SPEED, "groundSpeed", "initialLimit"); // Default
// 0.34
double limit = initialLimit - 0.0055 * Math.min(9, movementManager.groundTicks); double limit = initialLimit - 0.0055 * Math.min(9, movementManager.groundTicks);
// Leniency when moving back on ground // Leniency when moving back on ground
if (movementManager.groundTicks < 5) if (movementManager.groundTicks < 5)
@@ -183,8 +202,17 @@ public class SpeedCheck {
if (boxedIn) if (boxedIn)
limit *= 1.1D; limit *= 1.1D;
// Adjust for speed effects // Adjust for speed effects
if (player.hasPotionEffect(PotionEffectType.SPEED)) if (movementManager.hasSpeedEffect)
limit += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.06D; 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;
// Other speed increasing effects (idk why, bloody Bukkt..)
if (movementManager.hasIncreasingEffect && movementManager.groundTicks > 3)
limit *= 1.12D;
if (movementManager.hadIncreasingEffect && !movementManager.hasIncreasingEffect)
limit *= 1.08D;
if (movementManager.iceInfluenceTicks >= 50) { if (movementManager.iceInfluenceTicks >= 50) {
// When moving off ice // When moving off ice
if (!Utilities.couldBeOnIce(movingTowards)) if (!Utilities.couldBeOnIce(movingTowards))
@@ -219,8 +247,9 @@ public class SpeedCheck {
limit *= 0.68D; limit *= 0.68D;
if (distanceXZ - limit > 0) { if (distanceXZ - limit > 0) {
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED, "GroundSpeed",
"moved too fast on ground (speed=" + distanceXZ + ", limit=" + limit + ", blocking=" + player.isBlocking() + ")"); "moved too fast on ground (speed=" + distanceXZ + ", limit=" + limit + ", blocking="
+ player.isBlocking() + ", gt=" + movementManager.groundTicks + ")");
} }
} }
@@ -229,40 +258,45 @@ public class SpeedCheck {
public static CheckResult checkVerticalSpeed(Player player, Distance distance) { public static CheckResult checkVerticalSpeed(Player player, Distance distance) {
Backend backend = AntiCheatReloaded.getManager().getBackend(); Backend backend = AntiCheatReloaded.getManager().getBackend();
if (isSpeedExempt(player, backend) || player.getVehicle() != null || player.isSleeping()
|| Utilities.isNearWater(player))
return PASS;
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()) MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
.getMovementManager(); .getMovementManager();
// Riptiding exemption
if (movementManager.riptideTicks > 0)
return PASS;
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
if (!checksConfig.isSubcheckEnabled(CheckType.SPEED, "verticalSpeed")) if (!checksConfig.isSubcheckEnabled(CheckType.SPEED, "verticalSpeed"))
return PASS; return PASS;
if (player.isInsideVehicle() || player.isSleeping()
|| backend.isDoing(player, backend.velocitized, backend.getMagic().VELOCITY_EXTENSION()) || VersionUtil.isFlying(player)
|| VersionUtil.isRiptiding(player) || Utilities.isNearWater(player)) {
return PASS;
}
double maxMotionY = getMaxAcceptableMotionY(player, Utilities.isNearBed(distance.getTo()), double maxMotionY = getMaxAcceptableMotionY(player, Utilities.isNearBed(distance.getTo()),
Utilities.couldBeOnBoat(player), Utilities.isClimbableBlock(distance.getFrom().getBlock()) Utilities.couldBeOnBoat(player),
|| Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)), movementManager.halfMovement, checksConfig); Utilities.isClimbableBlock(distance.getFrom().getBlock())
|| Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)),
movementManager.halfMovement, checksConfig);
// Fix false positive with soulsand boost // Fix false positive with soulsand boost
if (movementManager.nearLiquidTicks > 6) if (movementManager.nearLiquidTicks > 6)
maxMotionY *= 1.0525D; maxMotionY *= 1.0525D;
if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0) { if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0) {
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED, "VerticalSpeed",
"exceeded vertical speed limit (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")"); "exceeded vertical speed limit (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")");
} }
return PASS; return PASS;
} }
private static double getMaxAcceptableMotionY(Player player, boolean nearBed, boolean couldBeOnBoat, boolean fromClimbable, boolean halfMovement, Checks checksConfig) { private static double getMaxAcceptableMotionY(Player player, boolean nearBed, boolean couldBeOnBoat,
boolean fromClimbable, boolean halfMovement, Checks checksConfig) {
// TODO config for these values // TODO config for these values
// TODO something funky vanilla stuff going on with 0.42, like 0.445.., check this.. // TODO something funky vanilla stuff going on with 0.42, like 0.445.., check
double base = couldBeOnBoat ? 0.600000025 : (nearBed ? 0.5625 : (halfMovement ? 0.6 : 0.42)); // this..
double base = couldBeOnBoat ? 0.600000025
: (nearBed ? 0.5625 : ((halfMovement || VersionUtil.isBountifulUpdate()) ? 0.6 : 0.42));
if (fromClimbable) if (fromClimbable)
base += checksConfig.getDouble(CheckType.SPEED, "verticalSpeed", "climbableCompensation"); // Default 0.04 base += checksConfig.getDouble(CheckType.SPEED, "verticalSpeed", "climbableCompensation"); // Default 0.04
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
base += player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() * 0.2D; if (player.hasPotionEffect(PotionEffectType.JUMP))
} base += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.2D;
return base; 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)) || Utilities.isNearHalfblock(to))
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;
}
}
@@ -32,6 +32,7 @@ import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.util.MovementManager; import com.rammelkast.anticheatreloaded.util.MovementManager;
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;
public class WaterWalkCheck { public class WaterWalkCheck {
@@ -42,34 +43,39 @@ public class WaterWalkCheck {
User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid); User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
MovementManager movementManager = user.getMovementManager(); MovementManager movementManager = user.getMovementManager();
if (movementManager.distanceXZ <= 0) if (movementManager.distanceXZ <= 0 || player.getVehicle() != null || Utilities.isOnLilyPad(player)
|| movementManager.riptideTicks > 0 || VersionUtil.isSwimming(player) || VersionUtil.isFlying(player)
|| player.getLocation().getBlock().getType().name().endsWith("CARPET"))
return PASS; return PASS;
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
Block blockBeneath = player.getLocation().clone().subtract(0, 0.1, 0).getBlock(); Block blockBeneath = player.getLocation().clone().subtract(0, 0.1, 0).getBlock();
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "walk") && blockBeneath.isLiquid() if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "walk") && blockBeneath.isLiquid()
&& Utilities.isSurroundedByWater(player) && Utilities.isSurroundedByWater(player)
&& ((movementManager.motionY == 0 && movementManager.lastMotionY == 0) || movementManager.motionY == Utilities.JUMP_MOTION_Y) && ((movementManager.motionY == 0 && movementManager.lastMotionY == 0)
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "walk", "minimumDistXZ")) || movementManager.motionY == Utilities.JUMP_MOTION_Y)
return new CheckResult(Result.FAILED, && movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "walk", "minimumDistXZ")
&& !movementManager.topSolid && !Utilities.couldBeOnBoat(player, 3, false))
return new CheckResult(Result.FAILED, "Walk",
"tried to walk on water (xz=" + Utilities.roundDouble(movementManager.distanceXZ, 5) + ")"); "tried to walk on water (xz=" + Utilities.roundDouble(movementManager.distanceXZ, 5) + ")");
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "hop") && blockBeneath.isLiquid() if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "hop") && blockBeneath.isLiquid()
&& Utilities.isSurroundedByWater(player) && movementManager.onGround && Utilities.isSurroundedByWater(player) && movementManager.onGround
&& Math.abs(movementManager.motionY) < checksConfig.getDouble(CheckType.WATER_WALK, "hop", "maxMotionY")) && Math.abs(movementManager.motionY) < checksConfig.getDouble(CheckType.WATER_WALK, "hop", "maxMotionY")
return new CheckResult(Result.FAILED, && !Utilities.couldBeOnBoat(player, 0.3, false))
return new CheckResult(Result.FAILED, "Hop",
"tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")"); "tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")");
double minAbsMotionY = 0.12D; double minAbsMotionY = 0.12D;
if (player.hasPotionEffect(PotionEffectType.SPEED)) if (player.hasPotionEffect(PotionEffectType.SPEED))
minAbsMotionY += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.05D; minAbsMotionY += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && blockBeneath.isLiquid() if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && blockBeneath.isLiquid()
&& Utilities.isSurroundedByWater(player) && Utilities.isSurroundedByWater(player)
&& Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY && Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "lunge", "minimumDistXZ") && movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "lunge", "minimumDistXZ")
&& movementManager.lastMotionY > -0.25) && movementManager.lastMotionY > -0.25
return new CheckResult(Result.FAILED, "tried to lunge in water (xz=" && !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(movementManager.distanceXZ, 5) + ", absMotionY="
+ Utilities.roundDouble(Math.abs(movementManager.lastMotionY - movementManager.motionY), 5) + ")"); + Utilities.roundDouble(Math.abs(movementManager.lastMotionY - movementManager.motionY), 5) + ")");
@@ -32,6 +32,7 @@ import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.providers.Checks; import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.event.EventListener; import com.rammelkast.anticheatreloaded.event.EventListener;
import com.rammelkast.anticheatreloaded.util.MovementManager;
import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.User;
public class BadPacketsCheck { public class BadPacketsCheck {
@@ -39,9 +40,10 @@ public class BadPacketsCheck {
public static void runCheck(Player player, PacketEvent event) { public static void runCheck(Player player, PacketEvent event) {
Backend backend = AntiCheatReloaded.getManager().getBackend(); Backend backend = AntiCheatReloaded.getManager().getBackend();
// Confirm if we should even check for BadPackets // Confirm if we should even check for BadPackets
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.BADPACKETS) || backend.isMovingExempt(player)) { if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.BADPACKETS)
|| backend.isMovingExempt(player) || player.isDead())
return; return;
}
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()); User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
PacketContainer packet = event.getPacket(); PacketContainer packet = event.getPacket();
float pitch = packet.getFloat().read(1); float pitch = packet.getFloat().read(1);
@@ -53,9 +55,11 @@ public class BadPacketsCheck {
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
double tps = AntiCheatReloaded.getPlugin().getTPS(); double tps = AntiCheatReloaded.getPlugin().getTPS();
if (user.isLagging() || tps < checksConfig.getDouble(CheckType.MOREPACKETS, "minimumTps")) { MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
.getMovementManager();
if (user.isLagging() || tps < checksConfig.getDouble(CheckType.MOREPACKETS, "minimumTps")
|| (System.currentTimeMillis() - movementManager.lastTeleport <= 150))
return; return;
}
double x = packet.getDoubles().read(0); double x = packet.getDoubles().read(0);
double y = packet.getDoubles().read(1); double y = packet.getDoubles().read(1);
@@ -66,14 +70,18 @@ public class BadPacketsCheck {
Location current = new Location(previous.getWorld(), x, y, z, yaw, pitch); Location current = new Location(previous.getWorld(), x, y, z, yaw, pitch);
double distance = previous.distanceSquared(current); double distance = previous.distanceSquared(current);
double maxDistance = checksConfig.getDouble(CheckType.BADPACKETS, "maxDistance"); 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); boolean hasNewLocation = packet.getBooleans().read(0);
if (distance > maxDistance) { if (distance > maxDistance) {
flag(player, event, "moved too far between packets (distance=" + new BigDecimal(distance).setScale(1, RoundingMode.HALF_UP) + ", max=" + maxDistance + ")"); flag(player, event, "moved too far between packets (distance="
+ new BigDecimal(distance).setScale(1, RoundingMode.HALF_UP) + ", max=" + maxDistance + ", at=" + movementManager.airTicks + ")");
return; return;
} else if (distance < 1E-10 && !hasNewLocation) { } else if (distance < 1E-10 && !hasNewLocation) {
// TODO this gives false positives when teleporting // TODO this gives false positives when teleporting
// Only found this in 1.8.8 though // Only found this in 1.8.8 though
//flag(player, event, "sent the same packet twice"); // flag(player, event, "sent the same packet twice");
return; return;
} }
} }
@@ -85,7 +93,7 @@ public class BadPacketsCheck {
@Override @Override
public void run() { public void run() {
EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player, EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player,
CheckType.BADPACKETS); CheckType.BADPACKETS, null);
player.teleport(player.getLocation()); player.teleport(player.getLocation());
} }
}); });
@@ -88,7 +88,7 @@ public class MorePacketsCheck {
@Override @Override
public void run() { public void run() {
EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player, EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player,
CheckType.MOREPACKETS); CheckType.MOREPACKETS, null);
player.teleport(player.getLocation()); player.teleport(player.getLocation());
} }
}); });
@@ -47,7 +47,8 @@ public class IllegalInteract {
} else if (event instanceof BlockBreakEvent } else if (event instanceof BlockBreakEvent
&& checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "break")) { && checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "break")) {
return checkBlockBreak(player, (BlockBreakEvent) event); return checkBlockBreak(player, (BlockBreakEvent) event);
} else if (event instanceof PlayerInteractEvent && checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "interact")) { } else if (event instanceof PlayerInteractEvent
&& checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "interact")) {
return checkInteract(player, (PlayerInteractEvent) event); return checkInteract(player, (PlayerInteractEvent) event);
} }
return PASS; return PASS;
@@ -67,21 +68,22 @@ public class IllegalInteract {
maxDistance += player.getVelocity().length() maxDistance += player.getVelocity().length()
* checksConfig.getDouble(CheckType.ILLEGAL_INTERACT, "interact", "velocityMultiplier"); * checksConfig.getDouble(CheckType.ILLEGAL_INTERACT, "interact", "velocityMultiplier");
if (distance > maxDistance) { if (distance > maxDistance) {
return new CheckResult(CheckResult.Result.FAILED, "tried to interact out of range (dist=" + distance + ", max=" + maxDistance + ")"); return new CheckResult(CheckResult.Result.FAILED, "Interact",
"tried to interact out of range (dist=" + distance + ", max=" + maxDistance + ")");
} }
return PASS; return PASS;
} }
private static CheckResult checkBlockBreak(Player player, BlockBreakEvent event) { private static CheckResult checkBlockBreak(Player player, BlockBreakEvent event) {
if (!isValidTarget(player, event.getBlock())) { if (!isValidTarget(player, event.getBlock())) {
return new CheckResult(CheckResult.Result.FAILED, "tried to break a block which was out of view"); return new CheckResult(CheckResult.Result.FAILED, "Break", "tried to break a block which was out of view");
} }
return PASS; return PASS;
} }
private static CheckResult checkBlockPlace(Player player, BlockPlaceEvent event) { private static CheckResult checkBlockPlace(Player player, BlockPlaceEvent event) {
if (!isValidTarget(player, event.getBlock())) { if (event.getBlock().getType().isSolid() && !isValidTarget(player, event.getBlock())) {
return new CheckResult(CheckResult.Result.FAILED, "tried to place a block out of their view"); return new CheckResult(CheckResult.Result.FAILED, "Place", "tried to place a block out of their view");
} }
return PASS; return PASS;
} }
@@ -89,8 +91,7 @@ public class IllegalInteract {
private static boolean isValidTarget(Player player, Block block) { private static boolean isValidTarget(Player player, Block block) {
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
double distance = player.getGameMode() == GameMode.CREATIVE ? 6.0 double distance = player.getGameMode() == GameMode.CREATIVE ? 6.0
: player.getLocation().getDirection().getY() > 0.9 ? 6.0 : player.getLocation().getDirection().getY() > 0.9 ? 6.0 : 5.5;
: 5.5;
Block targetBlock = VersionUtil.getTargetBlock(player, ((int) Math.ceil(distance))); Block targetBlock = VersionUtil.getTargetBlock(player, ((int) Math.ceil(distance)));
if (targetBlock == null) { if (targetBlock == null) {
// TODO better check here // TODO better check here
@@ -66,7 +66,7 @@ public class CommandBase {
execute(cs, args); execute(cs, args);
} else { } else {
if (args == null) { if (args == null) {
cs.sendMessage(GOLD + "" + ChatColor.BOLD + "AntiCheatReloaded " + GRAY + "version " + AntiCheatReloaded.getVersion()); 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 + ")");
} }
@@ -19,39 +19,44 @@
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.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.command.CommandBase; import com.rammelkast.anticheatreloaded.command.CommandBase;
import com.rammelkast.anticheatreloaded.manage.CheckManager;
import com.rammelkast.anticheatreloaded.util.Permission; import com.rammelkast.anticheatreloaded.util.Permission;
public class CommandChecks extends CommandBase { public class CommandChecks extends CommandBase {
private static final String NAME = "AntiCheatReloaded Checks Management"; private static final String NAME = "AntiCheatReloaded Checks Management";
private static final String COMMAND = "checks"; private static final String COMMAND = "checks";
private static final String USAGE = "anticheat checks"; private static final String USAGE = "anticheat checks";
private static final Permission PERMISSION = Permission.SYSTEM_CHECK; private static final Permission PERMISSION = Permission.SYSTEM_CHECK;
private static final String[] HELP = new String[2]; private static final String[] HELP = new String[2];
static { static {
HELP[0] = GRAY + "Use: " + AQUA + "/anticheat checks" + GRAY + " for a list of checks"; HELP[0] = GRAY + "Use: " + AQUA + "/anticheat checks" + GRAY + " for a list of checks";
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(GRAY + "Checks: "); CheckManager checkManager = AntiCheatReloaded.getManager().getCheckManager();
for (int i=0;i<CheckType.values().length;i++) { builder.append(GRAY + "Checks: ");
builder.append(CheckType.values()[i]); for (int i = 0; i < CheckType.values().length; i++) {
if (i<CheckType.values().length-1) { CheckType type = CheckType.values()[i];
builder.append(", "); builder.append((checkManager.isActive(type) ? ChatColor.GREEN : ChatColor.RED) + type.getName());
} if (i < CheckType.values().length - 1) {
} builder.append(", ");
HELP[1] = builder.toString(); }
} }
HELP[1] = builder.toString();
}
public CommandChecks() { public CommandChecks() {
super(NAME, COMMAND, USAGE, HELP, PERMISSION); super(NAME, COMMAND, USAGE, HELP, PERMISSION);
} }
@Override @Override
protected void execute(CommandSender cs, String[] args) { protected void execute(CommandSender cs, String[] args) {
sendHelp(cs); sendHelp(cs);
} }
} }
@@ -16,7 +16,6 @@
* 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 java.util.ArrayList; import java.util.ArrayList;
@@ -25,8 +24,8 @@ import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
@@ -38,153 +37,158 @@ import com.rammelkast.anticheatreloaded.util.Utilities;
public class CommandReport extends CommandBase { public class CommandReport extends CommandBase {
private static final String NAME = "AntiCheatReloaded 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: " + GOLD + "/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: " + GOLD + "/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: " + GOLD + "/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);
} }
@Override @Override
protected void execute(CommandSender cs, String[] args) { protected void execute(CommandSender cs, String[] args) {
if (args.length >= 1) { if (args.length >= 1) {
int page = 1; int page = 1;
if (args.length == 2) { if (args.length == 2) {
if (Utilities.isInt(args[1])) { if (Utilities.isInt(args[1])) {
page = Integer.parseInt(args[1]); page = Integer.parseInt(args[1]);
} else { } else {
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[1]); cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[1]);
} }
} }
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 " + GOLD + "/anticheat report [group]" + GRAY
cs.sendMessage(GRAY + "Use " + GOLD + "/anticheat report [group]" + GRAY + " for a list of players in each group."); + " 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])
groupReport(cs, group, page); || "all".equalsIgnoreCase(args[0])) {
return; groupReport(cs, group, page);
} return;
} }
}
Player targetPlayer = Bukkit.getPlayer(args[0]); @SuppressWarnings("deprecation")
if (targetPlayer == null) { OfflinePlayer targetPlayer = Bukkit.getOfflinePlayer(args[0]);
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]); if (targetPlayer == null) {
return; cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
} return;
}
// Test users User user = AntiCheatReloaded.getManager().getUserManager().getUser(targetPlayer.getUniqueId());
for (Player player : Bukkit.getOnlinePlayers()) { if (user != null) {
if (player.getUniqueId().equals(Bukkit.getPlayer(args[0]).getUniqueId())) { playerReport(cs, user, page);
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()); return;
playerReport(cs, user, page); }
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 { sendHelp(cs);
sendHelp(cs); }
} }
}
private void groupReport(CommandSender cs, Group group, int page) { private void groupReport(CommandSender cs, Group group, int page) {
List<User> users = USER_MANAGER.getUsersInGroup(group); List<User> users = USER_MANAGER.getUsersInGroup(group);
ChatColor color = group == null ? GREEN : group.getColor(); ChatColor color = group == null ? GREEN : group.getColor();
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(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD + "]----------------------"); cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD
cs.sendMessage(GRAY + "Group: " + color + groupName); + "]----------------------");
for (int x = 0; x < 7; x++) { cs.sendMessage(GRAY + "Group: " + color + groupName);
int index = ((page - 1) * 6) + (x + ((page - 1) * 1)); for (int x = 0; x < 7; x++) {
if (index < users.size()) { int index = ((page - 1) * 6) + (x + ((page - 1) * 1));
String player = users.get(index).getName(); if (index < users.size()) {
cs.sendMessage(GRAY + player); String player = users.get(index).getName();
} cs.sendMessage(GRAY + player);
} }
cs.sendMessage(MENU_END); }
} else { cs.sendMessage(MENU_END);
if (pages == 0) { } else {
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------"); if (pages == 0) {
cs.sendMessage(GRAY + "Group: " + color + groupName); cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
cs.sendMessage(GRAY + "There are no users in this group."); cs.sendMessage(GRAY + "Group: " + color + groupName);
cs.sendMessage(MENU_END); cs.sendMessage(GRAY + "There are no users in this group.");
} else { cs.sendMessage(MENU_END);
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages); } else {
} cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages);
} }
} }
}
private void playerReport(CommandSender cs, User user, int page) { private void playerReport(CommandSender cs, User user, int page) {
List<CheckType> types = new ArrayList<CheckType>(); List<CheckType> types = new ArrayList<CheckType>();
for (CheckType type : CheckType.values()) { for (CheckType type : CheckType.values()) {
if (type.getUses(user.getUUID()) > 0) { if (type.getUses(user.getUUID()) > 0) {
types.add(type); types.add(type);
} }
} }
UUID uuid = user.getUUID(); UUID uuid = user.getUUID();
String name = user.getName(); String name = user.getName();
int pages = (int) Math.ceil(((float) types.size()) / 6); int pages = (int) Math.ceil(((float) types.size()) / 6);
Group group = user.getGroup(); Group group = user.getGroup();
String groupString = GREEN + "Low"; String groupString = GREEN + "Low";
if (group != null) { if (group != null) {
groupString = group.getColor() + group.getName(); groupString = group.getColor() + group.getName();
} }
groupString += " (" + user.getLevel() + ")"; groupString += " (" + user.getLevel() + ")";
if (page <= pages && page > 0) { if (page <= pages && page > 0) {
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD + "]----------------------"); cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD
cs.sendMessage(GRAY + "Player: " + WHITE + name); + "]----------------------");
cs.sendMessage(GRAY + "Ping: " + WHITE + user.getPing() + "ms " + (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)")); cs.sendMessage(GRAY + "Player: " + WHITE + name);
cs.sendMessage(GRAY + "Group: " + groupString); int ping = user.getPing();
for (int x = 0; x < 6; x++) { cs.sendMessage(GRAY + "Ping: " + ((ping == -1) ? (RED + "Offline")
int index = ((page - 1) * 5) + (x + ((page - 1))); : (WHITE + "" + ping + "ms "
if (index < types.size()) { + (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"))));
CheckType type = types.get(index); cs.sendMessage(GRAY + "Group: " + groupString);
int use = type.getUses(uuid); for (int x = 0; x < 6; x++) {
ChatColor color = WHITE; int index = ((page - 1) * 5) + (x + ((page - 1)));
if (use >= 20) { if (index < types.size()) {
color = YELLOW; CheckType type = types.get(index);
} else if (use > 50) { int use = type.getUses(uuid);
color = RED; ChatColor color = WHITE;
} if (use >= 20) {
cs.sendMessage(GRAY + type.getName() + ": " + color + use); color = YELLOW;
} } else if (use > 50) {
} color = RED;
cs.sendMessage(MENU_END); }
} else { cs.sendMessage(GRAY + type.getName() + ": " + color + use);
if (pages == 0 && page == 1) { }
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------"); }
cs.sendMessage(GRAY + "Player: " + WHITE + name); cs.sendMessage(MENU_END);
cs.sendMessage(GRAY + "Ping: " + WHITE + user.getPing() + "ms " + (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)")); } else {
cs.sendMessage(GRAY + "Group: " + groupString); if (pages == 0 && page == 1) {
cs.sendMessage(GRAY + "This user has not failed any checks."); cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
cs.sendMessage(MENU_END); cs.sendMessage(GRAY + "Player: " + WHITE + name);
} else { int ping = user.getPing();
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages + 1); 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 + "This user has not failed any checks.");
cs.sendMessage(MENU_END);
} else {
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages + 1);
}
}
}
} }
@@ -36,6 +36,7 @@ public class Config extends ConfigurationFile {
public ConfigValue<Boolean> eventChains; public ConfigValue<Boolean> eventChains;
public ConfigValue<Boolean> enterprise; public ConfigValue<Boolean> enterprise;
public ConfigValue<Boolean> debugMode; public ConfigValue<Boolean> debugMode;
public ConfigValue<Boolean> disableBroadcast;
public ConfigValue<Boolean> blockChatSpamSpeed; public ConfigValue<Boolean> blockChatSpamSpeed;
public ConfigValue<Boolean> blockCommandSpamSpeed; public ConfigValue<Boolean> blockCommandSpamSpeed;
@@ -51,6 +52,7 @@ public class Config extends ConfigurationFile {
public ConfigValue<List<String>> disabledWorlds; public ConfigValue<List<String>> disabledWorlds;
public ConfigValue<Integer> notifyEveryVl; public ConfigValue<Integer> notifyEveryVl;
public ConfigValue<Integer> maxSetbackDistance;
public Config(AntiCheatReloaded plugin, Configuration config) { public Config(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME); super(plugin, config, FILENAME);
@@ -66,6 +68,7 @@ public class Config extends ConfigurationFile {
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"); 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");
@@ -85,5 +88,9 @@ public class Config extends ConfigurationFile {
if (notifyEveryVl.getValue() < 1) { if (notifyEveryVl.getValue() < 1) {
notifyEveryVl.setValue(5); notifyEveryVl.setValue(5);
} }
maxSetbackDistance = new ConfigValue<Integer>("system.max-setback-distance");
if (maxSetbackDistance.getValue() < 5) {
maxSetbackDistance.setValue(50);
}
} }
} }
@@ -99,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();
} }
@@ -46,10 +46,6 @@ public interface Magic {
* 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.
*/ */
@@ -38,7 +38,7 @@ public class BlockListener extends EventListener {
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());
noHack = false; noHack = false;
} }
} }
@@ -47,7 +47,7 @@ public class BlockListener extends EventListener {
CheckResult result = IllegalInteract.performCheck(player, event); CheckResult result = IllegalInteract.performCheck(player, event);
if (result.failed()) { if (result.failed()) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT); log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck());
noHack = false; noHack = false;
} }
} }
@@ -67,7 +67,7 @@ public class BlockListener extends EventListener {
result = IllegalInteract.performCheck(player, event); result = IllegalInteract.performCheck(player, event);
if (result.failed()) { if (result.failed()) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT); log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck());
noHack = false; noHack = false;
} }
} }
@@ -27,7 +27,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityPotionEffectEvent; import org.bukkit.event.entity.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.EntityShootBowEvent;
@@ -42,17 +42,6 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class EntityListener extends EventListener { public class EntityListener extends EventListener {
@EventHandler
public void onEntityPotionEffect(EntityPotionEffectEvent event) {
if (!(event.getEntity() instanceof Player))
return;
if (event.getNewEffect() == null)
return;
if (!VersionUtil.isLevitationEffect(event.getNewEffect()))
return;
getBackend().logLevitating((Player) event.getEntity(), event.getNewEffect().getDuration());
}
@EventHandler @EventHandler
public void onEntityShootBow(EntityShootBowEvent event) { public void onEntityShootBow(EntityShootBowEvent event) {
if (event.getEntity() instanceof Player) { if (event.getEntity() instanceof Player) {
@@ -61,7 +50,7 @@ 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);
} }
@@ -79,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);
@@ -99,7 +88,7 @@ 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);
} }
@@ -134,29 +123,36 @@ 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.KILLAURA)) { CheckResult result = KillAuraCheck.checkAngle(player, event);
CheckResult result = KillAuraCheck.checkAngle(player, event); if (result.failed()) {
if (result.failed()) { event.setCancelled(!silentMode());
event.setCancelled(!silentMode()); log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck());
log(result.getMessage(), player, CheckType.KILLAURA); noHack = false;
noHack = false; }
} }
} if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) { CheckResult result = KillAuraCheck.checkReach(player, event.getEntity());
CheckResult result = KillAuraCheck.checkReach(player, event.getEntity()); if (result.failed()) {
if (result.failed()) { event.setCancelled(!silentMode());
event.setCancelled(!silentMode()); log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck());
log(result.getMessage(), player, CheckType.KILLAURA); noHack = false;
noHack = false; }
} }
} if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
if (noHack) { CheckResult result = KillAuraCheck.checkPacketOrder(player, event.getEntity());
decrease(player); if (result.failed()) {
} event.setCancelled(!silentMode());
} log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck());
noHack = false;
}
}
if (noHack) {
decrease(player);
}
}
} }
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
@@ -16,12 +16,13 @@
* 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 java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@@ -48,7 +49,12 @@ public class EventListener implements Listener {
private static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration(); private static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration();
private static final DecimalFormat TPS_FORMAT = new DecimalFormat("##.##"); private static final DecimalFormat TPS_FORMAT = new DecimalFormat("##.##");
public static void log(String message, Player player, CheckType type) { static {
// What the hell, Java..
TPS_FORMAT.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ENGLISH));
}
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) if (user == null)
return; return;
@@ -56,23 +62,26 @@ public class EventListener implements Listener {
boolean debugMode = CONFIG.getConfig().debugMode.getValue(); boolean debugMode = CONFIG.getConfig().debugMode.getValue();
int vlForType = type.getUses(player.getUniqueId()) + 1; int vlForType = type.getUses(player.getUniqueId()) + 1;
int notifyEveryVl = CONFIG.getConfig().notifyEveryVl.getValue(); int notifyEveryVl = CONFIG.getConfig().notifyEveryVl.getValue();
String prefix = ChatColor.translateAlternateColorCodes('&', CONFIG.getLang().ALERT_PREFIX());
if (message == null || message.equals("")) { if (message == null || message.equals("")) {
if (debugMode) { if (debugMode) {
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY + player.getName() + " failed " message = prefix + player.getName() + " failed "
+ type.getName(); + type.getName();
} else { } else {
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY + player.getName() + " failed " message = prefix + player.getName() + " failed "
+ type.getName() + ChatColor.GOLD + " (x" + vlForType + ")"; + type.getName() + ChatColor.GOLD + " (x" + vlForType + ")";
} }
} else { } else {
if (debugMode) { if (debugMode) {
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY + player.getName() + " failed " message = prefix + player.getName() + " failed "
+ type.getName() + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message + type.getName() + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message
+ ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms" + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms"
+ ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS()); + ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS());
} else { } else {
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY + player.getName() + " failed " message = prefix
+ type.getName() + ChatColor.GOLD + " (x" + vlForType + ")" + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms" + 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()); + ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS());
} }
} }
@@ -22,14 +22,10 @@ package com.rammelkast.anticheatreloaded.event;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.User;
public class InventoryListener extends EventListener { public class InventoryListener extends EventListener {
@@ -45,7 +41,7 @@ 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);
} }
@@ -55,18 +51,4 @@ public class InventoryListener extends EventListener {
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler
public void onInventoryOpen(InventoryOpenEvent event) {
if (event.getInventory().getType() != InventoryType.BEACON) {
getUserManager().getUser(event.getPlayer().getUniqueId()).setInventorySnapshot(event.getInventory().getContents());
}
}
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
User user = getUserManager().getUser(event.getPlayer().getUniqueId());
if (user != null) {
user.removeInventorySnapshot();
}
}
} }
@@ -46,7 +46,6 @@ 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.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;
@@ -61,10 +60,12 @@ import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck; import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck; 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.ElytraCheck;
import com.rammelkast.anticheatreloaded.check.movement.FastLadderCheck; 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.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.player.IllegalInteract; import com.rammelkast.anticheatreloaded.check.player.IllegalInteract;
import com.rammelkast.anticheatreloaded.util.Distance; import com.rammelkast.anticheatreloaded.util.Distance;
@@ -72,6 +73,7 @@ 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 {
@@ -86,7 +88,7 @@ public class PlayerListener extends EventListener {
if (!silentMode()) if (!silentMode())
player.sendMessage(ChatColor.translateAlternateColorCodes('&', result.getMessage())); 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());
} }
} }
@@ -124,7 +126,7 @@ 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());
} }
} }
} }
@@ -134,10 +136,7 @@ public class PlayerListener extends EventListener {
@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()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@@ -156,7 +155,7 @@ public class PlayerListener extends EventListener {
CheckResult result = getBackend().checkSneakToggle(player); CheckResult result = getBackend().checkSneakToggle(player);
if (result.failed()) { if (result.failed()) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.SNEAK); log(result.getMessage(), player, CheckType.SNEAK, result.getSubCheck());
} }
} }
// getBackend().logToggleSneak(event.getPlayer()); // getBackend().logToggleSneak(event.getPlayer());
@@ -203,7 +202,7 @@ public class PlayerListener extends EventListener {
AntiCheatReloaded.sendToMainThread(new Runnable() { AntiCheatReloaded.sendToMainThread(new Runnable() {
@Override @Override
public void run() { public void run() {
log(null, player, CheckType.CHAT_SPAM); log(null, player, CheckType.CHAT_SPAM, result.getSubCheck());
} }
}); });
} }
@@ -217,7 +216,7 @@ public class PlayerListener extends EventListener {
AntiCheatReloaded.sendToMainThread(new Runnable() { AntiCheatReloaded.sendToMainThread(new Runnable() {
@Override @Override
public void run() { public void run() {
log(null, player, CheckType.CHAT_UNICODE); log(null, player, CheckType.CHAT_UNICODE, result.getSubCheck());
} }
}); });
} }
@@ -256,14 +255,11 @@ public class PlayerListener extends EventListener {
@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);
} }
@@ -292,7 +288,7 @@ public class PlayerListener extends EventListener {
} }
if (!VersionUtil.isBountifulUpdate()) { if (!VersionUtil.isBountifulUpdate()) {
if (itemInHand.getType() == Material.FIREWORK_ROCKET) { if (itemInHand.getType() == XMaterial.FIREWORK_ROCKET.parseMaterial()) {
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId()); ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
if (player.isGliding()) { if (player.isGliding()) {
// TODO config max elytra height? // TODO config max elytra height?
@@ -309,7 +305,7 @@ public class PlayerListener extends EventListener {
CheckResult result = IllegalInteract.performCheck(player, event); CheckResult result = IllegalInteract.performCheck(player, event);
if (result.failed()) { if (result.failed()) {
event.setCancelled(!silentMode()); event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT); log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck());
} }
} }
} }
@@ -324,7 +320,7 @@ 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());
} }
} }
@@ -383,7 +379,6 @@ 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());
@@ -395,13 +390,23 @@ 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.FLIGHT); log(result.getMessage(), player, CheckType.FLIGHT, result.getSubCheck());
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.ELYTRAFLY)) { if (getCheckManager().willCheckQuick(player, CheckType.ELYTRAFLY)) {
CheckResult result = ElytraCheck.runCheck(player, distance); CheckResult result = ElytraCheck.runCheck(player, distance);
if (result.failed()) { if (result.failed()) {
log(result.getMessage(), player, CheckType.ELYTRAFLY); log(result.getMessage(), player, CheckType.ELYTRAFLY, result.getSubCheck());
}
}
if (getCheckManager().willCheckQuick(player, CheckType.BOATFLY)) {
CheckResult result = BoatFlyCheck.runCheck(player, user.getMovementManager(), to);
if (result.failed()) {
if (!silentMode()) {
player.eject();
event.setTo(user.getGoodLocation(from.clone()));
}
log(result.getMessage(), player, CheckType.BOATFLY, result.getSubCheck());
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.VCLIP) if (getCheckManager().willCheckQuick(player, CheckType.VCLIP)
@@ -419,7 +424,7 @@ 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) if (getCheckManager().willCheckQuick(player, CheckType.NOFALL)
@@ -432,11 +437,10 @@ public class PlayerListener extends EventListener {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
// TODO better handling of this // 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();
@@ -448,8 +452,7 @@ 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.SPEED); log(result.getMessage(), player, CheckType.SPEED, result.getSubCheck());
changed = true;
} }
} }
CheckResult result = SpeedCheck.checkXZSpeed(player, x, z, event.getTo()); CheckResult result = SpeedCheck.checkXZSpeed(player, x, z, event.getTo());
@@ -457,8 +460,7 @@ 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.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)) {
@@ -468,8 +470,7 @@ public class PlayerListener extends EventListener {
// TODO check this // TODO check this
player.teleport(player.getLocation().clone().subtract(0, 0.52, 0)); 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.SPIDER)) { if (getCheckManager().willCheckQuick(player, CheckType.SPIDER)) {
@@ -478,8 +479,7 @@ 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 (getCheckManager().willCheckQuick(player, CheckType.FASTLADDER)) { if (getCheckManager().willCheckQuick(player, CheckType.FASTLADDER)) {
@@ -490,24 +490,29 @@ 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.FASTLADDER); log(result.getMessage(), player, CheckType.FASTLADDER, result.getSubCheck());
changed = true;
} }
} }
if (!changed) { if (getCheckManager().willCheckQuick(player, CheckType.STRAFE)) {
user.setGoodLocation(event.getFrom()); 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)) { if (getCheckManager().willCheckQuick(player, CheckType.AIMBOT)) {
CheckResult result = AimbotCheck.runCheck(player, event); CheckResult result = AimbotCheck.runCheck(player, event);
if (result.failed()) { if (result.failed()) {
log(result.getMessage(), player, CheckType.AIMBOT); log(result.getMessage(), player, CheckType.AIMBOT, result.getSubCheck());
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.VELOCITY)) { if (getCheckManager().willCheckQuick(player, CheckType.VELOCITY)) {
CheckResult result = VelocityCheck.runCheck(player, distance); CheckResult result = VelocityCheck.runCheck(player, distance);
if (result.failed()) { if (result.failed()) {
log(result.getMessage(), player, CheckType.VELOCITY); log(result.getMessage(), player, CheckType.VELOCITY, result.getSubCheck());
} }
} }
} }
@@ -55,7 +55,6 @@ public class CheckManager {
for (CheckType type : CheckType.values()) { for (CheckType type : CheckType.values()) {
if (!configuration.getChecks().isEnabled(type)) { if (!configuration.getChecks().isEnabled(type)) {
checkIgnoreList.add(type); checkIgnoreList.add(type);
break;
} }
} }
@@ -89,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);
@@ -96,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));
} }
@@ -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);
}
}
@@ -20,6 +20,10 @@ package com.rammelkast.anticheatreloaded.util;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
public class MovementManager { public class MovementManager {
@@ -43,8 +47,16 @@ public class MovementManager {
public double lastMotionY; public double lastMotionY;
// Horizontal distance of movement // Horizontal distance of movement
public double distanceXZ; 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 // Previous horizontal distance of movement
public double lastDistanceXZ; 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 // If the player touched the ground again this tick
public boolean touchedGroundThisTick = false; public boolean touchedGroundThisTick = false;
// Last recorded distance // Last recorded distance
@@ -71,6 +83,20 @@ public class MovementManager {
public int sneakingTicks; public int sneakingTicks;
// Ticks counter after being near a liquid // Ticks counter after being near a liquid
public int nearLiquidTicks; 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;
// If the player has a speed increasing effect
public boolean hasIncreasingEffect = false;
// If the player had a speed increasing effect previous tick
public boolean hadIncreasingEffect = false;
// Riptiding ticks
public int riptideTicks;
// Time of last update
public long lastUpdate;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void handle(Player player, Location from, Location to, Distance distance) { public void handle(Player player, Location from, Location to, Distance distance) {
@@ -80,14 +106,27 @@ public class MovementManager {
this.onGround = player.isOnGround(); this.onGround = player.isOnGround();
double x = distance.getXDifference(); double x = distance.getXDifference();
double z = distance.getZDifference(); double z = distance.getZDifference();
this.lastDistanceXZ = this.distanceXZ; this.lastDistanceXZ = this.distanceXZ;
this.lastDistanceX = this.distanceX;
this.lastDistanceZ = this.distanceZ;
this.distanceXZ = Math.sqrt(x * x + z * z); this.distanceXZ = Math.sqrt(x * x + z * z);
this.distanceX = x;
this.distanceZ = z;
// Account for standing on boat // Account for standing on boat
if (Utilities.couldBeOnBoat(player, 0.25)) if (Utilities.couldBeOnBoat(player, 0.25, true) && !Utilities.isSubmersed(player))
this.onGround = true; 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.touchedGroundThisTick = false;
this.halfMovement = false; this.halfMovement = false;
if (!this.onGround) { if (!this.onGround) {
@@ -131,6 +170,11 @@ public class MovementManager {
else else
this.sneakingTicks = 0; this.sneakingTicks = 0;
if (player.isBlocking())
this.blockingTicks++;
else
this.blockingTicks = 0;
if (Utilities.isNearWater(player)) if (Utilities.isNearWater(player))
this.nearLiquidTicks = 8; this.nearLiquidTicks = 8;
else { else {
@@ -140,6 +184,23 @@ public class MovementManager {
this.nearLiquidTicks = 0; this.nearLiquidTicks = 0;
} }
if (VersionUtil.CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
if (player.isRiptiding()) {
this.riptideTicks = 30;
} else {
if (this.riptideTicks > 0)
this.riptideTicks--;
else
this.riptideTicks = 0;
}
}
this.hadSpeedEffect = this.hasSpeedEffect;
this.hasSpeedEffect = player.hasPotionEffect(PotionEffectType.SPEED);
this.hadIncreasingEffect = this.hasIncreasingEffect;
this.hasIncreasingEffect = !player.getActivePotionEffects().isEmpty();
double lastDistanceSq = Math.sqrt(this.lastDistance.getXDifference() * this.lastDistance.getXDifference() double lastDistanceSq = Math.sqrt(this.lastDistance.getXDifference() * this.lastDistance.getXDifference()
+ this.lastDistance.getZDifference() * this.lastDistance.getZDifference()); + this.lastDistance.getZDifference() * this.lastDistance.getZDifference());
double currentDistanceSq = Math.sqrt(distance.getXDifference() * distance.getXDifference() double currentDistanceSq = Math.sqrt(distance.getXDifference() * distance.getXDifference()
@@ -154,12 +215,17 @@ public class MovementManager {
Location bottom = to.clone().add(0, -1, 0); Location bottom = to.clone().add(0, -1, 0);
this.bottomSolid = bottom.getBlock().getType().isSolid(); this.bottomSolid = bottom.getBlock().getType().isSolid();
if ((this.motionY > 0.464D && this.motionY <= 0.5625D) && (Utilities.couldBeOnHalfblock(to) || Utilities.isNearBed(to))) { if ((this.motionY > 0.42D && this.motionY <= 0.5625D)
&& (Utilities.couldBeOnHalfblock(to) || Utilities.isNearBed(to))) {
this.halfMovement = true; this.halfMovement = true;
this.halfMovementHistoryCounter = 30; this.halfMovementHistoryCounter = 30;
} else { } else {
if (this.halfMovementHistoryCounter > 0) if (this.halfMovementHistoryCounter > 0)
this.halfMovementHistoryCounter--; this.halfMovementHistoryCounter--;
} }
this.lastUpdate = System.currentTimeMillis();
// Update "good location"
AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()).setGoodLocation(from);
} }
} }
@@ -24,7 +24,10 @@ import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent; 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.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.movement.NoSlowCheck;
import com.rammelkast.anticheatreloaded.check.packet.BadPacketsCheck; import com.rammelkast.anticheatreloaded.check.packet.BadPacketsCheck;
import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck; import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck;
@@ -38,6 +41,8 @@ public class PacketListener {
@Override @Override
public void onPacketReceiving(PacketEvent event) { public void onPacketReceiving(PacketEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player == null || !player.isOnline())
return;
// Run MorePackets check // Run MorePackets check
MorePacketsCheck.runCheck(player, event); MorePacketsCheck.runCheck(player, event);
@@ -51,6 +56,9 @@ public class PacketListener {
@Override @Override
public void onPacketSending(PacketEvent event) { public void onPacketSending(PacketEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
// Check if we have an actual player object
if (player instanceof TemporaryPlayer)
return;
// Compensate for teleport // Compensate for teleport
MorePacketsCheck.compensate(player); MorePacketsCheck.compensate(player);
} }
@@ -77,4 +85,15 @@ public class PacketListener {
}); });
} }
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);
}
});
}
} }
@@ -27,7 +27,7 @@ public enum Permission {
CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP, CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP, CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL,
CHECK_KILLAURA, CHECK_UNICODE, CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY, CHECK_KILLAURA, CHECK_UNICODE, CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY,
CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGALINTERACT, CHECK_FASTLADDER, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGALINTERACT, CHECK_FASTLADDER,
CHECK_AIMBOT, CHECK_AIMBOT, CHECK_STRAFE, CHECK_NOSLOW, CHECK_BOATFLY,
/* System Nodes */ /* System Nodes */
SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_NOTICE, SYSTEM_CHECK, SYSTEM_RELOAD, SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_NOTICE, SYSTEM_CHECK, SYSTEM_RELOAD,
@@ -33,11 +33,15 @@ public class UpdateManager {
public static final String SPIGOT_VERSION_URL = "https://api.spigotmc.org/legacy/update.php?resource=" public static final String SPIGOT_VERSION_URL = "https://api.spigotmc.org/legacy/update.php?resource="
+ RESOURCE_ID; + RESOURCE_ID;
private final String latestVersion; private String latestVersion;
private final boolean isLatest; private boolean isLatest;
private final boolean isAhead; private boolean isAhead;
public UpdateManager() { public UpdateManager() {
this.update();
}
public void update() {
this.latestVersion = this.getOnlineData(SPIGOT_VERSION_URL); this.latestVersion = this.getOnlineData(SPIGOT_VERSION_URL);
if (this.latestVersion == null) { if (this.latestVersion == null) {
this.isLatest = true; this.isLatest = true;
@@ -20,15 +20,12 @@
package com.rammelkast.anticheatreloaded.util; package com.rammelkast.anticheatreloaded.util;
import java.sql.Timestamp; import java.sql.Timestamp;
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.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.ItemStack;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
@@ -41,7 +38,6 @@ public class User {
private final int id; private final int id;
private int level = 0; private int level = 0;
private Location goodLocation; private Location goodLocation;
private List<ItemStack> inventorySnapshot = null;
private Configuration config = AntiCheatReloaded.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];
@@ -68,6 +64,7 @@ public class User {
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.movementManager = new MovementManager();
this.ping = getPlayer() != null && getPlayer().isOnline() ? VersionUtil.getPlayerPing(getPlayer()) : -1;
} }
/** /**
@@ -217,7 +214,8 @@ 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;
} }
@@ -244,43 +242,6 @@ public class User {
return true; return true;
} }
/**
* Store a copy of the player's inventory, for use in resetting
*
* @param is ItemStack list to store
*/
public void setInventorySnapshot(ItemStack[] is) {
inventorySnapshot = new ArrayList<ItemStack>();
for (int i = 0; i < is.length; i++) {
if (is[i] != null) {
inventorySnapshot.add(is[i].clone());
}
}
}
/**
* Remove the current inventory snapshot
*/
public void removeInventorySnapshot() {
inventorySnapshot = null;
}
/**
* Restore the player's inventory with the current inventory snapshot
*
* @param inventory Player's inventory
*/
public void restoreInventory(Inventory inventory) {
if (inventorySnapshot != null) {
inventory.clear();
for (ItemStack is : inventorySnapshot) {
if (is != null) {
inventory.addItem(is);
}
}
}
}
/** /**
* Set the player's to location * Set the player's to location
* *
@@ -457,7 +418,8 @@ public class User {
} }
public boolean isLagging() { public boolean isLagging() {
return Math.abs(this.ping - this.lastPing) > config.getMagic().LAG_DETERMINATION(); return Math.abs(this.ping - this.lastPing) > config.getMagic().LAG_DETERMINATION()
&& this.ping > config.getMagic().LAG_DETERMINATION();
} }
public MovementManager getMovementManager() { public MovementManager getMovementManager() {
@@ -37,6 +37,7 @@ import org.bukkit.entity.Boat;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.BoundingBox;
import org.bukkit.util.NumberConversions; import org.bukkit.util.NumberConversions;
public final class Utilities { public final class Utilities {
@@ -45,10 +46,6 @@ public final class Utilities {
private static final List<Material> CLIMBABLE = 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 Material LILY_PAD;
public static final Material COB_WEB;
public static final Material IRON_BARS;
public static final double JUMP_MOTION_Y = 0.41999998688697815; public static final double JUMP_MOTION_Y = 0.41999998688697815;
/** /**
@@ -120,17 +117,23 @@ public final class Utilities {
public static boolean isNotNearSlime(Block block) { public static boolean isNotNearSlime(Block block) {
return !isSlime(block.getRelative(BlockFace.NORTH)) && !isSlime(block.getRelative(BlockFace.EAST)) 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)); && !isSlime(block.getRelative(BlockFace.SOUTH)) && !isSlime(block.getRelative(BlockFace.WEST))
&& !isSlime(block.getRelative(BlockFace.DOWN));
} }
public static boolean couldBeOnBoat(Player player) { public static boolean couldBeOnBoat(Player player) {
return couldBeOnBoat(player, 0.35); return couldBeOnBoat(player, 0.35, false);
} }
public static boolean couldBeOnBoat(Player player, double range) { public static boolean couldBeOnBoat(Player player, double range, boolean checkY) {
for (Entity entity : player.getNearbyEntities(range, range, range)) { for (Entity entity : player.getNearbyEntities(range, range, range)) {
if (entity instanceof Boat) if (entity instanceof Boat) {
return true; if (((Boat) entity).getLocation().getY() < player.getLocation().getY() + 0.25) {
return true;
} else if (!checkY) {
return true;
}
}
} }
return false; return false;
} }
@@ -143,11 +146,11 @@ public final class Utilities {
*/ */
public static boolean couldBeOnIce(Location location) { public static boolean couldBeOnIce(Location location) {
return isNearIce(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D, 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()))
|| isNearIce(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.26D,
location.getBlockZ())); location.getBlockZ()));
} }
/** /**
* Determine whether a block is a type of ice * Determine whether a block is a type of ice
* *
@@ -160,8 +163,7 @@ public final class Utilities {
} }
public static boolean isNearIce(Location location) { public static boolean isNearIce(Location location) {
return isIce(location.getBlock()) return isIce(location.getBlock()) || isIce(location.getBlock().getRelative(BlockFace.NORTH))
|| isIce(location.getBlock().getRelative(BlockFace.NORTH))
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH)) || isIce(location.getBlock().getRelative(BlockFace.SOUTH))
|| isIce(location.getBlock().getRelative(BlockFace.EAST)) || isIce(location.getBlock().getRelative(BlockFace.EAST))
|| isIce(location.getBlock().getRelative(BlockFace.WEST)) || isIce(location.getBlock().getRelative(BlockFace.WEST))
@@ -171,6 +173,32 @@ public final class Utilities {
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH_WEST)); || 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 * Determine whether a player could be standing on a halfblock
* *
@@ -178,14 +206,14 @@ public final class Utilities {
* @return true if the player could be standing on a halfblock * @return true if the player could be standing on a halfblock
*/ */
public static boolean couldBeOnHalfblock(Location location) { public static boolean couldBeOnHalfblock(Location location) {
return isNearHalfblock(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, return isNearHalfblock(
location.getBlockZ())) || isNearHalfblock(new Location(location.getWorld(), location.getX(), location.getY() - 0.51D, 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())); location.getBlockZ()));
} }
public static boolean isNearHalfblock(Location location) { public static boolean isNearHalfblock(Location location) {
return isHalfblock(location.getBlock()) return isHalfblock(location.getBlock()) || isHalfblock(location.getBlock().getRelative(BlockFace.NORTH))
|| isHalfblock(location.getBlock().getRelative(BlockFace.NORTH))
|| isHalfblock(location.getBlock().getRelative(BlockFace.SOUTH)) || isHalfblock(location.getBlock().getRelative(BlockFace.SOUTH))
|| isHalfblock(location.getBlock().getRelative(BlockFace.EAST)) || isHalfblock(location.getBlock().getRelative(BlockFace.EAST))
|| isHalfblock(location.getBlock().getRelative(BlockFace.WEST)) || isHalfblock(location.getBlock().getRelative(BlockFace.WEST))
@@ -196,10 +224,17 @@ public final class Utilities {
} }
public static boolean isHalfblock(Block block) { public static boolean isHalfblock(Block block) {
return isSlab(block) || isStair(block) || isWall(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 * Determine whether a player could be standing on slime
* *
@@ -208,11 +243,11 @@ public final class Utilities {
*/ */
public static boolean couldBeOnSlime(Location location) { public static boolean couldBeOnSlime(Location location) {
return isNearSlime(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D, 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()))
|| isNearSlime(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.51D,
location.getBlockZ())); location.getBlockZ()));
} }
/** /**
* Determine whether a block is a type of slime * Determine whether a block is a type of slime
* *
@@ -225,8 +260,7 @@ public final class Utilities {
} }
public static boolean isNearSlime(Location location) { public static boolean isNearSlime(Location location) {
return isSlime(location.getBlock()) return isSlime(location.getBlock()) || isSlime(location.getBlock().getRelative(BlockFace.NORTH))
|| isSlime(location.getBlock().getRelative(BlockFace.NORTH))
|| isSlime(location.getBlock().getRelative(BlockFace.SOUTH)) || isSlime(location.getBlock().getRelative(BlockFace.SOUTH))
|| isSlime(location.getBlock().getRelative(BlockFace.EAST)) || isSlime(location.getBlock().getRelative(BlockFace.EAST))
|| isSlime(location.getBlock().getRelative(BlockFace.WEST)) || isSlime(location.getBlock().getRelative(BlockFace.WEST))
@@ -347,8 +381,7 @@ public final class Utilities {
} }
public static boolean isNearBed(Location location) { public static boolean isNearBed(Location location) {
return isBed(location.getBlock()) return isBed(location.getBlock()) || isBed(location.getBlock().getRelative(BlockFace.NORTH))
|| isBed(location.getBlock().getRelative(BlockFace.NORTH))
|| isBed(location.getBlock().getRelative(BlockFace.SOUTH)) || isBed(location.getBlock().getRelative(BlockFace.SOUTH))
|| isBed(location.getBlock().getRelative(BlockFace.EAST)) || isBed(location.getBlock().getRelative(BlockFace.EAST))
|| isBed(location.getBlock().getRelative(BlockFace.WEST)) || isBed(location.getBlock().getRelative(BlockFace.WEST))
@@ -377,7 +410,7 @@ public final class Utilities {
*/ */
public static boolean isWall(Block block) { public static boolean isWall(Block block) {
Material type = block.getType(); Material type = block.getType();
return type.name().endsWith("WALL"); return type.name().endsWith("WALL") || type.name().endsWith("FENCE");
} }
/** /**
@@ -398,10 +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();
return block.getType() == LILY_PAD || block.getRelative(BlockFace.NORTH).getType() == LILY_PAD return block.getType() == XMaterial.LILY_PAD.parseMaterial()
|| block.getRelative(BlockFace.SOUTH).getType() == LILY_PAD || block.getRelative(BlockFace.NORTH).getType() == XMaterial.LILY_PAD.parseMaterial()
|| block.getRelative(BlockFace.EAST).getType() == LILY_PAD || block.getRelative(BlockFace.SOUTH).getType() == XMaterial.LILY_PAD.parseMaterial()
|| block.getRelative(BlockFace.WEST).getType() == LILY_PAD; || block.getRelative(BlockFace.EAST).getType() == XMaterial.LILY_PAD.parseMaterial()
|| block.getRelative(BlockFace.WEST).getType() == XMaterial.LILY_PAD.parseMaterial();
} }
/** /**
@@ -425,7 +459,7 @@ public final class Utilities {
return player.getLocation().getBlock().isLiquid() return player.getLocation().getBlock().isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid()
|| (!VersionUtil.isBountifulUpdate() || (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.AQUATIC_UPDATE)
&& (player.getLocation().getBlock().getType() == XMaterial.KELP_PLANT.parseMaterial() && (player.getLocation().getBlock().getType() == XMaterial.KELP_PLANT.parseMaterial()
|| player.getLocation().getBlock().getRelative(BlockFace.UP) || player.getLocation().getBlock().getRelative(BlockFace.UP)
.getType() == XMaterial.KELP_PLANT.parseMaterial() .getType() == XMaterial.KELP_PLANT.parseMaterial()
@@ -454,6 +488,26 @@ public final class Utilities {
|| player.getLocation().getBlock().getRelative(BlockFace.SOUTH_WEST).isLiquid(); || player.getLocation().getBlock().getRelative(BlockFace.SOUTH_WEST).isLiquid();
} }
/**
* Determine whether a location is near a liquid block
*
* @param location Location to check
* @return true if near liquid block
*/
public static boolean isNearWater(Location location) {
return location.getBlock().isLiquid()
|| location.getBlock().getRelative(BlockFace.UP).isLiquid()
|| location.getBlock().getRelative(BlockFace.DOWN).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 surrounded by liquid blocks * Determine whether a player is surrounded by liquid blocks
* *
@@ -462,8 +516,7 @@ public final class Utilities {
*/ */
public static boolean isSurroundedByWater(Player player) { public static boolean isSurroundedByWater(Player player) {
Location location = player.getLocation().clone().subtract(0, 0.1, 0); Location location = player.getLocation().clone().subtract(0, 0.1, 0);
return location.getBlock().isLiquid() return location.getBlock().isLiquid() && location.getBlock().getRelative(BlockFace.NORTH).isLiquid()
&& location.getBlock().getRelative(BlockFace.NORTH).isLiquid()
&& location.getBlock().getRelative(BlockFace.SOUTH).isLiquid() && location.getBlock().getRelative(BlockFace.SOUTH).isLiquid()
&& location.getBlock().getRelative(BlockFace.EAST).isLiquid() && location.getBlock().getRelative(BlockFace.EAST).isLiquid()
&& location.getBlock().getRelative(BlockFace.WEST).isLiquid() && location.getBlock().getRelative(BlockFace.WEST).isLiquid()
@@ -473,6 +526,32 @@ public final class Utilities {
&& location.getBlock().getRelative(BlockFace.SOUTH_WEST).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();
}
/** /**
* Determine whether a player is in a web * Determine whether a player is in a web
* *
@@ -480,9 +559,11 @@ 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() == COB_WEB return player.getLocation().getBlock().getType() == XMaterial.COBWEB.parseMaterial()
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == COB_WEB || player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == XMaterial.COBWEB
|| player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == COB_WEB; .parseMaterial()
|| player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == XMaterial.COBWEB
.parseMaterial();
} }
/** /**
@@ -501,6 +582,22 @@ public final class Utilities {
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.WEST)); || 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));
}
/** /**
* Determine whether a block is climbable * Determine whether a block is climbable
* *
@@ -678,6 +775,7 @@ public final class Utilities {
/** /**
* Rounds a float value to a scale * Rounds a float value to a scale
*
* @param value Value to round * @param value Value to round
* @param scale Scale * @param scale Scale
* @return rounded value * @return rounded value
@@ -688,6 +786,7 @@ public final class Utilities {
/** /**
* Rounds a double value to a scale * Rounds a double value to a scale
*
* @param value Value to round * @param value Value to round
* @param scale Scale * @param scale Scale
* @return rounded value * @return rounded value
@@ -697,12 +796,12 @@ public final class Utilities {
} }
public static int floor(double value) { public static int floor(double value) {
int rounded = (int) value; int rounded = (int) value;
return value < rounded ? rounded - 1 : rounded; return value < rounded ? rounded - 1 : rounded;
} }
public static boolean isHoneyBlock(Block block) { public static boolean isHoneyBlock(Block block) {
if (!VersionUtil.isOfVersion("v1_15")) { if (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.BEE_UPDATE)) {
return false; return false;
} }
return block.getType() == XMaterial.HONEY_BLOCK.parseMaterial(); return block.getType() == XMaterial.HONEY_BLOCK.parseMaterial();
@@ -711,242 +810,237 @@ public final class Utilities {
static { static {
// Start 1.8.8 // Start 1.8.8
if (VersionUtil.isBountifulUpdate()) { if (VersionUtil.isBountifulUpdate()) {
LILY_PAD = XMaterial.LILY_PAD.parseMaterial();
COB_WEB = XMaterial.COBWEB.parseMaterial();
IRON_BARS = XMaterial.IRON_BARS.parseMaterial();
// Start instant break materials // Start instant break materials
INSTANT_BREAK.add(XMaterial.COMPARATOR.parseMaterial()); INSTANT_BREAK.add(XMaterial.COMPARATOR.parseMaterial());
INSTANT_BREAK.add(XMaterial.REPEATER.parseMaterial()); INSTANT_BREAK.add(XMaterial.REPEATER.parseMaterial());
INSTANT_BREAK.add(Material.TORCH); INSTANT_BREAK.add(XMaterial.TORCH.parseMaterial());
INSTANT_BREAK.add(XMaterial.REDSTONE_TORCH.parseMaterial()); INSTANT_BREAK.add(XMaterial.REDSTONE_TORCH.parseMaterial());
INSTANT_BREAK.add(Material.REDSTONE_WIRE); INSTANT_BREAK.add(XMaterial.REDSTONE_WIRE.parseMaterial());
INSTANT_BREAK.add(Material.TRIPWIRE); INSTANT_BREAK.add(XMaterial.TRIPWIRE.parseMaterial());
INSTANT_BREAK.add(Material.TRIPWIRE_HOOK); INSTANT_BREAK.add(XMaterial.TRIPWIRE_HOOK.parseMaterial());
INSTANT_BREAK.add(Material.FIRE); INSTANT_BREAK.add(XMaterial.FIRE.parseMaterial());
INSTANT_BREAK.add(Material.FLOWER_POT); INSTANT_BREAK.add(XMaterial.FLOWER_POT.parseMaterial());
INSTANT_BREAK.add(Material.TNT); INSTANT_BREAK.add(XMaterial.TNT.parseMaterial());
INSTANT_BREAK.add(Material.SLIME_BLOCK); INSTANT_BREAK.add(XMaterial.SLIME_BLOCK.parseMaterial());
INSTANT_BREAK.add(Material.CARROT); INSTANT_BREAK.add(XMaterial.CARROT.parseMaterial());
INSTANT_BREAK.add(Material.DEAD_BUSH); INSTANT_BREAK.add(XMaterial.DEAD_BUSH.parseMaterial());
INSTANT_BREAK.add(Material.GRASS); INSTANT_BREAK.add(XMaterial.GRASS.parseMaterial());
INSTANT_BREAK.add(XMaterial.TALL_GRASS.parseMaterial()); INSTANT_BREAK.add(XMaterial.TALL_GRASS.parseMaterial());
INSTANT_BREAK.add(LILY_PAD); INSTANT_BREAK.add(XMaterial.LILY_PAD.parseMaterial());
INSTANT_BREAK.add(Material.MELON_STEM); INSTANT_BREAK.add(XMaterial.MELON_STEM.parseMaterial());
INSTANT_BREAK.add(Material.MELON_STEM); INSTANT_BREAK.add(XMaterial.MELON_STEM.parseMaterial());
INSTANT_BREAK.add(Material.BROWN_MUSHROOM); INSTANT_BREAK.add(XMaterial.BROWN_MUSHROOM.parseMaterial());
INSTANT_BREAK.add(Material.RED_MUSHROOM); INSTANT_BREAK.add(XMaterial.RED_MUSHROOM.parseMaterial());
INSTANT_BREAK.add(XMaterial.NETHER_WART.parseMaterial()); INSTANT_BREAK.add(XMaterial.NETHER_WART.parseMaterial());
INSTANT_BREAK.add(Material.POTATO); INSTANT_BREAK.add(XMaterial.POTATO.parseMaterial());
INSTANT_BREAK.add(Material.PUMPKIN_STEM); INSTANT_BREAK.add(XMaterial.PUMPKIN_STEM.parseMaterial());
INSTANT_BREAK.add(Material.PUMPKIN_STEM); INSTANT_BREAK.add(XMaterial.PUMPKIN_STEM.parseMaterial());
INSTANT_BREAK.add(XMaterial.OAK_SAPLING.parseMaterial()); INSTANT_BREAK.add(XMaterial.OAK_SAPLING.parseMaterial());
INSTANT_BREAK.add(Material.SUGAR_CANE); INSTANT_BREAK.add(XMaterial.SUGAR_CANE.parseMaterial());
INSTANT_BREAK.add(Material.WHEAT); INSTANT_BREAK.add(XMaterial.WHEAT.parseMaterial());
// End instant break materials // End instant break materials
// Start food // Start food
FOOD.add(Material.APPLE); FOOD.add(XMaterial.APPLE.parseMaterial());
FOOD.add(Material.BAKED_POTATO); FOOD.add(XMaterial.BAKED_POTATO.parseMaterial());
FOOD.add(Material.BREAD); FOOD.add(XMaterial.BREAD.parseMaterial());
FOOD.add(Material.CAKE); FOOD.add(XMaterial.CAKE.parseMaterial());
FOOD.add(Material.CARROT); FOOD.add(XMaterial.CARROT.parseMaterial());
FOOD.add(Material.COOKED_CHICKEN); FOOD.add(XMaterial.COOKED_CHICKEN.parseMaterial());
FOOD.add(XMaterial.COOKED_COD.parseMaterial()); FOOD.add(XMaterial.COOKED_COD.parseMaterial());
FOOD.add(XMaterial.COD.parseMaterial()); FOOD.add(XMaterial.COD.parseMaterial());
FOOD.add(Material.COOKED_MUTTON); FOOD.add(XMaterial.COOKED_MUTTON.parseMaterial());
FOOD.add(XMaterial.COOKED_PORKCHOP.parseMaterial()); FOOD.add(XMaterial.COOKED_PORKCHOP.parseMaterial());
FOOD.add(Material.COOKED_RABBIT); FOOD.add(XMaterial.COOKED_RABBIT.parseMaterial());
FOOD.add(Material.COOKIE); FOOD.add(XMaterial.COOKIE.parseMaterial());
FOOD.add(Material.GOLDEN_APPLE); FOOD.add(XMaterial.GOLDEN_APPLE.parseMaterial());
FOOD.add(Material.GOLDEN_CARROT); FOOD.add(XMaterial.GOLDEN_CARROT.parseMaterial());
FOOD.add(XMaterial.GLISTERING_MELON_SLICE.parseMaterial()); FOOD.add(XMaterial.GLISTERING_MELON_SLICE.parseMaterial());
FOOD.add(XMaterial.MUSHROOM_STEM.parseMaterial()); FOOD.add(XMaterial.MUSHROOM_STEM.parseMaterial());
FOOD.add(Material.POISONOUS_POTATO); FOOD.add(XMaterial.POISONOUS_POTATO.parseMaterial());
FOOD.add(Material.POTATO); FOOD.add(XMaterial.POTATO.parseMaterial());
FOOD.add(Material.PUMPKIN_PIE); FOOD.add(XMaterial.PUMPKIN_PIE.parseMaterial());
FOOD.add(Material.RABBIT_STEW); FOOD.add(XMaterial.RABBIT_STEW.parseMaterial());
FOOD.add(Material.COOKED_BEEF); FOOD.add(XMaterial.COOKED_BEEF.parseMaterial());
FOOD.add(XMaterial.BEEF.parseMaterial()); FOOD.add(XMaterial.BEEF.parseMaterial());
FOOD.add(Material.COOKED_CHICKEN); FOOD.add(XMaterial.COOKED_CHICKEN.parseMaterial());
FOOD.add(XMaterial.CHICKEN.parseMaterial()); FOOD.add(XMaterial.CHICKEN.parseMaterial());
FOOD.add(Material.MUTTON); FOOD.add(XMaterial.MUTTON.parseMaterial());
FOOD.add(XMaterial.PORKCHOP.parseMaterial()); FOOD.add(XMaterial.PORKCHOP.parseMaterial());
FOOD.add(Material.RABBIT); FOOD.add(XMaterial.RABBIT.parseMaterial());
FOOD.add(Material.COOKED_RABBIT); FOOD.add(XMaterial.COOKED_RABBIT.parseMaterial());
FOOD.add(Material.ROTTEN_FLESH); FOOD.add(XMaterial.ROTTEN_FLESH.parseMaterial());
FOOD.add(Material.SPIDER_EYE); FOOD.add(XMaterial.SPIDER_EYE.parseMaterial());
// Start combos // Start combos
COMBO.put(Material.SHEARS, XMaterial.WHITE_WOOL.parseMaterial()); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.WHITE_WOOL.parseMaterial());
COMBO.put(Material.IRON_SWORD, COB_WEB); COMBO.put(XMaterial.IRON_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
COMBO.put(Material.DIAMOND_SWORD, COB_WEB); COMBO.put(XMaterial.DIAMOND_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
COMBO.put(Material.STONE_SWORD, COB_WEB); COMBO.put(XMaterial.STONE_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
COMBO.put(XMaterial.WOODEN_SWORD.parseMaterial(), COB_WEB); COMBO.put(XMaterial.WOODEN_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
// End combos // End combos
// Start climbable // Start climbable
CLIMBABLE.add(Material.VINE); CLIMBABLE.add(XMaterial.VINE.parseMaterial());
CLIMBABLE.add(Material.LADDER); CLIMBABLE.add(XMaterial.LADDER.parseMaterial());
CLIMBABLE.add(Material.WATER); CLIMBABLE.add(XMaterial.WATER.parseMaterial());
// End climbable // End climbable
} }
// End 1.8.8 // End 1.8.8
// Start other version // Start other version
else { else {
LILY_PAD = Material.LILY_PAD; MinecraftVersion currentVersion = MinecraftVersion.getCurrentVersion();
COB_WEB = Material.COBWEB;
IRON_BARS = Material.IRON_BARS;
// Start instant break materials // Start instant break materials
INSTANT_BREAK.add(Material.COMPARATOR); INSTANT_BREAK.add(XMaterial.COMPARATOR.parseMaterial());
INSTANT_BREAK.add(Material.REPEATER); INSTANT_BREAK.add(XMaterial.REPEATER.parseMaterial());
INSTANT_BREAK.add(Material.TORCH); INSTANT_BREAK.add(XMaterial.TORCH.parseMaterial());
INSTANT_BREAK.add(Material.REDSTONE_TORCH); INSTANT_BREAK.add(XMaterial.REDSTONE_TORCH.parseMaterial());
INSTANT_BREAK.add(Material.REDSTONE_WIRE); INSTANT_BREAK.add(XMaterial.REDSTONE_WIRE.parseMaterial());
INSTANT_BREAK.add(Material.TRIPWIRE); INSTANT_BREAK.add(XMaterial.TRIPWIRE.parseMaterial());
INSTANT_BREAK.add(Material.TRIPWIRE_HOOK); INSTANT_BREAK.add(XMaterial.TRIPWIRE_HOOK.parseMaterial());
INSTANT_BREAK.add(Material.FIRE); INSTANT_BREAK.add(XMaterial.FIRE.parseMaterial());
INSTANT_BREAK.add(Material.FLOWER_POT); INSTANT_BREAK.add(XMaterial.FLOWER_POT.parseMaterial());
INSTANT_BREAK.add(Material.INFESTED_CHISELED_STONE_BRICKS); INSTANT_BREAK.add(XMaterial.INFESTED_CHISELED_STONE_BRICKS.parseMaterial());
INSTANT_BREAK.add(Material.INFESTED_COBBLESTONE); INSTANT_BREAK.add(XMaterial.INFESTED_COBBLESTONE.parseMaterial());
INSTANT_BREAK.add(Material.INFESTED_CRACKED_STONE_BRICKS); INSTANT_BREAK.add(XMaterial.INFESTED_CRACKED_STONE_BRICKS.parseMaterial());
INSTANT_BREAK.add(Material.INFESTED_MOSSY_STONE_BRICKS); INSTANT_BREAK.add(XMaterial.INFESTED_MOSSY_STONE_BRICKS.parseMaterial());
INSTANT_BREAK.add(Material.INFESTED_STONE); INSTANT_BREAK.add(XMaterial.INFESTED_STONE.parseMaterial());
INSTANT_BREAK.add(Material.INFESTED_STONE_BRICKS); INSTANT_BREAK.add(XMaterial.INFESTED_STONE_BRICKS.parseMaterial());
INSTANT_BREAK.add(Material.TNT); INSTANT_BREAK.add(XMaterial.TNT.parseMaterial());
INSTANT_BREAK.add(Material.SLIME_BLOCK); INSTANT_BREAK.add(XMaterial.SLIME_BLOCK.parseMaterial());
INSTANT_BREAK.add(Material.CARROTS); INSTANT_BREAK.add(XMaterial.CARROTS.parseMaterial());
INSTANT_BREAK.add(Material.DEAD_BUSH); INSTANT_BREAK.add(XMaterial.DEAD_BUSH.parseMaterial());
INSTANT_BREAK.add(Material.FERN); INSTANT_BREAK.add(XMaterial.FERN.parseMaterial());
INSTANT_BREAK.add(Material.LARGE_FERN); INSTANT_BREAK.add(XMaterial.LARGE_FERN.parseMaterial());
INSTANT_BREAK.add(Material.CHORUS_FLOWER); INSTANT_BREAK.add(XMaterial.CHORUS_FLOWER.parseMaterial());
INSTANT_BREAK.add(Material.SUNFLOWER); INSTANT_BREAK.add(XMaterial.SUNFLOWER.parseMaterial());
INSTANT_BREAK.add(Material.LILY_PAD); INSTANT_BREAK.add(XMaterial.LILY_PAD.parseMaterial());
INSTANT_BREAK.add(Material.MELON_STEM); INSTANT_BREAK.add(XMaterial.MELON_STEM.parseMaterial());
INSTANT_BREAK.add(Material.ATTACHED_MELON_STEM); INSTANT_BREAK.add(XMaterial.ATTACHED_MELON_STEM.parseMaterial());
INSTANT_BREAK.add(Material.BROWN_MUSHROOM); INSTANT_BREAK.add(XMaterial.BROWN_MUSHROOM.parseMaterial());
INSTANT_BREAK.add(Material.RED_MUSHROOM); INSTANT_BREAK.add(XMaterial.RED_MUSHROOM.parseMaterial());
INSTANT_BREAK.add(Material.NETHER_WART); INSTANT_BREAK.add(XMaterial.NETHER_WART.parseMaterial());
INSTANT_BREAK.add(Material.POTATOES); INSTANT_BREAK.add(XMaterial.POTATOES.parseMaterial());
INSTANT_BREAK.add(Material.PUMPKIN_STEM); INSTANT_BREAK.add(XMaterial.PUMPKIN_STEM.parseMaterial());
INSTANT_BREAK.add(Material.ATTACHED_PUMPKIN_STEM); INSTANT_BREAK.add(XMaterial.ATTACHED_PUMPKIN_STEM.parseMaterial());
INSTANT_BREAK.add(Material.ACACIA_SAPLING); INSTANT_BREAK.add(XMaterial.ACACIA_SAPLING.parseMaterial());
INSTANT_BREAK.add(Material.BIRCH_SAPLING); INSTANT_BREAK.add(XMaterial.BIRCH_SAPLING.parseMaterial());
INSTANT_BREAK.add(Material.DARK_OAK_SAPLING); INSTANT_BREAK.add(XMaterial.DARK_OAK_SAPLING.parseMaterial());
INSTANT_BREAK.add(Material.JUNGLE_SAPLING); INSTANT_BREAK.add(XMaterial.JUNGLE_SAPLING.parseMaterial());
INSTANT_BREAK.add(Material.OAK_SAPLING); INSTANT_BREAK.add(XMaterial.OAK_SAPLING.parseMaterial());
INSTANT_BREAK.add(Material.SPRUCE_SAPLING); INSTANT_BREAK.add(XMaterial.SPRUCE_SAPLING.parseMaterial());
INSTANT_BREAK.add(Material.SUGAR_CANE); INSTANT_BREAK.add(XMaterial.SUGAR_CANE.parseMaterial());
INSTANT_BREAK.add(Material.TALL_GRASS); INSTANT_BREAK.add(XMaterial.TALL_GRASS.parseMaterial());
INSTANT_BREAK.add(Material.TALL_SEAGRASS); INSTANT_BREAK.add(XMaterial.TALL_SEAGRASS.parseMaterial());
INSTANT_BREAK.add(Material.WHEAT); INSTANT_BREAK.add(XMaterial.WHEAT.parseMaterial());
// Start 1.14 objects // Start 1.14 objects
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15") || VersionUtil.isOfVersion("v1_16")) { if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
INSTANT_BREAK.add(Material.BAMBOO_SAPLING); INSTANT_BREAK.add(XMaterial.BAMBOO_SAPLING.parseMaterial());
INSTANT_BREAK.add(Material.CORNFLOWER); INSTANT_BREAK.add(XMaterial.CORNFLOWER.parseMaterial());
} }
// End 1.14 objects // End 1.14 objects
// Start 1.15 objects // Start 1.15 objects
if (VersionUtil.isOfVersion("v1_15") || VersionUtil.isOfVersion("v1_16")) { if (currentVersion.isAtLeast(MinecraftVersion.BEE_UPDATE)) {
INSTANT_BREAK.add(Material.HONEY_BLOCK); INSTANT_BREAK.add(XMaterial.HONEY_BLOCK.parseMaterial());
} }
// End 1.15 objects // End 1.15 objects
// End instant break materials // End instant break materials
// Start food // Start food
FOOD.add(Material.APPLE); FOOD.add(XMaterial.APPLE.parseMaterial());
FOOD.add(Material.BAKED_POTATO); FOOD.add(XMaterial.BAKED_POTATO.parseMaterial());
FOOD.add(Material.BEETROOT); FOOD.add(XMaterial.BEETROOT.parseMaterial());
FOOD.add(Material.BEETROOT_SOUP); FOOD.add(XMaterial.BEETROOT_SOUP.parseMaterial());
FOOD.add(Material.BREAD); FOOD.add(XMaterial.BREAD.parseMaterial());
FOOD.add(Material.CAKE); FOOD.add(XMaterial.CAKE.parseMaterial());
FOOD.add(Material.CARROT); FOOD.add(XMaterial.CARROT.parseMaterial());
FOOD.add(Material.CHORUS_FRUIT); FOOD.add(XMaterial.CHORUS_FRUIT.parseMaterial());
FOOD.add(Material.COOKED_BEEF); FOOD.add(XMaterial.COOKED_BEEF.parseMaterial());
FOOD.add(Material.COOKED_CHICKEN); FOOD.add(XMaterial.COOKED_CHICKEN.parseMaterial());
FOOD.add(Material.COOKED_COD); FOOD.add(XMaterial.COOKED_COD.parseMaterial());
FOOD.add(Material.COOKED_MUTTON); FOOD.add(XMaterial.COOKED_MUTTON.parseMaterial());
FOOD.add(Material.COOKED_PORKCHOP); FOOD.add(XMaterial.COOKED_PORKCHOP.parseMaterial());
FOOD.add(Material.COOKED_RABBIT); FOOD.add(XMaterial.COOKED_RABBIT.parseMaterial());
FOOD.add(Material.COOKED_SALMON); FOOD.add(XMaterial.COOKED_SALMON.parseMaterial());
FOOD.add(Material.COOKIE); FOOD.add(XMaterial.COOKIE.parseMaterial());
FOOD.add(Material.DRIED_KELP); FOOD.add(XMaterial.DRIED_KELP.parseMaterial());
FOOD.add(Material.ENCHANTED_GOLDEN_APPLE); FOOD.add(XMaterial.ENCHANTED_GOLDEN_APPLE.parseMaterial());
FOOD.add(Material.GOLDEN_APPLE); FOOD.add(XMaterial.GOLDEN_APPLE.parseMaterial());
FOOD.add(Material.GOLDEN_CARROT); FOOD.add(XMaterial.GOLDEN_CARROT.parseMaterial());
FOOD.add(Material.MELON_SLICE); FOOD.add(XMaterial.MELON_SLICE.parseMaterial());
FOOD.add(Material.MUSHROOM_STEW); FOOD.add(XMaterial.MUSHROOM_STEW.parseMaterial());
FOOD.add(Material.POISONOUS_POTATO); FOOD.add(XMaterial.POISONOUS_POTATO.parseMaterial());
FOOD.add(Material.POTATO); FOOD.add(XMaterial.POTATO.parseMaterial());
FOOD.add(Material.PUFFERFISH); FOOD.add(XMaterial.PUFFERFISH.parseMaterial());
FOOD.add(Material.PUMPKIN_PIE); FOOD.add(XMaterial.PUMPKIN_PIE.parseMaterial());
FOOD.add(Material.RABBIT_STEW); FOOD.add(XMaterial.RABBIT_STEW.parseMaterial());
FOOD.add(Material.BEEF); FOOD.add(XMaterial.BEEF.parseMaterial());
FOOD.add(Material.CHICKEN); FOOD.add(XMaterial.CHICKEN.parseMaterial());
FOOD.add(Material.COD); FOOD.add(XMaterial.COD.parseMaterial());
FOOD.add(Material.MUTTON); FOOD.add(XMaterial.MUTTON.parseMaterial());
FOOD.add(Material.PORKCHOP); FOOD.add(XMaterial.PORKCHOP.parseMaterial());
FOOD.add(Material.RABBIT); FOOD.add(XMaterial.RABBIT.parseMaterial());
FOOD.add(Material.SALMON); FOOD.add(XMaterial.SALMON.parseMaterial());
FOOD.add(Material.ROTTEN_FLESH); FOOD.add(XMaterial.ROTTEN_FLESH.parseMaterial());
FOOD.add(Material.SPIDER_EYE); FOOD.add(XMaterial.SPIDER_EYE.parseMaterial());
FOOD.add(Material.TROPICAL_FISH); FOOD.add(XMaterial.TROPICAL_FISH.parseMaterial());
// Start 1.14 objects // Start 1.14 objects
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15") || VersionUtil.isOfVersion("v1_16")) { if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
FOOD.add(Material.SUSPICIOUS_STEW); FOOD.add(XMaterial.SUSPICIOUS_STEW.parseMaterial());
FOOD.add(Material.SWEET_BERRIES); FOOD.add(XMaterial.SWEET_BERRIES.parseMaterial());
} }
// End 1.14 objects // End 1.14 objects
// Start 1.15 objects // Start 1.15 objects
if (VersionUtil.isOfVersion("v1_15") || VersionUtil.isOfVersion("v1_16")) { if (currentVersion.isAtLeast(MinecraftVersion.BEE_UPDATE)) {
FOOD.add(Material.HONEY_BOTTLE); FOOD.add(XMaterial.HONEY_BOTTLE.parseMaterial());
} }
// End 1.15 objects // End 1.15 objects
// End food // End food
// Start combos // Start combos
COMBO.put(Material.SHEARS, Material.BLACK_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.BLACK_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.BLUE_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.BLUE_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.BROWN_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.BROWN_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.CYAN_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.CYAN_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.GRAY_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.GRAY_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.GREEN_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.GREEN_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.LIGHT_BLUE_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.LIGHT_BLUE_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.LIGHT_GRAY_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.LIGHT_GRAY_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.LIME_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.LIME_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.MAGENTA_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.MAGENTA_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.MAGENTA_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.MAGENTA_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.ORANGE_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.ORANGE_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.PINK_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.PINK_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.PURPLE_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.PURPLE_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.RED_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.RED_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.WHITE_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.WHITE_WOOL.parseMaterial());
COMBO.put(Material.SHEARS, Material.YELLOW_WOOL); COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.YELLOW_WOOL.parseMaterial());
COMBO.put(Material.IRON_SWORD, Material.COBWEB); COMBO.put(XMaterial.IRON_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
COMBO.put(Material.DIAMOND_SWORD, Material.COBWEB); COMBO.put(XMaterial.DIAMOND_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
COMBO.put(Material.STONE_SWORD, Material.COBWEB); COMBO.put(XMaterial.STONE_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
COMBO.put(Material.WOODEN_SWORD, Material.COBWEB); COMBO.put(XMaterial.WOODEN_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
// End combos // End combos
// Start climbable // Start climbable
CLIMBABLE.add(Material.VINE); CLIMBABLE.add(XMaterial.VINE.parseMaterial());
CLIMBABLE.add(Material.LADDER); CLIMBABLE.add(XMaterial.LADDER.parseMaterial());
CLIMBABLE.add(Material.WATER); CLIMBABLE.add(XMaterial.WATER.parseMaterial());
// Start 1.14 objects // Start 1.14 objects
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15") || VersionUtil.isOfVersion("v1_16")) { if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
CLIMBABLE.add(Material.SCAFFOLDING); CLIMBABLE.add(XMaterial.SCAFFOLDING.parseMaterial());
CLIMBABLE.add(XMaterial.SWEET_BERRY_BUSH.parseMaterial());
} }
// End 1.14 objects // End 1.14 objects
// Start 1.16 objects // Start 1.16 objects
if (VersionUtil.isOfVersion("v1_16")) { if (currentVersion.isAtLeast(MinecraftVersion.NETHER_UPDATE)) {
CLIMBABLE.add(XMaterial.TWISTING_VINES.parseMaterial()); CLIMBABLE.add(XMaterial.TWISTING_VINES.parseMaterial());
CLIMBABLE.add(XMaterial.TWISTING_VINES_PLANT.parseMaterial()); CLIMBABLE.add(XMaterial.TWISTING_VINES_PLANT.parseMaterial());
CLIMBABLE.add(XMaterial.WEEPING_VINES.parseMaterial()); CLIMBABLE.add(XMaterial.WEEPING_VINES.parseMaterial());
CLIMBABLE.add(XMaterial.TWISTING_VINES_PLANT.parseMaterial()); CLIMBABLE.add(XMaterial.WEEPING_VINES_PLANT.parseMaterial());
} }
// End 1.16 objects // End 1.16 objects
// End climbable // End climbable
@@ -16,7 +16,6 @@
* 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.util; package com.rammelkast.anticheatreloaded.util;
import java.util.Arrays; import java.util.Arrays;
@@ -36,8 +35,8 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
public class VersionUtil { public class VersionUtil {
private static final List<String> SUPPORTED_VERSIONS = Arrays public static final MinecraftVersion CURRENT_VERSION;
.asList(new String[] { "v1_16", "v1_15", "v1_14", "v1_13", "v1_8_R3" }); private static final List<String> SUPPORTED_VERSIONS;
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];
@@ -74,15 +73,8 @@ public class VersionUtil {
|| AntiCheatReloaded.getManager().getBackend().justLevitated(player); || AntiCheatReloaded.getManager().getBackend().justLevitated(player);
} }
public static boolean isRiptiding(Player player) {
if (isBountifulUpdate()) {
return false;
}
return player.isRiptiding();
}
public static boolean isSlowFalling(Player player) { public static boolean isSlowFalling(Player player) {
if (isBountifulUpdate()) { if (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
return false; return false;
} }
return player.hasPotionEffect(PotionEffectType.SLOW_FALLING); return player.hasPotionEffect(PotionEffectType.SLOW_FALLING);
@@ -114,7 +106,7 @@ public class VersionUtil {
} }
public static Block getTargetBlock(Player player, int distance) { public static Block getTargetBlock(Player player, int distance) {
if (isBountifulUpdate()) { if (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
return player.getTargetBlock((Set<Material>) null, distance); return player.getTargetBlock((Set<Material>) null, distance);
} }
return player.getTargetBlockExact(distance); return player.getTargetBlockExact(distance);
@@ -134,4 +126,29 @@ public class VersionUtil {
return effect.getType().equals(PotionEffectType.LEVITATION); 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();
}
} }
@@ -22,12 +22,26 @@
*/ */
package com.rammelkast.anticheatreloaded.util; package com.rammelkast.anticheatreloaded.util;
import com.google.common.base.Enums; import java.util.ArrayList;
import com.google.common.cache.Cache; import java.util.Arrays;
import com.google.common.cache.CacheBuilder; import java.util.Collection;
import com.google.common.collect.ImmutableMap; import java.util.Collections;
import com.google.common.collect.ImmutableSet; import java.util.EnumMap;
import com.google.common.collect.Maps; import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.apache.commons.lang.WordUtils; import org.apache.commons.lang.WordUtils;
@@ -35,19 +49,18 @@ import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import javax.annotation.Nonnull; import com.google.common.base.Enums;
import javax.annotation.Nullable; import com.google.common.cache.Cache;
import java.util.*; import com.google.common.cache.CacheBuilder;
import java.util.concurrent.TimeUnit; import com.google.common.cache.CacheLoader;
import java.util.regex.Pattern; import com.google.common.cache.LoadingCache;
/** /**
* <b>XMaterial</b> - Data Values/Pre-flattening<br> * <b>XMaterial</b> - Data Values/Pre-flattening<br>
* 1.13 and above as priority. * 1.13 and above as priority.
* <p> * <p>
* This class is mainly designed to support ItemStacks. * This class is mainly designed to support ItemStacks. If you want to use it on blocks, you'll have to use
* If you want to use it on blocks you'll have to * <a href="https://github.com/CryptoMorin/XSeries/blob/master/src/main/java/com/cryptomorin/xseries/XBlock.java">XBlock</a>
* use <a href="https://github.com/CryptoMorin/XSeries/blob/master/XBlock.java">XBlock</a>
* <p> * <p>
* Pre-flattening: https://minecraft.gamepedia.com/Java_Edition_data_values/Pre-flattening * Pre-flattening: https://minecraft.gamepedia.com/Java_Edition_data_values/Pre-flattening
* Materials: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html * Materials: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
@@ -55,9 +68,13 @@ import java.util.regex.Pattern;
* Material IDs: https://minecraft-ids.grahamedgecombe.com/ * Material IDs: https://minecraft-ids.grahamedgecombe.com/
* Material Source Code: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Material.java * Material Source Code: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Material.java
* XMaterial v1: https://www.spigotmc.org/threads/329630/ * XMaterial v1: https://www.spigotmc.org/threads/329630/
* <p>
* This class will throw a "unsupported material" error if someone tries to use an item with an invalid data value which can only happen in 1.12 servers and below.
* To get an invalid item, (aka <a href="https://minecraft.fandom.com/wiki/Missing_Texture_Block">Missing Texture Block</a>) you can use the command
* <b>/give @p minecraft:dirt 1 10</b> where 1 is the item amount, and 10 is the data value. The material {@link #DIRT} with a data value of {@code 10} doesn't exist.
* *
* @author Crypto Morin * @author Crypto Morin
* @version 5.0.1 * @version 6.0.2
* @see Material * @see Material
* @see ItemStack * @see ItemStack
*/ */
@@ -72,11 +89,11 @@ public enum XMaterial {
ACACIA_PLANKS(4, "WOOD"), ACACIA_PLANKS(4, "WOOD"),
ACACIA_PRESSURE_PLATE("WOOD_PLATE"), ACACIA_PRESSURE_PLATE("WOOD_PLATE"),
ACACIA_SAPLING(4, "SAPLING"), ACACIA_SAPLING(4, "SAPLING"),
ACACIA_SIGN("SIGN"), ACACIA_SIGN("SIGN_POST", "SIGN"),
ACACIA_SLAB(4, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"), ACACIA_SLAB(4, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
ACACIA_STAIRS, ACACIA_STAIRS,
ACACIA_TRAPDOOR("TRAP_DOOR"), ACACIA_TRAPDOOR("TRAP_DOOR"),
ACACIA_WALL_SIGN("SIGN_POST", "WALL_SIGN"), ACACIA_WALL_SIGN("WALL_SIGN"),
ACACIA_WOOD("LOG_2"), ACACIA_WOOD("LOG_2"),
ACTIVATOR_RAIL, ACTIVATOR_RAIL,
/** /**
@@ -132,22 +149,22 @@ public enum XMaterial {
BIRCH_PLANKS(2, "WOOD"), BIRCH_PLANKS(2, "WOOD"),
BIRCH_PRESSURE_PLATE("WOOD_PLATE"), BIRCH_PRESSURE_PLATE("WOOD_PLATE"),
BIRCH_SAPLING(2, "SAPLING"), BIRCH_SAPLING(2, "SAPLING"),
BIRCH_SIGN("SIGN"), BIRCH_SIGN("SIGN_POST", "SIGN"),
BIRCH_SLAB(2, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"), BIRCH_SLAB(2, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
BIRCH_STAIRS("BIRCH_WOOD_STAIRS"), BIRCH_STAIRS("BIRCH_WOOD_STAIRS"),
BIRCH_TRAPDOOR("TRAP_DOOR"), BIRCH_TRAPDOOR("TRAP_DOOR"),
BIRCH_WALL_SIGN("SIGN_POST", "WALL_SIGN"), BIRCH_WALL_SIGN("WALL_SIGN"),
BIRCH_WOOD(2, "LOG"), BIRCH_WOOD(2, "LOG"),
BLACKSTONE("1.16"), BLACKSTONE("1.16"),
BLACKSTONE_SLAB("1.16"), BLACKSTONE_SLAB("1.16"),
BLACKSTONE_STAIRS("1.16"), BLACKSTONE_STAIRS("1.16"),
BLACKSTONE_WALL("1.16"), BLACKSTONE_WALL("1.16"),
BLACK_BANNER("BANNER", "STANDING_BANNER"), BLACK_BANNER("STANDING_BANNER", "BANNER"),
BLACK_BED(15, "BED_BLOCK", "BED"), BLACK_BED(15, "BED_BLOCK", "BED"),
BLACK_CARPET(15, "CARPET"), BLACK_CARPET(15, "CARPET"),
BLACK_CONCRETE(15, "CONCRETE"), BLACK_CONCRETE(15, "CONCRETE"),
BLACK_CONCRETE_POWDER(15, "CONCRETE_POWDER"), BLACK_CONCRETE_POWDER(15, "CONCRETE_POWDER"),
BLACK_DYE("1.14", "INK_SACK"), BLACK_DYE("1.14", "INK_SACK", "INK_SAC"),
BLACK_GLAZED_TERRACOTTA(15, "1.12", "HARD_CLAY", "STAINED_CLAY", "BLACK_TERRACOTTA"), BLACK_GLAZED_TERRACOTTA(15, "1.12", "HARD_CLAY", "STAINED_CLAY", "BLACK_TERRACOTTA"),
BLACK_SHULKER_BOX, BLACK_SHULKER_BOX,
BLACK_STAINED_GLASS(15, "STAINED_GLASS"), BLACK_STAINED_GLASS(15, "STAINED_GLASS"),
@@ -159,7 +176,7 @@ public enum XMaterial {
BLAZE_POWDER, BLAZE_POWDER,
BLAZE_ROD, BLAZE_ROD,
BLAZE_SPAWN_EGG(61, "MONSTER_EGG"), BLAZE_SPAWN_EGG(61, "MONSTER_EGG"),
BLUE_BANNER(4, "BANNER", "STANDING_BANNER"), BLUE_BANNER(4, "STANDING_BANNER", "BANNER"),
BLUE_BED(11, "BED_BLOCK", "BED"), BLUE_BED(11, "BED_BLOCK", "BED"),
BLUE_CARPET(11, "CARPET"), BLUE_CARPET(11, "CARPET"),
BLUE_CONCRETE(11, "CONCRETE"), BLUE_CONCRETE(11, "CONCRETE"),
@@ -192,7 +209,7 @@ public enum XMaterial {
BRICK_SLAB(4, "STEP"), BRICK_SLAB(4, "STEP"),
BRICK_STAIRS, BRICK_STAIRS,
BRICK_WALL, BRICK_WALL,
BROWN_BANNER(3, "BANNER", "STANDING_BANNER"), BROWN_BANNER(3, "STANDING_BANNER", "BANNER"),
BROWN_BED(12, "BED_BLOCK", "BED"), BROWN_BED(12, "BED_BLOCK", "BED"),
BROWN_CARPET(12, "CARPET"), BROWN_CARPET(12, "CARPET"),
BROWN_CONCRETE(12, "CONCRETE"), BROWN_CONCRETE(12, "CONCRETE"),
@@ -309,19 +326,19 @@ public enum XMaterial {
CRIMSON_PLANKS("1.16"), CRIMSON_PLANKS("1.16"),
CRIMSON_PRESSURE_PLATE("1.16"), CRIMSON_PRESSURE_PLATE("1.16"),
CRIMSON_ROOTS("1.16"), CRIMSON_ROOTS("1.16"),
CRIMSON_SIGN("1.16"), CRIMSON_SIGN("1.16", "SIGN_POST"),
CRIMSON_SLAB("1.16"), CRIMSON_SLAB("1.16"),
CRIMSON_STAIRS("1.16"), CRIMSON_STAIRS("1.16"),
CRIMSON_STEM("1.16"), CRIMSON_STEM("1.16"),
CRIMSON_TRAPDOOR("1.16"), CRIMSON_TRAPDOOR("1.16"),
CRIMSON_WALL_SIGN("1.16"), CRIMSON_WALL_SIGN("1.16", "WALL_SIGN"),
CROSSBOW, CROSSBOW,
CRYING_OBSIDIAN("1.16"), CRYING_OBSIDIAN("1.16"),
CUT_RED_SANDSTONE("1.13"), CUT_RED_SANDSTONE("1.13"),
CUT_RED_SANDSTONE_SLAB("STONE_SLAB2"), CUT_RED_SANDSTONE_SLAB("STONE_SLAB2"),
CUT_SANDSTONE("1.13"), CUT_SANDSTONE("1.13"),
CUT_SANDSTONE_SLAB("STEP"), CUT_SANDSTONE_SLAB("STEP"),
CYAN_BANNER(6, "BANNER", "STANDING_BANNER"), CYAN_BANNER(6, "STANDING_BANNER", "BANNER"),
CYAN_BED(9, "BED_BLOCK", "BED"), CYAN_BED(9, "BED_BLOCK", "BED"),
CYAN_CARPET(9, "CARPET"), CYAN_CARPET(9, "CARPET"),
CYAN_CONCRETE(9, "CONCRETE"), CYAN_CONCRETE(9, "CONCRETE"),
@@ -346,11 +363,11 @@ public enum XMaterial {
DARK_OAK_PLANKS(5, "WOOD"), DARK_OAK_PLANKS(5, "WOOD"),
DARK_OAK_PRESSURE_PLATE("WOOD_PLATE"), DARK_OAK_PRESSURE_PLATE("WOOD_PLATE"),
DARK_OAK_SAPLING(5, "SAPLING"), DARK_OAK_SAPLING(5, "SAPLING"),
DARK_OAK_SIGN("SIGN"), DARK_OAK_SIGN("SIGN_POST", "SIGN"),
DARK_OAK_SLAB(5, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"), DARK_OAK_SLAB(5, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
DARK_OAK_STAIRS, DARK_OAK_STAIRS,
DARK_OAK_TRAPDOOR("TRAP_DOOR"), DARK_OAK_TRAPDOOR("TRAP_DOOR"),
DARK_OAK_WALL_SIGN("SIGN_POST", "WALL_SIGN"), DARK_OAK_WALL_SIGN("WALL_SIGN"),
DARK_OAK_WOOD(1, "LOG", "LOG_2"), DARK_OAK_WOOD(1, "LOG", "LOG_2"),
DARK_PRISMARINE(1, "PRISMARINE"), DARK_PRISMARINE(1, "PRISMARINE"),
DARK_PRISMARINE_SLAB("1.13"), DARK_PRISMARINE_SLAB("1.13"),
@@ -437,7 +454,7 @@ public enum XMaterial {
FARMLAND("SOIL"), FARMLAND("SOIL"),
FEATHER, FEATHER,
FERMENTED_SPIDER_EYE, FERMENTED_SPIDER_EYE,
FERN(1, "LONG_GRASS"), FERN(2, "LONG_GRASS"),
/** /**
* For some reasons filled map items are really special. * For some reasons filled map items are really special.
* Their data value starts from 0 and every time a player * Their data value starts from 0 and every time a player
@@ -467,6 +484,7 @@ public enum XMaterial {
FURNACE_MINECART("POWERED_MINECART"), FURNACE_MINECART("POWERED_MINECART"),
GHAST_SPAWN_EGG(56, "MONSTER_EGG"), GHAST_SPAWN_EGG(56, "MONSTER_EGG"),
GHAST_TEAR, GHAST_TEAR,
GILDED_BLACKSTONE("1.16"),
GLASS, GLASS,
GLASS_BOTTLE, GLASS_BOTTLE,
GLASS_PANE("THIN_GLASS"), GLASS_PANE("THIN_GLASS"),
@@ -494,11 +512,11 @@ public enum XMaterial {
GRANITE_SLAB, GRANITE_SLAB,
GRANITE_STAIRS, GRANITE_STAIRS,
GRANITE_WALL, GRANITE_WALL,
GRASS, GRASS(1, "LONG_GRASS"),
GRASS_BLOCK("GRASS"), GRASS_BLOCK("GRASS"),
GRASS_PATH, GRASS_PATH,
GRAVEL, GRAVEL,
GRAY_BANNER(8, "BANNER", "STANDING_BANNER"), GRAY_BANNER(8, "STANDING_BANNER", "BANNER"),
GRAY_BED(7, "BED_BLOCK", "BED"), GRAY_BED(7, "BED_BLOCK", "BED"),
GRAY_CARPET(7, "CARPET"), GRAY_CARPET(7, "CARPET"),
GRAY_CONCRETE(7, "CONCRETE"), GRAY_CONCRETE(7, "CONCRETE"),
@@ -511,7 +529,7 @@ public enum XMaterial {
GRAY_TERRACOTTA(7, "HARD_CLAY", "STAINED_CLAY"), GRAY_TERRACOTTA(7, "HARD_CLAY", "STAINED_CLAY"),
GRAY_WALL_BANNER(8, "WALL_BANNER"), GRAY_WALL_BANNER(8, "WALL_BANNER"),
GRAY_WOOL(7, "WOOL"), GRAY_WOOL(7, "WOOL"),
GREEN_BANNER(2, "BANNER", "STANDING_BANNER"), GREEN_BANNER(2, "STANDING_BANNER", "BANNER"),
GREEN_BED(13, "BED_BLOCK", "BED"), GREEN_BED(13, "BED_BLOCK", "BED"),
GREEN_CARPET(13, "CARPET"), GREEN_CARPET(13, "CARPET"),
GREEN_CONCRETE(13, "CONCRETE"), GREEN_CONCRETE(13, "CONCRETE"),
@@ -550,6 +568,11 @@ public enum XMaterial {
INFESTED_MOSSY_STONE_BRICKS(3, "MONSTER_EGGS"), INFESTED_MOSSY_STONE_BRICKS(3, "MONSTER_EGGS"),
INFESTED_STONE("MONSTER_EGGS"), INFESTED_STONE("MONSTER_EGGS"),
INFESTED_STONE_BRICKS(2, "MONSTER_EGGS", "SMOOTH_BRICK"), INFESTED_STONE_BRICKS(2, "MONSTER_EGGS", "SMOOTH_BRICK"),
/**
* We will only add "INK_SAC" for {@link #BLACK_DYE} since it's
* the only material (linked with this material) that is added
* after 1.13, which means it can use both INK_SACK and INK_SAC.
*/
INK_SAC("INK_SACK"), INK_SAC("INK_SACK"),
IRON_AXE, IRON_AXE,
IRON_BARS("IRON_FENCE"), IRON_BARS("IRON_FENCE"),
@@ -582,11 +605,11 @@ public enum XMaterial {
JUNGLE_PLANKS(3, "WOOD"), JUNGLE_PLANKS(3, "WOOD"),
JUNGLE_PRESSURE_PLATE("WOOD_PLATE"), JUNGLE_PRESSURE_PLATE("WOOD_PLATE"),
JUNGLE_SAPLING(3, "SAPLING"), JUNGLE_SAPLING(3, "SAPLING"),
JUNGLE_SIGN("SIGN"), JUNGLE_SIGN("SIGN_POST", "SIGN"),
JUNGLE_SLAB(3, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"), JUNGLE_SLAB(3, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
JUNGLE_STAIRS("JUNGLE_WOOD_STAIRS"), JUNGLE_STAIRS("JUNGLE_WOOD_STAIRS"),
JUNGLE_TRAPDOOR("TRAP_DOOR"), JUNGLE_TRAPDOOR("TRAP_DOOR"),
JUNGLE_WALL_SIGN("SIGN_POST", "WALL_SIGN"), JUNGLE_WALL_SIGN("WALL_SIGN"),
JUNGLE_WOOD(3, "LOG"), JUNGLE_WOOD(3, "LOG"),
KELP("1.13"), KELP("1.13"),
KELP_PLANT("1.13"), KELP_PLANT("1.13"),
@@ -608,7 +631,7 @@ public enum XMaterial {
LEATHER_LEGGINGS, LEATHER_LEGGINGS,
LECTERN("1.14", "BOOKSHELF", ""), LECTERN("1.14", "BOOKSHELF", ""),
LEVER, LEVER,
LIGHT_BLUE_BANNER(12, "BANNER", "STANDING_BANNER"), LIGHT_BLUE_BANNER(12, "STANDING_BANNER", "BANNER"),
LIGHT_BLUE_BED(3, "BED_BLOCK", "BED"), LIGHT_BLUE_BED(3, "BED_BLOCK", "BED"),
LIGHT_BLUE_CARPET(3, "CARPET"), LIGHT_BLUE_CARPET(3, "CARPET"),
LIGHT_BLUE_CONCRETE(3, "CONCRETE"), LIGHT_BLUE_CONCRETE(3, "CONCRETE"),
@@ -619,9 +642,9 @@ public enum XMaterial {
LIGHT_BLUE_STAINED_GLASS(3, "STAINED_GLASS"), LIGHT_BLUE_STAINED_GLASS(3, "STAINED_GLASS"),
LIGHT_BLUE_STAINED_GLASS_PANE(3, "THIN_GLASS", "STAINED_GLASS_PANE"), LIGHT_BLUE_STAINED_GLASS_PANE(3, "THIN_GLASS", "STAINED_GLASS_PANE"),
LIGHT_BLUE_TERRACOTTA(3, "STAINED_CLAY"), LIGHT_BLUE_TERRACOTTA(3, "STAINED_CLAY"),
LIGHT_BLUE_WALL_BANNER(12, "WALL_BANNER", "BANNER", "STANDING_BANNER"), LIGHT_BLUE_WALL_BANNER(12, "WALL_BANNER", "STANDING_BANNER", "BANNER"),
LIGHT_BLUE_WOOL(3, "WOOL"), LIGHT_BLUE_WOOL(3, "WOOL"),
LIGHT_GRAY_BANNER(7, "BANNER", "STANDING_BANNER"), LIGHT_GRAY_BANNER(7, "STANDING_BANNER", "BANNER"),
LIGHT_GRAY_BED(8, "BED_BLOCK", "BED"), LIGHT_GRAY_BED(8, "BED_BLOCK", "BED"),
LIGHT_GRAY_CARPET(8, "CARPET"), LIGHT_GRAY_CARPET(8, "CARPET"),
LIGHT_GRAY_CONCRETE(8, "CONCRETE"), LIGHT_GRAY_CONCRETE(8, "CONCRETE"),
@@ -642,7 +665,7 @@ public enum XMaterial {
LILAC(1, "DOUBLE_PLANT"), LILAC(1, "DOUBLE_PLANT"),
LILY_OF_THE_VALLEY(15, "1.14", "WHITE_DYE", ""), LILY_OF_THE_VALLEY(15, "1.14", "WHITE_DYE", ""),
LILY_PAD("WATER_LILY"), LILY_PAD("WATER_LILY"),
LIME_BANNER(10, "BANNER", "STANDING_BANNER"), LIME_BANNER(10, "STANDING_BANNER", "BANNER"),
LIME_BED(5, "BED_BLOCK", "BED"), LIME_BED(5, "BED_BLOCK", "BED"),
LIME_CARPET(5, "CARPET"), LIME_CARPET(5, "CARPET"),
LIME_CONCRETE(5, "CONCRETE"), LIME_CONCRETE(5, "CONCRETE"),
@@ -659,7 +682,7 @@ public enum XMaterial {
LLAMA_SPAWN_EGG(103, "MONSTER_EGG"), LLAMA_SPAWN_EGG(103, "MONSTER_EGG"),
LODESTONE("1.16"), LODESTONE("1.16"),
LOOM("1.14"), LOOM("1.14"),
MAGENTA_BANNER(13, "BANNER", "STANDING_BANNER"), MAGENTA_BANNER(13, "STANDING_BANNER", "BANNER"),
MAGENTA_BED(2, "BED_BLOCK", "BED"), MAGENTA_BED(2, "BED_BLOCK", "BED"),
MAGENTA_CARPET(2, "CARPET"), MAGENTA_CARPET(2, "CARPET"),
MAGENTA_CONCRETE(2, "CONCRETE"), MAGENTA_CONCRETE(2, "CONCRETE"),
@@ -711,6 +734,7 @@ public enum XMaterial {
MUSIC_DISC_FAR("RECORD_6"), MUSIC_DISC_FAR("RECORD_6"),
MUSIC_DISC_MALL("RECORD_7"), MUSIC_DISC_MALL("RECORD_7"),
MUSIC_DISC_MELLOHI("RECORD_8"), MUSIC_DISC_MELLOHI("RECORD_8"),
MUSIC_DISC_PIGSTEP("1.16"),
MUSIC_DISC_STAL("RECORD_9"), MUSIC_DISC_STAL("RECORD_9"),
MUSIC_DISC_STRAD("RECORD_10"), MUSIC_DISC_STRAD("RECORD_10"),
MUSIC_DISC_WAIT("RECORD_11"), MUSIC_DISC_WAIT("RECORD_11"),
@@ -761,16 +785,16 @@ public enum XMaterial {
OAK_PLANKS("WOOD"), OAK_PLANKS("WOOD"),
OAK_PRESSURE_PLATE("WOOD_PLATE"), OAK_PRESSURE_PLATE("WOOD_PLATE"),
OAK_SAPLING("SAPLING"), OAK_SAPLING("SAPLING"),
OAK_SIGN("SIGN"), OAK_SIGN("SIGN_POST", "SIGN"),
OAK_SLAB("WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"), OAK_SLAB("WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
OAK_STAIRS("WOOD_STAIRS"), OAK_STAIRS("WOOD_STAIRS"),
OAK_TRAPDOOR("TRAP_DOOR"), OAK_TRAPDOOR("TRAP_DOOR"),
OAK_WALL_SIGN("SIGN_POST", "WALL_SIGN"), OAK_WALL_SIGN("WALL_SIGN"),
OAK_WOOD("LOG"), OAK_WOOD("LOG"),
OBSERVER, OBSERVER,
OBSIDIAN, OBSIDIAN,
OCELOT_SPAWN_EGG(98, "MONSTER_EGG"), OCELOT_SPAWN_EGG(98, "MONSTER_EGG"),
ORANGE_BANNER(14, "BANNER", "STANDING_BANNER"), ORANGE_BANNER(14, "STANDING_BANNER", "BANNER"),
ORANGE_BED(1, "BED_BLOCK", "BED"), ORANGE_BED(1, "BED_BLOCK", "BED"),
ORANGE_CARPET(1, "CARPET"), ORANGE_CARPET(1, "CARPET"),
ORANGE_CONCRETE(1, "CONCRETE"), ORANGE_CONCRETE(1, "CONCRETE"),
@@ -794,9 +818,11 @@ public enum XMaterial {
PETRIFIED_OAK_SLAB("WOOD_STEP"), PETRIFIED_OAK_SLAB("WOOD_STEP"),
PHANTOM_MEMBRANE("1.13"), PHANTOM_MEMBRANE("1.13"),
PHANTOM_SPAWN_EGG("1.13", "MONSTER_EGG", ""), PHANTOM_SPAWN_EGG("1.13", "MONSTER_EGG", ""),
PIGLIN_BANNER_PATTERN("1.16"),
PIGLIN_SPAWN_EGG(57, "MONSTER_EGG"),
PIG_SPAWN_EGG(90, "MONSTER_EGG"), PIG_SPAWN_EGG(90, "MONSTER_EGG"),
PILLAGER_SPAWN_EGG("1.14"), PILLAGER_SPAWN_EGG("1.14"),
PINK_BANNER(9, "BANNER", "STANDING_BANNER"), PINK_BANNER(9, "STANDING_BANNER", "BANNER"),
PINK_BED(6, "BED_BLOCK", "BED"), PINK_BED(6, "BED_BLOCK", "BED"),
PINK_CARPET(6, "CARPET"), PINK_CARPET(6, "CARPET"),
PINK_CONCRETE(6, "CONCRETE"), PINK_CONCRETE(6, "CONCRETE"),
@@ -852,6 +878,8 @@ public enum XMaterial {
POTTED_BROWN_MUSHROOM("FLOWER_POT"), POTTED_BROWN_MUSHROOM("FLOWER_POT"),
POTTED_CACTUS("FLOWER_POT"), POTTED_CACTUS("FLOWER_POT"),
POTTED_CORNFLOWER, POTTED_CORNFLOWER,
POTTED_CRIMSON_FUNGUS("1.16"),
POTTED_CRIMSON_ROOTS("1.16"),
POTTED_DANDELION("YELLOW_FLOWER", "FLOWER_POT"), POTTED_DANDELION("YELLOW_FLOWER", "FLOWER_POT"),
POTTED_DARK_OAK_SAPLING(5, "SAPLING", "FLOWER_POT"), POTTED_DARK_OAK_SAPLING(5, "SAPLING", "FLOWER_POT"),
POTTED_DEAD_BUSH("FLOWER_POT"), POTTED_DEAD_BUSH("FLOWER_POT"),
@@ -866,6 +894,8 @@ public enum XMaterial {
POTTED_RED_MUSHROOM("FLOWER_POT"), POTTED_RED_MUSHROOM("FLOWER_POT"),
POTTED_RED_TULIP(4, "RED_ROSE", "FLOWER_POT"), POTTED_RED_TULIP(4, "RED_ROSE", "FLOWER_POT"),
POTTED_SPRUCE_SAPLING(1, "SAPLING", "FLOWER_POT"), POTTED_SPRUCE_SAPLING(1, "SAPLING", "FLOWER_POT"),
POTTED_WARPED_FUNGUS("1.16"),
POTTED_WARPED_ROOTS("1.16"),
POTTED_WHITE_TULIP(6, "RED_ROSE", "FLOWER_POT"), POTTED_WHITE_TULIP(6, "RED_ROSE", "FLOWER_POT"),
POTTED_WITHER_ROSE, POTTED_WITHER_ROSE,
POWERED_RAIL, POWERED_RAIL,
@@ -885,7 +915,7 @@ public enum XMaterial {
PUMPKIN_PIE, PUMPKIN_PIE,
PUMPKIN_SEEDS, PUMPKIN_SEEDS,
PUMPKIN_STEM, PUMPKIN_STEM,
PURPLE_BANNER(5, "BANNER", "STANDING_BANNER"), PURPLE_BANNER(5, "STANDING_BANNER", "BANNER"),
PURPLE_BED(10, "BED_BLOCK", "BED"), PURPLE_BED(10, "BED_BLOCK", "BED"),
PURPLE_CARPET(10, "CARPET"), PURPLE_CARPET(10, "CARPET"),
PURPLE_CONCRETE(10, "CONCRETE"), PURPLE_CONCRETE(10, "CONCRETE"),
@@ -904,6 +934,7 @@ public enum XMaterial {
PURPUR_STAIRS, PURPUR_STAIRS,
QUARTZ, QUARTZ,
QUARTZ_BLOCK, QUARTZ_BLOCK,
QUARTZ_BRICKS("1.16"),
QUARTZ_PILLAR(2, "QUARTZ_BLOCK"), QUARTZ_PILLAR(2, "QUARTZ_BLOCK"),
QUARTZ_SLAB(7, "STEP"), QUARTZ_SLAB(7, "STEP"),
QUARTZ_STAIRS, QUARTZ_STAIRS,
@@ -932,7 +963,7 @@ public enum XMaterial {
REDSTONE_TORCH("REDSTONE_TORCH_OFF", "REDSTONE_TORCH_ON"), REDSTONE_TORCH("REDSTONE_TORCH_OFF", "REDSTONE_TORCH_ON"),
REDSTONE_WALL_TORCH, REDSTONE_WALL_TORCH,
REDSTONE_WIRE, REDSTONE_WIRE,
RED_BANNER(1, "BANNER", "STANDING_BANNER"), RED_BANNER(1, "STANDING_BANNER", "BANNER"),
/** /**
* Data value 14 or 0 * Data value 14 or 0
*/ */
@@ -940,10 +971,7 @@ public enum XMaterial {
RED_CARPET(14, "CARPET"), RED_CARPET(14, "CARPET"),
RED_CONCRETE(14, "CONCRETE"), RED_CONCRETE(14, "CONCRETE"),
RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"), RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"),
/** RED_DYE(1, "INK_SACK", "ROSE_RED"),
* Data value 0 or 1?
*/
RED_DYE(0, "INK_SACK", "ROSE_RED"),
RED_GLAZED_TERRACOTTA(14, "1.12", "HARD_CLAY", "STAINED_CLAY", "RED_TERRACOTTA"), RED_GLAZED_TERRACOTTA(14, "1.12", "HARD_CLAY", "STAINED_CLAY", "RED_TERRACOTTA"),
RED_MUSHROOM, RED_MUSHROOM,
RED_MUSHROOM_BLOCK("RED_MUSHROOM", "HUGE_MUSHROOM_2"), RED_MUSHROOM_BLOCK("RED_MUSHROOM", "HUGE_MUSHROOM_2"),
@@ -963,7 +991,7 @@ public enum XMaterial {
RED_TULIP(4, "RED_ROSE"), RED_TULIP(4, "RED_ROSE"),
RED_WALL_BANNER(1, "WALL_BANNER"), RED_WALL_BANNER(1, "WALL_BANNER"),
RED_WOOL(14, "WOOL"), RED_WOOL(14, "WOOL"),
REPEATER("DIODE", "DIODE_BLOCK_ON", "DIODE_BLOCK_OFF"), REPEATER("DIODE_BLOCK_ON", "DIODE_BLOCK_OFF", "DIODE"),
REPEATING_COMMAND_BLOCK("COMMAND", "COMMAND_REPEATING"), REPEATING_COMMAND_BLOCK("COMMAND", "COMMAND_REPEATING"),
RESPAWN_ANCHOR("1.16"), RESPAWN_ANCHOR("1.16"),
ROSE_BUSH(4, "DOUBLE_PLANT"), ROSE_BUSH(4, "DOUBLE_PLANT"),
@@ -1032,16 +1060,16 @@ public enum XMaterial {
SPRUCE_DOOR("SPRUCE_DOOR_ITEM", "SPRUCE_DOOR"), SPRUCE_DOOR("SPRUCE_DOOR_ITEM", "SPRUCE_DOOR"),
SPRUCE_FENCE, SPRUCE_FENCE,
SPRUCE_FENCE_GATE, SPRUCE_FENCE_GATE,
SPRUCE_LEAVES(1, "LEAVES"), SPRUCE_LEAVES(1, "LEAVES", "LEAVES_2"),
SPRUCE_LOG(1, "LOG"), SPRUCE_LOG(1, "LOG"),
SPRUCE_PLANKS(1, "WOOD"), SPRUCE_PLANKS(1, "WOOD"),
SPRUCE_PRESSURE_PLATE("WOOD_PLATE"), SPRUCE_PRESSURE_PLATE("WOOD_PLATE"),
SPRUCE_SAPLING(1, "SAPLING"), SPRUCE_SAPLING(1, "SAPLING"),
SPRUCE_SIGN("SIGN"), SPRUCE_SIGN("SIGN_POST", "SIGN"),
SPRUCE_SLAB(1, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"), SPRUCE_SLAB(1, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
SPRUCE_STAIRS("SPRUCE_WOOD_STAIRS"), SPRUCE_STAIRS("SPRUCE_WOOD_STAIRS"),
SPRUCE_TRAPDOOR("TRAP_DOOR"), SPRUCE_TRAPDOOR("TRAP_DOOR"),
SPRUCE_WALL_SIGN("SIGN_POST", "WALL_SIGN"), SPRUCE_WALL_SIGN("WALL_SIGN"),
SPRUCE_WOOD(1, "LOG"), SPRUCE_WOOD(1, "LOG"),
SQUID_SPAWN_EGG(94, "MONSTER_EGG"), SQUID_SPAWN_EGG(94, "MONSTER_EGG"),
STICK, STICK,
@@ -1062,6 +1090,7 @@ public enum XMaterial {
STONE_STAIRS, STONE_STAIRS,
STONE_SWORD, STONE_SWORD,
STRAY_SPAWN_EGG(6, "MONSTER_EGG"), STRAY_SPAWN_EGG(6, "MONSTER_EGG"),
STRIDER_SPAWN_EGG("1.16"),
STRING, STRING,
STRIPPED_ACACIA_LOG("LOG_2"), STRIPPED_ACACIA_LOG("LOG_2"),
STRIPPED_ACACIA_WOOD("LOG_2"), STRIPPED_ACACIA_WOOD("LOG_2"),
@@ -1144,12 +1173,12 @@ public enum XMaterial {
WARPED_PLANKS("1.16"), WARPED_PLANKS("1.16"),
WARPED_PRESSURE_PLATE("1.16"), WARPED_PRESSURE_PLATE("1.16"),
WARPED_ROOTS("1.16"), WARPED_ROOTS("1.16"),
WARPED_SIGN("1.16"), WARPED_SIGN("1.16", "SIGN_POST"),
WARPED_SLAB("1.16"), WARPED_SLAB("1.16"),
WARPED_STAIRS("1.16"), WARPED_STAIRS("1.16"),
WARPED_STEM("1.16"), WARPED_STEM("1.16"),
WARPED_TRAPDOOR("1.16"), WARPED_TRAPDOOR("1.16"),
WARPED_WALL_SIGN("1.16"), WARPED_WALL_SIGN("1.16", "WALL_SIGN"),
WARPED_WART_BLOCK("1.16"), WARPED_WART_BLOCK("1.16"),
/** /**
* This is used for blocks only. * This is used for blocks only.
@@ -1169,7 +1198,7 @@ public enum XMaterial {
*/ */
WHEAT("CROPS"), WHEAT("CROPS"),
WHEAT_SEEDS("SEEDS"), WHEAT_SEEDS("SEEDS"),
WHITE_BANNER(15, "BANNER", "STANDING_BANNER"), WHITE_BANNER(15, "STANDING_BANNER", "BANNER"),
WHITE_BED("BED_BLOCK", "BED"), WHITE_BED("BED_BLOCK", "BED"),
WHITE_CARPET("CARPET"), WHITE_CARPET("CARPET"),
WHITE_CONCRETE("CONCRETE"), WHITE_CONCRETE("CONCRETE"),
@@ -1196,7 +1225,7 @@ public enum XMaterial {
WOODEN_SWORD("WOOD_SWORD"), WOODEN_SWORD("WOOD_SWORD"),
WRITABLE_BOOK("BOOK_AND_QUILL"), WRITABLE_BOOK("BOOK_AND_QUILL"),
WRITTEN_BOOK, WRITTEN_BOOK,
YELLOW_BANNER(11, "BANNER", "STANDING_BANNER"), YELLOW_BANNER(11, "STANDING_BANNER", "BANNER"),
YELLOW_BED(4, "BED_BLOCK", "BED"), YELLOW_BED(4, "BED_BLOCK", "BED"),
YELLOW_CARPET(4, "CARPET"), YELLOW_CARPET(4, "CARPET"),
YELLOW_CONCRETE(4, "CONCRETE"), YELLOW_CONCRETE(4, "CONCRETE"),
@@ -1209,22 +1238,31 @@ public enum XMaterial {
YELLOW_TERRACOTTA(4, "HARD_CLAY", "STAINED_CLAY"), YELLOW_TERRACOTTA(4, "HARD_CLAY", "STAINED_CLAY"),
YELLOW_WALL_BANNER(11, "WALL_BANNER"), YELLOW_WALL_BANNER(11, "WALL_BANNER"),
YELLOW_WOOL(4, "WOOL"), YELLOW_WOOL(4, "WOOL"),
ZOGLIN_SPAWN_EGG("1.16"),
ZOMBIE_HEAD(2, "SKULL", "SKULL_ITEM"), ZOMBIE_HEAD(2, "SKULL", "SKULL_ITEM"),
ZOMBIE_HORSE_SPAWN_EGG(29, "MONSTER_EGG"), ZOMBIE_HORSE_SPAWN_EGG(29, "MONSTER_EGG"),
ZOMBIE_SPAWN_EGG(54, "MONSTER_EGG"), ZOMBIE_SPAWN_EGG(54, "MONSTER_EGG"),
ZOMBIE_VILLAGER_SPAWN_EGG(27, "MONSTER_EGG"), ZOMBIE_VILLAGER_SPAWN_EGG(27, "MONSTER_EGG"),
ZOMBIE_WALL_HEAD(2, "SKULL", "SKULL_ITEM"), ZOMBIE_WALL_HEAD(2, "SKULL", "SKULL_ITEM"),
PIGLIN_SPAWN_EGG(57, "MONSTER_EGG"),
ZOMBIFIED_PIGLIN_SPAWN_EGG(57, "MONSTER_EGG", "ZOMBIE_PIGMAN_SPAWN_EGG"); ZOMBIFIED_PIGLIN_SPAWN_EGG(57, "MONSTER_EGG", "ZOMBIE_PIGMAN_SPAWN_EGG");
/** /**
* An immutable cached set of {@link XMaterial#values()} to avoid allocating memory for * Cached set of {@link XMaterial#values()} to avoid allocating memory for
* calling the method every time. * calling the method every time.
* This list is unmodifiable.
* *
* @since 2.0.0 * @since 2.0.0
*/ */
public static final EnumSet<XMaterial> VALUES = EnumSet.allOf(XMaterial.class); public static final List<XMaterial> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
/**
* We don't want to use {@link Enums#getIfPresent(Class, String)} to avoid a few checks.
*
* @since 5.1.0
*/
private static final Map<String, XMaterial> NAMES = new HashMap<>();
/** /**
* A set of material names that can be damaged. * A set of material names that can be damaged.
* <p> * <p>
@@ -1233,13 +1271,13 @@ public enum XMaterial {
* *
* @since 1.0.0 * @since 1.0.0
*/ */
private static final ImmutableSet<String> DAMAGEABLE = ImmutableSet.of( private static final Set<String> DAMAGEABLE = new HashSet<>(Arrays.asList(
"HELMET", "CHESTPLATE", "LEGGINGS", "BOOTS", "HELMET", "CHESTPLATE", "LEGGINGS", "BOOTS",
"SWORD", "AXE", "PICKAXE", "SHOVEL", "HOE", "SWORD", "AXE", "PICKAXE", "SHOVEL", "HOE",
"ELYTRA", "TRIDENT", "HORSE_ARMOR", "BARDING", "ELYTRA", "TRIDENT", "HORSE_ARMOR", "BARDING",
"SHEARS", "FLINT_AND_STEEL", "BOW", "FISHING_ROD", "SHEARS", "FLINT_AND_STEEL", "BOW", "FISHING_ROD",
"CARROT_ON_A_STICK", "CARROT_STICK", "SPADE", "SHIELD" "CARROT_ON_A_STICK", "CARROT_STICK", "SPADE", "SHIELD"
); ));
/** /**
* <b>XMaterial Paradox (Duplication Check)</b> * <b>XMaterial Paradox (Duplication Check)</b>
* <p> * <p>
@@ -1250,29 +1288,25 @@ public enum XMaterial {
* *
* @since 3.0.0 * @since 3.0.0
*/ */
private static final ImmutableMap<XMaterial, XMaterial> duplicated = Maps.immutableEnumMap(ImmutableMap.<XMaterial, XMaterial>builder() private static final EnumMap<XMaterial, XMaterial> DUPLICATED = new EnumMap<XMaterial, XMaterial>(XMaterial.class);
.put(MELON, MELON_SLICE) /**
.put(CARROT, CARROTS) * Guava (Google Core Libraries for Java)'s cache for performance and timed caches.
.put(POTATO, POTATOES) * For strings that match a certain XMaterial. Mostly cached for configs.
.put(BEETROOT, BEETROOTS) *
.put(BROWN_MUSHROOM, BROWN_MUSHROOM_BLOCK) * @since 1.0.0
.put(BRICK, BRICKS) */
.put(NETHER_BRICK, NETHER_BRICKS) private static final Cache<String, XMaterial> NAME_CACHE = CacheBuilder.newBuilder()
.expireAfterAccess(15, TimeUnit.MINUTES)
// Illegal Elements .build();
// Since both 1.12 and 1.13 have <type>_DOOR XMaterial will use it /**
// for 1.12 to parse the material, but it needs <type>_DOOR_ITEM. * Guava (Google Core Libraries for Java)'s cache for performance and timed caches.
// We'll trick XMaterial into thinking this needs to be parsed * For XMaterials that are already parsed once.
// using the old methods. *
// These materials have their enum name added to the legacy list as well. * @since 3.0.0
.put(DARK_OAK_DOOR, DARK_OAK_DOOR) */
.put(ACACIA_DOOR, ACACIA_DOOR) private static final Cache<XMaterial, Optional<Material>> PARSED_CACHE = CacheBuilder.newBuilder()
.put(BIRCH_DOOR, BIRCH_DOOR) .expireAfterAccess(10, TimeUnit.MINUTES)
.put(JUNGLE_DOOR, JUNGLE_DOOR) .build();
.put(SPRUCE_DOOR, SPRUCE_DOOR)
.build()
);
/* /*
* A set of all the legacy names without duplicates. * A set of all the legacy names without duplicates.
* <p> * <p>
@@ -1287,36 +1321,24 @@ public enum XMaterial {
.filter(m -> m.charAt(1) == '.') .filter(m -> m.charAt(1) == '.')
.collect(Collectors.collectingAndThen(Collectors.toSet(), ImmutableSet::copyOf)); .collect(Collectors.collectingAndThen(Collectors.toSet(), ImmutableSet::copyOf));
*/ */
/** /**
* Guava (Google Core Libraries for Java)'s cache for performance and timed caches. * This is used for {@link #isOneOf(Collection)}
* For strings that match a certain XMaterial. Mostly cached for configs.
* *
* @since 1.0.0 * @since 3.4.0
*/ */
private static final Cache<String, XMaterial> NAME_CACHE = CacheBuilder.newBuilder() private static final LoadingCache<String, Pattern> CACHED_REGEX = CacheBuilder.newBuilder()
.softValues() .expireAfterAccess(1, TimeUnit.HOURS)
.expireAfterAccess(15, TimeUnit.MINUTES) .build(new CacheLoader<String, Pattern>() {
.build(); @Override
/** public Pattern load(@Nonnull String str) {
* Guava (Google Core Libraries for Java)'s cache for performance and timed caches. try {
* For XMaterials that are already parsed once. return Pattern.compile(str);
* } catch (PatternSyntaxException ex) {
* @since 3.0.0 ex.printStackTrace();
*/ return null;
private static final Cache<XMaterial, Optional<Material>> PARSED_CACHE = CacheBuilder.newBuilder() }
.softValues() }
.expireAfterAccess(10, TimeUnit.MINUTES) });
.concurrencyLevel(Runtime.getRuntime().availableProcessors())
.build();
/**
* Pre-compiled RegEx pattern.
* Include both replacements to avoid recreating string multiple times with multiple RegEx checks.
*
* @since 3.0.0
*/
private static final Pattern FORMAT_PATTERN = Pattern.compile("\\W+");
/** /**
* The current version of the server in the a form of a major version. * The current version of the server in the a form of a major version.
* *
@@ -1330,6 +1352,35 @@ public enum XMaterial {
* @since 3.0.0 * @since 3.0.0
*/ */
private static final boolean ISFLAT = supports(13); private static final boolean ISFLAT = supports(13);
static {
DUPLICATED.put(MELON, MELON_SLICE);
DUPLICATED.put(CARROT, CARROTS);
DUPLICATED.put(POTATO, POTATOES);
DUPLICATED.put(BEETROOT, BEETROOTS);
DUPLICATED.put(BROWN_MUSHROOM, BROWN_MUSHROOM_BLOCK);
DUPLICATED.put(BRICK, BRICKS);
DUPLICATED.put(NETHER_BRICK, NETHER_BRICKS);
// Illegal Elements
// Since both 1.12 and 1.13 have <type>_DOOR XMaterial will use it
// for 1.12 to parse the material, but it needs <type>_DOOR_ITEM.
// We'll trick XMaterial into thinking this needs to be parsed
// using the old methods.
// Some of these materials have their enum name added to the legacy list as well.
DUPLICATED.put(DARK_OAK_DOOR, DARK_OAK_DOOR);
DUPLICATED.put(ACACIA_DOOR, ACACIA_DOOR);
DUPLICATED.put(BIRCH_DOOR, BIRCH_DOOR);
DUPLICATED.put(JUNGLE_DOOR, JUNGLE_DOOR);
DUPLICATED.put(SPRUCE_DOOR, SPRUCE_DOOR);
DUPLICATED.put(CAULDRON, CAULDRON);
DUPLICATED.put(BREWING_STAND, BREWING_STAND);
}
static {
for (XMaterial material : VALUES) NAMES.put(material.name(), material);
}
/** /**
* The data value of this material https://minecraft.gamepedia.com/Java_Edition_data_values/Pre-flattening * The data value of this material https://minecraft.gamepedia.com/Java_Edition_data_values/Pre-flattening
* *
@@ -1382,7 +1433,7 @@ public enum XMaterial {
* An invocation of this method yields exactly the same result as the expression: * An invocation of this method yields exactly the same result as the expression:
* <p> * <p>
* <blockquote> * <blockquote>
* {@link #getVersion()} == 1.8 * !{@link #supports(int)} 9
* </blockquote> * </blockquote>
* *
* @since 2.0.0 * @since 2.0.0
@@ -1391,6 +1442,18 @@ public enum XMaterial {
return !supports(9); return !supports(9);
} }
/**
* Gets the {@link XMaterial} with this name without throwing an exception.
*
* @param name the name of the material.
* @return an optional that can be empty.
* @since 5.1.0
*/
@Nonnull
private static Optional<XMaterial> getIfPresent(@Nonnull String name) {
return Optional.ofNullable(NAMES.get(name));
}
/** /**
* The current version of the server. * The current version of the server.
* *
@@ -1442,8 +1505,9 @@ public enum XMaterial {
Validate.notEmpty(name, "Cannot check for null or empty material name"); Validate.notEmpty(name, "Cannot check for null or empty material name");
name = format(name); name = format(name);
for (XMaterial materials : VALUES) for (XMaterial materials : VALUES) {
if (materials.name().equals(name)) return true; if (materials.name().equals(name)) return true;
}
return false; return false;
} }
@@ -1463,13 +1527,13 @@ public enum XMaterial {
/** /**
* Parses material name and data value from the specified string. * Parses material name and data value from the specified string.
* The seperators are: <b>, or :</b> * The separator for the material name and its data value is {@code :}
* Spaces are allowed. Mostly used when getting materials from config for old school minecrafters. * Spaces are allowed. Mostly used when getting materials from config for old school minecrafters.
* <p> * <p>
* <b>Examples</b> * <b>Examples</b>
* <p><pre> * <p><pre>
* {@code INK_SACK:1 -> RED_DYE} * {@code INK_SACK:1 -> RED_DYE}
* {@code WOOL, 14 -> RED_WOOL} * {@code WOOL: 14 -> RED_WOOL}
* </pre> * </pre>
* *
* @param name the material string that consists of the material name, data and separator character. * @param name the material string that consists of the material name, data and separator character.
@@ -1477,14 +1541,17 @@ public enum XMaterial {
* @see #matchXMaterial(String) * @see #matchXMaterial(String)
* @since 3.0.0 * @since 3.0.0
*/ */
@Nonnull
private static Optional<XMaterial> matchXMaterialWithData(String name) { private static Optional<XMaterial> matchXMaterialWithData(String name) {
for (char separator : new char[]{',', ':'}) { int index = name.indexOf(':');
int index = name.indexOf(separator); if (index != -1) {
if (index == -1) continue;
String mat = format(name.substring(0, index)); String mat = format(name.substring(0, index));
byte data = Byte.parseByte(StringUtils.deleteWhitespace(name.substring(index + 1)));
return matchDefinedXMaterial(mat, data); try {
byte data = (byte) Integer.parseInt(StringUtils.deleteWhitespace(name.substring(index + 1)));
return matchDefinedXMaterial(mat, data);
} catch (NumberFormatException ignored) {
}
} }
return Optional.empty(); return Optional.empty();
@@ -1502,7 +1569,7 @@ public enum XMaterial {
public static XMaterial matchXMaterial(@Nonnull Material material) { public static XMaterial matchXMaterial(@Nonnull Material material) {
Objects.requireNonNull(material, "Cannot match null material"); Objects.requireNonNull(material, "Cannot match null material");
return matchDefinedXMaterial(material.name(), (byte) -1) return matchDefinedXMaterial(material.name(), (byte) -1)
.orElseThrow(() -> new IllegalArgumentException("Unsupported Material With No Bytes: " + material.name())); .orElseThrow(() -> new IllegalArgumentException("Unsupported material with no data value: " + material.name()));
} }
/** /**
@@ -1522,7 +1589,7 @@ public enum XMaterial {
byte data = (byte) (ISFLAT || isDamageable(material) ? 0 : item.getDurability()); byte data = (byte) (ISFLAT || isDamageable(material) ? 0 : item.getDurability());
return matchDefinedXMaterial(material, data) return matchDefinedXMaterial(material, data)
.orElseThrow(() -> new IllegalArgumentException("Unsupported Material: " + material + " (" + data + ')')); .orElseThrow(() -> new IllegalArgumentException("Unsupported material: " + material + " (" + data + ')'));
} }
/** /**
@@ -1544,11 +1611,12 @@ public enum XMaterial {
// Do basic number and boolean checks before accessing more complex enum stuff. // Do basic number and boolean checks before accessing more complex enum stuff.
// Maybe we can simplify (ISFLAT || !duplicated) with the (!ISFLAT && duplicated) under it to save a few nanoseconds? // Maybe we can simplify (ISFLAT || !duplicated) with the (!ISFLAT && duplicated) under it to save a few nanoseconds?
// if (!Boolean.valueOf(Boolean.getBoolean(Boolean.TRUE.toString())).equals(Boolean.FALSE.booleanValue())) return null; // if (!Boolean.valueOf(Boolean.getBoolean(Boolean.TRUE.toString())).equals(Boolean.FALSE.booleanValue())) return null;
if (data <= 0 && !duplicated) { Optional<XMaterial> xMaterial = null;
if (data <= 0 && (ISFLAT || !duplicated)) {
// Apparently the transform method is more efficient than toJavaUtil() // Apparently the transform method is more efficient than toJavaUtil()
// toJavaUtil isn't even supported in older versions. // toJavaUtil isn't even supported in older versions.
Optional<XMaterial> xMat = Enums.getIfPresent(XMaterial.class, name).transform(Optional::of).or(Optional.empty()); xMaterial = getIfPresent(name);
if (xMat.isPresent()) return xMat; if (xMaterial.isPresent()) return xMaterial;
} }
// XMaterial Paradox (Duplication Check) // XMaterial Paradox (Duplication Check)
@@ -1566,7 +1634,7 @@ public enum XMaterial {
// A solution for XMaterial Paradox. // A solution for XMaterial Paradox.
// Manually parses the duplicated materials to find the exact material based on the server version. // Manually parses the duplicated materials to find the exact material based on the server version.
// If ends with "S" -> Plural Form Material // If ends with "S" -> Plural Form Material
return Enums.getIfPresent(XMaterial.class, name).transform(Optional::of).or(Optional.empty()); return xMaterial == null ? getIfPresent(name) : xMaterial;
} }
return Optional.ofNullable(xMat); return Optional.ofNullable(xMat);
} }
@@ -1585,7 +1653,7 @@ public enum XMaterial {
*/ */
private static boolean isDuplicated(@Nonnull String name) { private static boolean isDuplicated(@Nonnull String name) {
// Don't use matchXMaterial() since this method is being called from matchXMaterial() itself and will cause a StackOverflowError. // Don't use matchXMaterial() since this method is being called from matchXMaterial() itself and will cause a StackOverflowError.
for (Map.Entry<XMaterial, XMaterial> duplicated : duplicated.entrySet()) { for (Map.Entry<XMaterial, XMaterial> duplicated : DUPLICATED.entrySet()) {
XMaterial material = duplicated.getKey(); XMaterial material = duplicated.getKey();
if (material.name().equals(name) || material.anyMatchLegacy(name)) return true; if (material.name().equals(name) || material.anyMatchLegacy(name)) return true;
} }
@@ -1614,16 +1682,41 @@ public enum XMaterial {
/** /**
* Attempts to build the string like an enum name. * Attempts to build the string like an enum name.
* Removes all the spaces, numbers and extra non-English characters. Also removes some config/in-game based strings. * Removes all the spaces, and extra non-English characters. Also removes some config/in-game based strings.
* While this method is hard to maintain, it's extremely efficient. It's approximately more than x5 times faster than
* the normal RegEx + String Methods approach for both formatted and unformatted material names.
* *
* @param name the material name to modify. * @param name the material name to modify.
* @return a Material enum name. * @return a Material enum name.
* @since 2.0.0 * @since 2.0.0
*/ */
@Nonnull @Nonnull
private static String format(@Nonnull String name) { protected static String format(@Nonnull String name) {
return FORMAT_PATTERN.matcher( int len = name.length();
name.trim().replace('-', '_').replace(' ', '_')).replaceAll("").toUpperCase(Locale.ENGLISH); char[] chs = new char[len];
int count = 0;
boolean appendUnderline = false;
for (int i = 0; i < len; ++i) {
char ch = name.charAt(i);
if (!appendUnderline && count != 0 && (ch == '-' || ch == ' ' || ch == '_') && chs[count] != '_') appendUnderline = true;
else {
boolean number = false;
// Old materials have numbers in them.
if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (number = (ch >= '0' && ch <= '9'))) {
if (appendUnderline) {
chs[count++] = '_';
appendUnderline = false;
}
if (number) chs[count++] = ch;
else chs[count++] = (char) (ch & 0x5f);
}
}
}
return new String(chs, 0, count);
} }
/** /**
@@ -1709,8 +1802,9 @@ public enum XMaterial {
*/ */
public static boolean isDamageable(@Nonnull String name) { public static boolean isDamageable(@Nonnull String name) {
Objects.requireNonNull(name, "Material name cannot be null"); Objects.requireNonNull(name, "Material name cannot be null");
for (String damageable : DAMAGEABLE) for (String damageable : DAMAGEABLE) {
if (name.contains(damageable)) return true; if (name.contains(damageable)) return true;
}
return false; return false;
} }
@@ -1750,32 +1844,31 @@ public enum XMaterial {
* <p> * <p>
* Want to learn RegEx? You can mess around in <a href="https://regexr.com/">RegExr</a> website. * Want to learn RegEx? You can mess around in <a href="https://regexr.com/">RegExr</a> website.
* *
* @param material the base material to match other materials with.
* @param materials the material names to check base material on. * @param materials the material names to check base material on.
* @return true if one of the given material names is similar to the base material. * @return true if one of the given material names is similar to the base material.
* @since 3.1.1 * @since 3.1.1
*/ */
public static boolean isOneOf(@Nonnull Material material, @Nullable List<String> materials) { public boolean isOneOf(@Nullable Collection<String> materials) {
if (materials == null || materials.isEmpty()) return false; if (materials == null || materials.isEmpty()) return false;
Objects.requireNonNull(material, "Cannot match materials with a null material"); String name = this.name();
String name = material.name();
for (String comp : materials) { for (String comp : materials) {
comp = comp.toUpperCase(); String checker = comp.toUpperCase(Locale.ENGLISH);
if (comp.startsWith("CONTAINS:")) { if (checker.startsWith("CONTAINS:")) {
comp = format(comp.substring(9)); comp = format(checker.substring(9));
if (name.contains(comp)) return true; if (name.contains(comp)) return true;
continue; continue;
} }
if (comp.startsWith("REGEX:")) { if (checker.startsWith("REGEX:")) {
comp = comp.substring(6); comp = comp.substring(6);
if (name.matches(comp)) return true; Pattern pattern = CACHED_REGEX.getUnchecked(comp);
if (pattern != null && pattern.matcher(name).matches()) return true;
continue; continue;
} }
// Direct Object Equals // Direct Object Equals
Optional<XMaterial> mat = matchXMaterial(comp); Optional<XMaterial> xMat = matchXMaterial(comp);
if (mat.isPresent() && mat.get().parseMaterial() == material) return true; if (xMat.isPresent() && xMat.get() == this) return true;
} }
return false; return false;
} }
@@ -1809,27 +1902,14 @@ public enum XMaterial {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public ItemStack setType(@Nonnull ItemStack item) { public ItemStack setType(@Nonnull ItemStack item) {
Objects.requireNonNull(item, "Cannot set material for null ItemStack"); Objects.requireNonNull(item, "Cannot set material for null ItemStack");
Material material = this.parseMaterial();
Objects.requireNonNull(material, "Unsupported material: " + this.name());
item.setType(this.parseMaterial()); item.setType(material);
if (!ISFLAT && !this.isDamageable()) item.setDurability(this.data); if (!ISFLAT && !this.isDamageable()) item.setDurability(this.data);
return item; return item;
} }
/**
* Checks if the list of given material names matches the given base material.
* Mostly used for configs.
*
* @param materials the material names to check base material on.
* @return true if one of the given material names is similar to the base material.
* @see #isOneOf(Material, List)
* @since 3.0.0
*/
public boolean isOneOf(@Nullable List<String> materials) {
Material material = this.parseMaterial();
if (material == null) return false;
return isOneOf(material, materials);
}
/** /**
* Checks if the given string matches any of this material's legacy material names. * Checks if the given string matches any of this material's legacy material names.
* All the values passed to this method will not be null or empty and are formatted correctly. * All the values passed to this method will not be null or empty and are formatted correctly.
@@ -1868,7 +1948,7 @@ public enum XMaterial {
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public int getId() { public int getId() {
if (this.data != 0 || (this.legacy.length != 0 && Integer.parseInt(this.legacy[0].substring(2)) >= 13)) return -1; if (this.data != 0 || (this.legacy.length != 0 && this.legacy[0].charAt(1) == '.' && Integer.parseInt(this.legacy[0].substring(2)) >= 13)) return -1;
Material material = this.parseMaterial(); Material material = this.parseMaterial();
return material == null ? -1 : material.getId(); return material == null ? -1 : material.getId();
} }
@@ -1881,7 +1961,7 @@ public enum XMaterial {
* @since 2.0.0 * @since 2.0.0
*/ */
public boolean isDuplicated() { public boolean isDuplicated() {
return duplicated.containsKey(this); return DUPLICATED.containsKey(this);
} }
/** /**
@@ -1984,7 +2064,8 @@ public enum XMaterial {
if (mat == null) mat = requestOldMaterial(suggest); if (mat == null) mat = requestOldMaterial(suggest);
} }
if (mat != null) PARSED_CACHE.put(this, Optional.ofNullable(mat)); Optional<Material> opt = Optional.ofNullable(mat);
PARSED_CACHE.put(this, opt);
return mat; return mat;
} }
+59 -48
View File
@@ -1,4 +1,7 @@
# AntiCheatReloaded checks configuration file # 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 # Flight check settings
# Checks if a player moves wrongly in the air # Checks if a player moves wrongly in the air
flight: flight:
@@ -15,7 +18,7 @@ flight:
accountForTpsDrops: 250 accountForTpsDrops: 250
# How many milliseconds to account for teleports # How many milliseconds to account for teleports
# Increase this is you debug 'had too little Y dropoff' after teleports # Increase this is you debug 'had too little Y dropoff' after teleports
accountForTeleports: 100 accountForTeleports: 400
# Checks for climbing behaviour in air # Checks for climbing behaviour in air
# Debugs as 'tried to climb air' # Debugs as 'tried to climb air'
airClimb: airClimb:
@@ -23,7 +26,7 @@ flight:
enabled: true enabled: true
# How many milliseconds to account for teleports # How many milliseconds to account for teleports
# Increase this is you debug 'tried to climb air' after teleports # Increase this is you debug 'tried to climb air' after teleports
accountForTeleports: 50 accountForTeleports: 300
# Checks if a player is faking it's ground status to fly # Checks if a player is faking it's ground status to fly
# Debugs as 'faked ground to fly' # Debugs as 'faked ground to fly'
groundFlight: groundFlight:
@@ -38,16 +41,14 @@ flight:
maxOffset: 0.005 maxOffset: 0.005
# How many milliseconds to account for teleports # How many milliseconds to account for teleports
# Increase this is you debug 'ignored gravity' after teleports # Increase this is you debug 'ignored gravity' after teleports
accountForTeleports: 100 accountForTeleports: 300
# Amount of illegal moves before flagging # Amount of illegal moves before flagging
vlBeforeFlag: 5 vlBeforeFlag: 5
# ElytraFly check settings # ElytraFly check settings
# Checks for illegal upward elytra movement # Checks for illegal upward elytra movement
elytrafly: elytrafly:
# Should this check be enabled? # Should this check be enabled?
enabled: true enabled: true
# Speed check settings # Speed check settings
# Checks if a player moves too fast # Checks if a player moves too fast
speed: speed:
@@ -60,7 +61,6 @@ speed:
baseLimit: 0.03125 baseLimit: 0.03125
# Prediction multiplier for custom walk speeds # Prediction multiplier for custom walk speeds
walkSpeedMultiplier: 1.4 walkSpeedMultiplier: 1.4
# Checks movement acceleration in the air # Checks movement acceleration in the air
# Debugs as 'exceeded acceleration limits' # Debugs as 'exceeded acceleration limits'
airAcceleration: airAcceleration:
@@ -70,7 +70,6 @@ speed:
baseLimit: 0.3725 baseLimit: 0.3725
# Limit multiplier for custom walk speeds # Limit multiplier for custom walk speeds
walkSpeedMultiplier: 1.4 walkSpeedMultiplier: 1.4
# Checks movement acceleration in the air # Checks movement acceleration in the air
# Debugs as 'had unexpected jumping behaviour' # Debugs as 'had unexpected jumping behaviour'
jumpBehaviour: jumpBehaviour:
@@ -78,7 +77,6 @@ speed:
enabled: true enabled: true
# Minimum movement distance needed to flag # Minimum movement distance needed to flag
minimumDistXZ: 0.42 minimumDistXZ: 0.42
# Checks movement speed on the ground # Checks movement speed on the ground
# Debugs as 'moved too fast on ground' # Debugs as 'moved too fast on ground'
groundSpeed: groundSpeed:
@@ -86,7 +84,6 @@ speed:
enabled: true enabled: true
# Initial speed limit value # Initial speed limit value
initialLimit: 0.34 initialLimit: 0.34
# Checks movement acceleration in the air # Checks movement acceleration in the air
# Debugs as 'exceeded vertical speed limit' # Debugs as 'exceeded vertical speed limit'
verticalSpeed: verticalSpeed:
@@ -94,12 +91,20 @@ speed:
enabled: true enabled: true
# Extra compensation when moving off a ladder up a slab # Extra compensation when moving off a ladder up a slab
climbableCompensation: 0.04 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: 300
# Maximum angle change when moving in air
maxAngleChange: 0.5
# Minimum movement distance for the strafe check to be active
minActivationDistance: 0.04
# WaterWalk check settings # WaterWalk check settings
# Checks if a player is walking on water # Checks if a player is walking on water
waterwalk: waterwalk:
# Should this check be enabled?
enabled: true
# Checks for vanilla water walking/jumping # Checks for vanilla water walking/jumping
# Debugs as 'tried to walk on water' # Debugs as 'tried to walk on water'
walk: walk:
@@ -109,21 +114,20 @@ waterwalk:
# This combats false positives, while giving hackers not much leniency # This combats false positives, while giving hackers not much leniency
minimumDistXZ: 0.092 minimumDistXZ: 0.092
# Checks for small hops on top of water # Checks for small hops on top of water
# Debugs as 'tried to lunge on water' # Debugs as 'tried to hop on water'
hop: hop:
# Should this part of the check be enabled? # Should this part of the check be enabled?
enabled: true enabled: true
# Maximum lunge Y motion to flag # Maximum lunge Y motion to flag
maxMotionY: 0.10 maxMotionY: 0.1
# Checks for small lunges in water # Checks for small lunges in water
# Debugs as 'tried to walk on water' # Debugs as 'tried to lunge in water'
lunge: lunge:
# Should this part of the check be enabled? # Should this part of the check be enabled?
enabled: true enabled: true
# Minimum xz distance before flagging # Minimum xz distance before flagging
# This combats false positives, while giving hackers not much leniency # This combats false positives, while giving hackers not much leniency
minimumDistXZ: 0.098 minimumDistXZ: 0.098
# FastLadder check settings # FastLadder check settings
# Checks if a player moves too fast on a ladder # Checks if a player moves too fast on a ladder
fastladder: fastladder:
@@ -135,7 +139,13 @@ fastladder:
speedDownMax: 0.15 speedDownMax: 0.15
# Amount of illegal ladder moves before flagging # Amount of illegal ladder moves before flagging
vlBeforeFlag: 3 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 # KillAura check settings
# Checks if the player uses a form of kill aura # Checks if the player uses a form of kill aura
killaura: killaura:
@@ -158,7 +168,6 @@ killaura:
pingCompensation: 0.0025 pingCompensation: 0.0025
# The multiplier of extra compensation for velocity # The multiplier of extra compensation for velocity
velocityMultiplier: 1.2 velocityMultiplier: 1.2
# Checks if the target it within a players viewing angle # Checks if the target it within a players viewing angle
# Debugs as 'tried to attack from an illegal angle' # Debugs as 'tried to attack from an illegal angle'
angle: angle:
@@ -168,7 +177,17 @@ killaura:
maxDifference: 50 maxDifference: 50
# Amount of illegally angled hits before flagging # Amount of illegally angled hits before flagging
vlBeforeFlag: 3 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 # Aimbot check settings
# Checks if the player is sending aimbot-like movements # Checks if the player is sending aimbot-like movements
aimbot: aimbot:
@@ -178,23 +197,20 @@ aimbot:
minYaw: 30 minYaw: 30
# Maximum yaw difference when repeated # Maximum yaw difference when repeated
maxYaw: 355 maxYaw: 355
# Criticals check settings # Criticals check settings
# Checks if the player tries to do a crit without needed conditions # Checks if the player tries to do a crit without needed conditions
criticals: criticals:
# Should this check be enabled? # Should this check be enabled?
enabled: true enabled: true
# Velocity check settings # Velocity check settings
# Checks if the player ignores knockback # Checks if the player ignores knockback
velocity: velocity:
# Should this check be enabled? # Should this check be enabled?
enabled: true enabled: true
# Minimum percentage of the given knockback a player has to meet # Minimum percentage of the given knockback a player has to meet
minimumPercentage: 98 minimumPercentage: 75
# Amount of low-velocity moments before flagging # Amount of low-velocity moments before flagging
vlBeforeFlag: 2 vlBeforeFlag: 2
# FastPlace check settings # FastPlace check settings
# Checks if the player places blocks too fast # Checks if the player places blocks too fast
fastplace: fastplace:
@@ -203,12 +219,11 @@ fastplace:
# Minimum time in milliseconds between block places # Minimum time in milliseconds between block places
minimumTime: 50 minimumTime: 50
# Amount of fastplace-moments before flagging a survival player # Amount of fastplace-moments before flagging a survival player
vlBeforeFlagSurvival: 2 vlBeforeFlagSurvival: 3
# Amount of fastplace-moments before flagging a creative player # Amount of fastplace-moments before flagging a creative player
vlBeforeFlagCreative: 3 vlBeforeFlagCreative: 4
# Amount of time in milliseconds to prevent a player from placing blocks after flagging # Amount of time in milliseconds to prevent a player from placing blocks after flagging
blockPlacementTime: 1000 blockPlacementTime: 1000
# IllegalInteract check settings # IllegalInteract check settings
# Checks if the player is using, placing or breaking blocks from illegal angles # Checks if the player is using, placing or breaking blocks from illegal angles
illegalinteract: illegalinteract:
@@ -237,7 +252,6 @@ illegalinteract:
pingCompensation: 0.0045 pingCompensation: 0.0045
# The multiplier of extra compensation for velocity # The multiplier of extra compensation for velocity
velocityMultiplier: 1.5 velocityMultiplier: 1.5
# BadPackets check settings # BadPackets check settings
# Checks for illegal packets # Checks for illegal packets
badpackets: badpackets:
@@ -247,7 +261,6 @@ badpackets:
minimumTps: 17.5 minimumTps: 17.5
# Maximum distance a player can move between packets # Maximum distance a player can move between packets
maxDistance: 25.0 maxDistance: 25.0
# MorePackets check settings # MorePackets check settings
# Checks for an extra amount of packets and modified game timers # Checks for an extra amount of packets and modified game timers
morepackets: morepackets:
@@ -256,18 +269,17 @@ morepackets:
# Minimum server TPS needed for MorePackets to be active # Minimum server TPS needed for MorePackets to be active
minimumTps: 17.5 minimumTps: 17.5
# Maximum amount of lag compensation a player can acquire (50ms = 1 tick) # Maximum amount of lag compensation a player can acquire (50ms = 1 tick)
minimumClamp: 500 minimumClamp: 1000
# The amount of milliseconds offset between packets before flagging (50ms = 1 tick) # The amount of milliseconds offset between packets before flagging (50ms = 1 tick)
triggerBalance: 100 triggerBalance: 100
# The amount of milliseconds to compensate for a teleport (50ms = 1 tick) # The amount of milliseconds to compensate for a teleport (50ms = 1 tick)
teleportCompensation: 150 teleportCompensation: 300
# Should MorePackets be disabled for 'lagging' players? # Should MorePackets be disabled for 'lagging' players?
# This can easily be spoofed by clients! # This can easily be spoofed by clients!
disableForLagging: false disableForLagging: false
# Maximum ping value before MorePackets stops checking a player (-1 to disable) # Maximum ping value before MorePackets stops checking a player (-1 to disable)
# This can easily be spoofed by clients! # This can easily be spoofed by clients!
maxPing: -1 maxPing: -1
# Sneak check settings # Sneak check settings
# Checks if the player toggles sneak too fast # Checks if the player toggles sneak too fast
sneak: sneak:
@@ -277,16 +289,25 @@ sneak:
# This can easily be spoofed by clients! # This can easily be spoofed by clients!
disableForLagging: false disableForLagging: false
# Minimum server TPS needed for sneak # Minimum server TPS needed for sneak
minimumTps: 12 minimumTps: 15
# Minimum time in milliseconds between sneak toggles # Minimum time in milliseconds between sneak toggles
minToggleTime: 75 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 # Spider check settings
# Checks if the player tries to climb a non-climbable block # Checks if the player tries to climb a non-climbable block
spider: spider:
# Should this check be enabled? # Should this check be enabled?
enabled: true enabled: true
# NoFall check settings # NoFall check settings
# Checks if the player tries to ignore fall damage # Checks if the player tries to ignore fall damage
nofall: nofall:
@@ -294,7 +315,6 @@ nofall:
enabled: true enabled: true
# Amount of moves with a modified fall distance before flagging # Amount of moves with a modified fall distance before flagging
vlBeforeFlag: 6 vlBeforeFlag: 6
# Sprint check settings # Sprint check settings
# Checks if the player tries to sprint without the needed conditions # Checks if the player tries to sprint without the needed conditions
sprint: sprint:
@@ -302,7 +322,6 @@ sprint:
enabled: true enabled: true
# Minimum food level needed to sprint # Minimum food level needed to sprint
sprintFoodMin: 6 sprintFoodMin: 6
# FastBow check settings # FastBow check settings
# Checks if the player fires a bow too fast # Checks if the player fires a bow too fast
fastbow: fastbow:
@@ -310,7 +329,6 @@ fastbow:
enabled: true enabled: true
# Maximum percent error between predicted bow force and actual bow force # Maximum percent error between predicted bow force and actual bow force
bowError: 0.25 bowError: 0.25
# FastEat check settings # FastEat check settings
# Checks if the player consumes food too fast # Checks if the player consumes food too fast
fasteat: fasteat:
@@ -318,7 +336,6 @@ fasteat:
enabled: true enabled: true
# Minimum time in milliseconds it takes to consume food # Minimum time in milliseconds it takes to consume food
eatTimeMin: 1000 eatTimeMin: 1000
# FastHeal check settings # FastHeal check settings
# Checks if the player regains health too fast # Checks if the player regains health too fast
fastheal: fastheal:
@@ -330,10 +347,10 @@ fastheal:
# This can easily be spoofed by clients! # This can easily be spoofed by clients!
disableForLagging: false disableForLagging: false
# The minimum time it takes to regenerate health in milliseconds # The minimum time it takes to regenerate health in milliseconds
minHealTime: 495 # Vanilla is 500, but enforcing this will cause too many false positives
minHealTime: 475
# Amount of milliseconds a player can heal faster per millisecond of ping # Amount of milliseconds a player can heal faster per millisecond of ping
pingCompensation: 0.15 pingCompensation: 0.25
# FastProjectile check settings # FastProjectile check settings
# Checks if the player fires a projectile too fast # Checks if the player fires a projectile too fast
fastprojectile: fastprojectile:
@@ -343,7 +360,6 @@ fastprojectile:
projectilesToWait: 10 projectilesToWait: 10
# The minimum time in milliseconds it should have taken for the player fire 'projectilesToWait' projectiles # The minimum time in milliseconds it should have taken for the player fire 'projectilesToWait' projectiles
minimumTime: 1500 minimumTime: 1500
# ItemSpam check settings # ItemSpam check settings
# Checks if the player drops items too fast # Checks if the player drops items too fast
itemspam: itemspam:
@@ -353,7 +369,6 @@ itemspam:
dropsToWait: 10 dropsToWait: 10
# The minimum time in milliseconds it should have taken for the player to drop items 'dropsToWait' times # The minimum time in milliseconds it should have taken for the player to drop items 'dropsToWait' times
minimumTime: 800 minimumTime: 800
# FastInventory check settings # FastInventory check settings
# Checks if the player moves items in the inventory too fast # Checks if the player moves items in the inventory too fast
fastinventory: fastinventory:
@@ -363,19 +378,16 @@ fastinventory:
clicksToWait: 10 clicksToWait: 10
# The minimum time in milliseconds it should have taken for the player to click 'clicksToWait' times # The minimum time in milliseconds it should have taken for the player to click 'clicksToWait' times
minimumTime: 50 minimumTime: 50
# vClip check settings # vClip check settings
# Checks if the player is clipping # Checks if the player is clipping
vclip: vclip:
# Should this check be enabled? # Should this check be enabled?
enabled: true enabled: true
# ChatUnicode check settings # ChatUnicode check settings
# Checks for illegal unicode characters in the chat # Checks for illegal unicode characters in the chat
chatunicode: chatunicode:
# Should this check be enabled? # Should this check be enabled?
enabled: true enabled: true
# ChatSpam check settings # ChatSpam check settings
# Checks for a spam of chat messages # Checks for a spam of chat messages
chatspam: chatspam:
@@ -389,14 +401,13 @@ chatspam:
levelActionOne: 5 levelActionOne: 5
# Number of chat spam violations before action two (see config.yml) is executed # Number of chat spam violations before action two (see config.yml) is executed
levelActionTwo: 10 levelActionTwo: 10
# CommandSpam check settings # CommandSpam check settings
# Checks for a spam of commands # Checks for a spam of commands
commandspam: commandspam:
# Should this check be enabled? # Should this check be enabled?
enabled: true enabled: true
# Minimum time between commands # Minimum time between commands
timeMin: 400 timeMin: 250
# Time in milliseconds after which repeating a command is ignored # Time in milliseconds after which repeating a command is ignored
repeatIgnore: 500 repeatIgnore: 500
# Number of command spam violations before action one (see config.yml) is executed # Number of command spam violations before action one (see config.yml) is executed
+7 -1
View File
@@ -24,6 +24,8 @@ system:
# If silent mode is on, players will not be stopped when they try to hack, and AntiCheatReloaded will do everything possible to keep them unaware of their rising hack level. # If silent mode is on, players will not be stopped when they try to hack, and AntiCheatReloaded will do everything possible to keep them unaware of their rising hack level.
# However, alerts will still be sent to console and to admins online, and events will still take place. # However, alerts will still be sent to console and to admins online, and events will still take place.
silent-mode: false silent-mode: false
# Disable broadcasts about why a player was kicked
disable-broadcast: false
# Should ops be exempt from all checks? # Should ops be exempt from all checks?
exempt-op: false exempt-op: false
# Should AntiCheatReloaded track plugins in its own registered events? # Should AntiCheatReloaded track plugins in its own registered events?
@@ -38,7 +40,11 @@ system:
# Minimum value is 1, default is 8 # Minimum value is 1, default is 8
# Example with 5: notifications after 5 vl, 10vl, 15vl, etc. # Example with 5: notifications after 5 vl, 10vl, 15vl, etc.
notify-every-vl: 8 notify-every-vl: 8
# Use /AntiCheatReloaded checks for a list of valid checks # Maximum distance a player can be set back
# If the last known valid location is further away than this,
# the player will be rubberbanded at their current location
# Minimum value is 5, default is 50
max-setback-distance: 50
disable-in: disable-in:
- example-world - example-world
- example-world-2 - example-world-2
+2 -2
View File
@@ -3,6 +3,6 @@
# To disable warnings or kicking, change WARN and/or KICK to NONE # To disable warnings or kicking, change WARN and/or KICK to NONE
groups: groups:
- 'Low : 50 : GREEN : NONE' - 'Low : 50 : GREEN : NONE'
- 'Medium : 100 : YELLOW : WARN' - 'Medium : 60 : YELLOW : WARN'
- 'High : 175 : RED : KICK' - 'High : 75 : RED : KICK'
- 'Custom : -1 : GREEN : COMMAND[ban %player%;]' - 'Custom : -1 : GREEN : COMMAND[ban %player%;]'
+27 -9
View File
@@ -1,17 +1,35 @@
# AntiCheatReloaded language file # AntiCheatReloaded language file
# The alert message when a player enters a higher group
ALERT: ALERT:
- '&c%player% has just entered the %group% hack group.' - '&6&lACR &8> &7%player% has just entered the %group% hack group.'
- '&c%player%''s last failed check was: %check%.' - '&6&lACR &8> &7%player%''s last failed check was: %check%.'
- '&cType ''/acr report %player%'' for more information.' - '&6&lACR &8> &7Type ''/acr report %player%'' for more information.'
# The warning a player receives when reaching a certain level
# Only sent when enabled in groups.yml
WARNING: WARNING:
- '&6&lACR &8>&7 You have been flagged for using cheats.' - '&6&lACR &8>&7 You have been flagged for using cheats.'
- '&6&lACR &8>&7 If you continue to cheat, action will be taken.' - '&6&lACR &8>&7 If you continue to cheat, action will be taken.'
BAN_REASON: '&6&lACR &8> &7Banned by AntiCheatReloaded' # Ban message
BAN_REASON: '&6&lACR &8> &7Banned for unfair advantage'
# Message to broadcast when banned
# Only sent when enabled in config.yml
BAN_BROADCAST: '&6&lACR &8> &7%player% was banned for cheating' BAN_BROADCAST: '&6&lACR &8> &7%player% was banned for cheating'
KICK_REASON: '&6&lACR &8> &7Kicked for cheating' # Kick message
KICK_REASON: '&6&lACR &8> &7Kicked for unfair advantage'
# Message to broadcast when kicked
# Only sent when enabled in config.yml
KICK_BROADCAST: '&6&lACR &8> &7%player% was kicked for cheating' KICK_BROADCAST: '&6&lACR &8> &7%player% was kicked for cheating'
SPAM_WARNING: '&cStop spamming the server or you will be kicked!' # The warning message to send when a player is spamming
SPAM_KICK_REASON: '&cKicked for spamming' SPAM_WARNING: '&6&lACR &8> &7Stop spamming the server or you will be kicked!'
SPAM_KICK_BROADCAST: '&c%player% was kicked for spamming' # Kick reason when spamming
SPAM_BAN_REASON: '&cBanned for spamming' SPAM_KICK_REASON: '&6&lACR &8> &7Kicked for spamming'
# Message to broadcast when kicked for spamming
# Only sent when enabled in config.yml
SPAM_KICK_BROADCAST: '&6&lACR &8> &7%player% was kicked for spamming'
# Ban reason when spamming
SPAM_BAN_REASON: '&6&lACR &8> &7Banned for spamming'
# Message to broadcast when banned for spamming
# Only sent when enabled in config.yml
SPAM_BAN_BROADCAST: '&c%player% was banned for spamming' SPAM_BAN_BROADCAST: '&c%player% was banned for spamming'
# The prefix for staff and debug alerts
ALERT_PREFIX: "&6&lACR &8> &7"
+10 -13
View File
@@ -1,34 +1,31 @@
# Time to exempt a player from moving because of entering/exiting a vehicle # Time to exempt a player from moving because of entering/exiting a vehicle
# Increase in case of false positives # Increase in case of false positives
ENTERED_EXITED_TIME: 1000 ENTERED_EXITED_TIME: 2500
# Time to exempt a player from moving because of teleporting # Time to exempt a player from moving because of teleporting
# Increase in case of false positives # Increase in case of false positives
TELEPORT_TIME: 1000 TELEPORT_TIME: 1500
# Time to exempt a player from moving because of exiting fly mode
# Changing this value is almost never required
EXIT_FLY_TIME: 2000
# Time to exempt a player from moving because of joining the server # Time to exempt a player from moving because of joining the server
# If your server is slow when a player joins, increasing this value is important # If your server is slow when a player joins, increasing this value is important
# Shouldn't be lower than 1500 or higher than 5000 # Shouldn't be lower than 1500 or higher than 5000
JOIN_TIME: 2000 JOIN_TIME: 2000
# Time to exempt a player from moving because of taking damage # Time to exempt a player from moving because of taking damage
# Can be decreased very slightly to increase detection # Can be decreased very slightly to increase detection
# Increasing in case of false positives is almost never necessary and is not advised # Increase in case of false positives after taking damage
DAMAGE_TIME: 3000 DAMAGE_TIME: 500
# Time to exempt a player from moving because of taking damage with knockback effects # Time to exempt a player from moving because of taking damage with knockback effects
# Can be decreased very slightly to increase detection # Can be decreased very slightly to increase detection
# Increase in case of false positives, but shouldn't be necessary # Increase in case of false positives after knockback
KNOCKBACK_DAMAGE_TIME: 4000 KNOCKBACK_DAMAGE_TIME: 2000
# Time to exempt a player from moving because of taking damage from an explosion # Time to exempt a player from moving because of taking damage from an explosion
# Can be decreased very slightly to increase detection # Can be decreased very slightly to increase detection
# Increasing in case of false positives is almost never necessary and is not advised # Increasing in case of false positives after explosions
EXPLOSION_DAMAGE_TIME: 5000 EXPLOSION_DAMAGE_TIME: 2500
# Amount of seconds to extend a players velocitized state after receiving velocity again # Amount of seconds to extend a players velocitized state after receiving velocity again
VELOCITY_EXTENSION: 2 VELOCITY_EXTENSION: 2
# Time a player is considered to have a change in velocity # Time a player is considered to have a change in velocity
VELOCITY_TIME: 2000 VELOCITY_TIME: 1000
# This is a set value and shouldn't be changed unless you know what you're doing # This is a set value and shouldn't be changed unless you know what you're doing
VELOCITY_PREVENT: 5000 VELOCITY_PREVENT: 2000
# This is a set value and shouldn't be changed unless you know what you're doing # This is a set value and shouldn't be changed unless you know what you're doing
VELOCITY_MAXTIMES: 2 VELOCITY_MAXTIMES: 2
# Minimum travel distance for move to be considered a teleport and subsequently be ignored # Minimum travel distance for move to be considered a teleport and subsequently be ignored
+12
View File
@@ -127,6 +127,15 @@ permissions:
anticheat.check.aimbot: anticheat.check.aimbot:
description: Allow players to use aimbot description: Allow players to use aimbot
default: false default: false
anticheat.check.strafe:
description: Allow players to use strafe hacks
default: false
anticheat.check.noslow:
description: Allow players to use NoSlow hacks
default: false
anticheat.check.boatfly:
description: Allow players to use boat fly hacks
default: false
anticheat.check.exempt: anticheat.check.exempt:
description: Total exemption from checks description: Total exemption from checks
default: false default: false
@@ -158,3 +167,6 @@ permissions:
anticheat.check.illegalinteract: true anticheat.check.illegalinteract: true
anticheat.check.fastladder: true anticheat.check.fastladder: true
anticheat.check.aimbot: true anticheat.check.aimbot: true
anticheat.check.strafe: true
anticheat.check.noslow: true
anticheat.check.boatfly: true