mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 14:38:46 +00:00
Code cleanup, prepare for release
This commit is contained in:
1 parent
df3c410436
commit
a7419e3968
15 files changed
+150
-158
No files matched your search
@@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.rammelkast.anticheatreloaded</groupId>
|
<groupId>com.rammelkast.anticheatreloaded</groupId>
|
||||||
<artifactId>AntiCheatReloaded</artifactId>
|
<artifactId>AntiCheatReloaded</artifactId>
|
||||||
<version>1.8.1-PRE</version>
|
<version>1.8.1</version>
|
||||||
<name>AntiCheatReloaded</name>
|
<name>AntiCheatReloaded</name>
|
||||||
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
|
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ public class AntiCheatReloaded extends JavaPlugin {
|
|||||||
private static UpdateManager updateManager;
|
private static UpdateManager updateManager;
|
||||||
|
|
||||||
private double tps = -1;
|
private double tps = -1;
|
||||||
private int currentTick;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@@ -152,7 +151,6 @@ public class AntiCheatReloaded extends JavaPlugin {
|
|||||||
tps = (tps == 0.0D ? ticks : (tps + ticks) / 2.0D);
|
tps = (tps == 0.0D ? ticks : (tps + ticks) / 2.0D);
|
||||||
ticks = 1;
|
ticks = 1;
|
||||||
}
|
}
|
||||||
currentTick++;
|
|
||||||
}
|
}
|
||||||
}.runTaskTimer(this, 40L, 1L);
|
}.runTaskTimer(this, 40L, 1L);
|
||||||
// Launch MorePackets timer
|
// Launch MorePackets timer
|
||||||
|
|||||||
@@ -30,13 +30,11 @@ import org.bukkit.GameMode;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
|
||||||
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||||
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
|
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
|
||||||
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
|
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
|
||||||
@@ -58,7 +56,6 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
|||||||
public class Backend {
|
public class Backend {
|
||||||
public Map<UUID, Long> velocitized = new HashMap<UUID, Long>();
|
public Map<UUID, Long> velocitized = new HashMap<UUID, Long>();
|
||||||
private List<UUID> isAscending = new ArrayList<UUID>();
|
private List<UUID> isAscending = new ArrayList<UUID>();
|
||||||
private Map<UUID, Integer> ascensionCount = new HashMap<UUID, Integer>();
|
|
||||||
private Map<UUID, Integer> chatLevel = new HashMap<UUID, Integer>();
|
private Map<UUID, Integer> chatLevel = new HashMap<UUID, Integer>();
|
||||||
private Map<UUID, Integer> commandLevel = new HashMap<UUID, Integer>();
|
private Map<UUID, Integer> commandLevel = new HashMap<UUID, Integer>();
|
||||||
private Map<UUID, Integer> nofallViolation = new HashMap<UUID, Integer>();
|
private Map<UUID, Integer> nofallViolation = new HashMap<UUID, Integer>();
|
||||||
@@ -86,11 +83,9 @@ public class Backend {
|
|||||||
private Map<UUID, Long> inventoryTime = new HashMap<UUID, Long>();
|
private Map<UUID, Long> inventoryTime = new HashMap<UUID, Long>();
|
||||||
private Map<UUID, Integer> inventoryClicks = new HashMap<UUID, Integer>();
|
private Map<UUID, Integer> inventoryClicks = new HashMap<UUID, Integer>();
|
||||||
private Map<UUID, Material> itemInHand = new HashMap<UUID, Material>();
|
private Map<UUID, Material> itemInHand = new HashMap<UUID, Material>();
|
||||||
private Map<UUID, Integer> steps = new HashMap<UUID, Integer>();
|
|
||||||
private Map<UUID, Long> stepTime = new HashMap<UUID, Long>();
|
|
||||||
private HashSet<Byte> transparent = new HashSet<Byte>();
|
private HashSet<Byte> transparent = new HashSet<Byte>();
|
||||||
private Map<UUID, Long> lastFallPacket = new HashMap<UUID, Long>();
|
private Map<UUID, Long> lastFallPacket = new HashMap<UUID, Long>();
|
||||||
private Map<String, Integer> fastSneakViolations = new HashMap<String, Integer>();
|
private Map<UUID, Integer> fastSneakViolations = new HashMap<UUID, Integer>();
|
||||||
|
|
||||||
private Magic magic;
|
private Magic magic;
|
||||||
private AntiCheatManager manager = null;
|
private AntiCheatManager manager = null;
|
||||||
@@ -118,67 +113,66 @@ public class Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void garbageClean(Player player) {
|
public void garbageClean(Player player) {
|
||||||
UUID pU = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
|
|
||||||
VelocityCheck.cleanPlayer(player);
|
blocksDropped.remove(uuid);
|
||||||
MorePacketsCheck.MOVE_COUNT.remove(player.getUniqueId());
|
blockTime.remove(uuid);
|
||||||
blocksDropped.remove(pU);
|
brokenBlock.remove(uuid);
|
||||||
blockTime.remove(pU);
|
placedBlock.remove(uuid);
|
||||||
FlightCheck.MOVING_EXEMPT.remove(pU);
|
bowWindUp.remove(uuid);
|
||||||
brokenBlock.remove(pU);
|
startEat.remove(uuid);
|
||||||
placedBlock.remove(pU);
|
lastHeal.remove(uuid);
|
||||||
bowWindUp.remove(pU);
|
sprinted.remove(uuid);
|
||||||
startEat.remove(pU);
|
instantBreakExempt.remove(uuid);
|
||||||
lastHeal.remove(pU);
|
isAscending.remove(uuid);
|
||||||
sprinted.remove(pU);
|
nofallViolation.remove(uuid);
|
||||||
WaterWalkCheck.IS_IN_WATER.remove(pU);
|
fastBreakViolation.remove(uuid);
|
||||||
WaterWalkCheck.IS_IN_WATER_CACHE.remove(pU);
|
fastBreaks.remove(uuid);
|
||||||
instantBreakExempt.remove(pU);
|
blockBreakHolder.remove(uuid);
|
||||||
isAscending.remove(player.getUniqueId());
|
lastBlockBroken.remove(uuid);
|
||||||
ascensionCount.remove(player.getUniqueId());
|
fastPlaceViolation.remove(uuid);
|
||||||
FlightCheck.BLOCKS_OVER_FLIGHT.remove(pU);
|
lastBlockPlaced.remove(uuid);
|
||||||
nofallViolation.remove(pU);
|
lastBlockPlaceTime.remove(uuid);
|
||||||
fastBreakViolation.remove(pU);
|
blockPunches.remove(uuid);
|
||||||
YAxisCheck.Y_AXIS_VIOLATIONS.remove(pU);
|
projectilesShot.remove(uuid);
|
||||||
YAxisCheck.LAST_Y_AXIS_VIOLATION.remove(pU);
|
velocitized.remove(uuid);
|
||||||
YAxisCheck.LAST_Y_COORD_CACHE.remove(pU);
|
velocitytrack.remove(uuid);
|
||||||
YAxisCheck.LAST_Y_TIME.remove(pU);
|
startEat.remove(uuid);
|
||||||
WaterWalkCheck.WATER_ASCENSION_VIOLATIONS.remove(pU);
|
lastHeal.remove(uuid);
|
||||||
WaterWalkCheck.WATER_SPEED_VIOLATIONS.remove(pU);
|
projectileTime.remove(uuid);
|
||||||
fastBreaks.remove(pU);
|
bowWindUp.remove(uuid);
|
||||||
blockBreakHolder.remove(pU);
|
instantBreakExempt.remove(uuid);
|
||||||
lastBlockBroken.remove(pU);
|
sprinted.remove(uuid);
|
||||||
fastPlaceViolation.remove(pU);
|
brokenBlock.remove(uuid);
|
||||||
lastBlockPlaced.remove(pU);
|
placedBlock.remove(uuid);
|
||||||
lastBlockPlaceTime.remove(pU);
|
blockTime.remove(uuid);
|
||||||
blockPunches.remove(pU);
|
blocksDropped.remove(uuid);
|
||||||
projectilesShot.remove(pU);
|
lastInventoryTime.remove(uuid);
|
||||||
velocitized.remove(pU);
|
inventoryTime.remove(uuid);
|
||||||
velocitytrack.remove(pU);
|
inventoryClicks.remove(uuid);
|
||||||
startEat.remove(pU);
|
lastFallPacket.remove(uuid);
|
||||||
lastHeal.remove(pU);
|
fastSneakViolations.remove(uuid);
|
||||||
projectileTime.remove(pU);
|
VelocityCheck.VIOLATIONS.remove(uuid);
|
||||||
bowWindUp.remove(pU);
|
MorePacketsCheck.MOVE_COUNT.remove(uuid);
|
||||||
instantBreakExempt.remove(pU);
|
GlideCheck.LAST_MOTION_Y.remove(uuid);
|
||||||
sprinted.remove(pU);
|
GlideCheck.LAST_FALL_DISTANCE.remove(uuid);
|
||||||
brokenBlock.remove(pU);
|
GlideCheck.VIOLATIONS.remove(uuid);
|
||||||
placedBlock.remove(pU);
|
SpeedCheck.SPEED_VIOLATIONS.remove(uuid);
|
||||||
FlightCheck.MOVING_EXEMPT.remove(pU);
|
ElytraCheck.JUMP_Y_VALUE.remove(uuid);
|
||||||
blockTime.remove(pU);
|
KillAuraCheck.ANGLE_FLAGS.remove(uuid);
|
||||||
blocksDropped.remove(pU);
|
KillAuraCheck.PITCH_MOVEMENTS_CACHE.remove(uuid);
|
||||||
lastInventoryTime.remove(pU);
|
KillAuraCheck.GCD_CACHE.remove(uuid);
|
||||||
inventoryTime.remove(pU);
|
FlightCheck.MOVING_EXEMPT.remove(uuid);
|
||||||
inventoryClicks.remove(pU);
|
FlightCheck.ASCENSION_COUNT.remove(uuid);
|
||||||
lastFallPacket.remove(pU);
|
FlightCheck.BLOCKS_OVER_FLIGHT.remove(uuid);
|
||||||
fastSneakViolations.remove(player.getUniqueId().toString());
|
YAxisCheck.Y_AXIS_VIOLATIONS.remove(uuid);
|
||||||
GlideCheck.LAST_MOTION_Y.remove(pU);
|
YAxisCheck.LAST_Y_AXIS_VIOLATION.remove(uuid);
|
||||||
GlideCheck.LAST_FALL_DISTANCE.remove(pU);
|
YAxisCheck.LAST_Y_COORD_CACHE.remove(uuid);
|
||||||
GlideCheck.VIOLATIONS.remove(pU);
|
YAxisCheck.LAST_Y_TIME.remove(uuid);
|
||||||
SpeedCheck.SPEED_VIOLATIONS.remove(player.getUniqueId());
|
WaterWalkCheck.IS_IN_WATER.remove(uuid);
|
||||||
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId().toString());
|
WaterWalkCheck.IS_IN_WATER_CACHE.remove(uuid);
|
||||||
KillAuraCheck.ANGLE_FLAGS.remove(pU);
|
WaterWalkCheck.WATER_ASCENSION_VIOLATIONS.remove(uuid);
|
||||||
KillAuraCheck.PITCH_MOVEMENTS_CACHE.remove(pU);
|
WaterWalkCheck.WATER_SPEED_VIOLATIONS.remove(uuid);
|
||||||
KillAuraCheck.GCD_CACHE.remove(pU);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckResult checkFastBow(Player player, float force) {
|
public CheckResult checkFastBow(Player player, float force) {
|
||||||
@@ -321,24 +315,24 @@ public class Backend {
|
|||||||
&& !Utilities.cantStandAtExp(location)) {
|
&& !Utilities.cantStandAtExp(location)) {
|
||||||
double i = x > magic.XZ_SPEED_MAX_SNEAK() ? x : z > magic.XZ_SPEED_MAX_SNEAK() ? z : -1;
|
double i = x > magic.XZ_SPEED_MAX_SNEAK() ? x : z > magic.XZ_SPEED_MAX_SNEAK() ? z : -1;
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
if (this.fastSneakViolations.containsKey(player.getUniqueId().toString())) {
|
if (this.fastSneakViolations.containsKey(player.getUniqueId())) {
|
||||||
int flags = this.fastSneakViolations.get(player.getUniqueId().toString());
|
int flags = this.fastSneakViolations.get(player.getUniqueId());
|
||||||
if (flags >= 3) { // TODO possible config
|
if (flags >= 3) { // TODO possible config
|
||||||
return new CheckResult(CheckResult.Result.FAILED,
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
"was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")");
|
"was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")");
|
||||||
}
|
}
|
||||||
this.fastSneakViolations.put(player.getUniqueId().toString(), flags + 1);
|
this.fastSneakViolations.put(player.getUniqueId(), flags + 1);
|
||||||
return PASS;
|
return PASS;
|
||||||
} else {
|
} else {
|
||||||
this.fastSneakViolations.put(player.getUniqueId().toString(), 1);
|
this.fastSneakViolations.put(player.getUniqueId(), 1);
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.fastSneakViolations.remove(player.getUniqueId().toString());
|
this.fastSneakViolations.remove(player.getUniqueId());
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.fastSneakViolations.remove(player.getUniqueId().toString());
|
this.fastSneakViolations.remove(player.getUniqueId());
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -383,39 +377,6 @@ public class Backend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckResult checkAscension(Player player, double y1, double y2) {
|
|
||||||
int max = magic.ASCENSION_COUNT_MAX();
|
|
||||||
String string = "";
|
|
||||||
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
|
|
||||||
max += 12;
|
|
||||||
string = " with jump potion";
|
|
||||||
}
|
|
||||||
Block block = player.getLocation().getBlock();
|
|
||||||
if (!isMovingExempt(player) && !Utilities.isInWater(player) && !VersionUtil.isFlying(player)
|
|
||||||
&& !justBroke(player) && !Utilities.isClimbableBlock(player.getLocation().getBlock())
|
|
||||||
&& !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
|
|
||||||
&& !Utilities.isClimbableBlock(player.getLocation().clone().add(0, -0.98, 0).getBlock())
|
|
||||||
&& !player.isInsideVehicle() && !YAxisCheck.isMoveUpBlock(player.getLocation().add(0, -1, 0).getBlock())
|
|
||||||
&& !YAxisCheck.isMoveUpBlock(player.getLocation().add(0, -0.5, 0).getBlock())) {
|
|
||||||
// TODO isMoveUpBlock does not seem to be a success with stairs
|
|
||||||
if (y1 < y2) {
|
|
||||||
if (!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid()
|
|
||||||
&& !block.getRelative(BlockFace.EAST).isLiquid()
|
|
||||||
&& !block.getRelative(BlockFace.WEST).isLiquid()) {
|
|
||||||
increment(player, ascensionCount, max);
|
|
||||||
if (ascensionCount.get(player.getUniqueId()) >= max) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED,
|
|
||||||
"ascended " + ascensionCount.get(player.getUniqueId()) + " times in a row (max = " + max
|
|
||||||
+ string + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ascensionCount.put(player.getUniqueId(), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkSwing(Player player, Block block) {
|
public CheckResult checkSwing(Player player, Block block) {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
if (!isInstantBreakExempt(player)) {
|
if (!isInstantBreakExempt(player)) {
|
||||||
@@ -809,7 +770,7 @@ public class Backend {
|
|||||||
GlideCheck.LAST_FALL_DISTANCE.remove(player.getUniqueId());
|
GlideCheck.LAST_FALL_DISTANCE.remove(player.getUniqueId());
|
||||||
GlideCheck.LAST_MOTION_Y.remove(player.getUniqueId());
|
GlideCheck.LAST_MOTION_Y.remove(player.getUniqueId());
|
||||||
GlideCheck.VIOLATIONS.remove(player.getUniqueId());
|
GlideCheck.VIOLATIONS.remove(player.getUniqueId());
|
||||||
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId().toString());
|
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logExitFly(final Player player) {
|
public void logExitFly(final Player player) {
|
||||||
@@ -887,35 +848,35 @@ public class Backend {
|
|||||||
commandLevel.put(user.getUUID(), level + 1);
|
commandLevel.put(user.getUUID(), level + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int increment(Player player, Map<UUID, Integer> ascensionCount2, int num) {
|
public int increment(Player player, Map<UUID, Integer> map, int num) {
|
||||||
UUID name = player.getUniqueId();
|
UUID name = player.getUniqueId();
|
||||||
if (ascensionCount2.get(name) == null) {
|
if (map.get(name) == null) {
|
||||||
ascensionCount2.put(name, 1);
|
map.put(name, 1);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
int amount = ascensionCount2.get(name) + 1;
|
int amount = map.get(name) + 1;
|
||||||
if (amount < num + 1) {
|
if (amount < num + 1) {
|
||||||
ascensionCount2.put(name, amount);
|
map.put(name, amount);
|
||||||
return amount;
|
return amount;
|
||||||
} else {
|
} else {
|
||||||
ascensionCount2.put(name, num);
|
map.put(name, num);
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int incrementOld(Player player, Map<UUID, Integer> ascensionCount2, int num) {
|
public int incrementOld(Player player, Map<UUID, Integer> map, int num) {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
if (ascensionCount2.get(uuid) == null) {
|
if (map.get(uuid) == null) {
|
||||||
ascensionCount2.put(uuid, 1);
|
map.put(uuid, 1);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
int amount = ascensionCount2.get(uuid) + 1;
|
int amount = map.get(uuid) + 1;
|
||||||
if (amount < num + 1) {
|
if (amount < num + 1) {
|
||||||
ascensionCount2.put(uuid, amount);
|
map.put(uuid, amount);
|
||||||
return amount;
|
return amount;
|
||||||
} else {
|
} else {
|
||||||
ascensionCount2.put(uuid, num);
|
map.put(uuid, num);
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,11 +35,7 @@ import com.rammelkast.anticheatreloaded.event.EventListener;
|
|||||||
|
|
||||||
public class VelocityCheck {
|
public class VelocityCheck {
|
||||||
|
|
||||||
private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>();
|
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
|
||||||
|
|
||||||
public static void cleanPlayer(Player p) {
|
|
||||||
VL_COUNT.remove(p.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void runCheck(EntityDamageByEntityEvent e, final Player player) {
|
public static void runCheck(EntityDamageByEntityEvent e, final Player player) {
|
||||||
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.VELOCITY))
|
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.VELOCITY))
|
||||||
@@ -51,24 +47,24 @@ public class VelocityCheck {
|
|||||||
if (!player.isOnline())
|
if (!player.isOnline())
|
||||||
return;
|
return;
|
||||||
if (then.distance(player.getLocation()) < 0.125) {
|
if (then.distance(player.getLocation()) < 0.125) {
|
||||||
if (!VL_COUNT.containsKey(player.getUniqueId()))
|
if (!VIOLATIONS.containsKey(player.getUniqueId()))
|
||||||
VL_COUNT.put(player.getUniqueId(), 1);
|
VIOLATIONS.put(player.getUniqueId(), 1);
|
||||||
else {
|
else {
|
||||||
VL_COUNT.put(player.getUniqueId(), VL_COUNT.get(player.getUniqueId()) + 1);
|
VIOLATIONS.put(player.getUniqueId(), VIOLATIONS.get(player.getUniqueId()) + 1);
|
||||||
if (VL_COUNT.get(player.getUniqueId()) > AntiCheatReloaded.getManager().getBackend().getMagic()
|
if (VIOLATIONS.get(player.getUniqueId()) > AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||||
.VELOCITY_MAX_FLAGS()) {
|
.VELOCITY_MAX_FLAGS()) {
|
||||||
EventListener.log(
|
EventListener.log(
|
||||||
new CheckResult(CheckResult.Result.FAILED,
|
new CheckResult(CheckResult.Result.FAILED,
|
||||||
"had zero/low velocity " + VL_COUNT.get(player.getUniqueId()) + " times (max="
|
"had zero/low velocity " + VIOLATIONS.get(player.getUniqueId()) + " times (max="
|
||||||
+ AntiCheatReloaded.getManager().getBackend().getMagic()
|
+ AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||||
.VELOCITY_MAX_FLAGS()
|
.VELOCITY_MAX_FLAGS()
|
||||||
+ ", dist=" + then.distance(player.getLocation()) + ")").getMessage(),
|
+ ", dist=" + then.distance(player.getLocation()) + ")").getMessage(),
|
||||||
player, CheckType.VELOCITY);
|
player, CheckType.VELOCITY);
|
||||||
VL_COUNT.remove(player.getUniqueId());
|
VIOLATIONS.remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
VL_COUNT.remove(player.getUniqueId());
|
VIOLATIONS.remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskLater(AntiCheatReloaded.getPlugin(), 4);
|
}.runTaskLater(AntiCheatReloaded.getPlugin(), 4);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
package com.rammelkast.anticheatreloaded.check.movement;
|
package com.rammelkast.anticheatreloaded.check.movement;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -33,7 +34,7 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
|||||||
|
|
||||||
public class ElytraCheck {
|
public class ElytraCheck {
|
||||||
|
|
||||||
public static final HashMap<String, Double> JUMP_Y_VALUE = new HashMap<String, Double>();
|
public static final HashMap<UUID, Double> JUMP_Y_VALUE = new HashMap<UUID, Double>();
|
||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
public static CheckResult runCheck(Player player, Distance distance) {
|
public static CheckResult runCheck(Player player, Distance distance) {
|
||||||
@@ -42,7 +43,7 @@ public class ElytraCheck {
|
|||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
String uuid = player.getUniqueId().toString();
|
UUID uuid = player.getUniqueId();
|
||||||
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()) {
|
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()) {
|
||||||
// This was a teleport, so skip check.
|
// This was a teleport, so skip check.
|
||||||
JUMP_Y_VALUE.remove(uuid);
|
JUMP_Y_VALUE.remove(uuid);
|
||||||
|
|||||||
@@ -24,10 +24,13 @@ import java.util.Map;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
@@ -40,6 +43,7 @@ public class FlightCheck {
|
|||||||
|
|
||||||
public static final Map<UUID, Double> BLOCKS_OVER_FLIGHT = new HashMap<UUID, Double>();
|
public static final Map<UUID, Double> BLOCKS_OVER_FLIGHT = new HashMap<UUID, Double>();
|
||||||
public static final Map<UUID, Long> MOVING_EXEMPT = new HashMap<UUID, Long>();
|
public static final Map<UUID, Long> MOVING_EXEMPT = new HashMap<UUID, Long>();
|
||||||
|
public static final Map<UUID, Integer> ASCENSION_COUNT = new HashMap<UUID, Integer>();
|
||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
public static CheckResult runCheck(Player player, Distance distance) {
|
public static CheckResult runCheck(Player player, Distance distance) {
|
||||||
@@ -80,6 +84,40 @@ public class FlightCheck {
|
|||||||
}
|
}
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CheckResult checkAscension(Player player, double y1, double y2) {
|
||||||
|
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||||
|
int max = backend.getMagic().ASCENSION_COUNT_MAX();
|
||||||
|
String string = "";
|
||||||
|
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
|
||||||
|
max += 12;
|
||||||
|
string = " with jump potion";
|
||||||
|
}
|
||||||
|
Block block = player.getLocation().getBlock();
|
||||||
|
if (!isMovingExempt(player) && !Utilities.isInWater(player) && !VersionUtil.isFlying(player)
|
||||||
|
&& !backend.justBroke(player) && !Utilities.isClimbableBlock(player.getLocation().getBlock())
|
||||||
|
&& !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
|
||||||
|
&& !Utilities.isClimbableBlock(player.getLocation().clone().add(0, -0.98, 0).getBlock())
|
||||||
|
&& !player.isInsideVehicle() && !YAxisCheck.isMoveUpBlock(player.getLocation().add(0, -1, 0).getBlock())
|
||||||
|
&& !YAxisCheck.isMoveUpBlock(player.getLocation().add(0, -0.5, 0).getBlock())) {
|
||||||
|
// TODO isMoveUpBlock does not seem to be a success with stairs
|
||||||
|
if (y1 < y2) {
|
||||||
|
if (!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid()
|
||||||
|
&& !block.getRelative(BlockFace.EAST).isLiquid()
|
||||||
|
&& !block.getRelative(BlockFace.WEST).isLiquid()) {
|
||||||
|
backend.increment(player, ASCENSION_COUNT, max);
|
||||||
|
if (ASCENSION_COUNT.get(player.getUniqueId()) >= max) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"ascended " + ASCENSION_COUNT.get(player.getUniqueId()) + " times in a row (max = " + max
|
||||||
|
+ string + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ASCENSION_COUNT.put(player.getUniqueId(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isMovingExempt(Player player) {
|
public static boolean isMovingExempt(Player player) {
|
||||||
return isDoing(player, MOVING_EXEMPT, -1) || player.isInsideVehicle();
|
return isDoing(player, MOVING_EXEMPT, -1) || player.isInsideVehicle();
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
package com.rammelkast.anticheatreloaded.command.executors;
|
package com.rammelkast.anticheatreloaded.command.executors;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -27,12 +31,10 @@ import org.bukkit.entity.Player;
|
|||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||||
import com.rammelkast.anticheatreloaded.manage.CheckManager;
|
import com.rammelkast.anticheatreloaded.util.Group;
|
||||||
import com.rammelkast.anticheatreloaded.util.*;
|
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
import java.util.ArrayList;
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class CommandReport extends CommandBase {
|
public class CommandReport extends CommandBase {
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
|||||||
import com.rammelkast.anticheatreloaded.manage.CheckManager;
|
import com.rammelkast.anticheatreloaded.manage.CheckManager;
|
||||||
import com.rammelkast.anticheatreloaded.manage.UserManager;
|
import com.rammelkast.anticheatreloaded.manage.UserManager;
|
||||||
import com.rammelkast.anticheatreloaded.util.User;
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
|
||||||
|
|
||||||
public class EventListener implements Listener {
|
public class EventListener implements Listener {
|
||||||
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
|
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||||
@@ -263,10 +262,10 @@ public class PlayerListener extends EventListener {
|
|||||||
|
|
||||||
if (!VersionUtil.isBountifulUpdate()) {
|
if (!VersionUtil.isBountifulUpdate()) {
|
||||||
if (itemInHand.getType() == Material.FIREWORK_ROCKET) {
|
if (itemInHand.getType() == Material.FIREWORK_ROCKET) {
|
||||||
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId().toString());
|
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
|
||||||
if (player.isGliding()) {
|
if (player.isGliding()) {
|
||||||
// TODO config max elytra height?
|
// TODO config max elytra height?
|
||||||
ElytraCheck.JUMP_Y_VALUE.put(player.getUniqueId().toString(), 9999.99D);
|
ElytraCheck.JUMP_Y_VALUE.put(player.getUniqueId(), 9999.99D);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -485,7 +484,7 @@ public class PlayerListener extends EventListener {
|
|||||||
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.FLIGHT) && !player.isFlying()) {
|
if (getCheckManager().willCheck(player, CheckType.FLIGHT) && !player.isFlying()) {
|
||||||
CheckResult result1 = YAxisCheck.runCheck(player, new Distance(from, to));
|
CheckResult result1 = YAxisCheck.runCheck(player, new Distance(from, to));
|
||||||
CheckResult result2 = getBackend().checkAscension(player, from.getY(), to.getY());
|
CheckResult result2 = FlightCheck.checkAscension(player, from.getY(), to.getY());
|
||||||
String log = result1.failed() ? result1.getMessage() : result2.failed() ? result2.getMessage() : "";
|
String log = result1.failed() ? result1.getMessage() : result2.failed() ? result2.getMessage() : "";
|
||||||
if (!log.equals("")) {
|
if (!log.equals("")) {
|
||||||
if (!silentMode()) {
|
if (!silentMode()) {
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class VehicleListener extends EventListener {
|
|||||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
||||||
if (VersionUtil.isBountifulUpdate()) {
|
if (VersionUtil.isBountifulUpdate()) {
|
||||||
|
|||||||
@@ -19,20 +19,19 @@
|
|||||||
|
|
||||||
package com.rammelkast.anticheatreloaded.manage;
|
package com.rammelkast.anticheatreloaded.manage;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
|
||||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
|
||||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p/>
|
* <p/>
|
||||||
* The manager that AntiCheat will check with to see if it should watch certain checks and certain players.
|
* The manager that AntiCheat will check with to see if it should watch certain checks and certain players.
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public class UpdateManager {
|
|||||||
builder.append((char) readChar);
|
builder.append((char) readChar);
|
||||||
}
|
}
|
||||||
data = builder.toString();
|
data = builder.toString();
|
||||||
|
reader.close();
|
||||||
} catch (IOException exception) {}
|
} catch (IOException exception) {}
|
||||||
finally {
|
finally {
|
||||||
if (stream != null) {
|
if (stream != null) {
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ public class VersionUtil {
|
|||||||
return player.getInventory().getBoots().containsEnchantment(Enchantment.FROST_WALKER);
|
return player.getInventory().getBoots().containsEnchantment(Enchantment.FROST_WALKER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public static ItemStack getItemInHand(Player player) {
|
public static ItemStack getItemInHand(Player player) {
|
||||||
if (isBountifulUpdate()) {
|
if (isBountifulUpdate()) {
|
||||||
return player.getItemInHand();
|
return player.getItemInHand();
|
||||||
|
|||||||
@@ -1124,7 +1124,6 @@ public enum XMaterial {
|
|||||||
*
|
*
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
|
||||||
private static final ImmutableMap<XMaterial, XMaterial> DUPLICATED = Maps.immutableEnumMap(ImmutableMap.<XMaterial, XMaterial>builder()
|
private static final ImmutableMap<XMaterial, XMaterial> DUPLICATED = Maps.immutableEnumMap(ImmutableMap.<XMaterial, XMaterial>builder()
|
||||||
.put(MELON, MELON_SLICE)
|
.put(MELON, MELON_SLICE)
|
||||||
.put(CARROT, CARROTS)
|
.put(CARROT, CARROTS)
|
||||||
@@ -1847,7 +1846,6 @@ public enum XMaterial {
|
|||||||
* @return data of this material, or 0 if none.
|
* @return data of this material, or 0 if none.
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public byte getData() {
|
public byte getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -1916,7 +1914,6 @@ public enum XMaterial {
|
|||||||
* @see #matchXMaterial(String, byte)
|
* @see #matchXMaterial(String, byte)
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("OptionalAssignedToNull")
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Material parseMaterial(boolean suggest) {
|
public Material parseMaterial(boolean suggest) {
|
||||||
Optional<Material> cache = PARSED_CACHE.getIfPresent(this);
|
Optional<Material> cache = PARSED_CACHE.getIfPresent(this);
|
||||||
|
|||||||
Reference in new issue
Block a user