Added GhostHand and Unicode chat check and fixed broken fly check.

Furthermore:
+ Updated and documented magic.yml
+ Added support for missing CAVE_AIR material
+ Average ping for blink check can now be configured
+ Removed /acr update from help command
+ Added UpdateManager.java to be used in future update messages
+ Better MainHand/OffHand support

I've been busy :)
This commit is contained in:
Rammelkast committed 2020-03-24 20:15:31 +01:00
1 parent acea36929b
commit fec1286c8d
22 files changed
+596 -193

No files matched your search

@@ -19,18 +19,77 @@
package com.rammelkast.anticheatreloaded.check.player;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.List;
import org.bukkit.GameMode;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
import com.rammelkast.anticheatreloaded.util.Utilities;
/**
*
* @author Rammelkast
*
*/
public class GhosthandCheck {
public static final Map<UUID, Integer> FLAG_COUNT = new HashMap<UUID, Integer>();
public static final int MAX_FLAGS = 3; // TODO config?
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static CheckResult performCheck(Player player, Event event) {
if (event instanceof BlockPlaceEvent) {
return checkBlockPlace(player, (BlockPlaceEvent) event);
} else if (event instanceof BlockBreakEvent) {
return checkBlockBreak(player, (BlockBreakEvent) event);
}
return PASS;
}
private static CheckResult checkBlockBreak(Player player, BlockBreakEvent event) {
if (!isValidBreakTarget(player, event.getBlock())) {
return new CheckResult(CheckResult.Result.FAILED,
player.getName() + " tried to break a block which was out of view");
}
return PASS;
}
private static CheckResult checkBlockPlace(Player player, BlockPlaceEvent event) {
if (!isValidPlaceTarget(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) {
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 (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;
}
}
return targetBlocks.contains(block);
}
}