mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 22:14:49 +00:00
Compare commits
28
Commits
1.9.3
..
1.9.6-PRE1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd1db83a98 | ||
|
|
646e906ada | ||
|
|
9473781a26 | ||
|
|
6497891e43 | ||
|
|
0dc3a8053d | ||
|
|
1b5f2dcaa1 | ||
|
|
b232026644 | ||
|
|
0c91ec7ba4 | ||
|
|
abff433510 | ||
|
|
fad298086c | ||
|
|
8b413a382a | ||
|
|
1428b55591 | ||
|
|
a84b573fa8 | ||
|
|
9211003d6d | ||
|
|
01df416236 | ||
|
|
619c8efae1 | ||
|
|
ab2fcc5521 | ||
|
|
8843725ede | ||
|
|
0d9b8707dd | ||
|
|
6e2eae7d1e | ||
|
|
ef5b4069ce | ||
|
|
3b9b39c49a | ||
|
|
09c42905d0 | ||
|
|
8de7ae1c59 | ||
|
|
768331011e | ||
|
|
1f48785d1d | ||
|
|
7cd90cfb61 | ||
|
|
5f181c556e |
No files matched your search
@@ -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']
|
||||
@@ -1,4 +1,4 @@
|
||||
AntiCheatReloaded
|
||||
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.
|
||||
|
||||
@@ -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;
|
||||
* 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
|
||||
* Whether or not you are using protocol hacks (ViaVersion etc.)
|
||||
* Any logs relating to the issue
|
||||
@@ -24,7 +24,6 @@ Hacks blocked
|
||||
* Flight/Glide
|
||||
* ElytraFly
|
||||
* WaterWalk/Jesus
|
||||
* NoSwing
|
||||
* FastBreak
|
||||
* FastPlace
|
||||
* Chat spam
|
||||
@@ -45,8 +44,10 @@ Hacks blocked
|
||||
* FastProjectile
|
||||
* ItemSpam
|
||||
* FastInventory
|
||||
* MorePackets/Timer
|
||||
* BadPackets
|
||||
* Velocity/Anti-Knockback
|
||||
* IllegalInteract (Scaffold)
|
||||
* FastLadder
|
||||
* Timer
|
||||
* Blink
|
||||
* Anti-Knockback
|
||||
* Scaffold
|
||||
* FastLadder
|
||||
* Strafe
|
||||
* NoSlow
|
||||
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.rammelkast.anticheatreloaded</groupId>
|
||||
<artifactId>AntiCheatReloaded</artifactId>
|
||||
<version>1.9.3</version>
|
||||
<version>1.9.6-PRE</version>
|
||||
<name>AntiCheatReloaded</name>
|
||||
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
|
||||
<properties>
|
||||
@@ -22,7 +22,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5</version>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
@@ -31,7 +31,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
@@ -44,7 +44,6 @@
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.rammelkast.*</include>
|
||||
<include>com.cryptomorin.*</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
@@ -55,7 +54,7 @@
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-file</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>3.4.1</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<resources>
|
||||
@@ -70,6 +69,7 @@
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>4.6.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
@@ -80,7 +80,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -101,8 +101,9 @@ public class AntiCheatReloaded extends JavaPlugin {
|
||||
: (ChatColor.RED + "(NOT SUPPORTED!)")));
|
||||
|
||||
getLogger().info("Enabling packet listeners");
|
||||
PacketListener.listenKeepAlivePackets();
|
||||
PacketListener.listenMovementPackets();
|
||||
PacketListener.listenKeepAlivePackets();
|
||||
PacketListener.listenUseItemPackets();
|
||||
|
||||
updateManager = new UpdateManager();
|
||||
|
||||
@@ -164,6 +165,10 @@ public class AntiCheatReloaded extends JavaPlugin {
|
||||
tps = (tps == 0.0D ? ticks : (tps + ticks) / 2.0D);
|
||||
ticks = 1;
|
||||
}
|
||||
|
||||
// Check for updates every 12 hours
|
||||
if (ticks % 864000 == 0)
|
||||
updateManager.update();
|
||||
}
|
||||
}.runTaskTimer(this, 40L, 1L);
|
||||
}
|
||||
|
||||
@@ -152,5 +152,4 @@ public class AntiCheatAPI {
|
||||
return AntiCheatReloaded.getManager();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -18,10 +18,8 @@
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -41,6 +39,7 @@ import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.NoSlowCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
@@ -55,7 +54,6 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
public class Backend {
|
||||
public Map<UUID, Long> velocitized = new HashMap<UUID, Long>();
|
||||
private Map<UUID, Long> levitatingEnd = new HashMap<UUID, Long>();
|
||||
private List<UUID> isAscending = new ArrayList<UUID>();
|
||||
private Map<UUID, Integer> chatLevel = new HashMap<UUID, Integer>();
|
||||
private Map<UUID, Integer> commandLevel = new HashMap<UUID, Integer>();
|
||||
private Map<UUID, Integer> nofallViolation = new HashMap<UUID, Integer>();
|
||||
@@ -121,7 +119,6 @@ public class Backend {
|
||||
startEat.remove(uuid);
|
||||
lastHeal.remove(uuid);
|
||||
sprinted.remove(uuid);
|
||||
isAscending.remove(uuid);
|
||||
nofallViolation.remove(uuid);
|
||||
blockBreakHolder.remove(uuid);
|
||||
fastPlaceViolation.remove(uuid);
|
||||
@@ -156,6 +153,8 @@ public class Backend {
|
||||
KillAuraCheck.ANGLE_FLAGS.remove(uuid);
|
||||
KillAuraCheck.PACKETORDER_FLAGS.remove(uuid);
|
||||
FlightCheck.MOVING_EXEMPT.remove(uuid);
|
||||
NoSlowCheck.LAST_RELEASE.remove(uuid);
|
||||
NoSlowCheck.VIOLATIONS.remove(uuid);
|
||||
}
|
||||
|
||||
public CheckResult checkFastBow(Player player, float force) {
|
||||
@@ -218,7 +217,8 @@ public class Backend {
|
||||
public CheckResult checkSpider(Player player, double y) {
|
||||
if (y <= 0.11761 && y >= 0.11759 && !Utilities.isClimbableBlock(player.getLocation().getBlock())
|
||||
&& !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
|
||||
&& !Utilities.isClimbableBlock(player.getLocation().clone().add(0, -0.98, 0).getBlock())) {
|
||||
&& !Utilities.isClimbableBlock(player.getLocation().clone().add(0, -0.98, 0).getBlock())
|
||||
&& !Utilities.isNearClimbable(player)) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"tried to climb a non-climbable block (" + player.getLocation().getBlock().getType() + ")");
|
||||
} else {
|
||||
@@ -231,8 +231,11 @@ public class Backend {
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping()
|
||||
&& !isMovingExempt(player) && !justPlaced(player) && !Utilities.isNearWater(player)
|
||||
&& !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")
|
||||
&& !VersionUtil.isSlowFalling(player) && !Utilities
|
||||
.isNearShulkerBox(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation())) {
|
||||
&& !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 (nofallViolation.get(uuid) == null) {
|
||||
nofallViolation.put(uuid, 1);
|
||||
@@ -244,8 +247,8 @@ public class Backend {
|
||||
int vlBeforeFlag = checksConfig.getInteger(CheckType.NOFALL, "vlBeforeFlag");
|
||||
if (i >= vlBeforeFlag) {
|
||||
nofallViolation.put(player.getUniqueId(), 1);
|
||||
return new CheckResult(CheckResult.Result.FAILED, "tried to avoid fall damage (fall distance = 0 "
|
||||
+ i + " times in a row, max=" + vlBeforeFlag + ")");
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"tried to avoid fall damage (" + i + " times in a row, max=" + vlBeforeFlag + ")");
|
||||
} else {
|
||||
return PASS;
|
||||
}
|
||||
@@ -307,15 +310,6 @@ public class Backend {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public void logAscension(Player player, double y1, double y2) {
|
||||
UUID name = player.getUniqueId();
|
||||
if (y1 < y2 && !isAscending.contains(name)) {
|
||||
isAscending.add(name);
|
||||
} else {
|
||||
isAscending.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
public CheckResult checkFastPlace(Player player) {
|
||||
int vlBeforeFlagSurvival = checksConfig.getInteger(CheckType.FAST_PLACE, "vlBeforeFlagSurvival");
|
||||
int vlBeforeFlagCreative = checksConfig.getInteger(CheckType.FAST_PLACE, "vlBeforeFlagCreative");
|
||||
@@ -616,10 +610,6 @@ public class Backend {
|
||||
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public void logExitFly(final Player player) {
|
||||
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.EXIT_FLY_TIME());
|
||||
}
|
||||
|
||||
public void logBoatCollision(final Player player) {
|
||||
// TODO config??
|
||||
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + 100 /* 2 ticks */);
|
||||
@@ -634,10 +624,6 @@ public class Backend {
|
||||
return isDoing(player, FlightCheck.MOVING_EXEMPT, -1);
|
||||
}
|
||||
|
||||
public boolean isAscending(Player player) {
|
||||
return isAscending.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
public boolean isDoing(Player player, Map<UUID, Long> map, double max) {
|
||||
if (map.containsKey(player.getUniqueId())) {
|
||||
if (max != -1) {
|
||||
|
||||
@@ -26,6 +26,7 @@ public class CheckResult {
|
||||
}
|
||||
|
||||
private Result result;
|
||||
private String subCheck;
|
||||
private String message;
|
||||
private int data;
|
||||
|
||||
@@ -34,6 +35,12 @@ public class CheckResult {
|
||||
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) {
|
||||
this(result);
|
||||
this.message = message;
|
||||
@@ -46,11 +53,15 @@ public class CheckResult {
|
||||
public boolean failed() {
|
||||
return result == Result.FAILED;
|
||||
}
|
||||
|
||||
public String getSubCheck() {
|
||||
return subCheck;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
public Result getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,9 @@ public enum CheckType {
|
||||
ILLEGAL_INTERACT(Permission.CHECK_ILLEGALINTERACT, "IllegalInteract"),
|
||||
FASTLADDER(Permission.CHECK_FASTLADDER, "FastLadder"),
|
||||
AIMBOT(Permission.CHECK_AIMBOT, "Aimbot"),
|
||||
STRAFE(Permission.CHECK_STRAFE, "Strafe");
|
||||
STRAFE(Permission.CHECK_STRAFE, "Strafe"),
|
||||
NOSLOW(Permission.CHECK_NOSLOW, "NoSlow"),
|
||||
BOATFLY(Permission.CHECK_BOATFLY, "BoatFly");
|
||||
|
||||
private final Permission permission;
|
||||
private final String displayName;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class CriticalsCheck {
|
||||
event.setCancelled(true);
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, "tried to do a critical without needed conditions")
|
||||
.getMessage(),
|
||||
player, CheckType.CRITICALS);
|
||||
player, CheckType.CRITICALS, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@@ -59,6 +60,8 @@ public class KillAuraCheck {
|
||||
double allowedReach = target.getVelocity().length() < 0.08
|
||||
? checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.normal")
|
||||
: checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.velocitized");
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
allowedReach += 1.5D;
|
||||
// Lag compensation
|
||||
double lagExtraReach = checksConfig.getDouble(CheckType.KILLAURA, "reach", "lagCompensation.lagExtraReach");
|
||||
double pingCompensation = checksConfig.getDouble(CheckType.KILLAURA, "reach",
|
||||
@@ -78,7 +81,7 @@ public class KillAuraCheck {
|
||||
double reachedDistance = ((LivingEntity) target).getLocation().toVector()
|
||||
.distance(player.getLocation().toVector());
|
||||
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) + ")");
|
||||
return PASS;
|
||||
}
|
||||
@@ -111,7 +114,7 @@ public class KillAuraCheck {
|
||||
int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "angle", "vlBeforeFlag");
|
||||
if (flags >= vlBeforeFlag) {
|
||||
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) + ")");
|
||||
}
|
||||
|
||||
@@ -147,7 +150,7 @@ public class KillAuraCheck {
|
||||
int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "packetOrder", "vlBeforeFlag");
|
||||
if (flags >= vlBeforeFlag) {
|
||||
PACKETORDER_FLAGS.remove(uuid);
|
||||
return new CheckResult(Result.FAILED, "suspicious packet order (elapsed=" + elapsed + ")");
|
||||
return new CheckResult(Result.FAILED, "PacketOrder", "suspicious packet order (elapsed=" + elapsed + ")");
|
||||
}
|
||||
|
||||
PACKETORDER_FLAGS.put(uuid, flags + 1);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -71,9 +71,11 @@ public class ElytraCheck {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
double lastY = JUMP_Y_VALUE.get(uuid);
|
||||
if (lastY < distance.toY()) {
|
||||
double diff = distance.toY() - lastY;
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* 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;
|
||||
@@ -31,6 +30,7 @@ import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
public class FastLadderCheck {
|
||||
|
||||
@@ -38,11 +38,11 @@ public class FastLadderCheck {
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
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
|
||||
if (!Utilities.isClimbableBlock(player.getLocation().getBlock())
|
||||
|| !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
|
||||
|| player.getLocation().getBlock().isLiquid()) {
|
||||
|| player.getLocation().getBlock().isLiquid() || VersionUtil.isFlying(player)) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@@ -50,7 +51,8 @@ public class FlightCheck {
|
||||
public static CheckResult runCheck(Player player, Distance distance) {
|
||||
if (distance.getYDifference() >= AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|
||||
|| VersionUtil.isFlying(player) || player.getVehicle() != null
|
||||
|| AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)) {
|
||||
|| AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)
|
||||
|| VersionUtil.isRiptiding(player)) {
|
||||
// This was a teleport or user is flying/using elytra/in a vehicle, so we don't
|
||||
// care
|
||||
// about it.
|
||||
@@ -91,19 +93,27 @@ public class FlightCheck {
|
||||
// Fixes snow false positive
|
||||
if (movementManager.motionY < 0.004 && Utilities
|
||||
.isNearHalfblock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN).getLocation()))
|
||||
maxMotionY = 0.004D;
|
||||
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)))
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
&& !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 + ")");
|
||||
|
||||
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)
|
||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||
.getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports"))
|
||||
&& !VersionUtil.isSlowFalling(player) && !Utilities.isInWeb(player)
|
||||
&& movementManager.elytraEffectTicks <= 25)
|
||||
return new CheckResult(CheckResult.Result.FAILED, "had too little Y dropoff (diff="
|
||||
&& !VersionUtil.isSlowFalling(player) && !Utilities.isNearWeb(player)
|
||||
&& 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) + ")");
|
||||
}
|
||||
// End AirFlight
|
||||
@@ -121,10 +131,11 @@ public class FlightCheck {
|
||||
&& !player.hasPotionEffect(PotionEffectType.JUMP)
|
||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
|
||||
&& (!Utilities.isNearBed(distance.getTo())
|
||||
|| (Utilities.isNearBed(distance.getTo()) && movementManager.motionY > 0.12675))
|
||||
&& (!Utilities.isNearBed(distance.getTo()) || ((Utilities.isNearBed(distance.getTo())
|
||||
|| Utilities.isNearBed(distance.getTo().clone().add(0, -0.51, 0)))
|
||||
&& movementManager.motionY > 0.15))
|
||||
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25)
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
||||
"tried to climb air (mY=" + movementManager.motionY + ")");
|
||||
|
||||
// TODO hardcoded value against false again..
|
||||
@@ -135,7 +146,7 @@ public class FlightCheck {
|
||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
|
||||
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
||||
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
|
||||
}
|
||||
// End AirClimb
|
||||
@@ -144,8 +155,8 @@ public class FlightCheck {
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "groundFlight") && movementManager.onGround
|
||||
&& Utilities.cantStandAt(distance.getTo().getBlock().getRelative(BlockFace.DOWN))
|
||||
&& Utilities.cantStandAt(distance.getFrom().getBlock().getRelative(BlockFace.DOWN))
|
||||
&& Utilities.cantStandAt(distance.getTo().getBlock()) && movementManager.groundTicks > 2) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
&& Utilities.cantStandAt(distance.getTo().getBlock())) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "GroundFlight",
|
||||
"faked ground to fly (mY=" + movementManager.motionY + ", gt=" + movementManager.groundTicks + ")");
|
||||
}
|
||||
// End GroundFlight
|
||||
@@ -155,17 +166,25 @@ public class FlightCheck {
|
||||
&& movementManager.motionY < 0 && !backend.justVelocity(player)
|
||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||
.getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports"))
|
||||
&& !Utilities.isInWeb(player) && movementManager.elytraEffectTicks <= 25) {
|
||||
&& !Utilities.isNearWeb(player) && movementManager.elytraEffectTicks <= 25
|
||||
&& !VersionUtil.isSlowFalling(player)) {
|
||||
double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION;
|
||||
double offset = Math.abs(gravitatedY - movementManager.motionY);
|
||||
double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset");
|
||||
if (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) {
|
||||
int vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0) + 1;
|
||||
GRAVITY_VIOLATIONS.put(player.getUniqueId(), vl);
|
||||
int vlBeforeFlag = checksConfig.getInteger(CheckType.FLIGHT, "gravity", "vlBeforeFlag");
|
||||
if (vl >= vlBeforeFlag)
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
if (vl >= vlBeforeFlag) {
|
||||
GRAVITY_VIOLATIONS.put(player.getUniqueId(), Math.max(0, vl - 2));
|
||||
return new CheckResult(CheckResult.Result.FAILED, "Gravity",
|
||||
"ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")");
|
||||
}
|
||||
} else {
|
||||
GRAVITY_VIOLATIONS.remove(player.getUniqueId());
|
||||
}
|
||||
@@ -175,31 +194,4 @@ public class FlightCheck {
|
||||
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,8 +34,7 @@ import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
/**
|
||||
* @author Rammelkast
|
||||
* TODO soulsand speed
|
||||
* @author Rammelkast TODO soulsand speed TODO buffer system
|
||||
*/
|
||||
public class SpeedCheck {
|
||||
|
||||
@@ -47,7 +46,8 @@ public class SpeedCheck {
|
||||
|
||||
public static CheckResult checkXZSpeed(Player player, double x, double z, Location movingTowards) {
|
||||
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
if (isSpeedExempt(player, backend) || player.getVehicle() != null || Utilities.isInWater(player))
|
||||
if (isSpeedExempt(player, backend) || player.getVehicle() != null || Utilities.isInWater(player)
|
||||
|| VersionUtil.isRiptiding(player))
|
||||
return PASS;
|
||||
|
||||
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||
@@ -55,11 +55,15 @@ public class SpeedCheck {
|
||||
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
double distanceXZ = movementManager.distanceXZ;
|
||||
boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid;
|
||||
|
||||
|
||||
// AirSpeed
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airSpeed") && movementManager.airTicks > 1 && movementManager.elytraEffectTicks <= 0 && !Utilities.isNearClimbable(player)) {
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airSpeed") && movementManager.airTicks > 1
|
||||
&& movementManager.elytraEffectTicks <= 0 && !Utilities.isNearClimbable(player)) {
|
||||
double multiplier = 0.985D;
|
||||
double predict = 0.36 * Math.pow(multiplier, movementManager.airTicks + 1);
|
||||
// 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
|
||||
// Adjust for ice
|
||||
if (movementManager.iceInfluenceTicks > 0) {
|
||||
@@ -70,12 +74,12 @@ public class SpeedCheck {
|
||||
if (boxedIn)
|
||||
iceIncrement += 0.45D;
|
||||
if (!Utilities.couldBeOnIce(movingTowards))
|
||||
iceIncrement *= 2.5D;
|
||||
iceIncrement *= 2.5D;
|
||||
predict += iceIncrement;
|
||||
}
|
||||
// Leniency when boxed in
|
||||
if (boxedIn && movementManager.airTicks < 3)
|
||||
limit *= 1.2D;
|
||||
predict *= 1.2D;
|
||||
// Adjust for slime
|
||||
if (movementManager.slimeInfluenceTicks > 0) {
|
||||
double slimeIncrement = 0.022 * Math.pow(1.0375, movementManager.slimeInfluenceTicks);
|
||||
@@ -85,13 +89,16 @@ public class SpeedCheck {
|
||||
predict += slimeIncrement;
|
||||
}
|
||||
// Adjust for speed effects
|
||||
if (player.hasPotionEffect(PotionEffectType.SPEED))
|
||||
if (movementManager.hasSpeedEffect)
|
||||
predict += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
|
||||
if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect)
|
||||
limit *= 1.2D;
|
||||
// Adjust for jump boost effects
|
||||
if (player.hasPotionEffect(PotionEffectType.JUMP))
|
||||
predict += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.05D;
|
||||
// Adjust for custom walking speed
|
||||
double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "walkSpeedMultiplier"); // Default 1.4
|
||||
double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "walkSpeedMultiplier"); // Default
|
||||
// 1.4
|
||||
predict += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1);
|
||||
// Slabs sometimes allow for a slight boost after jump
|
||||
if (movementManager.halfMovementHistoryCounter > 0)
|
||||
@@ -102,25 +109,30 @@ public class SpeedCheck {
|
||||
if (Utilities.couldBeOnBoat(player, 0.5, true))
|
||||
predict *= 1.25D;
|
||||
// Strafing in air when nearing terminal velocity gives false positives
|
||||
// This fixes the issue but gives hackers some leniency which means we need another check for this
|
||||
// This fixes the issue but gives hackers some leniency which means we need
|
||||
// another check for this
|
||||
double deltaMotionY = movementManager.motionY - movementManager.lastMotionY;
|
||||
if (deltaMotionY < 0 && deltaMotionY >= -0.06)
|
||||
predict *= 1.5D;
|
||||
if ((deltaMotionY < 0 && deltaMotionY >= -0.08) || movementManager.airTicks >= 40
|
||||
&& (movingTowards.getBlockY() - player.getWorld().getHighestBlockYAt(movingTowards)) <= 1.5)
|
||||
predict *= (movementManager.airTicks > 60 ? 4.0D : (movementManager.airTicks > 30 ? 3.0D : 2.0D));
|
||||
// Players can move faster in air with slow falling
|
||||
if (VersionUtil.isSlowFalling(player))
|
||||
predict *= 1.25D;
|
||||
// Prevent NoSlow
|
||||
// TODO better way for this
|
||||
if (player.isBlocking() && movementManager.airTicks > 2)
|
||||
if (movementManager.blockingTicks > 3 && movementManager.airTicks > 2)
|
||||
predict *= 0.8D;
|
||||
if (movementManager.blockingTicks > 10 && movementManager.airTicks > 2)
|
||||
predict *= 0.5D;
|
||||
// Fixes false positive when coming out of water
|
||||
if (movementManager.nearLiquidTicks >= 7 && movementManager.airTicks >= 14
|
||||
&& movementManager.motionY < -0.18 && movementManager.motionY > -0.182)
|
||||
predict += Math.abs(movementManager.motionY);
|
||||
|
||||
|
||||
if (distanceXZ - predict > limit) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "moved too fast in air (speed=" + distanceXZ
|
||||
+ ", limit=" + predict + ", block=" + player.isBlocking() + ", box=" + boxedIn + ", at=" + movementManager.airTicks + ")");
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirSpeed",
|
||||
"moved too fast in air (speed=" + distanceXZ + ", limit=" + predict + ", block="
|
||||
+ movementManager.blockingTicks + ", box=" + boxedIn + ", at="
|
||||
+ movementManager.airTicks + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,21 +145,22 @@ public class SpeedCheck {
|
||||
double limit = checksConfig.getDouble(CheckType.SPEED, "airAcceleration", "baseLimit"); // Default 0.3725
|
||||
// Slight increase when boxed in
|
||||
if (boxedIn)
|
||||
limit *= 1.05D;
|
||||
limit *= 1.08D;
|
||||
// Adjust for speed effects
|
||||
if (player.hasPotionEffect(PotionEffectType.SPEED))
|
||||
limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.0225D;
|
||||
// Adjust for slabs
|
||||
if (movementManager.halfMovementHistoryCounter > 15)
|
||||
limit *= 2.0D;
|
||||
limit *= 2.05D;
|
||||
// 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);
|
||||
// Boats sometimes give a false positive
|
||||
if (Utilities.couldBeOnBoat(player))
|
||||
limit *= 1.25D;
|
||||
if (initialAcceleration > limit) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirAcceleration",
|
||||
"exceeded acceleration limits (acceleration=" + initialAcceleration + ", max=" + limit + ")");
|
||||
}
|
||||
}
|
||||
@@ -155,19 +168,24 @@ public class SpeedCheck {
|
||||
// JumpBehaviour
|
||||
// Works against YPorts and mini jumps
|
||||
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
|
||||
if (movementManager.airTicksBeforeGrounded == movementManager.groundTicks) {
|
||||
double minimumDistXZ = checksConfig.getDouble(CheckType.SPEED, "jumpBehaviour", "minimumDistXZ"); // Default 0.42
|
||||
if (distanceXZ >= minimumDistXZ) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "had unexpected jumping behaviour");
|
||||
double minimumDistXZ = checksConfig.getDouble(CheckType.SPEED, "jumpBehaviour", "minimumDistXZ"); // Default
|
||||
|
||||
if (distanceXZ >= minimumDistXZ || movementManager.lastDistanceXZ >= minimumDistXZ) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "JumpBehaviour",
|
||||
"had unexpected jumping behaviour (dXZ=" + Utilities.roundDouble(distanceXZ, 4) + ", lXZ="
|
||||
+ Utilities.roundDouble(movementManager.lastDistanceXZ, 4) + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// GroundSpeed
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "groundSpeed") && movementManager.groundTicks > 1) {
|
||||
double initialLimit = checksConfig.getDouble(CheckType.SPEED, "groundSpeed", "initialLimit"); // Default 0.34
|
||||
double initialLimit = checksConfig.getDouble(CheckType.SPEED, "groundSpeed", "initialLimit"); // Default
|
||||
// 0.34
|
||||
double limit = initialLimit - 0.0055 * Math.min(9, movementManager.groundTicks);
|
||||
// Leniency when moving back on ground
|
||||
if (movementManager.groundTicks < 5)
|
||||
@@ -182,8 +200,17 @@ public class SpeedCheck {
|
||||
if (boxedIn)
|
||||
limit *= 1.1D;
|
||||
// Adjust for speed effects
|
||||
if (player.hasPotionEffect(PotionEffectType.SPEED))
|
||||
if (movementManager.hasSpeedEffect)
|
||||
limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.06D;
|
||||
if (movementManager.hasSpeedEffect && movementManager.groundTicks > 3)
|
||||
limit *= 1.4D;
|
||||
if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect)
|
||||
limit *= 1.2D;
|
||||
// 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) {
|
||||
// When moving off ice
|
||||
if (!Utilities.couldBeOnIce(movingTowards))
|
||||
@@ -216,13 +243,14 @@ public class SpeedCheck {
|
||||
// TODO config
|
||||
if (movementManager.sneakingTicks > 1)
|
||||
limit *= 0.68D;
|
||||
|
||||
|
||||
if (distanceXZ - limit > 0) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"moved too fast on ground (speed=" + distanceXZ + ", limit=" + limit + ", blocking=" + player.isBlocking() + ")");
|
||||
return new CheckResult(CheckResult.Result.FAILED, "GroundSpeed",
|
||||
"moved too fast on ground (speed=" + distanceXZ + ", limit=" + limit + ", blocking="
|
||||
+ player.isBlocking() + ", gt=" + movementManager.groundTicks + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return PASS;
|
||||
}
|
||||
|
||||
@@ -236,27 +264,32 @@ public class SpeedCheck {
|
||||
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
if (!checksConfig.isSubcheckEnabled(CheckType.SPEED, "verticalSpeed"))
|
||||
return PASS;
|
||||
|
||||
|
||||
double maxMotionY = getMaxAcceptableMotionY(player, Utilities.isNearBed(distance.getTo()),
|
||||
Utilities.couldBeOnBoat(player), Utilities.isClimbableBlock(distance.getFrom().getBlock())
|
||||
|| Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)), movementManager.halfMovement, checksConfig);
|
||||
Utilities.couldBeOnBoat(player),
|
||||
Utilities.isClimbableBlock(distance.getFrom().getBlock())
|
||||
|| Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)),
|
||||
movementManager.halfMovement, checksConfig);
|
||||
// Fix false positive with soulsand boost
|
||||
if (movementManager.nearLiquidTicks > 6)
|
||||
maxMotionY *= 1.0525D;
|
||||
if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
return new CheckResult(CheckResult.Result.FAILED, "VerticalSpeed",
|
||||
"exceeded vertical speed limit (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static double getMaxAcceptableMotionY(Player player, boolean nearBed, boolean couldBeOnBoat, boolean fromClimbable, boolean halfMovement, Checks checksConfig) {
|
||||
|
||||
private static double getMaxAcceptableMotionY(Player player, boolean nearBed, boolean couldBeOnBoat,
|
||||
boolean fromClimbable, boolean halfMovement, Checks checksConfig) {
|
||||
// TODO config for these values
|
||||
// TODO something funky vanilla stuff going on with 0.42, like 0.445.., check this..
|
||||
double base = couldBeOnBoat ? 0.600000025 : (nearBed ? 0.5625 : ((halfMovement || VersionUtil.isBountifulUpdate()) ? 0.6 : 0.42));
|
||||
// TODO something funky vanilla stuff going on with 0.42, like 0.445.., check
|
||||
// this..
|
||||
double base = couldBeOnBoat ? 0.600000025
|
||||
: (nearBed ? 0.5625 : ((halfMovement || VersionUtil.isBountifulUpdate()) ? 0.6 : 0.42));
|
||||
if (fromClimbable)
|
||||
base += checksConfig.getDouble(CheckType.SPEED, "verticalSpeed", "climbableCompensation"); // Default 0.04
|
||||
|
||||
|
||||
if (player.hasPotionEffect(PotionEffectType.JUMP))
|
||||
base += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.2D;
|
||||
return base;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
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;
|
||||
|
||||
@@ -29,6 +30,7 @@ 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;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -41,15 +43,17 @@ public class StrafeCheck {
|
||||
|
||||
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))
|
||||
|| 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)
|
||||
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);
|
||||
@@ -57,9 +61,9 @@ public class StrafeCheck {
|
||||
|
||||
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()))
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class WaterWalkCheck {
|
||||
MovementManager movementManager = user.getMovementManager();
|
||||
|
||||
if (movementManager.distanceXZ <= 0 || player.getVehicle() != null || Utilities.isOnLilyPad(player)
|
||||
|| VersionUtil.isRiptiding(player) || VersionUtil.isSwimming(player))
|
||||
|| VersionUtil.isRiptiding(player) || VersionUtil.isSwimming(player) || VersionUtil.isFlying(player))
|
||||
return PASS;
|
||||
|
||||
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
@@ -55,14 +55,14 @@ public class WaterWalkCheck {
|
||||
|| movementManager.motionY == Utilities.JUMP_MOTION_Y)
|
||||
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "walk", "minimumDistXZ")
|
||||
&& !movementManager.topSolid && !Utilities.couldBeOnBoat(player, 3, false))
|
||||
return new CheckResult(Result.FAILED,
|
||||
return new CheckResult(Result.FAILED, "Walk",
|
||||
"tried to walk on water (xz=" + Utilities.roundDouble(movementManager.distanceXZ, 5) + ")");
|
||||
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "hop") && blockBeneath.isLiquid()
|
||||
&& Utilities.isSurroundedByWater(player) && movementManager.onGround
|
||||
&& Math.abs(movementManager.motionY) < checksConfig.getDouble(CheckType.WATER_WALK, "hop", "maxMotionY")
|
||||
&& !Utilities.couldBeOnBoat(player, 0.3, false))
|
||||
return new CheckResult(Result.FAILED,
|
||||
return new CheckResult(Result.FAILED, "Hop",
|
||||
"tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")");
|
||||
|
||||
double minAbsMotionY = 0.12D;
|
||||
@@ -72,8 +72,9 @@ public class WaterWalkCheck {
|
||||
&& Utilities.isSurroundedByWater(player)
|
||||
&& Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY
|
||||
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "lunge", "minimumDistXZ")
|
||||
&& movementManager.lastMotionY > -0.25)
|
||||
return new CheckResult(Result.FAILED, "tried to lunge in water (xz="
|
||||
&& movementManager.lastMotionY > -0.25
|
||||
&& !Utilities.couldBeOnBoat(player, 0.3, false))
|
||||
return new CheckResult(Result.FAILED, "Lunge", "tried to lunge in water (xz="
|
||||
+ Utilities.roundDouble(movementManager.distanceXZ, 5) + ", absMotionY="
|
||||
+ Utilities.roundDouble(Math.abs(movementManager.lastMotionY - movementManager.motionY), 5) + ")");
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class BadPacketsCheck {
|
||||
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||
.getMovementManager();
|
||||
if (user.isLagging() || tps < checksConfig.getDouble(CheckType.MOREPACKETS, "minimumTps")
|
||||
|| (System.currentTimeMillis() - movementManager.lastTeleport <= 100))
|
||||
|| (System.currentTimeMillis() - movementManager.lastTeleport <= 150))
|
||||
return;
|
||||
|
||||
double x = packet.getDoubles().read(0);
|
||||
@@ -70,10 +70,13 @@ public class BadPacketsCheck {
|
||||
Location current = new Location(previous.getWorld(), x, y, z, yaw, pitch);
|
||||
double distance = previous.distanceSquared(current);
|
||||
double maxDistance = checksConfig.getDouble(CheckType.BADPACKETS, "maxDistance");
|
||||
// Fix falling false
|
||||
if (movementManager.airTicks >= 40 && movementManager.motionY < 0 && movementManager.lastMotionY < 0)
|
||||
maxDistance *= 1.5D;
|
||||
boolean hasNewLocation = packet.getBooleans().read(0);
|
||||
if (distance > maxDistance) {
|
||||
flag(player, event, "moved too far between packets (distance="
|
||||
+ new BigDecimal(distance).setScale(1, RoundingMode.HALF_UP) + ", max=" + maxDistance + ")");
|
||||
+ new BigDecimal(distance).setScale(1, RoundingMode.HALF_UP) + ", max=" + maxDistance + ", at=" + movementManager.airTicks + ")");
|
||||
return;
|
||||
} else if (distance < 1E-10 && !hasNewLocation) {
|
||||
// TODO this gives false positives when teleporting
|
||||
@@ -90,7 +93,7 @@ public class BadPacketsCheck {
|
||||
@Override
|
||||
public void run() {
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player,
|
||||
CheckType.BADPACKETS);
|
||||
CheckType.BADPACKETS, null);
|
||||
player.teleport(player.getLocation());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -88,7 +88,7 @@ public class MorePacketsCheck {
|
||||
@Override
|
||||
public void run() {
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player,
|
||||
CheckType.MOREPACKETS);
|
||||
CheckType.MOREPACKETS, null);
|
||||
player.teleport(player.getLocation());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -47,7 +47,8 @@ public class IllegalInteract {
|
||||
} else if (event instanceof BlockBreakEvent
|
||||
&& checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "break")) {
|
||||
return checkBlockBreak(player, (BlockBreakEvent) event);
|
||||
} else if (event instanceof PlayerInteractEvent && checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "interact")) {
|
||||
} else if (event instanceof PlayerInteractEvent
|
||||
&& checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "interact")) {
|
||||
return checkInteract(player, (PlayerInteractEvent) event);
|
||||
}
|
||||
return PASS;
|
||||
@@ -67,21 +68,22 @@ public class IllegalInteract {
|
||||
maxDistance += player.getVelocity().length()
|
||||
* checksConfig.getDouble(CheckType.ILLEGAL_INTERACT, "interact", "velocityMultiplier");
|
||||
if (distance > maxDistance) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "tried to interact out of range (dist=" + distance + ", max=" + maxDistance + ")");
|
||||
return new CheckResult(CheckResult.Result.FAILED, "Interact",
|
||||
"tried to interact out of range (dist=" + distance + ", max=" + maxDistance + ")");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static CheckResult checkBlockBreak(Player player, BlockBreakEvent event) {
|
||||
if (!isValidTarget(player, event.getBlock())) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "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;
|
||||
}
|
||||
|
||||
private static CheckResult checkBlockPlace(Player player, BlockPlaceEvent event) {
|
||||
if (!isValidTarget(player, event.getBlock())) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "tried to place a block out of their view");
|
||||
if (event.getBlock().getType().isSolid() && !isValidTarget(player, event.getBlock())) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "Place", "tried to place a block out of their view");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
@@ -89,8 +91,7 @@ public class IllegalInteract {
|
||||
private static boolean isValidTarget(Player player, Block block) {
|
||||
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
double distance = player.getGameMode() == GameMode.CREATIVE ? 6.0
|
||||
: player.getLocation().getDirection().getY() > 0.9 ? 6.0
|
||||
: 5.5;
|
||||
: player.getLocation().getDirection().getY() > 0.9 ? 6.0 : 5.5;
|
||||
Block targetBlock = VersionUtil.getTargetBlock(player, ((int) Math.ceil(distance)));
|
||||
if (targetBlock == null) {
|
||||
// TODO better check here
|
||||
|
||||
+144
-140
@@ -16,7 +16,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.command.executors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -25,8 +24,8 @@ import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
@@ -38,153 +37,158 @@ import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
|
||||
public class CommandReport extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheatReloaded Reports";
|
||||
private static final String COMMAND = "report";
|
||||
private static final String USAGE = "anticheat report [group/user]";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_REPORT;
|
||||
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 [user]" + GRAY + " to see a single user's report",
|
||||
GRAY + "Use: " + GOLD + "/anticheat report [user/group] [num]" + GRAY + " to see pages of a report",
|
||||
};
|
||||
private static final String NAME = "AntiCheatReloaded Reports";
|
||||
private static final String COMMAND = "report";
|
||||
private static final String USAGE = "anticheat report [group/user]";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_REPORT;
|
||||
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 [user]" + GRAY + " to see a single user's report",
|
||||
GRAY + "Use: " + GOLD + "/anticheat report [user/group] [num]" + GRAY + " to see pages of a report", };
|
||||
|
||||
public CommandReport() {
|
||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||
}
|
||||
public CommandReport() {
|
||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(CommandSender cs, String[] args) {
|
||||
if (args.length >= 1) {
|
||||
int page = 1;
|
||||
if (args.length == 2) {
|
||||
if (Utilities.isInt(args[1])) {
|
||||
page = Integer.parseInt(args[1]);
|
||||
} else {
|
||||
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[1]);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void execute(CommandSender cs, String[] args) {
|
||||
if (args.length >= 1) {
|
||||
int page = 1;
|
||||
if (args.length == 2) {
|
||||
if (Utilities.isInt(args[1])) {
|
||||
page = Integer.parseInt(args[1]);
|
||||
} else {
|
||||
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if ("low".equalsIgnoreCase(args[0])) {
|
||||
groupReport(cs, null, page);
|
||||
}
|
||||
else if ("all".equalsIgnoreCase(args[0])) {
|
||||
cs.sendMessage(GREEN + "Low: " + WHITE + USER_MANAGER.getUsersInGroup(null).size() + " players");
|
||||
for (Group g : CONFIG.getGroups().getGroups()) {
|
||||
int numPlayers = USER_MANAGER.getUsersInGroup(g).size();
|
||||
cs.sendMessage(g.getColor() + g.getName() + WHITE + ": " + numPlayers + " players");
|
||||
}
|
||||
cs.sendMessage(GRAY + "Use " + GOLD + "/anticheat report [group]" + GRAY + " for a list of players in each group.");
|
||||
} else {
|
||||
// Test groups
|
||||
for (Group group : CONFIG.getGroups().getGroups()) {
|
||||
if (group.getName().equalsIgnoreCase(args[0]) || "low".equalsIgnoreCase(args[0]) || "all".equalsIgnoreCase(args[0])) {
|
||||
groupReport(cs, group, page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Player targetPlayer = Bukkit.getPlayer(args[0]);
|
||||
if (targetPlayer == null) {
|
||||
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
|
||||
return;
|
||||
}
|
||||
if ("low".equalsIgnoreCase(args[0])) {
|
||||
groupReport(cs, null, page);
|
||||
} else if ("all".equalsIgnoreCase(args[0])) {
|
||||
cs.sendMessage(GREEN + "Low: " + WHITE + USER_MANAGER.getUsersInGroup(null).size() + " players");
|
||||
for (Group g : CONFIG.getGroups().getGroups()) {
|
||||
int numPlayers = USER_MANAGER.getUsersInGroup(g).size();
|
||||
cs.sendMessage(g.getColor() + g.getName() + WHITE + ": " + numPlayers + " players");
|
||||
}
|
||||
cs.sendMessage(GRAY + "Use " + GOLD + "/anticheat report [group]" + GRAY
|
||||
+ " for a list of players in each group.");
|
||||
} else {
|
||||
// Test groups
|
||||
for (Group group : CONFIG.getGroups().getGroups()) {
|
||||
if (group.getName().equalsIgnoreCase(args[0]) || "low".equalsIgnoreCase(args[0])
|
||||
|| "all".equalsIgnoreCase(args[0])) {
|
||||
groupReport(cs, group, page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Test users
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (player.getUniqueId().equals(Bukkit.getPlayer(args[0]).getUniqueId())) {
|
||||
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
playerReport(cs, user, page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer targetPlayer = Bukkit.getOfflinePlayer(args[0]);
|
||||
if (targetPlayer == null) {
|
||||
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Neither of these
|
||||
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
|
||||
}
|
||||
} else {
|
||||
sendHelp(cs);
|
||||
}
|
||||
}
|
||||
User user = AntiCheatReloaded.getManager().getUserManager().getUser(targetPlayer.getUniqueId());
|
||||
if (user != null) {
|
||||
playerReport(cs, user, page);
|
||||
return;
|
||||
}
|
||||
|
||||
private void groupReport(CommandSender cs, Group group, int page) {
|
||||
List<User> users = USER_MANAGER.getUsersInGroup(group);
|
||||
ChatColor color = group == null ? GREEN : group.getColor();
|
||||
String groupName = group == null ? "Low" : group.getName();
|
||||
int pages = (int) Math.ceil(((float) users.size()) / 7);
|
||||
if (page <= pages && page > 0) {
|
||||
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD + "]----------------------");
|
||||
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
||||
for (int x = 0; x < 7; x++) {
|
||||
int index = ((page - 1) * 6) + (x + ((page - 1) * 1));
|
||||
if (index < users.size()) {
|
||||
String player = users.get(index).getName();
|
||||
cs.sendMessage(GRAY + player);
|
||||
}
|
||||
}
|
||||
cs.sendMessage(MENU_END);
|
||||
} else {
|
||||
if (pages == 0) {
|
||||
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
|
||||
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
||||
cs.sendMessage(GRAY + "There are no users in this group.");
|
||||
cs.sendMessage(MENU_END);
|
||||
} else {
|
||||
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages);
|
||||
}
|
||||
}
|
||||
}
|
||||
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
|
||||
}
|
||||
} else {
|
||||
sendHelp(cs);
|
||||
}
|
||||
}
|
||||
|
||||
private void playerReport(CommandSender cs, User user, int page) {
|
||||
List<CheckType> types = new ArrayList<CheckType>();
|
||||
for (CheckType type : CheckType.values()) {
|
||||
if (type.getUses(user.getUUID()) > 0) {
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
private void groupReport(CommandSender cs, Group group, int page) {
|
||||
List<User> users = USER_MANAGER.getUsersInGroup(group);
|
||||
ChatColor color = group == null ? GREEN : group.getColor();
|
||||
String groupName = group == null ? "Low" : group.getName();
|
||||
int pages = (int) Math.ceil(((float) users.size()) / 7);
|
||||
if (page <= pages && page > 0) {
|
||||
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD
|
||||
+ "]----------------------");
|
||||
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
||||
for (int x = 0; x < 7; x++) {
|
||||
int index = ((page - 1) * 6) + (x + ((page - 1) * 1));
|
||||
if (index < users.size()) {
|
||||
String player = users.get(index).getName();
|
||||
cs.sendMessage(GRAY + player);
|
||||
}
|
||||
}
|
||||
cs.sendMessage(MENU_END);
|
||||
} else {
|
||||
if (pages == 0) {
|
||||
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
|
||||
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
||||
cs.sendMessage(GRAY + "There are no users in this group.");
|
||||
cs.sendMessage(MENU_END);
|
||||
} else {
|
||||
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UUID uuid = user.getUUID();
|
||||
String name = user.getName();
|
||||
int pages = (int) Math.ceil(((float) types.size()) / 6);
|
||||
private void playerReport(CommandSender cs, User user, int page) {
|
||||
List<CheckType> types = new ArrayList<CheckType>();
|
||||
for (CheckType type : CheckType.values()) {
|
||||
if (type.getUses(user.getUUID()) > 0) {
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
Group group = user.getGroup();
|
||||
String groupString = GREEN + "Low";
|
||||
UUID uuid = user.getUUID();
|
||||
String name = user.getName();
|
||||
int pages = (int) Math.ceil(((float) types.size()) / 6);
|
||||
|
||||
if (group != null) {
|
||||
groupString = group.getColor() + group.getName();
|
||||
}
|
||||
groupString += " (" + user.getLevel() + ")";
|
||||
Group group = user.getGroup();
|
||||
String groupString = GREEN + "Low";
|
||||
|
||||
if (page <= pages && page > 0) {
|
||||
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 + "Group: " + groupString);
|
||||
for (int x = 0; x < 6; x++) {
|
||||
int index = ((page - 1) * 5) + (x + ((page - 1)));
|
||||
if (index < types.size()) {
|
||||
CheckType type = types.get(index);
|
||||
int use = type.getUses(uuid);
|
||||
ChatColor color = WHITE;
|
||||
if (use >= 20) {
|
||||
color = YELLOW;
|
||||
} else if (use > 50) {
|
||||
color = RED;
|
||||
}
|
||||
cs.sendMessage(GRAY + type.getName() + ": " + color + use);
|
||||
}
|
||||
}
|
||||
cs.sendMessage(MENU_END);
|
||||
} else {
|
||||
if (pages == 0 && page == 1) {
|
||||
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + 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 + "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);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (group != null) {
|
||||
groupString = group.getColor() + group.getName();
|
||||
}
|
||||
groupString += " (" + user.getLevel() + ")";
|
||||
|
||||
if (page <= pages && page > 0) {
|
||||
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD
|
||||
+ "]----------------------");
|
||||
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
||||
int ping = user.getPing();
|
||||
cs.sendMessage(GRAY + "Ping: " + ((ping == -1) ? (RED + "Offline")
|
||||
: (WHITE + "" + ping + "ms "
|
||||
+ (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"))));
|
||||
cs.sendMessage(GRAY + "Group: " + groupString);
|
||||
for (int x = 0; x < 6; x++) {
|
||||
int index = ((page - 1) * 5) + (x + ((page - 1)));
|
||||
if (index < types.size()) {
|
||||
CheckType type = types.get(index);
|
||||
int use = type.getUses(uuid);
|
||||
ChatColor color = WHITE;
|
||||
if (use >= 20) {
|
||||
color = YELLOW;
|
||||
} else if (use > 50) {
|
||||
color = RED;
|
||||
}
|
||||
cs.sendMessage(GRAY + type.getName() + ": " + color + use);
|
||||
}
|
||||
}
|
||||
cs.sendMessage(MENU_END);
|
||||
} else {
|
||||
if (pages == 0 && page == 1) {
|
||||
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
|
||||
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
||||
int ping = user.getPing();
|
||||
cs.sendMessage(GRAY + "Ping: " + ((ping == -1) ? (RED + "Offline")
|
||||
: (WHITE + "" + ping + "ms "
|
||||
+ (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"))));
|
||||
cs.sendMessage(GRAY + "Group: " + groupString);
|
||||
cs.sendMessage(GRAY + "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> enterprise;
|
||||
public ConfigValue<Boolean> debugMode;
|
||||
public ConfigValue<Boolean> disableBroadcast;
|
||||
|
||||
public ConfigValue<Boolean> blockChatSpamSpeed;
|
||||
public ConfigValue<Boolean> blockCommandSpamSpeed;
|
||||
@@ -67,6 +68,7 @@ public class Config extends ConfigurationFile {
|
||||
eventChains = new ConfigValue<Boolean>("system.event-chains");
|
||||
enterprise = new ConfigValue<Boolean>("system.enterprise");
|
||||
debugMode = new ConfigValue<Boolean>("system.debug-mode");
|
||||
disableBroadcast = new ConfigValue<Boolean>("system.disable-broadcast");
|
||||
|
||||
blockChatSpamSpeed = new ConfigValue<Boolean>("spam.chat.block-speed");
|
||||
blockChatSpamRepetition = new ConfigValue<Boolean>("spam.chat.block-repetition");
|
||||
@@ -86,7 +88,6 @@ public class Config extends ConfigurationFile {
|
||||
if (notifyEveryVl.getValue() < 1) {
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -38,7 +38,7 @@ public class BlockListener extends EventListener {
|
||||
CheckResult result = getBackend().checkFastPlace(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FAST_PLACE);
|
||||
log(result.getMessage(), player, CheckType.FAST_PLACE, result.getSubCheck());
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class BlockListener extends EventListener {
|
||||
CheckResult result = IllegalInteract.performCheck(player, event);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT);
|
||||
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck());
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class BlockListener extends EventListener {
|
||||
result = IllegalInteract.performCheck(player, event);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT);
|
||||
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck());
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,11 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
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.RegainReason;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
@@ -43,17 +42,6 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
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
|
||||
public void onEntityShootBow(EntityShootBowEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
@@ -62,7 +50,7 @@ public class EntityListener extends EventListener {
|
||||
CheckResult result = getBackend().checkFastBow(player, event.getForce());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FAST_BOW);
|
||||
log(result.getMessage(), player, CheckType.FAST_BOW, result.getSubCheck());
|
||||
} else {
|
||||
decrease(player);
|
||||
}
|
||||
@@ -80,7 +68,7 @@ public class EntityListener extends EventListener {
|
||||
CheckResult result = getBackend().checkFastHeal(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FAST_HEAL);
|
||||
log(result.getMessage(), player, CheckType.FAST_HEAL, result.getSubCheck());
|
||||
} else {
|
||||
decrease(player);
|
||||
getBackend().logHeal(player);
|
||||
@@ -100,7 +88,7 @@ public class EntityListener extends EventListener {
|
||||
CheckResult result = getBackend().checkFastEat(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FAST_EAT);
|
||||
log(result.getMessage(), player, CheckType.FAST_EAT, result.getSubCheck());
|
||||
} else {
|
||||
decrease(player);
|
||||
}
|
||||
@@ -141,7 +129,7 @@ public class EntityListener extends EventListener {
|
||||
CheckResult result = KillAuraCheck.checkAngle(player, event);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.KILLAURA);
|
||||
log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck());
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
@@ -149,7 +137,7 @@ public class EntityListener extends EventListener {
|
||||
CheckResult result = KillAuraCheck.checkReach(player, event.getEntity());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.KILLAURA);
|
||||
log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck());
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
@@ -157,7 +145,7 @@ public class EntityListener extends EventListener {
|
||||
CheckResult result = KillAuraCheck.checkPacketOrder(player, event.getEntity());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.KILLAURA);
|
||||
log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck());
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.event;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -48,7 +49,12 @@ public class EventListener implements Listener {
|
||||
private static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration();
|
||||
private static final DecimalFormat TPS_FORMAT = new DecimalFormat("##.##");
|
||||
|
||||
public static void log(String message, Player player, CheckType type) {
|
||||
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());
|
||||
if (user == null)
|
||||
return;
|
||||
@@ -56,23 +62,26 @@ public class EventListener implements Listener {
|
||||
boolean debugMode = CONFIG.getConfig().debugMode.getValue();
|
||||
int vlForType = type.getUses(player.getUniqueId()) + 1;
|
||||
int notifyEveryVl = CONFIG.getConfig().notifyEveryVl.getValue();
|
||||
String prefix = ChatColor.translateAlternateColorCodes('&', CONFIG.getLang().ALERT_PREFIX());
|
||||
if (message == null || message.equals("")) {
|
||||
if (debugMode) {
|
||||
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY + player.getName() + " failed "
|
||||
message = prefix + player.getName() + " failed "
|
||||
+ type.getName();
|
||||
} 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 + ")";
|
||||
}
|
||||
} else {
|
||||
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
|
||||
+ ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms"
|
||||
+ ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS());
|
||||
} else {
|
||||
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY + player.getName() + " failed "
|
||||
+ type.getName() + ChatColor.GOLD + " (x" + vlForType + ")" + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms"
|
||||
message = prefix
|
||||
+ player.getName() + " failed " + type.getName() + ChatColor.GOLD + " (x" + vlForType + ")"
|
||||
+ ChatColor.DARK_GRAY + " | " + ChatColor.GRAY
|
||||
+ (subcheck != null ? ("type: " + subcheck.toLowerCase() + ", ") : "") + "ping: " + user.getPing() + "ms"
|
||||
+ ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class InventoryListener extends EventListener {
|
||||
player.getInventory().clear();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.FAST_INVENTORY);
|
||||
log(result.getMessage(), player, CheckType.FAST_INVENTORY, result.getSubCheck());
|
||||
} else {
|
||||
decrease(player);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
||||
@@ -61,6 +60,7 @@ import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.BoatFlyCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.FastLadderCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
|
||||
@@ -73,6 +73,7 @@ import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
import com.rammelkast.anticheatreloaded.util.XMaterial;
|
||||
|
||||
public class PlayerListener extends EventListener {
|
||||
|
||||
@@ -87,7 +88,7 @@ public class PlayerListener extends EventListener {
|
||||
if (!silentMode())
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', result.getMessage()));
|
||||
getBackend().processCommandSpammer(player);
|
||||
log(null, player, CheckType.COMMAND_SPAM);
|
||||
log(null, player, CheckType.COMMAND_SPAM, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +126,7 @@ public class PlayerListener extends EventListener {
|
||||
CheckResult result = getBackend().checkProjectile(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FAST_PROJECTILE);
|
||||
log(result.getMessage(), player, CheckType.FAST_PROJECTILE, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,10 +136,7 @@ public class PlayerListener extends EventListener {
|
||||
|
||||
@EventHandler
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -157,7 +155,7 @@ public class PlayerListener extends EventListener {
|
||||
CheckResult result = getBackend().checkSneakToggle(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.SNEAK);
|
||||
log(result.getMessage(), player, CheckType.SNEAK, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
// getBackend().logToggleSneak(event.getPlayer());
|
||||
@@ -204,7 +202,7 @@ public class PlayerListener extends EventListener {
|
||||
AntiCheatReloaded.sendToMainThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
log(null, player, CheckType.CHAT_SPAM);
|
||||
log(null, player, CheckType.CHAT_SPAM, result.getSubCheck());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -218,7 +216,7 @@ public class PlayerListener extends EventListener {
|
||||
AntiCheatReloaded.sendToMainThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
log(null, player, CheckType.CHAT_UNICODE);
|
||||
log(null, player, CheckType.CHAT_UNICODE, result.getSubCheck());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -261,7 +259,7 @@ public class PlayerListener extends EventListener {
|
||||
CheckResult result = getBackend().checkSprintHungry(event);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.SPRINT);
|
||||
log(result.getMessage(), player, CheckType.SPRINT, result.getSubCheck());
|
||||
} else {
|
||||
decrease(player);
|
||||
}
|
||||
@@ -290,7 +288,7 @@ public class PlayerListener extends EventListener {
|
||||
}
|
||||
|
||||
if (!VersionUtil.isBountifulUpdate()) {
|
||||
if (itemInHand.getType() == Material.FIREWORK_ROCKET) {
|
||||
if (itemInHand.getType() == XMaterial.FIREWORK_ROCKET.parseMaterial()) {
|
||||
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
|
||||
if (player.isGliding()) {
|
||||
// TODO config max elytra height?
|
||||
@@ -307,7 +305,7 @@ public class PlayerListener extends EventListener {
|
||||
CheckResult result = IllegalInteract.performCheck(player, event);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT);
|
||||
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -322,7 +320,7 @@ public class PlayerListener extends EventListener {
|
||||
CheckResult result = getBackend().checkFastDrop(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.ITEM_SPAM);
|
||||
log(result.getMessage(), player, CheckType.ITEM_SPAM, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,7 +379,6 @@ public class PlayerListener extends EventListener {
|
||||
|
||||
final Distance distance = new Distance(from, to);
|
||||
final double y = distance.getYDifference();
|
||||
getBackend().logAscension(player, from.getY(), to.getY());
|
||||
|
||||
final User user = getUserManager().getUser(player.getUniqueId());
|
||||
user.setTo(to.getX(), to.getY(), to.getZ());
|
||||
@@ -393,13 +390,23 @@ public class PlayerListener extends EventListener {
|
||||
if (!silentMode()) {
|
||||
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)) {
|
||||
CheckResult result = ElytraCheck.runCheck(player, distance);
|
||||
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)
|
||||
@@ -417,7 +424,7 @@ public class PlayerListener extends EventListener {
|
||||
}
|
||||
player.damage(3);
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.VCLIP);
|
||||
log(result.getMessage(), player, CheckType.VCLIP, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.NOFALL)
|
||||
@@ -430,7 +437,7 @@ public class PlayerListener extends EventListener {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
// TODO better handling of this
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.NOFALL);
|
||||
log(result.getMessage(), player, CheckType.NOFALL, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,7 +452,7 @@ public class PlayerListener extends EventListener {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.SPEED);
|
||||
log(result.getMessage(), player, CheckType.SPEED, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
CheckResult result = SpeedCheck.checkXZSpeed(player, x, z, event.getTo());
|
||||
@@ -453,7 +460,7 @@ public class PlayerListener extends EventListener {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.SPEED);
|
||||
log(result.getMessage(), player, CheckType.SPEED, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) {
|
||||
@@ -463,7 +470,7 @@ public class PlayerListener extends EventListener {
|
||||
// TODO check this
|
||||
player.teleport(player.getLocation().clone().subtract(0, 0.52, 0));
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.WATER_WALK);
|
||||
log(result.getMessage(), player, CheckType.WATER_WALK, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.SPIDER)) {
|
||||
@@ -472,7 +479,7 @@ public class PlayerListener extends EventListener {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.SPIDER);
|
||||
log(result.getMessage(), player, CheckType.SPIDER, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.FASTLADDER)) {
|
||||
@@ -483,7 +490,7 @@ public class PlayerListener extends EventListener {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.FASTLADDER);
|
||||
log(result.getMessage(), player, CheckType.FASTLADDER, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.STRAFE)) {
|
||||
@@ -492,20 +499,20 @@ public class PlayerListener extends EventListener {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.STRAFE);
|
||||
log(result.getMessage(), player, CheckType.STRAFE, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.AIMBOT)) {
|
||||
CheckResult result = AimbotCheck.runCheck(player, event);
|
||||
if (result.failed()) {
|
||||
log(result.getMessage(), player, CheckType.AIMBOT);
|
||||
log(result.getMessage(), player, CheckType.AIMBOT, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.VELOCITY)) {
|
||||
CheckResult result = VelocityCheck.runCheck(player, distance);
|
||||
if (result.failed()) {
|
||||
log(result.getMessage(), player, CheckType.VELOCITY);
|
||||
log(result.getMessage(), player, CheckType.VELOCITY, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ public class LoggingManager {
|
||||
}
|
||||
|
||||
public void logToPlayers(String message) {
|
||||
if(config.getConfig().disableBroadcast.getValue()) return;
|
||||
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (Permission.SYSTEM_NOTICE.get(player)) {
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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,8 @@ package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
|
||||
@@ -81,6 +83,16 @@ public class MovementManager {
|
||||
public int sneakingTicks;
|
||||
// Ticks counter after being near a liquid
|
||||
public int nearLiquidTicks;
|
||||
// Ticks of player blocking
|
||||
public int blockingTicks;
|
||||
// If the player has a speed effect
|
||||
public boolean hasSpeedEffect = false;
|
||||
// If the player had speed effect previous tick
|
||||
public boolean hadSpeedEffect = false;
|
||||
// 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;
|
||||
// Time of last update
|
||||
public long lastUpdate;
|
||||
|
||||
@@ -104,6 +116,15 @@ public class MovementManager {
|
||||
if (Utilities.couldBeOnBoat(player, 0.25, true) && !Utilities.isSubmersed(player))
|
||||
this.onGround = true;
|
||||
|
||||
// Handle 1.9+ potion effects
|
||||
if (MinecraftVersion.atOrAbove(MinecraftVersion.COMBAT_UPDATE)) {
|
||||
for (PotionEffect effect : player.getActivePotionEffects()) {
|
||||
if (!VersionUtil.isLevitationEffect(effect))
|
||||
return;
|
||||
AntiCheatReloaded.getManager().getBackend().logLevitating(player, 1);
|
||||
}
|
||||
}
|
||||
|
||||
this.touchedGroundThisTick = false;
|
||||
this.halfMovement = false;
|
||||
if (!this.onGround) {
|
||||
@@ -146,6 +167,11 @@ public class MovementManager {
|
||||
this.sneakingTicks++;
|
||||
else
|
||||
this.sneakingTicks = 0;
|
||||
|
||||
if (player.isBlocking())
|
||||
this.blockingTicks++;
|
||||
else
|
||||
this.blockingTicks = 0;
|
||||
|
||||
if (Utilities.isNearWater(player))
|
||||
this.nearLiquidTicks = 8;
|
||||
@@ -155,6 +181,12 @@ public class MovementManager {
|
||||
else
|
||||
this.nearLiquidTicks = 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()
|
||||
+ this.lastDistance.getZDifference() * this.lastDistance.getZDifference());
|
||||
|
||||
@@ -24,7 +24,10 @@ import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.injector.server.TemporaryPlayer;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerDigType;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.NoSlowCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.packet.BadPacketsCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck;
|
||||
|
||||
@@ -38,6 +41,8 @@ public class PacketListener {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player == null || !player.isOnline())
|
||||
return;
|
||||
|
||||
// Run MorePackets check
|
||||
MorePacketsCheck.runCheck(player, event);
|
||||
@@ -51,6 +56,9 @@ public class PacketListener {
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
// Check if we have an actual player object
|
||||
if (player instanceof TemporaryPlayer)
|
||||
return;
|
||||
// Compensate for teleport
|
||||
MorePacketsCheck.compensate(player);
|
||||
}
|
||||
@@ -76,5 +84,16 @@ 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_KILLAURA, CHECK_UNICODE, CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY,
|
||||
CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGALINTERACT, CHECK_FASTLADDER,
|
||||
CHECK_AIMBOT, CHECK_STRAFE,
|
||||
CHECK_AIMBOT, CHECK_STRAFE, CHECK_NOSLOW, CHECK_BOATFLY,
|
||||
|
||||
/* System Nodes */
|
||||
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="
|
||||
+ RESOURCE_ID;
|
||||
|
||||
private final String latestVersion;
|
||||
private final boolean isLatest;
|
||||
private final boolean isAhead;
|
||||
private String latestVersion;
|
||||
private boolean isLatest;
|
||||
private boolean isAhead;
|
||||
|
||||
public UpdateManager() {
|
||||
this.update();
|
||||
}
|
||||
|
||||
public void update() {
|
||||
this.latestVersion = this.getOnlineData(SPIGOT_VERSION_URL);
|
||||
if (this.latestVersion == null) {
|
||||
this.isLatest = true;
|
||||
|
||||
@@ -68,6 +68,7 @@ public class User {
|
||||
this.name = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getName() : "";
|
||||
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1;
|
||||
this.movementManager = new MovementManager();
|
||||
this.ping = getPlayer() != null && getPlayer().isOnline() ? VersionUtil.getPlayerPing(getPlayer()) : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,10 +45,7 @@ public final class Utilities {
|
||||
private static final List<Material> FOOD = new ArrayList<Material>();
|
||||
private static final List<Material> CLIMBABLE = new ArrayList<Material>();
|
||||
private static final Map<Material, Material> COMBO = new HashMap<Material, Material>();
|
||||
|
||||
public static final Material LILY_PAD;
|
||||
public static final Material COB_WEB;
|
||||
|
||||
|
||||
public static final double JUMP_MOTION_Y = 0.41999998688697815;
|
||||
|
||||
/**
|
||||
@@ -117,16 +114,17 @@ public final class Utilities {
|
||||
public static boolean canStand(Block block) {
|
||||
return !(block.isLiquid() || block.getType() == Material.AIR);
|
||||
}
|
||||
|
||||
|
||||
public static boolean isNotNearSlime(Block block) {
|
||||
return !isSlime(block.getRelative(BlockFace.NORTH)) && !isSlime(block.getRelative(BlockFace.EAST))
|
||||
&& !isSlime(block.getRelative(BlockFace.SOUTH)) && !isSlime(block.getRelative(BlockFace.WEST)) && !isSlime(block.getRelative(BlockFace.DOWN));
|
||||
&& !isSlime(block.getRelative(BlockFace.SOUTH)) && !isSlime(block.getRelative(BlockFace.WEST))
|
||||
&& !isSlime(block.getRelative(BlockFace.DOWN));
|
||||
}
|
||||
|
||||
|
||||
public static boolean couldBeOnBoat(Player player) {
|
||||
return couldBeOnBoat(player, 0.35, false);
|
||||
}
|
||||
|
||||
|
||||
public static boolean couldBeOnBoat(Player player, double range, boolean checkY) {
|
||||
for (Entity entity : player.getNearbyEntities(range, range, range)) {
|
||||
if (entity instanceof Boat) {
|
||||
@@ -148,11 +146,11 @@ public final class Utilities {
|
||||
*/
|
||||
public static boolean couldBeOnIce(Location location) {
|
||||
return isNearIce(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D,
|
||||
location.getBlockZ())) || isNearIce(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.26D,
|
||||
location.getBlockZ()))
|
||||
|| isNearIce(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.26D,
|
||||
location.getBlockZ()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether a block is a type of ice
|
||||
*
|
||||
@@ -163,10 +161,9 @@ public final class Utilities {
|
||||
Material type = block.getType();
|
||||
return type.name().endsWith("ICE");
|
||||
}
|
||||
|
||||
|
||||
public static boolean isNearIce(Location location) {
|
||||
return isIce(location.getBlock())
|
||||
|| isIce(location.getBlock().getRelative(BlockFace.NORTH))
|
||||
return isIce(location.getBlock()) || isIce(location.getBlock().getRelative(BlockFace.NORTH))
|
||||
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH))
|
||||
|| isIce(location.getBlock().getRelative(BlockFace.EAST))
|
||||
|| isIce(location.getBlock().getRelative(BlockFace.WEST))
|
||||
@@ -175,7 +172,7 @@ public final class Utilities {
|
||||
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|
||||
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether a block is a shulker box
|
||||
*
|
||||
@@ -186,12 +183,13 @@ public final class Utilities {
|
||||
Material type = block.getType();
|
||||
return type.name().endsWith("SHULKER_BOX");
|
||||
}
|
||||
|
||||
|
||||
public static boolean isNearShulkerBox(Location location) {
|
||||
if (VersionUtil.isBountifulUpdate())
|
||||
// Shulkers are 1.12+
|
||||
if (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.COLOR_UPDATE)) {
|
||||
return false;
|
||||
return isShulkerBox(location.getBlock())
|
||||
|| isShulkerBox(location.getBlock().getRelative(BlockFace.NORTH))
|
||||
}
|
||||
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))
|
||||
@@ -200,7 +198,7 @@ public final class Utilities {
|
||||
|| isShulkerBox(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|
||||
|| isShulkerBox(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether a player could be standing on a halfblock
|
||||
*
|
||||
@@ -208,14 +206,14 @@ public final class Utilities {
|
||||
* @return true if the player could be standing on a halfblock
|
||||
*/
|
||||
public static boolean couldBeOnHalfblock(Location location) {
|
||||
return isNearHalfblock(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D,
|
||||
location.getBlockZ())) || isNearHalfblock(new Location(location.getWorld(), location.getX(), location.getY() - 0.51D,
|
||||
return isNearHalfblock(
|
||||
new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, location.getBlockZ()))
|
||||
|| isNearHalfblock(new Location(location.getWorld(), location.getX(), location.getY() - 0.51D,
|
||||
location.getBlockZ()));
|
||||
}
|
||||
|
||||
|
||||
public static boolean isNearHalfblock(Location location) {
|
||||
return isHalfblock(location.getBlock())
|
||||
|| isHalfblock(location.getBlock().getRelative(BlockFace.NORTH))
|
||||
return isHalfblock(location.getBlock()) || isHalfblock(location.getBlock().getRelative(BlockFace.NORTH))
|
||||
|| isHalfblock(location.getBlock().getRelative(BlockFace.SOUTH))
|
||||
|| isHalfblock(location.getBlock().getRelative(BlockFace.EAST))
|
||||
|| isHalfblock(location.getBlock().getRelative(BlockFace.WEST))
|
||||
@@ -224,18 +222,19 @@ public final class Utilities {
|
||||
|| isHalfblock(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|
||||
|| isHalfblock(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
|
||||
}
|
||||
|
||||
|
||||
public static boolean isHalfblock(Block block) {
|
||||
if (!VersionUtil.isBountifulUpdate()) {
|
||||
// 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;
|
||||
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
|
||||
*
|
||||
@@ -244,11 +243,11 @@ public final class Utilities {
|
||||
*/
|
||||
public static boolean couldBeOnSlime(Location location) {
|
||||
return isNearSlime(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D,
|
||||
location.getBlockZ())) || isNearSlime(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.51D,
|
||||
location.getBlockZ()))
|
||||
|| isNearSlime(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.51D,
|
||||
location.getBlockZ()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether a block is a type of slime
|
||||
*
|
||||
@@ -259,10 +258,9 @@ public final class Utilities {
|
||||
Material type = block.getType();
|
||||
return type.equals(XMaterial.SLIME_BLOCK.parseMaterial());
|
||||
}
|
||||
|
||||
|
||||
public static boolean isNearSlime(Location location) {
|
||||
return isSlime(location.getBlock())
|
||||
|| isSlime(location.getBlock().getRelative(BlockFace.NORTH))
|
||||
return isSlime(location.getBlock()) || isSlime(location.getBlock().getRelative(BlockFace.NORTH))
|
||||
|| isSlime(location.getBlock().getRelative(BlockFace.SOUTH))
|
||||
|| isSlime(location.getBlock().getRelative(BlockFace.EAST))
|
||||
|| isSlime(location.getBlock().getRelative(BlockFace.WEST))
|
||||
@@ -271,7 +269,7 @@ public final class Utilities {
|
||||
|| isSlime(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|
||||
|| isSlime(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether a player is fully submerged in water
|
||||
*
|
||||
@@ -370,7 +368,7 @@ public final class Utilities {
|
||||
Material type = block.getType();
|
||||
return type.name().endsWith("SLAB");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether a block is a bed
|
||||
*
|
||||
@@ -381,10 +379,9 @@ public final class Utilities {
|
||||
Material type = block.getType();
|
||||
return type.name().endsWith("BED");
|
||||
}
|
||||
|
||||
|
||||
public static boolean isNearBed(Location location) {
|
||||
return isBed(location.getBlock())
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.NORTH))
|
||||
return isBed(location.getBlock()) || isBed(location.getBlock().getRelative(BlockFace.NORTH))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.SOUTH))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.EAST))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.WEST))
|
||||
@@ -404,7 +401,7 @@ public final class Utilities {
|
||||
Material type = block.getType();
|
||||
return type.name().endsWith("STAIRS");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether a block is a wall
|
||||
*
|
||||
@@ -434,10 +431,11 @@ public final class Utilities {
|
||||
*/
|
||||
public static boolean isOnLilyPad(Player player) {
|
||||
Block block = player.getLocation().getBlock();
|
||||
return block.getType() == LILY_PAD || block.getRelative(BlockFace.NORTH).getType() == LILY_PAD
|
||||
|| block.getRelative(BlockFace.SOUTH).getType() == LILY_PAD
|
||||
|| block.getRelative(BlockFace.EAST).getType() == LILY_PAD
|
||||
|| block.getRelative(BlockFace.WEST).getType() == LILY_PAD;
|
||||
return block.getType() == XMaterial.LILY_PAD.parseMaterial()
|
||||
|| block.getRelative(BlockFace.NORTH).getType() == XMaterial.LILY_PAD.parseMaterial()
|
||||
|| block.getRelative(BlockFace.SOUTH).getType() == XMaterial.LILY_PAD.parseMaterial()
|
||||
|| block.getRelative(BlockFace.EAST).getType() == XMaterial.LILY_PAD.parseMaterial()
|
||||
|| block.getRelative(BlockFace.WEST).getType() == XMaterial.LILY_PAD.parseMaterial();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -461,7 +459,7 @@ public final class Utilities {
|
||||
return player.getLocation().getBlock().isLiquid()
|
||||
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).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().getRelative(BlockFace.UP)
|
||||
.getType() == XMaterial.KELP_PLANT.parseMaterial()
|
||||
@@ -490,6 +488,26 @@ public final class Utilities {
|
||||
|| 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
|
||||
*
|
||||
@@ -498,8 +516,7 @@ public final class Utilities {
|
||||
*/
|
||||
public static boolean isSurroundedByWater(Player player) {
|
||||
Location location = player.getLocation().clone().subtract(0, 0.1, 0);
|
||||
return location.getBlock().isLiquid()
|
||||
&& location.getBlock().getRelative(BlockFace.NORTH).isLiquid()
|
||||
return location.getBlock().isLiquid() && location.getBlock().getRelative(BlockFace.NORTH).isLiquid()
|
||||
&& location.getBlock().getRelative(BlockFace.SOUTH).isLiquid()
|
||||
&& location.getBlock().getRelative(BlockFace.EAST).isLiquid()
|
||||
&& location.getBlock().getRelative(BlockFace.WEST).isLiquid()
|
||||
@@ -509,6 +526,32 @@ public final class Utilities {
|
||||
&& 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
|
||||
*
|
||||
@@ -516,11 +559,13 @@ public final class Utilities {
|
||||
* @return true if in web
|
||||
*/
|
||||
public static boolean isInWeb(Player player) {
|
||||
return player.getLocation().getBlock().getType() == COB_WEB
|
||||
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == COB_WEB
|
||||
|| player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == COB_WEB;
|
||||
return player.getLocation().getBlock().getType() == XMaterial.COBWEB.parseMaterial()
|
||||
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == XMaterial.COBWEB
|
||||
.parseMaterial()
|
||||
|| player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == XMaterial.COBWEB
|
||||
.parseMaterial();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether a player is near a climbable block
|
||||
*
|
||||
@@ -536,7 +581,7 @@ public final class Utilities {
|
||||
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.EAST))
|
||||
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.WEST));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether a location is near a climbable block
|
||||
*
|
||||
@@ -730,6 +775,7 @@ public final class Utilities {
|
||||
|
||||
/**
|
||||
* Rounds a float value to a scale
|
||||
*
|
||||
* @param value Value to round
|
||||
* @param scale Scale
|
||||
* @return rounded value
|
||||
@@ -737,9 +783,10 @@ public final class Utilities {
|
||||
public static float roundFloat(float value, int scale) {
|
||||
return new BigDecimal(value).setScale(scale, RoundingMode.HALF_UP).floatValue();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rounds a double value to a scale
|
||||
*
|
||||
* @param value Value to round
|
||||
* @param scale Scale
|
||||
* @return rounded value
|
||||
@@ -747,14 +794,14 @@ public final class Utilities {
|
||||
public static double roundDouble(double value, int scale) {
|
||||
return new BigDecimal(value).setScale(scale, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
|
||||
public static int floor(double value) {
|
||||
int rounded = (int) value;
|
||||
return value < rounded ? rounded - 1 : rounded;
|
||||
}
|
||||
|
||||
int rounded = (int) value;
|
||||
return value < rounded ? rounded - 1 : rounded;
|
||||
}
|
||||
|
||||
public static boolean isHoneyBlock(Block block) {
|
||||
if (!VersionUtil.isOfVersion("v1_15")) {
|
||||
if (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.BEE_UPDATE)) {
|
||||
return false;
|
||||
}
|
||||
return block.getType() == XMaterial.HONEY_BLOCK.parseMaterial();
|
||||
@@ -763,237 +810,233 @@ public final class Utilities {
|
||||
static {
|
||||
// Start 1.8.8
|
||||
if (VersionUtil.isBountifulUpdate()) {
|
||||
LILY_PAD = XMaterial.LILY_PAD.parseMaterial();
|
||||
COB_WEB = XMaterial.COBWEB.parseMaterial();
|
||||
|
||||
// Start instant break materials
|
||||
INSTANT_BREAK.add(XMaterial.COMPARATOR.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.REPEATER.parseMaterial());
|
||||
INSTANT_BREAK.add(Material.TORCH);
|
||||
INSTANT_BREAK.add(XMaterial.TORCH.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.REDSTONE_TORCH.parseMaterial());
|
||||
INSTANT_BREAK.add(Material.REDSTONE_WIRE);
|
||||
INSTANT_BREAK.add(Material.TRIPWIRE);
|
||||
INSTANT_BREAK.add(Material.TRIPWIRE_HOOK);
|
||||
INSTANT_BREAK.add(Material.FIRE);
|
||||
INSTANT_BREAK.add(Material.FLOWER_POT);
|
||||
INSTANT_BREAK.add(Material.TNT);
|
||||
INSTANT_BREAK.add(Material.SLIME_BLOCK);
|
||||
INSTANT_BREAK.add(Material.CARROT);
|
||||
INSTANT_BREAK.add(Material.DEAD_BUSH);
|
||||
INSTANT_BREAK.add(Material.GRASS);
|
||||
INSTANT_BREAK.add(XMaterial.REDSTONE_WIRE.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.TRIPWIRE.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.TRIPWIRE_HOOK.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.FIRE.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.FLOWER_POT.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.TNT.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.SLIME_BLOCK.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.CARROT.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.DEAD_BUSH.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.GRASS.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.TALL_GRASS.parseMaterial());
|
||||
INSTANT_BREAK.add(LILY_PAD);
|
||||
INSTANT_BREAK.add(Material.MELON_STEM);
|
||||
INSTANT_BREAK.add(Material.MELON_STEM);
|
||||
INSTANT_BREAK.add(Material.BROWN_MUSHROOM);
|
||||
INSTANT_BREAK.add(Material.RED_MUSHROOM);
|
||||
INSTANT_BREAK.add(XMaterial.LILY_PAD.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.MELON_STEM.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.MELON_STEM.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.BROWN_MUSHROOM.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.RED_MUSHROOM.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.NETHER_WART.parseMaterial());
|
||||
INSTANT_BREAK.add(Material.POTATO);
|
||||
INSTANT_BREAK.add(Material.PUMPKIN_STEM);
|
||||
INSTANT_BREAK.add(Material.PUMPKIN_STEM);
|
||||
INSTANT_BREAK.add(XMaterial.POTATO.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.PUMPKIN_STEM.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.PUMPKIN_STEM.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.OAK_SAPLING.parseMaterial());
|
||||
INSTANT_BREAK.add(Material.SUGAR_CANE);
|
||||
INSTANT_BREAK.add(Material.WHEAT);
|
||||
INSTANT_BREAK.add(XMaterial.SUGAR_CANE.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.WHEAT.parseMaterial());
|
||||
// End instant break materials
|
||||
|
||||
// Start food
|
||||
FOOD.add(Material.APPLE);
|
||||
FOOD.add(Material.BAKED_POTATO);
|
||||
FOOD.add(Material.BREAD);
|
||||
FOOD.add(Material.CAKE);
|
||||
FOOD.add(Material.CARROT);
|
||||
FOOD.add(Material.COOKED_CHICKEN);
|
||||
FOOD.add(XMaterial.APPLE.parseMaterial());
|
||||
FOOD.add(XMaterial.BAKED_POTATO.parseMaterial());
|
||||
FOOD.add(XMaterial.BREAD.parseMaterial());
|
||||
FOOD.add(XMaterial.CAKE.parseMaterial());
|
||||
FOOD.add(XMaterial.CARROT.parseMaterial());
|
||||
FOOD.add(XMaterial.COOKED_CHICKEN.parseMaterial());
|
||||
FOOD.add(XMaterial.COOKED_COD.parseMaterial());
|
||||
FOOD.add(XMaterial.COD.parseMaterial());
|
||||
FOOD.add(Material.COOKED_MUTTON);
|
||||
FOOD.add(XMaterial.COOKED_MUTTON.parseMaterial());
|
||||
FOOD.add(XMaterial.COOKED_PORKCHOP.parseMaterial());
|
||||
FOOD.add(Material.COOKED_RABBIT);
|
||||
FOOD.add(Material.COOKIE);
|
||||
FOOD.add(Material.GOLDEN_APPLE);
|
||||
FOOD.add(Material.GOLDEN_CARROT);
|
||||
FOOD.add(XMaterial.COOKED_RABBIT.parseMaterial());
|
||||
FOOD.add(XMaterial.COOKIE.parseMaterial());
|
||||
FOOD.add(XMaterial.GOLDEN_APPLE.parseMaterial());
|
||||
FOOD.add(XMaterial.GOLDEN_CARROT.parseMaterial());
|
||||
FOOD.add(XMaterial.GLISTERING_MELON_SLICE.parseMaterial());
|
||||
FOOD.add(XMaterial.MUSHROOM_STEM.parseMaterial());
|
||||
FOOD.add(Material.POISONOUS_POTATO);
|
||||
FOOD.add(Material.POTATO);
|
||||
FOOD.add(Material.PUMPKIN_PIE);
|
||||
FOOD.add(Material.RABBIT_STEW);
|
||||
FOOD.add(Material.COOKED_BEEF);
|
||||
FOOD.add(XMaterial.POISONOUS_POTATO.parseMaterial());
|
||||
FOOD.add(XMaterial.POTATO.parseMaterial());
|
||||
FOOD.add(XMaterial.PUMPKIN_PIE.parseMaterial());
|
||||
FOOD.add(XMaterial.RABBIT_STEW.parseMaterial());
|
||||
FOOD.add(XMaterial.COOKED_BEEF.parseMaterial());
|
||||
FOOD.add(XMaterial.BEEF.parseMaterial());
|
||||
FOOD.add(Material.COOKED_CHICKEN);
|
||||
FOOD.add(XMaterial.COOKED_CHICKEN.parseMaterial());
|
||||
FOOD.add(XMaterial.CHICKEN.parseMaterial());
|
||||
FOOD.add(Material.MUTTON);
|
||||
FOOD.add(XMaterial.MUTTON.parseMaterial());
|
||||
FOOD.add(XMaterial.PORKCHOP.parseMaterial());
|
||||
FOOD.add(Material.RABBIT);
|
||||
FOOD.add(Material.COOKED_RABBIT);
|
||||
FOOD.add(Material.ROTTEN_FLESH);
|
||||
FOOD.add(Material.SPIDER_EYE);
|
||||
FOOD.add(XMaterial.RABBIT.parseMaterial());
|
||||
FOOD.add(XMaterial.COOKED_RABBIT.parseMaterial());
|
||||
FOOD.add(XMaterial.ROTTEN_FLESH.parseMaterial());
|
||||
FOOD.add(XMaterial.SPIDER_EYE.parseMaterial());
|
||||
|
||||
// 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(Material.DIAMOND_SWORD, COB_WEB);
|
||||
COMBO.put(Material.STONE_SWORD, COB_WEB);
|
||||
COMBO.put(XMaterial.WOODEN_SWORD.parseMaterial(), COB_WEB);
|
||||
COMBO.put(XMaterial.IRON_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
|
||||
COMBO.put(XMaterial.DIAMOND_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
|
||||
COMBO.put(XMaterial.STONE_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
|
||||
COMBO.put(XMaterial.WOODEN_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
|
||||
// End combos
|
||||
|
||||
|
||||
// Start climbable
|
||||
CLIMBABLE.add(Material.VINE);
|
||||
CLIMBABLE.add(Material.LADDER);
|
||||
CLIMBABLE.add(Material.WATER);
|
||||
CLIMBABLE.add(XMaterial.VINE.parseMaterial());
|
||||
CLIMBABLE.add(XMaterial.LADDER.parseMaterial());
|
||||
CLIMBABLE.add(XMaterial.WATER.parseMaterial());
|
||||
// End climbable
|
||||
}
|
||||
// End 1.8.8
|
||||
// Start other version
|
||||
else {
|
||||
LILY_PAD = Material.LILY_PAD;
|
||||
COB_WEB = Material.COBWEB;
|
||||
|
||||
MinecraftVersion currentVersion = MinecraftVersion.getCurrentVersion();
|
||||
|
||||
// Start instant break materials
|
||||
INSTANT_BREAK.add(Material.COMPARATOR);
|
||||
INSTANT_BREAK.add(Material.REPEATER);
|
||||
INSTANT_BREAK.add(Material.TORCH);
|
||||
INSTANT_BREAK.add(Material.REDSTONE_TORCH);
|
||||
INSTANT_BREAK.add(Material.REDSTONE_WIRE);
|
||||
INSTANT_BREAK.add(Material.TRIPWIRE);
|
||||
INSTANT_BREAK.add(Material.TRIPWIRE_HOOK);
|
||||
INSTANT_BREAK.add(Material.FIRE);
|
||||
INSTANT_BREAK.add(Material.FLOWER_POT);
|
||||
INSTANT_BREAK.add(Material.INFESTED_CHISELED_STONE_BRICKS);
|
||||
INSTANT_BREAK.add(Material.INFESTED_COBBLESTONE);
|
||||
INSTANT_BREAK.add(Material.INFESTED_CRACKED_STONE_BRICKS);
|
||||
INSTANT_BREAK.add(Material.INFESTED_MOSSY_STONE_BRICKS);
|
||||
INSTANT_BREAK.add(Material.INFESTED_STONE);
|
||||
INSTANT_BREAK.add(Material.INFESTED_STONE_BRICKS);
|
||||
INSTANT_BREAK.add(Material.TNT);
|
||||
INSTANT_BREAK.add(Material.SLIME_BLOCK);
|
||||
INSTANT_BREAK.add(Material.CARROTS);
|
||||
INSTANT_BREAK.add(Material.DEAD_BUSH);
|
||||
INSTANT_BREAK.add(Material.FERN);
|
||||
INSTANT_BREAK.add(Material.LARGE_FERN);
|
||||
INSTANT_BREAK.add(Material.CHORUS_FLOWER);
|
||||
INSTANT_BREAK.add(Material.SUNFLOWER);
|
||||
INSTANT_BREAK.add(Material.LILY_PAD);
|
||||
INSTANT_BREAK.add(Material.MELON_STEM);
|
||||
INSTANT_BREAK.add(Material.ATTACHED_MELON_STEM);
|
||||
INSTANT_BREAK.add(Material.BROWN_MUSHROOM);
|
||||
INSTANT_BREAK.add(Material.RED_MUSHROOM);
|
||||
INSTANT_BREAK.add(Material.NETHER_WART);
|
||||
INSTANT_BREAK.add(Material.POTATOES);
|
||||
INSTANT_BREAK.add(Material.PUMPKIN_STEM);
|
||||
INSTANT_BREAK.add(Material.ATTACHED_PUMPKIN_STEM);
|
||||
INSTANT_BREAK.add(Material.ACACIA_SAPLING);
|
||||
INSTANT_BREAK.add(Material.BIRCH_SAPLING);
|
||||
INSTANT_BREAK.add(Material.DARK_OAK_SAPLING);
|
||||
INSTANT_BREAK.add(Material.JUNGLE_SAPLING);
|
||||
INSTANT_BREAK.add(Material.OAK_SAPLING);
|
||||
INSTANT_BREAK.add(Material.SPRUCE_SAPLING);
|
||||
INSTANT_BREAK.add(Material.SUGAR_CANE);
|
||||
INSTANT_BREAK.add(Material.TALL_GRASS);
|
||||
INSTANT_BREAK.add(Material.TALL_SEAGRASS);
|
||||
INSTANT_BREAK.add(Material.WHEAT);
|
||||
INSTANT_BREAK.add(XMaterial.COMPARATOR.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.REPEATER.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.TORCH.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.REDSTONE_TORCH.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.REDSTONE_WIRE.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.TRIPWIRE.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.TRIPWIRE_HOOK.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.FIRE.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.FLOWER_POT.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.INFESTED_CHISELED_STONE_BRICKS.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.INFESTED_COBBLESTONE.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.INFESTED_CRACKED_STONE_BRICKS.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.INFESTED_MOSSY_STONE_BRICKS.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.INFESTED_STONE.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.INFESTED_STONE_BRICKS.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.TNT.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.SLIME_BLOCK.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.CARROTS.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.DEAD_BUSH.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.FERN.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.LARGE_FERN.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.CHORUS_FLOWER.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.SUNFLOWER.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.LILY_PAD.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.MELON_STEM.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.ATTACHED_MELON_STEM.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.BROWN_MUSHROOM.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.RED_MUSHROOM.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.NETHER_WART.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.POTATOES.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.PUMPKIN_STEM.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.ATTACHED_PUMPKIN_STEM.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.ACACIA_SAPLING.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.BIRCH_SAPLING.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.DARK_OAK_SAPLING.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.JUNGLE_SAPLING.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.OAK_SAPLING.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.SPRUCE_SAPLING.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.SUGAR_CANE.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.TALL_GRASS.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.TALL_SEAGRASS.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.WHEAT.parseMaterial());
|
||||
// Start 1.14 objects
|
||||
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15") || VersionUtil.isOfVersion("v1_16")) {
|
||||
INSTANT_BREAK.add(Material.BAMBOO_SAPLING);
|
||||
INSTANT_BREAK.add(Material.CORNFLOWER);
|
||||
if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
|
||||
INSTANT_BREAK.add(XMaterial.BAMBOO_SAPLING.parseMaterial());
|
||||
INSTANT_BREAK.add(XMaterial.CORNFLOWER.parseMaterial());
|
||||
}
|
||||
// End 1.14 objects
|
||||
// Start 1.15 objects
|
||||
if (VersionUtil.isOfVersion("v1_15") || VersionUtil.isOfVersion("v1_16")) {
|
||||
INSTANT_BREAK.add(Material.HONEY_BLOCK);
|
||||
if (currentVersion.isAtLeast(MinecraftVersion.BEE_UPDATE)) {
|
||||
INSTANT_BREAK.add(XMaterial.HONEY_BLOCK.parseMaterial());
|
||||
}
|
||||
// End 1.15 objects
|
||||
// End instant break materials
|
||||
|
||||
// Start food
|
||||
FOOD.add(Material.APPLE);
|
||||
FOOD.add(Material.BAKED_POTATO);
|
||||
FOOD.add(Material.BEETROOT);
|
||||
FOOD.add(Material.BEETROOT_SOUP);
|
||||
FOOD.add(Material.BREAD);
|
||||
FOOD.add(Material.CAKE);
|
||||
FOOD.add(Material.CARROT);
|
||||
FOOD.add(Material.CHORUS_FRUIT);
|
||||
FOOD.add(Material.COOKED_BEEF);
|
||||
FOOD.add(Material.COOKED_CHICKEN);
|
||||
FOOD.add(Material.COOKED_COD);
|
||||
FOOD.add(Material.COOKED_MUTTON);
|
||||
FOOD.add(Material.COOKED_PORKCHOP);
|
||||
FOOD.add(Material.COOKED_RABBIT);
|
||||
FOOD.add(Material.COOKED_SALMON);
|
||||
FOOD.add(Material.COOKIE);
|
||||
FOOD.add(Material.DRIED_KELP);
|
||||
FOOD.add(Material.ENCHANTED_GOLDEN_APPLE);
|
||||
FOOD.add(Material.GOLDEN_APPLE);
|
||||
FOOD.add(Material.GOLDEN_CARROT);
|
||||
FOOD.add(Material.MELON_SLICE);
|
||||
FOOD.add(Material.MUSHROOM_STEW);
|
||||
FOOD.add(Material.POISONOUS_POTATO);
|
||||
FOOD.add(Material.POTATO);
|
||||
FOOD.add(Material.PUFFERFISH);
|
||||
FOOD.add(Material.PUMPKIN_PIE);
|
||||
FOOD.add(Material.RABBIT_STEW);
|
||||
FOOD.add(Material.BEEF);
|
||||
FOOD.add(Material.CHICKEN);
|
||||
FOOD.add(Material.COD);
|
||||
FOOD.add(Material.MUTTON);
|
||||
FOOD.add(Material.PORKCHOP);
|
||||
FOOD.add(Material.RABBIT);
|
||||
FOOD.add(Material.SALMON);
|
||||
FOOD.add(Material.ROTTEN_FLESH);
|
||||
FOOD.add(Material.SPIDER_EYE);
|
||||
FOOD.add(Material.TROPICAL_FISH);
|
||||
FOOD.add(XMaterial.APPLE.parseMaterial());
|
||||
FOOD.add(XMaterial.BAKED_POTATO.parseMaterial());
|
||||
FOOD.add(XMaterial.BEETROOT.parseMaterial());
|
||||
FOOD.add(XMaterial.BEETROOT_SOUP.parseMaterial());
|
||||
FOOD.add(XMaterial.BREAD.parseMaterial());
|
||||
FOOD.add(XMaterial.CAKE.parseMaterial());
|
||||
FOOD.add(XMaterial.CARROT.parseMaterial());
|
||||
FOOD.add(XMaterial.CHORUS_FRUIT.parseMaterial());
|
||||
FOOD.add(XMaterial.COOKED_BEEF.parseMaterial());
|
||||
FOOD.add(XMaterial.COOKED_CHICKEN.parseMaterial());
|
||||
FOOD.add(XMaterial.COOKED_COD.parseMaterial());
|
||||
FOOD.add(XMaterial.COOKED_MUTTON.parseMaterial());
|
||||
FOOD.add(XMaterial.COOKED_PORKCHOP.parseMaterial());
|
||||
FOOD.add(XMaterial.COOKED_RABBIT.parseMaterial());
|
||||
FOOD.add(XMaterial.COOKED_SALMON.parseMaterial());
|
||||
FOOD.add(XMaterial.COOKIE.parseMaterial());
|
||||
FOOD.add(XMaterial.DRIED_KELP.parseMaterial());
|
||||
FOOD.add(XMaterial.ENCHANTED_GOLDEN_APPLE.parseMaterial());
|
||||
FOOD.add(XMaterial.GOLDEN_APPLE.parseMaterial());
|
||||
FOOD.add(XMaterial.GOLDEN_CARROT.parseMaterial());
|
||||
FOOD.add(XMaterial.MELON_SLICE.parseMaterial());
|
||||
FOOD.add(XMaterial.MUSHROOM_STEW.parseMaterial());
|
||||
FOOD.add(XMaterial.POISONOUS_POTATO.parseMaterial());
|
||||
FOOD.add(XMaterial.POTATO.parseMaterial());
|
||||
FOOD.add(XMaterial.PUFFERFISH.parseMaterial());
|
||||
FOOD.add(XMaterial.PUMPKIN_PIE.parseMaterial());
|
||||
FOOD.add(XMaterial.RABBIT_STEW.parseMaterial());
|
||||
FOOD.add(XMaterial.BEEF.parseMaterial());
|
||||
FOOD.add(XMaterial.CHICKEN.parseMaterial());
|
||||
FOOD.add(XMaterial.COD.parseMaterial());
|
||||
FOOD.add(XMaterial.MUTTON.parseMaterial());
|
||||
FOOD.add(XMaterial.PORKCHOP.parseMaterial());
|
||||
FOOD.add(XMaterial.RABBIT.parseMaterial());
|
||||
FOOD.add(XMaterial.SALMON.parseMaterial());
|
||||
FOOD.add(XMaterial.ROTTEN_FLESH.parseMaterial());
|
||||
FOOD.add(XMaterial.SPIDER_EYE.parseMaterial());
|
||||
FOOD.add(XMaterial.TROPICAL_FISH.parseMaterial());
|
||||
// Start 1.14 objects
|
||||
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15") || VersionUtil.isOfVersion("v1_16")) {
|
||||
FOOD.add(Material.SUSPICIOUS_STEW);
|
||||
FOOD.add(Material.SWEET_BERRIES);
|
||||
if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
|
||||
FOOD.add(XMaterial.SUSPICIOUS_STEW.parseMaterial());
|
||||
FOOD.add(XMaterial.SWEET_BERRIES.parseMaterial());
|
||||
}
|
||||
// End 1.14 objects
|
||||
// Start 1.15 objects
|
||||
if (VersionUtil.isOfVersion("v1_15") || VersionUtil.isOfVersion("v1_16")) {
|
||||
FOOD.add(Material.HONEY_BOTTLE);
|
||||
if (currentVersion.isAtLeast(MinecraftVersion.BEE_UPDATE)) {
|
||||
FOOD.add(XMaterial.HONEY_BOTTLE.parseMaterial());
|
||||
}
|
||||
// End 1.15 objects
|
||||
// End food
|
||||
|
||||
// Start combos
|
||||
COMBO.put(Material.SHEARS, Material.BLACK_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.BLUE_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.BROWN_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.CYAN_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.GRAY_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.GREEN_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.LIGHT_BLUE_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.LIGHT_GRAY_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.LIME_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.MAGENTA_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.MAGENTA_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.ORANGE_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.PINK_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.PURPLE_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.RED_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.WHITE_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.YELLOW_WOOL);
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.BLACK_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.BLUE_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.BROWN_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.CYAN_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.GRAY_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.GREEN_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.LIGHT_BLUE_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.LIGHT_GRAY_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.LIME_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.MAGENTA_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.MAGENTA_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.ORANGE_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.PINK_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.PURPLE_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.RED_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.WHITE_WOOL.parseMaterial());
|
||||
COMBO.put(XMaterial.SHEARS.parseMaterial(), XMaterial.YELLOW_WOOL.parseMaterial());
|
||||
|
||||
COMBO.put(Material.IRON_SWORD, Material.COBWEB);
|
||||
COMBO.put(Material.DIAMOND_SWORD, Material.COBWEB);
|
||||
COMBO.put(Material.STONE_SWORD, Material.COBWEB);
|
||||
COMBO.put(Material.WOODEN_SWORD, Material.COBWEB);
|
||||
COMBO.put(XMaterial.IRON_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
|
||||
COMBO.put(XMaterial.DIAMOND_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
|
||||
COMBO.put(XMaterial.STONE_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
|
||||
COMBO.put(XMaterial.WOODEN_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
|
||||
// End combos
|
||||
|
||||
|
||||
// Start climbable
|
||||
CLIMBABLE.add(Material.VINE);
|
||||
CLIMBABLE.add(Material.LADDER);
|
||||
CLIMBABLE.add(Material.WATER);
|
||||
CLIMBABLE.add(XMaterial.VINE.parseMaterial());
|
||||
CLIMBABLE.add(XMaterial.LADDER.parseMaterial());
|
||||
CLIMBABLE.add(XMaterial.WATER.parseMaterial());
|
||||
// Start 1.14 objects
|
||||
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15")
|
||||
|| VersionUtil.isOfVersion("v1_16")) {
|
||||
CLIMBABLE.add(Material.SCAFFOLDING);
|
||||
if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
|
||||
CLIMBABLE.add(XMaterial.SCAFFOLDING.parseMaterial());
|
||||
CLIMBABLE.add(XMaterial.SWEET_BERRY_BUSH.parseMaterial());
|
||||
}
|
||||
// End 1.14 objects
|
||||
|
||||
|
||||
// Start 1.16 objects
|
||||
if (VersionUtil.isOfVersion("v1_16")) {
|
||||
if (currentVersion.isAtLeast(MinecraftVersion.NETHER_UPDATE)) {
|
||||
CLIMBABLE.add(XMaterial.TWISTING_VINES.parseMaterial());
|
||||
CLIMBABLE.add(XMaterial.TWISTING_VINES_PLANT.parseMaterial());
|
||||
CLIMBABLE.add(XMaterial.WEEPING_VINES.parseMaterial());
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -36,8 +35,8 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
|
||||
public class VersionUtil {
|
||||
|
||||
private static final List<String> SUPPORTED_VERSIONS = Arrays
|
||||
.asList(new String[] { "v1_16", "v1_15", "v1_14", "v1_13", "v1_8_R3" });
|
||||
private static final List<String> SUPPORTED_VERSIONS;
|
||||
private static final MinecraftVersion CURRENT_VERSION;
|
||||
|
||||
public static String getVersion() {
|
||||
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||
@@ -75,14 +74,14 @@ public class VersionUtil {
|
||||
}
|
||||
|
||||
public static boolean isRiptiding(Player player) {
|
||||
if (isBountifulUpdate()) {
|
||||
if (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
|
||||
return false;
|
||||
}
|
||||
return player.isRiptiding();
|
||||
}
|
||||
|
||||
public static boolean isSlowFalling(Player player) {
|
||||
if (isBountifulUpdate()) {
|
||||
if (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
|
||||
return false;
|
||||
}
|
||||
return player.hasPotionEffect(PotionEffectType.SLOW_FALLING);
|
||||
@@ -114,7 +113,7 @@ public class VersionUtil {
|
||||
}
|
||||
|
||||
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.getTargetBlockExact(distance);
|
||||
@@ -142,16 +141,21 @@ public class VersionUtil {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (player.hasPotionEffect(type))
|
||||
return player.getPotionEffect(type).getAmplifier() + 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean isSwimming(Player player) {
|
||||
if (isBountifulUpdate()) {
|
||||
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;
|
||||
|
||||
import com.google.common.base.Enums;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
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.Validate;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
@@ -35,19 +49,18 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
import com.google.common.base.Enums;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
|
||||
/**
|
||||
* <b>XMaterial</b> - Data Values/Pre-flattening<br>
|
||||
* 1.13 and above as priority.
|
||||
* <p>
|
||||
* This class is mainly designed to support ItemStacks.
|
||||
* If you want to use it on blocks you'll have to
|
||||
* use <a href="https://github.com/CryptoMorin/XSeries/blob/master/XBlock.java">XBlock</a>
|
||||
* This class is mainly designed to support ItemStacks. If you want to use it on blocks, you'll have to use
|
||||
* <a href="https://github.com/CryptoMorin/XSeries/blob/master/src/main/java/com/cryptomorin/xseries/XBlock.java">XBlock</a>
|
||||
* <p>
|
||||
* Pre-flattening: https://minecraft.gamepedia.com/Java_Edition_data_values/Pre-flattening
|
||||
* 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 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/
|
||||
* <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
|
||||
* @version 5.0.1
|
||||
* @version 6.0.2
|
||||
* @see Material
|
||||
* @see ItemStack
|
||||
*/
|
||||
@@ -72,11 +89,11 @@ public enum XMaterial {
|
||||
ACACIA_PLANKS(4, "WOOD"),
|
||||
ACACIA_PRESSURE_PLATE("WOOD_PLATE"),
|
||||
ACACIA_SAPLING(4, "SAPLING"),
|
||||
ACACIA_SIGN("SIGN"),
|
||||
ACACIA_SIGN("SIGN_POST", "SIGN"),
|
||||
ACACIA_SLAB(4, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
||||
ACACIA_STAIRS,
|
||||
ACACIA_TRAPDOOR("TRAP_DOOR"),
|
||||
ACACIA_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
||||
ACACIA_WALL_SIGN("WALL_SIGN"),
|
||||
ACACIA_WOOD("LOG_2"),
|
||||
ACTIVATOR_RAIL,
|
||||
/**
|
||||
@@ -132,22 +149,22 @@ public enum XMaterial {
|
||||
BIRCH_PLANKS(2, "WOOD"),
|
||||
BIRCH_PRESSURE_PLATE("WOOD_PLATE"),
|
||||
BIRCH_SAPLING(2, "SAPLING"),
|
||||
BIRCH_SIGN("SIGN"),
|
||||
BIRCH_SIGN("SIGN_POST", "SIGN"),
|
||||
BIRCH_SLAB(2, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
||||
BIRCH_STAIRS("BIRCH_WOOD_STAIRS"),
|
||||
BIRCH_TRAPDOOR("TRAP_DOOR"),
|
||||
BIRCH_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
||||
BIRCH_WALL_SIGN("WALL_SIGN"),
|
||||
BIRCH_WOOD(2, "LOG"),
|
||||
BLACKSTONE("1.16"),
|
||||
BLACKSTONE_SLAB("1.16"),
|
||||
BLACKSTONE_STAIRS("1.16"),
|
||||
BLACKSTONE_WALL("1.16"),
|
||||
BLACK_BANNER("BANNER", "STANDING_BANNER"),
|
||||
BLACK_BANNER("STANDING_BANNER", "BANNER"),
|
||||
BLACK_BED(15, "BED_BLOCK", "BED"),
|
||||
BLACK_CARPET(15, "CARPET"),
|
||||
BLACK_CONCRETE(15, "CONCRETE"),
|
||||
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_SHULKER_BOX,
|
||||
BLACK_STAINED_GLASS(15, "STAINED_GLASS"),
|
||||
@@ -159,7 +176,7 @@ public enum XMaterial {
|
||||
BLAZE_POWDER,
|
||||
BLAZE_ROD,
|
||||
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_CARPET(11, "CARPET"),
|
||||
BLUE_CONCRETE(11, "CONCRETE"),
|
||||
@@ -192,7 +209,7 @@ public enum XMaterial {
|
||||
BRICK_SLAB(4, "STEP"),
|
||||
BRICK_STAIRS,
|
||||
BRICK_WALL,
|
||||
BROWN_BANNER(3, "BANNER", "STANDING_BANNER"),
|
||||
BROWN_BANNER(3, "STANDING_BANNER", "BANNER"),
|
||||
BROWN_BED(12, "BED_BLOCK", "BED"),
|
||||
BROWN_CARPET(12, "CARPET"),
|
||||
BROWN_CONCRETE(12, "CONCRETE"),
|
||||
@@ -309,19 +326,19 @@ public enum XMaterial {
|
||||
CRIMSON_PLANKS("1.16"),
|
||||
CRIMSON_PRESSURE_PLATE("1.16"),
|
||||
CRIMSON_ROOTS("1.16"),
|
||||
CRIMSON_SIGN("1.16"),
|
||||
CRIMSON_SIGN("1.16", "SIGN_POST"),
|
||||
CRIMSON_SLAB("1.16"),
|
||||
CRIMSON_STAIRS("1.16"),
|
||||
CRIMSON_STEM("1.16"),
|
||||
CRIMSON_TRAPDOOR("1.16"),
|
||||
CRIMSON_WALL_SIGN("1.16"),
|
||||
CRIMSON_WALL_SIGN("1.16", "WALL_SIGN"),
|
||||
CROSSBOW,
|
||||
CRYING_OBSIDIAN("1.16"),
|
||||
CUT_RED_SANDSTONE("1.13"),
|
||||
CUT_RED_SANDSTONE_SLAB("STONE_SLAB2"),
|
||||
CUT_SANDSTONE("1.13"),
|
||||
CUT_SANDSTONE_SLAB("STEP"),
|
||||
CYAN_BANNER(6, "BANNER", "STANDING_BANNER"),
|
||||
CYAN_BANNER(6, "STANDING_BANNER", "BANNER"),
|
||||
CYAN_BED(9, "BED_BLOCK", "BED"),
|
||||
CYAN_CARPET(9, "CARPET"),
|
||||
CYAN_CONCRETE(9, "CONCRETE"),
|
||||
@@ -346,11 +363,11 @@ public enum XMaterial {
|
||||
DARK_OAK_PLANKS(5, "WOOD"),
|
||||
DARK_OAK_PRESSURE_PLATE("WOOD_PLATE"),
|
||||
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_STAIRS,
|
||||
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_PRISMARINE(1, "PRISMARINE"),
|
||||
DARK_PRISMARINE_SLAB("1.13"),
|
||||
@@ -437,7 +454,7 @@ public enum XMaterial {
|
||||
FARMLAND("SOIL"),
|
||||
FEATHER,
|
||||
FERMENTED_SPIDER_EYE,
|
||||
FERN(1, "LONG_GRASS"),
|
||||
FERN(2, "LONG_GRASS"),
|
||||
/**
|
||||
* For some reasons filled map items are really special.
|
||||
* Their data value starts from 0 and every time a player
|
||||
@@ -467,6 +484,7 @@ public enum XMaterial {
|
||||
FURNACE_MINECART("POWERED_MINECART"),
|
||||
GHAST_SPAWN_EGG(56, "MONSTER_EGG"),
|
||||
GHAST_TEAR,
|
||||
GILDED_BLACKSTONE("1.16"),
|
||||
GLASS,
|
||||
GLASS_BOTTLE,
|
||||
GLASS_PANE("THIN_GLASS"),
|
||||
@@ -494,11 +512,11 @@ public enum XMaterial {
|
||||
GRANITE_SLAB,
|
||||
GRANITE_STAIRS,
|
||||
GRANITE_WALL,
|
||||
GRASS,
|
||||
GRASS(1, "LONG_GRASS"),
|
||||
GRASS_BLOCK("GRASS"),
|
||||
GRASS_PATH,
|
||||
GRAVEL,
|
||||
GRAY_BANNER(8, "BANNER", "STANDING_BANNER"),
|
||||
GRAY_BANNER(8, "STANDING_BANNER", "BANNER"),
|
||||
GRAY_BED(7, "BED_BLOCK", "BED"),
|
||||
GRAY_CARPET(7, "CARPET"),
|
||||
GRAY_CONCRETE(7, "CONCRETE"),
|
||||
@@ -511,7 +529,7 @@ public enum XMaterial {
|
||||
GRAY_TERRACOTTA(7, "HARD_CLAY", "STAINED_CLAY"),
|
||||
GRAY_WALL_BANNER(8, "WALL_BANNER"),
|
||||
GRAY_WOOL(7, "WOOL"),
|
||||
GREEN_BANNER(2, "BANNER", "STANDING_BANNER"),
|
||||
GREEN_BANNER(2, "STANDING_BANNER", "BANNER"),
|
||||
GREEN_BED(13, "BED_BLOCK", "BED"),
|
||||
GREEN_CARPET(13, "CARPET"),
|
||||
GREEN_CONCRETE(13, "CONCRETE"),
|
||||
@@ -550,6 +568,11 @@ public enum XMaterial {
|
||||
INFESTED_MOSSY_STONE_BRICKS(3, "MONSTER_EGGS"),
|
||||
INFESTED_STONE("MONSTER_EGGS"),
|
||||
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"),
|
||||
IRON_AXE,
|
||||
IRON_BARS("IRON_FENCE"),
|
||||
@@ -582,11 +605,11 @@ public enum XMaterial {
|
||||
JUNGLE_PLANKS(3, "WOOD"),
|
||||
JUNGLE_PRESSURE_PLATE("WOOD_PLATE"),
|
||||
JUNGLE_SAPLING(3, "SAPLING"),
|
||||
JUNGLE_SIGN("SIGN"),
|
||||
JUNGLE_SIGN("SIGN_POST", "SIGN"),
|
||||
JUNGLE_SLAB(3, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
||||
JUNGLE_STAIRS("JUNGLE_WOOD_STAIRS"),
|
||||
JUNGLE_TRAPDOOR("TRAP_DOOR"),
|
||||
JUNGLE_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
||||
JUNGLE_WALL_SIGN("WALL_SIGN"),
|
||||
JUNGLE_WOOD(3, "LOG"),
|
||||
KELP("1.13"),
|
||||
KELP_PLANT("1.13"),
|
||||
@@ -608,7 +631,7 @@ public enum XMaterial {
|
||||
LEATHER_LEGGINGS,
|
||||
LECTERN("1.14", "BOOKSHELF", ""),
|
||||
LEVER,
|
||||
LIGHT_BLUE_BANNER(12, "BANNER", "STANDING_BANNER"),
|
||||
LIGHT_BLUE_BANNER(12, "STANDING_BANNER", "BANNER"),
|
||||
LIGHT_BLUE_BED(3, "BED_BLOCK", "BED"),
|
||||
LIGHT_BLUE_CARPET(3, "CARPET"),
|
||||
LIGHT_BLUE_CONCRETE(3, "CONCRETE"),
|
||||
@@ -619,9 +642,9 @@ public enum XMaterial {
|
||||
LIGHT_BLUE_STAINED_GLASS(3, "STAINED_GLASS"),
|
||||
LIGHT_BLUE_STAINED_GLASS_PANE(3, "THIN_GLASS", "STAINED_GLASS_PANE"),
|
||||
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_GRAY_BANNER(7, "BANNER", "STANDING_BANNER"),
|
||||
LIGHT_GRAY_BANNER(7, "STANDING_BANNER", "BANNER"),
|
||||
LIGHT_GRAY_BED(8, "BED_BLOCK", "BED"),
|
||||
LIGHT_GRAY_CARPET(8, "CARPET"),
|
||||
LIGHT_GRAY_CONCRETE(8, "CONCRETE"),
|
||||
@@ -642,7 +665,7 @@ public enum XMaterial {
|
||||
LILAC(1, "DOUBLE_PLANT"),
|
||||
LILY_OF_THE_VALLEY(15, "1.14", "WHITE_DYE", ""),
|
||||
LILY_PAD("WATER_LILY"),
|
||||
LIME_BANNER(10, "BANNER", "STANDING_BANNER"),
|
||||
LIME_BANNER(10, "STANDING_BANNER", "BANNER"),
|
||||
LIME_BED(5, "BED_BLOCK", "BED"),
|
||||
LIME_CARPET(5, "CARPET"),
|
||||
LIME_CONCRETE(5, "CONCRETE"),
|
||||
@@ -659,7 +682,7 @@ public enum XMaterial {
|
||||
LLAMA_SPAWN_EGG(103, "MONSTER_EGG"),
|
||||
LODESTONE("1.16"),
|
||||
LOOM("1.14"),
|
||||
MAGENTA_BANNER(13, "BANNER", "STANDING_BANNER"),
|
||||
MAGENTA_BANNER(13, "STANDING_BANNER", "BANNER"),
|
||||
MAGENTA_BED(2, "BED_BLOCK", "BED"),
|
||||
MAGENTA_CARPET(2, "CARPET"),
|
||||
MAGENTA_CONCRETE(2, "CONCRETE"),
|
||||
@@ -711,6 +734,7 @@ public enum XMaterial {
|
||||
MUSIC_DISC_FAR("RECORD_6"),
|
||||
MUSIC_DISC_MALL("RECORD_7"),
|
||||
MUSIC_DISC_MELLOHI("RECORD_8"),
|
||||
MUSIC_DISC_PIGSTEP("1.16"),
|
||||
MUSIC_DISC_STAL("RECORD_9"),
|
||||
MUSIC_DISC_STRAD("RECORD_10"),
|
||||
MUSIC_DISC_WAIT("RECORD_11"),
|
||||
@@ -761,16 +785,16 @@ public enum XMaterial {
|
||||
OAK_PLANKS("WOOD"),
|
||||
OAK_PRESSURE_PLATE("WOOD_PLATE"),
|
||||
OAK_SAPLING("SAPLING"),
|
||||
OAK_SIGN("SIGN"),
|
||||
OAK_SIGN("SIGN_POST", "SIGN"),
|
||||
OAK_SLAB("WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
||||
OAK_STAIRS("WOOD_STAIRS"),
|
||||
OAK_TRAPDOOR("TRAP_DOOR"),
|
||||
OAK_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
||||
OAK_WALL_SIGN("WALL_SIGN"),
|
||||
OAK_WOOD("LOG"),
|
||||
OBSERVER,
|
||||
OBSIDIAN,
|
||||
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_CARPET(1, "CARPET"),
|
||||
ORANGE_CONCRETE(1, "CONCRETE"),
|
||||
@@ -794,9 +818,11 @@ public enum XMaterial {
|
||||
PETRIFIED_OAK_SLAB("WOOD_STEP"),
|
||||
PHANTOM_MEMBRANE("1.13"),
|
||||
PHANTOM_SPAWN_EGG("1.13", "MONSTER_EGG", ""),
|
||||
PIGLIN_BANNER_PATTERN("1.16"),
|
||||
PIGLIN_SPAWN_EGG(57, "MONSTER_EGG"),
|
||||
PIG_SPAWN_EGG(90, "MONSTER_EGG"),
|
||||
PILLAGER_SPAWN_EGG("1.14"),
|
||||
PINK_BANNER(9, "BANNER", "STANDING_BANNER"),
|
||||
PINK_BANNER(9, "STANDING_BANNER", "BANNER"),
|
||||
PINK_BED(6, "BED_BLOCK", "BED"),
|
||||
PINK_CARPET(6, "CARPET"),
|
||||
PINK_CONCRETE(6, "CONCRETE"),
|
||||
@@ -852,6 +878,8 @@ public enum XMaterial {
|
||||
POTTED_BROWN_MUSHROOM("FLOWER_POT"),
|
||||
POTTED_CACTUS("FLOWER_POT"),
|
||||
POTTED_CORNFLOWER,
|
||||
POTTED_CRIMSON_FUNGUS("1.16"),
|
||||
POTTED_CRIMSON_ROOTS("1.16"),
|
||||
POTTED_DANDELION("YELLOW_FLOWER", "FLOWER_POT"),
|
||||
POTTED_DARK_OAK_SAPLING(5, "SAPLING", "FLOWER_POT"),
|
||||
POTTED_DEAD_BUSH("FLOWER_POT"),
|
||||
@@ -866,6 +894,8 @@ public enum XMaterial {
|
||||
POTTED_RED_MUSHROOM("FLOWER_POT"),
|
||||
POTTED_RED_TULIP(4, "RED_ROSE", "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_WITHER_ROSE,
|
||||
POWERED_RAIL,
|
||||
@@ -885,7 +915,7 @@ public enum XMaterial {
|
||||
PUMPKIN_PIE,
|
||||
PUMPKIN_SEEDS,
|
||||
PUMPKIN_STEM,
|
||||
PURPLE_BANNER(5, "BANNER", "STANDING_BANNER"),
|
||||
PURPLE_BANNER(5, "STANDING_BANNER", "BANNER"),
|
||||
PURPLE_BED(10, "BED_BLOCK", "BED"),
|
||||
PURPLE_CARPET(10, "CARPET"),
|
||||
PURPLE_CONCRETE(10, "CONCRETE"),
|
||||
@@ -904,6 +934,7 @@ public enum XMaterial {
|
||||
PURPUR_STAIRS,
|
||||
QUARTZ,
|
||||
QUARTZ_BLOCK,
|
||||
QUARTZ_BRICKS("1.16"),
|
||||
QUARTZ_PILLAR(2, "QUARTZ_BLOCK"),
|
||||
QUARTZ_SLAB(7, "STEP"),
|
||||
QUARTZ_STAIRS,
|
||||
@@ -932,7 +963,7 @@ public enum XMaterial {
|
||||
REDSTONE_TORCH("REDSTONE_TORCH_OFF", "REDSTONE_TORCH_ON"),
|
||||
REDSTONE_WALL_TORCH,
|
||||
REDSTONE_WIRE,
|
||||
RED_BANNER(1, "BANNER", "STANDING_BANNER"),
|
||||
RED_BANNER(1, "STANDING_BANNER", "BANNER"),
|
||||
/**
|
||||
* Data value 14 or 0
|
||||
*/
|
||||
@@ -940,10 +971,7 @@ public enum XMaterial {
|
||||
RED_CARPET(14, "CARPET"),
|
||||
RED_CONCRETE(14, "CONCRETE"),
|
||||
RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"),
|
||||
/**
|
||||
* Data value 0 or 1?
|
||||
*/
|
||||
RED_DYE(0, "INK_SACK", "ROSE_RED"),
|
||||
RED_DYE(1, "INK_SACK", "ROSE_RED"),
|
||||
RED_GLAZED_TERRACOTTA(14, "1.12", "HARD_CLAY", "STAINED_CLAY", "RED_TERRACOTTA"),
|
||||
RED_MUSHROOM,
|
||||
RED_MUSHROOM_BLOCK("RED_MUSHROOM", "HUGE_MUSHROOM_2"),
|
||||
@@ -963,7 +991,7 @@ public enum XMaterial {
|
||||
RED_TULIP(4, "RED_ROSE"),
|
||||
RED_WALL_BANNER(1, "WALL_BANNER"),
|
||||
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"),
|
||||
RESPAWN_ANCHOR("1.16"),
|
||||
ROSE_BUSH(4, "DOUBLE_PLANT"),
|
||||
@@ -1032,16 +1060,16 @@ public enum XMaterial {
|
||||
SPRUCE_DOOR("SPRUCE_DOOR_ITEM", "SPRUCE_DOOR"),
|
||||
SPRUCE_FENCE,
|
||||
SPRUCE_FENCE_GATE,
|
||||
SPRUCE_LEAVES(1, "LEAVES"),
|
||||
SPRUCE_LEAVES(1, "LEAVES", "LEAVES_2"),
|
||||
SPRUCE_LOG(1, "LOG"),
|
||||
SPRUCE_PLANKS(1, "WOOD"),
|
||||
SPRUCE_PRESSURE_PLATE("WOOD_PLATE"),
|
||||
SPRUCE_SAPLING(1, "SAPLING"),
|
||||
SPRUCE_SIGN("SIGN"),
|
||||
SPRUCE_SIGN("SIGN_POST", "SIGN"),
|
||||
SPRUCE_SLAB(1, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
||||
SPRUCE_STAIRS("SPRUCE_WOOD_STAIRS"),
|
||||
SPRUCE_TRAPDOOR("TRAP_DOOR"),
|
||||
SPRUCE_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
||||
SPRUCE_WALL_SIGN("WALL_SIGN"),
|
||||
SPRUCE_WOOD(1, "LOG"),
|
||||
SQUID_SPAWN_EGG(94, "MONSTER_EGG"),
|
||||
STICK,
|
||||
@@ -1062,6 +1090,7 @@ public enum XMaterial {
|
||||
STONE_STAIRS,
|
||||
STONE_SWORD,
|
||||
STRAY_SPAWN_EGG(6, "MONSTER_EGG"),
|
||||
STRIDER_SPAWN_EGG("1.16"),
|
||||
STRING,
|
||||
STRIPPED_ACACIA_LOG("LOG_2"),
|
||||
STRIPPED_ACACIA_WOOD("LOG_2"),
|
||||
@@ -1144,12 +1173,12 @@ public enum XMaterial {
|
||||
WARPED_PLANKS("1.16"),
|
||||
WARPED_PRESSURE_PLATE("1.16"),
|
||||
WARPED_ROOTS("1.16"),
|
||||
WARPED_SIGN("1.16"),
|
||||
WARPED_SIGN("1.16", "SIGN_POST"),
|
||||
WARPED_SLAB("1.16"),
|
||||
WARPED_STAIRS("1.16"),
|
||||
WARPED_STEM("1.16"),
|
||||
WARPED_TRAPDOOR("1.16"),
|
||||
WARPED_WALL_SIGN("1.16"),
|
||||
WARPED_WALL_SIGN("1.16", "WALL_SIGN"),
|
||||
WARPED_WART_BLOCK("1.16"),
|
||||
/**
|
||||
* This is used for blocks only.
|
||||
@@ -1169,7 +1198,7 @@ public enum XMaterial {
|
||||
*/
|
||||
WHEAT("CROPS"),
|
||||
WHEAT_SEEDS("SEEDS"),
|
||||
WHITE_BANNER(15, "BANNER", "STANDING_BANNER"),
|
||||
WHITE_BANNER(15, "STANDING_BANNER", "BANNER"),
|
||||
WHITE_BED("BED_BLOCK", "BED"),
|
||||
WHITE_CARPET("CARPET"),
|
||||
WHITE_CONCRETE("CONCRETE"),
|
||||
@@ -1196,7 +1225,7 @@ public enum XMaterial {
|
||||
WOODEN_SWORD("WOOD_SWORD"),
|
||||
WRITABLE_BOOK("BOOK_AND_QUILL"),
|
||||
WRITTEN_BOOK,
|
||||
YELLOW_BANNER(11, "BANNER", "STANDING_BANNER"),
|
||||
YELLOW_BANNER(11, "STANDING_BANNER", "BANNER"),
|
||||
YELLOW_BED(4, "BED_BLOCK", "BED"),
|
||||
YELLOW_CARPET(4, "CARPET"),
|
||||
YELLOW_CONCRETE(4, "CONCRETE"),
|
||||
@@ -1209,22 +1238,31 @@ public enum XMaterial {
|
||||
YELLOW_TERRACOTTA(4, "HARD_CLAY", "STAINED_CLAY"),
|
||||
YELLOW_WALL_BANNER(11, "WALL_BANNER"),
|
||||
YELLOW_WOOL(4, "WOOL"),
|
||||
ZOGLIN_SPAWN_EGG("1.16"),
|
||||
ZOMBIE_HEAD(2, "SKULL", "SKULL_ITEM"),
|
||||
ZOMBIE_HORSE_SPAWN_EGG(29, "MONSTER_EGG"),
|
||||
ZOMBIE_SPAWN_EGG(54, "MONSTER_EGG"),
|
||||
ZOMBIE_VILLAGER_SPAWN_EGG(27, "MONSTER_EGG"),
|
||||
ZOMBIE_WALL_HEAD(2, "SKULL", "SKULL_ITEM"),
|
||||
PIGLIN_SPAWN_EGG(57, "MONSTER_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.
|
||||
* This list is unmodifiable.
|
||||
*
|
||||
* @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.
|
||||
* <p>
|
||||
@@ -1233,13 +1271,13 @@ public enum XMaterial {
|
||||
*
|
||||
* @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",
|
||||
"SWORD", "AXE", "PICKAXE", "SHOVEL", "HOE",
|
||||
"ELYTRA", "TRIDENT", "HORSE_ARMOR", "BARDING",
|
||||
"SHEARS", "FLINT_AND_STEEL", "BOW", "FISHING_ROD",
|
||||
"CARROT_ON_A_STICK", "CARROT_STICK", "SPADE", "SHIELD"
|
||||
);
|
||||
));
|
||||
/**
|
||||
* <b>XMaterial Paradox (Duplication Check)</b>
|
||||
* <p>
|
||||
@@ -1250,29 +1288,25 @@ public enum XMaterial {
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
private static final ImmutableMap<XMaterial, XMaterial> duplicated = Maps.immutableEnumMap(ImmutableMap.<XMaterial, XMaterial>builder()
|
||||
.put(MELON, MELON_SLICE)
|
||||
.put(CARROT, CARROTS)
|
||||
.put(POTATO, POTATOES)
|
||||
.put(BEETROOT, BEETROOTS)
|
||||
.put(BROWN_MUSHROOM, BROWN_MUSHROOM_BLOCK)
|
||||
.put(BRICK, BRICKS)
|
||||
.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.
|
||||
// These materials have their enum name added to the legacy list as well.
|
||||
.put(DARK_OAK_DOOR, DARK_OAK_DOOR)
|
||||
.put(ACACIA_DOOR, ACACIA_DOOR)
|
||||
.put(BIRCH_DOOR, BIRCH_DOOR)
|
||||
.put(JUNGLE_DOOR, JUNGLE_DOOR)
|
||||
.put(SPRUCE_DOOR, SPRUCE_DOOR)
|
||||
|
||||
.build()
|
||||
);
|
||||
private static final EnumMap<XMaterial, XMaterial> DUPLICATED = new EnumMap<XMaterial, XMaterial>(XMaterial.class);
|
||||
/**
|
||||
* Guava (Google Core Libraries for Java)'s cache for performance and timed caches.
|
||||
* For strings that match a certain XMaterial. Mostly cached for configs.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static final Cache<String, XMaterial> NAME_CACHE = CacheBuilder.newBuilder()
|
||||
.expireAfterAccess(15, TimeUnit.MINUTES)
|
||||
.build();
|
||||
/**
|
||||
* Guava (Google Core Libraries for Java)'s cache for performance and timed caches.
|
||||
* For XMaterials that are already parsed once.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
private static final Cache<XMaterial, Optional<Material>> PARSED_CACHE = CacheBuilder.newBuilder()
|
||||
.expireAfterAccess(10, TimeUnit.MINUTES)
|
||||
.build();
|
||||
/*
|
||||
* A set of all the legacy names without duplicates.
|
||||
* <p>
|
||||
@@ -1287,36 +1321,24 @@ public enum XMaterial {
|
||||
.filter(m -> m.charAt(1) == '.')
|
||||
.collect(Collectors.collectingAndThen(Collectors.toSet(), ImmutableSet::copyOf));
|
||||
*/
|
||||
|
||||
/**
|
||||
* Guava (Google Core Libraries for Java)'s cache for performance and timed caches.
|
||||
* For strings that match a certain XMaterial. Mostly cached for configs.
|
||||
* This is used for {@link #isOneOf(Collection)}
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 3.4.0
|
||||
*/
|
||||
private static final Cache<String, XMaterial> NAME_CACHE = CacheBuilder.newBuilder()
|
||||
.softValues()
|
||||
.expireAfterAccess(15, TimeUnit.MINUTES)
|
||||
.build();
|
||||
/**
|
||||
* Guava (Google Core Libraries for Java)'s cache for performance and timed caches.
|
||||
* For XMaterials that are already parsed once.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
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+");
|
||||
private static final LoadingCache<String, Pattern> CACHED_REGEX = CacheBuilder.newBuilder()
|
||||
.expireAfterAccess(1, TimeUnit.HOURS)
|
||||
.build(new CacheLoader<String, Pattern>() {
|
||||
@Override
|
||||
public Pattern load(@Nonnull String str) {
|
||||
try {
|
||||
return Pattern.compile(str);
|
||||
} catch (PatternSyntaxException ex) {
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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
|
||||
*
|
||||
@@ -1382,7 +1433,7 @@ public enum XMaterial {
|
||||
* An invocation of this method yields exactly the same result as the expression:
|
||||
* <p>
|
||||
* <blockquote>
|
||||
* {@link #getVersion()} == 1.8
|
||||
* !{@link #supports(int)} 9
|
||||
* </blockquote>
|
||||
*
|
||||
* @since 2.0.0
|
||||
@@ -1391,6 +1442,18 @@ public enum XMaterial {
|
||||
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.
|
||||
*
|
||||
@@ -1442,8 +1505,9 @@ public enum XMaterial {
|
||||
Validate.notEmpty(name, "Cannot check for null or empty material name");
|
||||
name = format(name);
|
||||
|
||||
for (XMaterial materials : VALUES)
|
||||
for (XMaterial materials : VALUES) {
|
||||
if (materials.name().equals(name)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1463,13 +1527,13 @@ public enum XMaterial {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* <p>
|
||||
* <b>Examples</b>
|
||||
* <p><pre>
|
||||
* {@code INK_SACK:1 -> RED_DYE}
|
||||
* {@code WOOL, 14 -> RED_WOOL}
|
||||
* {@code WOOL: 14 -> RED_WOOL}
|
||||
* </pre>
|
||||
*
|
||||
* @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)
|
||||
* @since 3.0.0
|
||||
*/
|
||||
@Nonnull
|
||||
private static Optional<XMaterial> matchXMaterialWithData(String name) {
|
||||
for (char separator : new char[]{',', ':'}) {
|
||||
int index = name.indexOf(separator);
|
||||
if (index == -1) continue;
|
||||
|
||||
int index = name.indexOf(':');
|
||||
if (index != -1) {
|
||||
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();
|
||||
@@ -1502,7 +1569,7 @@ public enum XMaterial {
|
||||
public static XMaterial matchXMaterial(@Nonnull Material material) {
|
||||
Objects.requireNonNull(material, "Cannot match null material");
|
||||
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());
|
||||
|
||||
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.
|
||||
// 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 (data <= 0 && !duplicated) {
|
||||
Optional<XMaterial> xMaterial = null;
|
||||
if (data <= 0 && (ISFLAT || !duplicated)) {
|
||||
// Apparently the transform method is more efficient than toJavaUtil()
|
||||
// toJavaUtil isn't even supported in older versions.
|
||||
Optional<XMaterial> xMat = Enums.getIfPresent(XMaterial.class, name).transform(Optional::of).or(Optional.empty());
|
||||
if (xMat.isPresent()) return xMat;
|
||||
xMaterial = getIfPresent(name);
|
||||
if (xMaterial.isPresent()) return xMaterial;
|
||||
}
|
||||
|
||||
// XMaterial Paradox (Duplication Check)
|
||||
@@ -1566,7 +1634,7 @@ public enum XMaterial {
|
||||
// A solution for XMaterial Paradox.
|
||||
// Manually parses the duplicated materials to find the exact material based on the server version.
|
||||
// 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);
|
||||
}
|
||||
@@ -1585,7 +1653,7 @@ public enum XMaterial {
|
||||
*/
|
||||
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.
|
||||
for (Map.Entry<XMaterial, XMaterial> duplicated : duplicated.entrySet()) {
|
||||
for (Map.Entry<XMaterial, XMaterial> duplicated : DUPLICATED.entrySet()) {
|
||||
XMaterial material = duplicated.getKey();
|
||||
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.
|
||||
* 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.
|
||||
* @return a Material enum name.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Nonnull
|
||||
private static String format(@Nonnull String name) {
|
||||
return FORMAT_PATTERN.matcher(
|
||||
name.trim().replace('-', '_').replace(' ', '_')).replaceAll("").toUpperCase(Locale.ENGLISH);
|
||||
protected static String format(@Nonnull String name) {
|
||||
int len = name.length();
|
||||
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) {
|
||||
Objects.requireNonNull(name, "Material name cannot be null");
|
||||
for (String damageable : DAMAGEABLE)
|
||||
for (String damageable : DAMAGEABLE) {
|
||||
if (name.contains(damageable)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1750,32 +1844,31 @@ public enum XMaterial {
|
||||
* <p>
|
||||
* 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.
|
||||
* @return true if one of the given material names is similar to the base material.
|
||||
* @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;
|
||||
Objects.requireNonNull(material, "Cannot match materials with a null material");
|
||||
String name = material.name();
|
||||
String name = this.name();
|
||||
|
||||
for (String comp : materials) {
|
||||
comp = comp.toUpperCase();
|
||||
if (comp.startsWith("CONTAINS:")) {
|
||||
comp = format(comp.substring(9));
|
||||
String checker = comp.toUpperCase(Locale.ENGLISH);
|
||||
if (checker.startsWith("CONTAINS:")) {
|
||||
comp = format(checker.substring(9));
|
||||
if (name.contains(comp)) return true;
|
||||
continue;
|
||||
}
|
||||
if (comp.startsWith("REGEX:")) {
|
||||
if (checker.startsWith("REGEX:")) {
|
||||
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;
|
||||
}
|
||||
|
||||
// Direct Object Equals
|
||||
Optional<XMaterial> mat = matchXMaterial(comp);
|
||||
if (mat.isPresent() && mat.get().parseMaterial() == material) return true;
|
||||
Optional<XMaterial> xMat = matchXMaterial(comp);
|
||||
if (xMat.isPresent() && xMat.get() == this) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1809,27 +1902,14 @@ public enum XMaterial {
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemStack setType(@Nonnull ItemStack item) {
|
||||
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);
|
||||
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.
|
||||
* 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")
|
||||
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();
|
||||
return material == null ? -1 : material.getId();
|
||||
}
|
||||
@@ -1881,7 +1961,7 @@ public enum XMaterial {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
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) PARSED_CACHE.put(this, Optional.ofNullable(mat));
|
||||
Optional<Material> opt = Optional.ofNullable(mat);
|
||||
PARSED_CACHE.put(this, opt);
|
||||
return mat;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ flight:
|
||||
accountForTpsDrops: 250
|
||||
# How many milliseconds to account for teleports
|
||||
# Increase this is you debug 'had too little Y dropoff' after teleports
|
||||
accountForTeleports: 100
|
||||
accountForTeleports: 400
|
||||
# Checks for climbing behaviour in air
|
||||
# Debugs as 'tried to climb air'
|
||||
airClimb:
|
||||
@@ -26,7 +26,7 @@ flight:
|
||||
enabled: true
|
||||
# How many milliseconds to account for 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
|
||||
# Debugs as 'faked ground to fly'
|
||||
groundFlight:
|
||||
@@ -41,16 +41,14 @@ flight:
|
||||
maxOffset: 0.005
|
||||
# How many milliseconds to account for teleports
|
||||
# Increase this is you debug 'ignored gravity' after teleports
|
||||
accountForTeleports: 100
|
||||
accountForTeleports: 300
|
||||
# Amount of illegal moves before flagging
|
||||
vlBeforeFlag: 5
|
||||
|
||||
# ElytraFly check settings
|
||||
# Checks for illegal upward elytra movement
|
||||
elytrafly:
|
||||
# Should this check be enabled?
|
||||
enabled: true
|
||||
|
||||
# Speed check settings
|
||||
# Checks if a player moves too fast
|
||||
speed:
|
||||
@@ -63,7 +61,6 @@ speed:
|
||||
baseLimit: 0.03125
|
||||
# Prediction multiplier for custom walk speeds
|
||||
walkSpeedMultiplier: 1.4
|
||||
|
||||
# Checks movement acceleration in the air
|
||||
# Debugs as 'exceeded acceleration limits'
|
||||
airAcceleration:
|
||||
@@ -73,7 +70,6 @@ speed:
|
||||
baseLimit: 0.3725
|
||||
# Limit multiplier for custom walk speeds
|
||||
walkSpeedMultiplier: 1.4
|
||||
|
||||
# Checks movement acceleration in the air
|
||||
# Debugs as 'had unexpected jumping behaviour'
|
||||
jumpBehaviour:
|
||||
@@ -81,7 +77,6 @@ speed:
|
||||
enabled: true
|
||||
# Minimum movement distance needed to flag
|
||||
minimumDistXZ: 0.42
|
||||
|
||||
# Checks movement speed on the ground
|
||||
# Debugs as 'moved too fast on ground'
|
||||
groundSpeed:
|
||||
@@ -89,7 +84,6 @@ speed:
|
||||
enabled: true
|
||||
# Initial speed limit value
|
||||
initialLimit: 0.34
|
||||
|
||||
# Checks movement acceleration in the air
|
||||
# Debugs as 'exceeded vertical speed limit'
|
||||
verticalSpeed:
|
||||
@@ -97,19 +91,17 @@ speed:
|
||||
enabled: true
|
||||
# Extra compensation when moving off a ladder up a slab
|
||||
climbableCompensation: 0.04
|
||||
|
||||
# Strafe check settings
|
||||
# Checks if a player switches movement angle in air
|
||||
strafe:
|
||||
# Should this check be enabled?
|
||||
enabled: true
|
||||
# How many milliseconds to account for teleports
|
||||
accountForTeleports: 100
|
||||
accountForTeleports: 300
|
||||
# Maximum angle change when moving in air
|
||||
maxAngleChange: 0.25
|
||||
maxAngleChange: 0.5
|
||||
# Minimum movement distance for the strafe check to be active
|
||||
minActivationDistance: 0.025
|
||||
|
||||
minActivationDistance: 0.04
|
||||
# WaterWalk check settings
|
||||
# Checks if a player is walking on water
|
||||
waterwalk:
|
||||
@@ -127,7 +119,7 @@ waterwalk:
|
||||
# Should this part of the check be enabled?
|
||||
enabled: true
|
||||
# Maximum lunge Y motion to flag
|
||||
maxMotionY: 0.10
|
||||
maxMotionY: 0.1
|
||||
# Checks for small lunges in water
|
||||
# Debugs as 'tried to lunge in water'
|
||||
lunge:
|
||||
@@ -136,7 +128,6 @@ waterwalk:
|
||||
# Minimum xz distance before flagging
|
||||
# This combats false positives, while giving hackers not much leniency
|
||||
minimumDistXZ: 0.098
|
||||
|
||||
# FastLadder check settings
|
||||
# Checks if a player moves too fast on a ladder
|
||||
fastladder:
|
||||
@@ -148,7 +139,13 @@ fastladder:
|
||||
speedDownMax: 0.15
|
||||
# Amount of illegal ladder moves before flagging
|
||||
vlBeforeFlag: 3
|
||||
|
||||
# BoatFly check settings
|
||||
# Checks if the player is flying in a boat
|
||||
boatfly:
|
||||
# Should this check be enabled?
|
||||
enabled: true
|
||||
# Amount of in-boat airborne moments before flagging
|
||||
vlBeforeFlag: 2
|
||||
# KillAura check settings
|
||||
# Checks if the player uses a form of kill aura
|
||||
killaura:
|
||||
@@ -171,7 +168,6 @@ killaura:
|
||||
pingCompensation: 0.0025
|
||||
# The multiplier of extra compensation for velocity
|
||||
velocityMultiplier: 1.2
|
||||
|
||||
# Checks if the target it within a players viewing angle
|
||||
# Debugs as 'tried to attack from an illegal angle'
|
||||
angle:
|
||||
@@ -181,7 +177,6 @@ killaura:
|
||||
maxDifference: 50
|
||||
# Amount of illegally angled hits before flagging
|
||||
vlBeforeFlag: 3
|
||||
|
||||
# Checks if the player has a suspicious packet order
|
||||
# Debugs as 'suspicious packet order'
|
||||
packetOrder:
|
||||
@@ -193,7 +188,6 @@ killaura:
|
||||
minElapsedTime: 5
|
||||
# Amount of suspicious combat packet situations before flagging
|
||||
vlBeforeFlag: 3
|
||||
|
||||
# Aimbot check settings
|
||||
# Checks if the player is sending aimbot-like movements
|
||||
aimbot:
|
||||
@@ -203,13 +197,11 @@ aimbot:
|
||||
minYaw: 30
|
||||
# Maximum yaw difference when repeated
|
||||
maxYaw: 355
|
||||
|
||||
# Criticals check settings
|
||||
# Checks if the player tries to do a crit without needed conditions
|
||||
criticals:
|
||||
# Should this check be enabled?
|
||||
enabled: true
|
||||
|
||||
# Velocity check settings
|
||||
# Checks if the player ignores knockback
|
||||
velocity:
|
||||
@@ -219,7 +211,6 @@ velocity:
|
||||
minimumPercentage: 75
|
||||
# Amount of low-velocity moments before flagging
|
||||
vlBeforeFlag: 2
|
||||
|
||||
# FastPlace check settings
|
||||
# Checks if the player places blocks too fast
|
||||
fastplace:
|
||||
@@ -228,12 +219,11 @@ fastplace:
|
||||
# Minimum time in milliseconds between block places
|
||||
minimumTime: 50
|
||||
# Amount of fastplace-moments before flagging a survival player
|
||||
vlBeforeFlagSurvival: 2
|
||||
vlBeforeFlagSurvival: 3
|
||||
# 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
|
||||
blockPlacementTime: 1000
|
||||
|
||||
# IllegalInteract check settings
|
||||
# Checks if the player is using, placing or breaking blocks from illegal angles
|
||||
illegalinteract:
|
||||
@@ -262,7 +252,6 @@ illegalinteract:
|
||||
pingCompensation: 0.0045
|
||||
# The multiplier of extra compensation for velocity
|
||||
velocityMultiplier: 1.5
|
||||
|
||||
# BadPackets check settings
|
||||
# Checks for illegal packets
|
||||
badpackets:
|
||||
@@ -272,7 +261,6 @@ badpackets:
|
||||
minimumTps: 17.5
|
||||
# Maximum distance a player can move between packets
|
||||
maxDistance: 25.0
|
||||
|
||||
# MorePackets check settings
|
||||
# Checks for an extra amount of packets and modified game timers
|
||||
morepackets:
|
||||
@@ -281,18 +269,17 @@ morepackets:
|
||||
# Minimum server TPS needed for MorePackets to be active
|
||||
minimumTps: 17.5
|
||||
# Maximum amount of lag compensation a player can acquire (50ms = 1 tick)
|
||||
minimumClamp: 500
|
||||
minimumClamp: 1000
|
||||
# The amount of milliseconds offset between packets before flagging (50ms = 1 tick)
|
||||
triggerBalance: 100
|
||||
# The amount of milliseconds to compensate for a teleport (50ms = 1 tick)
|
||||
teleportCompensation: 150
|
||||
teleportCompensation: 300
|
||||
# Should MorePackets be disabled for 'lagging' players?
|
||||
# This can easily be spoofed by clients!
|
||||
disableForLagging: false
|
||||
# Maximum ping value before MorePackets stops checking a player (-1 to disable)
|
||||
# This can easily be spoofed by clients!
|
||||
maxPing: -1
|
||||
|
||||
# Sneak check settings
|
||||
# Checks if the player toggles sneak too fast
|
||||
sneak:
|
||||
@@ -302,16 +289,25 @@ sneak:
|
||||
# This can easily be spoofed by clients!
|
||||
disableForLagging: false
|
||||
# Minimum server TPS needed for sneak
|
||||
minimumTps: 12
|
||||
minimumTps: 15
|
||||
# Minimum time in milliseconds between sneak toggles
|
||||
minToggleTime: 75
|
||||
|
||||
# NoSlow check settings
|
||||
# Checks if the player moves too fast while blocking
|
||||
noslow:
|
||||
# Should this check be enabled?
|
||||
enabled: true
|
||||
# Minimum time difference in milliseconds between toggling use item state
|
||||
minimumDifference: 75
|
||||
# Minimum movement distance needed to flag
|
||||
minimumDistXZ: 0.15
|
||||
# Amount of no slowdown moments before flagging
|
||||
vlBeforeFlag: 3
|
||||
# Spider check settings
|
||||
# Checks if the player tries to climb a non-climbable block
|
||||
spider:
|
||||
# Should this check be enabled?
|
||||
enabled: true
|
||||
|
||||
# NoFall check settings
|
||||
# Checks if the player tries to ignore fall damage
|
||||
nofall:
|
||||
@@ -319,7 +315,6 @@ nofall:
|
||||
enabled: true
|
||||
# Amount of moves with a modified fall distance before flagging
|
||||
vlBeforeFlag: 6
|
||||
|
||||
# Sprint check settings
|
||||
# Checks if the player tries to sprint without the needed conditions
|
||||
sprint:
|
||||
@@ -327,7 +322,6 @@ sprint:
|
||||
enabled: true
|
||||
# Minimum food level needed to sprint
|
||||
sprintFoodMin: 6
|
||||
|
||||
# FastBow check settings
|
||||
# Checks if the player fires a bow too fast
|
||||
fastbow:
|
||||
@@ -335,7 +329,6 @@ fastbow:
|
||||
enabled: true
|
||||
# Maximum percent error between predicted bow force and actual bow force
|
||||
bowError: 0.25
|
||||
|
||||
# FastEat check settings
|
||||
# Checks if the player consumes food too fast
|
||||
fasteat:
|
||||
@@ -343,7 +336,6 @@ fasteat:
|
||||
enabled: true
|
||||
# Minimum time in milliseconds it takes to consume food
|
||||
eatTimeMin: 1000
|
||||
|
||||
# FastHeal check settings
|
||||
# Checks if the player regains health too fast
|
||||
fastheal:
|
||||
@@ -355,10 +347,10 @@ fastheal:
|
||||
# This can easily be spoofed by clients!
|
||||
disableForLagging: false
|
||||
# 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
|
||||
pingCompensation: 0.15
|
||||
|
||||
pingCompensation: 0.25
|
||||
# FastProjectile check settings
|
||||
# Checks if the player fires a projectile too fast
|
||||
fastprojectile:
|
||||
@@ -368,7 +360,6 @@ fastprojectile:
|
||||
projectilesToWait: 10
|
||||
# The minimum time in milliseconds it should have taken for the player fire 'projectilesToWait' projectiles
|
||||
minimumTime: 1500
|
||||
|
||||
# ItemSpam check settings
|
||||
# Checks if the player drops items too fast
|
||||
itemspam:
|
||||
@@ -378,7 +369,6 @@ itemspam:
|
||||
dropsToWait: 10
|
||||
# The minimum time in milliseconds it should have taken for the player to drop items 'dropsToWait' times
|
||||
minimumTime: 800
|
||||
|
||||
# FastInventory check settings
|
||||
# Checks if the player moves items in the inventory too fast
|
||||
fastinventory:
|
||||
@@ -388,19 +378,16 @@ fastinventory:
|
||||
clicksToWait: 10
|
||||
# The minimum time in milliseconds it should have taken for the player to click 'clicksToWait' times
|
||||
minimumTime: 50
|
||||
|
||||
# vClip check settings
|
||||
# Checks if the player is clipping
|
||||
vclip:
|
||||
# Should this check be enabled?
|
||||
enabled: true
|
||||
|
||||
# ChatUnicode check settings
|
||||
# Checks for illegal unicode characters in the chat
|
||||
chatunicode:
|
||||
# Should this check be enabled?
|
||||
enabled: true
|
||||
|
||||
# ChatSpam check settings
|
||||
# Checks for a spam of chat messages
|
||||
chatspam:
|
||||
@@ -414,17 +401,16 @@ chatspam:
|
||||
levelActionOne: 5
|
||||
# Number of chat spam violations before action two (see config.yml) is executed
|
||||
levelActionTwo: 10
|
||||
|
||||
# CommandSpam check settings
|
||||
# Checks for a spam of commands
|
||||
commandspam:
|
||||
# Should this check be enabled?
|
||||
enabled: true
|
||||
# Minimum time between commands
|
||||
timeMin: 400
|
||||
timeMin: 250
|
||||
# Time in milliseconds after which repeating a command is ignored
|
||||
repeatIgnore: 500
|
||||
# Number of command spam violations before action one (see config.yml) is executed
|
||||
levelActionOne: 5
|
||||
# Number of command spam violations before action two (see config.yml) is executed
|
||||
levelActionTwo: 10
|
||||
levelActionTwo: 10
|
||||
@@ -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.
|
||||
# However, alerts will still be sent to console and to admins online, and events will still take place.
|
||||
silent-mode: false
|
||||
# Disable broadcasts about why a player was kicked
|
||||
disable-broadcast: false
|
||||
# Should ops be exempt from all checks?
|
||||
exempt-op: false
|
||||
# Should AntiCheatReloaded track plugins in its own registered events?
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
# To disable warnings or kicking, change WARN and/or KICK to NONE
|
||||
groups:
|
||||
- 'Low : 50 : GREEN : NONE'
|
||||
- 'Medium : 100 : YELLOW : WARN'
|
||||
- 'High : 175 : RED : KICK'
|
||||
- 'Medium : 60 : YELLOW : WARN'
|
||||
- 'High : 75 : RED : KICK'
|
||||
- 'Custom : -1 : GREEN : COMMAND[ban %player%;]'
|
||||
@@ -1,17 +1,35 @@
|
||||
# AntiCheatReloaded language file
|
||||
# The alert message when a player enters a higher group
|
||||
ALERT:
|
||||
- '&c%player% has just entered the %group% hack group.'
|
||||
- '&c%player%''s last failed check was: %check%.'
|
||||
- '&cType ''/acr report %player%'' for more information.'
|
||||
- '&6&lACR &8> &7%player% has just entered the %group% hack group.'
|
||||
- '&6&lACR &8> &7%player%''s last failed check was: %check%.'
|
||||
- '&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:
|
||||
- '&6&lACR &8>&7 You have been flagged for using cheats.'
|
||||
- '&6&lACR &8>&7 If you continue to cheat, action will be taken.'
|
||||
# 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'
|
||||
# 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'
|
||||
SPAM_WARNING: '&cStop spamming the server or you will be kicked!'
|
||||
SPAM_KICK_REASON: '&cKicked for spamming'
|
||||
SPAM_KICK_BROADCAST: '&c%player% was kicked for spamming'
|
||||
SPAM_BAN_REASON: '&cBanned for spamming'
|
||||
SPAM_BAN_BROADCAST: '&c%player% was banned for spamming'
|
||||
# The warning message to send when a player is spamming
|
||||
SPAM_WARNING: '&6&lACR &8> &7Stop spamming the server or you will be kicked!'
|
||||
# Kick reason when 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'
|
||||
# The prefix for staff and debug alerts
|
||||
ALERT_PREFIX: "&6&lACR &8> &7"
|
||||
@@ -1,28 +1,25 @@
|
||||
# Time to exempt a player from moving because of entering/exiting a vehicle
|
||||
# Increase in case of false positives
|
||||
ENTERED_EXITED_TIME: 250
|
||||
ENTERED_EXITED_TIME: 2500
|
||||
# Time to exempt a player from moving because of teleporting
|
||||
# Increase in case of false positives
|
||||
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
|
||||
# If your server is slow when a player joins, increasing this value is important
|
||||
# Shouldn't be lower than 1500 or higher than 5000
|
||||
JOIN_TIME: 2000
|
||||
# Time to exempt a player from moving because of taking damage
|
||||
# Can be decreased very slightly to increase detection
|
||||
# Increasing in case of false positives is almost never necessary and is not advised
|
||||
DAMAGE_TIME: 3000
|
||||
# Increase in case of false positives after taking damage
|
||||
DAMAGE_TIME: 500
|
||||
# Time to exempt a player from moving because of taking damage with knockback effects
|
||||
# Can be decreased very slightly to increase detection
|
||||
# Increase in case of false positives, but shouldn't be necessary
|
||||
KNOCKBACK_DAMAGE_TIME: 4000
|
||||
# Increase in case of false positives after knockback
|
||||
KNOCKBACK_DAMAGE_TIME: 2000
|
||||
# Time to exempt a player from moving because of taking damage from an explosion
|
||||
# Can be decreased very slightly to increase detection
|
||||
# Increasing in case of false positives is almost never necessary and is not advised
|
||||
EXPLOSION_DAMAGE_TIME: 5000
|
||||
# Increasing in case of false positives after explosions
|
||||
EXPLOSION_DAMAGE_TIME: 2500
|
||||
# Amount of seconds to extend a players velocitized state after receiving velocity again
|
||||
VELOCITY_EXTENSION: 2
|
||||
# Time a player is considered to have a change in velocity
|
||||
|
||||
@@ -127,9 +127,15 @@ permissions:
|
||||
anticheat.check.aimbot:
|
||||
description: Allow players to use aimbot
|
||||
default: false
|
||||
anticheat.check.aimbot:
|
||||
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:
|
||||
description: Total exemption from checks
|
||||
default: false
|
||||
@@ -161,4 +167,6 @@ permissions:
|
||||
anticheat.check.illegalinteract: true
|
||||
anticheat.check.fastladder: true
|
||||
anticheat.check.aimbot: true
|
||||
anticheat.check.strafe: true
|
||||
anticheat.check.strafe: true
|
||||
anticheat.check.noslow: true
|
||||
anticheat.check.boatfly: true
|
||||
Reference in new issue
Block a user