mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Sort of fixed badly broken and untested GhostHand check, added update messaging.
Check will still need to be improved, but seems to work without false positives for now.
This commit is contained in:
1 parent
e89a6cfd88
commit
2ba98f9f9c
8 files changed
+50
-41
No files matched your search
@@ -44,6 +44,7 @@ import com.rammelkast.anticheatreloaded.event.PlayerListener;
|
||||
import com.rammelkast.anticheatreloaded.event.VehicleListener;
|
||||
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||
import com.rammelkast.anticheatreloaded.metrics.Metrics;
|
||||
import com.rammelkast.anticheatreloaded.util.UpdateManager;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
@@ -58,6 +59,7 @@ public class AntiCheatReloaded extends JavaPlugin {
|
||||
private static ProtocolManager protocolManager;
|
||||
private static SecureRandom random;
|
||||
private static Long loadTime;
|
||||
private static UpdateManager updateManager;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@@ -91,7 +93,7 @@ public class AntiCheatReloaded extends JavaPlugin {
|
||||
if (!VersionUtil.isSupported()) {
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.RED + "The version of this server is NOT supported by ACR! The plugin will be buggy!");
|
||||
}
|
||||
getLogger().info("Found ProtocolLib, enabling checks that use ProtcolLib...");
|
||||
getLogger().info("Enabling checks that use ProtcolLib");
|
||||
// Enable packetlisteners
|
||||
BlinkCheck.startTimer();
|
||||
BlinkCheck.listenPackets();
|
||||
@@ -145,6 +147,8 @@ public class AntiCheatReloaded extends JavaPlugin {
|
||||
}
|
||||
}, 90L);
|
||||
|
||||
updateManager = new UpdateManager();
|
||||
|
||||
// End tests
|
||||
verboseLog("Finished loading.");
|
||||
|
||||
@@ -306,4 +310,8 @@ public class AntiCheatReloaded extends JavaPlugin {
|
||||
Bukkit.broadcast(message, "anticheat.system.alert");
|
||||
}
|
||||
|
||||
public static UpdateManager getUpdateManager() {
|
||||
return updateManager;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,7 +33,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@@ -48,6 +47,7 @@ import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.YAxisCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.player.GhosthandCheck;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Lang;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
||||
@@ -333,13 +333,6 @@ public class Backend {
|
||||
}
|
||||
}
|
||||
|
||||
public CheckResult checkSprintStill(Player player, Location from, Location to) {
|
||||
/*if(!isMovingExempt(player) && player.isSprinting() && from.getX() == to.getX() && from.getZ() == to.getZ()) {
|
||||
return new CheckResult(Result.FAILED, player.getName()+" sprinted while standing still (xyz = "+(int)from.getX()+","+(int)from.getY()+","+(int)from.getZ()+")");
|
||||
}*/
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public CheckResult checkVClip(Player player, Distance distance) {
|
||||
double from = Math.round(distance.fromY());
|
||||
double to = Math.round(distance.toY());
|
||||
|
||||
@@ -45,14 +45,14 @@ public class KillAuraCheck {
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static void listenPackets() {
|
||||
AntiCheatReloaded.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(),
|
||||
/*AntiCheatReloaded.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(),
|
||||
ListenerPriority.LOWEST, new PacketType[] { PacketType.Play.Client.POSITION_LOOK }) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
PacketContainer packet = e.getPacket();
|
||||
}
|
||||
});
|
||||
});*/
|
||||
}
|
||||
|
||||
public static CheckResult checkAngle(Player player, EntityDamageEvent event) {
|
||||
@@ -83,7 +83,7 @@ public class KillAuraCheck {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static double calculateYawDifference(Location from, Location to) {
|
||||
public static double calculateYawDifference(Location from, Location to) {
|
||||
Location clonedFrom = from.clone();
|
||||
Vector startVector = clonedFrom.toVector();
|
||||
Vector targetVector = to.toVector();
|
||||
|
||||
@@ -19,9 +19,8 @@
|
||||
|
||||
package com.rammelkast.anticheatreloaded.check.player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
@@ -30,6 +29,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class GhosthandCheck {
|
||||
}
|
||||
|
||||
private static CheckResult checkBlockBreak(Player player, BlockBreakEvent event) {
|
||||
if (!isValidBreakTarget(player, event.getBlock())) {
|
||||
if (!isValidTarget(player, event.getBlock())) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
player.getName() + " tried to break a block which was out of view");
|
||||
}
|
||||
@@ -55,41 +55,44 @@ public class GhosthandCheck {
|
||||
}
|
||||
|
||||
private static CheckResult checkBlockPlace(Player player, BlockPlaceEvent event) {
|
||||
if (!isValidPlaceTarget(player, event.getBlock())) {
|
||||
if (!isValidTarget(player, event.getBlock())) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
player.getName() + " tried to place a block out of their view");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static boolean isValidPlaceTarget(Player player, Block block) {
|
||||
private static boolean isValidTarget(Player player, Block block) {
|
||||
Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
|
||||
double distance =
|
||||
player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
||||
: player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
||||
: magic.BLOCK_MAX_DISTANCE();
|
||||
Block targetBlock = player.getTargetBlockExact((int) Math.ceil(distance));
|
||||
if (targetBlock == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Utilities.isClimbableBlock(targetBlock)) {
|
||||
if (targetBlock.getLocation().distance(player.getLocation()) <= distance) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return targetBlock.equals(block) || targetBlock.getLocation().distance(block.getLocation()) <= 1.51;
|
||||
}
|
||||
|
||||
private static boolean isValidBreakTarget(Player player, Block block) {
|
||||
Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
|
||||
double distance =
|
||||
player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
||||
: player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
||||
: magic.BLOCK_MAX_DISTANCE();
|
||||
List<Block> targetBlocks = player.getLastTwoTargetBlocks(null, (int) Math.ceil(distance));
|
||||
for (Block target : targetBlocks) {
|
||||
if (Utilities.isClimbableBlock(target)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (targetBlock.equals(block)) {
|
||||
return true;
|
||||
}
|
||||
return targetBlocks.contains(block);
|
||||
|
||||
Location eyeLocation = player.getEyeLocation();
|
||||
|
||||
double yawDifference = KillAuraCheck.calculateYawDifference(eyeLocation, block.getLocation());
|
||||
double playerYaw = player.getEyeLocation().getYaw();
|
||||
|
||||
double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
|
||||
if (Math.round(angleDifference) > magic.GHOSTHAND_MAX_ANGLE_DIFFERENCE()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -382,4 +382,8 @@ public interface Magic {
|
||||
* The maximum amount of violations before flagging player as a cheater; TYPE=INTEGER, Leniency=INCREASE
|
||||
*/
|
||||
public int KILLAURA_MAX_ANGLE_VIOLATIONS();
|
||||
/**
|
||||
* The maximum angle difference allowed when breaking or placing blocks; TYPE=INTEGER, Leniency=INCREASE
|
||||
*/
|
||||
public int GHOSTHAND_MAX_ANGLE_DIFFERENCE();
|
||||
}
|
||||
@@ -325,6 +325,10 @@ public class PlayerListener extends EventListener {
|
||||
}
|
||||
|
||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
|
||||
if (player.hasPermission("anticheat.admin") && !AntiCheatReloaded.getUpdateManager().isLatest()) {
|
||||
player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + "Your version of AntiCheatReloaded is outdated! You can download " + AntiCheatReloaded.getUpdateManager().getLatestVersion() + " from the Spigot forums or DevBukkit.");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
@@ -344,13 +348,6 @@ public class PlayerListener extends EventListener {
|
||||
//KillAuraCheck.doMove(event);
|
||||
//TODO
|
||||
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.SPRINT)) {
|
||||
CheckResult result = getBackend().checkSprintStill(player, from, to);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.SPRINT);
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) {
|
||||
CheckResult result = FlightCheck.runCheck(player, distance);
|
||||
if (result.failed()) {
|
||||
|
||||
Reference in new issue
Block a user