mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 06:28:52 +00:00
Add fast animation check. Fixes #251
This commit is contained in:
1 parent
26bd4e0f78
commit
3a746ef45e
7 files changed
+47
-17
No files matched your search
@@ -39,6 +39,14 @@ import net.h31ix.anticheat.config.ConfigurationFile;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class Magic extends ConfigurationFile {
|
public class Magic extends ConfigurationFile {
|
||||||
|
/**
|
||||||
|
* The number of animations to wait before checking fastclicking; Type=integer; +Leniency=Increase.
|
||||||
|
*/
|
||||||
|
public int ANIMATION_CHECK;
|
||||||
|
/**
|
||||||
|
* The minimum time it should have taken for the player to click X times; Type=integer; +Leniency=Increase.
|
||||||
|
*/
|
||||||
|
public long ANIMATION_TIMEMIN;
|
||||||
/**
|
/**
|
||||||
* Time to exempt a player from moving because of entering/exiting a vehicle; Type=system, +Leniency=Increase.
|
* Time to exempt a player from moving because of entering/exiting a vehicle; Type=system, +Leniency=Increase.
|
||||||
*/
|
*/
|
||||||
@@ -444,6 +452,8 @@ public class Magic extends ConfigurationFile {
|
|||||||
TIMER_STEP_CHECK = new ConfigValue<Integer>("TIMER_STEP_CHECK").getValue();
|
TIMER_STEP_CHECK = new ConfigValue<Integer>("TIMER_STEP_CHECK").getValue();
|
||||||
TIMER_TIMEMIN = new ConfigValue<Integer>("TIMER_TIMEMIN").getValue();
|
TIMER_TIMEMIN = new ConfigValue<Integer>("TIMER_TIMEMIN").getValue();
|
||||||
TELEPORT_MIN = new ConfigValue<Integer>("TELEPORT_MIN").getValue();
|
TELEPORT_MIN = new ConfigValue<Integer>("TELEPORT_MIN").getValue();
|
||||||
|
ANIMATION_CHECK = new ConfigValue<Integer>("ANIMATION_CHECK").getValue();
|
||||||
|
ANIMATION_TIMEMIN = new ConfigValue<Integer>("ANIMATION_TIMEMIN").getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getVersion() {
|
public double getVersion() {
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ public class PlayerListener extends EventListener {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerEnterBed(PlayerBedEnterEvent event) {
|
public void onPlayerEnterBed(PlayerBedEnterEvent event) {
|
||||||
|
if (event.getBed().getType() != Material.BED) return;
|
||||||
getBackend().logEnterExit(event.getPlayer());
|
getBackend().logEnterExit(event.getPlayer());
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
@@ -238,6 +239,7 @@ public class PlayerListener extends EventListener {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerExitBed(PlayerBedLeaveEvent event) {
|
public void onPlayerExitBed(PlayerBedLeaveEvent event) {
|
||||||
|
if (event.getBed().getType() != Material.BED) return;
|
||||||
getBackend().logEnterExit(event.getPlayer());
|
getBackend().logEnterExit(event.getPlayer());
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
@@ -246,7 +248,13 @@ public class PlayerListener extends EventListener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerAnimation(PlayerAnimationEvent event) {
|
public void onPlayerAnimation(PlayerAnimationEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
getBackend().logAnimation(player);
|
if (getCheckManager().willCheck(player, CheckType.FAST_ANIMATION)) {
|
||||||
|
CheckResult result = getBackend().checkFastAnimation(player);
|
||||||
|
if (result.failed()) {
|
||||||
|
event.setCancelled(!silentMode());
|
||||||
|
log(result.getMessage(), player, CheckType.FAST_ANIMATION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class AnticheatManager {
|
|||||||
|
|
||||||
public void log(String message, int i) {
|
public void log(String message, int i) {
|
||||||
if (i != 1 && getConfiguration().getConfig().logToConsole.getValue()) {
|
if (i != 1 && getConfiguration().getConfig().logToConsole.getValue()) {
|
||||||
plugin.getLogger().info(ChatColor.RED + message);
|
Bukkit.getConsoleSender().sendMessage("[AntiCheat] " + ChatColor.RED + message);
|
||||||
}
|
}
|
||||||
if (i == 0 && getConfiguration().getConfig().fileLogLevel.getValue() == LOG_LEVEL_HIGH) // Not an alert, normal log message
|
if (i == 0 && getConfiguration().getConfig().fileLogLevel.getValue() == LOG_LEVEL_HIGH) // Not an alert, normal log message
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ public class Backend {
|
|||||||
private Map<String, Long> stepTime = new HashMap<String, Long>();
|
private Map<String, Long> stepTime = new HashMap<String, Long>();
|
||||||
private HashSet<Byte> transparent = new HashSet<Byte>();
|
private HashSet<Byte> transparent = new HashSet<Byte>();
|
||||||
private Map<String, Long> lastFallPacket = new HashMap<String, Long>();
|
private Map<String, Long> lastFallPacket = new HashMap<String, Long>();
|
||||||
|
private Map<String, Long> animationTime = new HashMap<String, Long>();
|
||||||
|
private Map<String, Integer> animations = new HashMap<String, Integer>();
|
||||||
|
|
||||||
private Magic magic;
|
private Magic magic;
|
||||||
private AnticheatManager manager = null;
|
private AnticheatManager manager = null;
|
||||||
@@ -839,6 +841,26 @@ public class Backend {
|
|||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CheckResult checkFastAnimation(final Player player) {
|
||||||
|
animated.put(player.getName(), System.currentTimeMillis());
|
||||||
|
increment(player, blockPunches, magic.BLOCK_PUNCH_MIN);
|
||||||
|
itemInHand.put(player.getName(), player.getItemInHand().getType());
|
||||||
|
|
||||||
|
String name = player.getName();
|
||||||
|
int clicks = animations.containsKey(name) ? animations.get(name) + 1 : 1;
|
||||||
|
animations.put(name, clicks);
|
||||||
|
if (clicks == 1) {
|
||||||
|
animationTime.put(name, System.currentTimeMillis());
|
||||||
|
} else if (clicks == magic.ANIMATION_CHECK) {
|
||||||
|
long time = System.currentTimeMillis() - animationTime.get(name);
|
||||||
|
animations.put(name, 0);
|
||||||
|
if (time < magic.ANIMATION_TIMEMIN) {
|
||||||
|
return new CheckResult(Result.FAILED, player.getName() + " clicked " + clicks + " times in " + time + " ms (max=" + magic.ANIMATION_CHECK + " in " + magic.ANIMATION_TIMEMIN + " ms)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
public void clearChatLevel(Player player) {
|
public void clearChatLevel(Player player) {
|
||||||
chatLevel.remove(player.getName());
|
chatLevel.remove(player.getName());
|
||||||
}
|
}
|
||||||
@@ -909,25 +931,11 @@ public class Backend {
|
|||||||
return isDoing(player, placedBlock, magic.BLOCK_PLACE_MIN);
|
return isDoing(player, placedBlock, magic.BLOCK_PLACE_MIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logAnimation(final Player player) {
|
|
||||||
//System.out.println("Log animation");
|
|
||||||
animated.put(player.getName(), System.currentTimeMillis());
|
|
||||||
increment(player, blockPunches, magic.BLOCK_PUNCH_MIN);
|
|
||||||
itemInHand.put(player.getName(), player.getItemInHand().getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetAnimation(final Player player) {
|
public void resetAnimation(final Player player) {
|
||||||
animated.remove(player.getName());
|
animated.remove(player.getName());
|
||||||
blockPunches.put(player.getName(), 0);
|
blockPunches.put(player.getName(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean justAnimated(Player player, Block block) {
|
|
||||||
if (player.getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) || (Utilities.isInstantBreak(block.getType()) || (player.getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return justAnimated(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean justAnimated(Player player) {
|
private boolean justAnimated(Player player) {
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
if (animated.containsKey(name)) {
|
if (animated.containsKey(name)) {
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public enum CheckType {
|
|||||||
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE),
|
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE),
|
||||||
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
||||||
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
||||||
|
FAST_ANIMATION(Permission.CHECK_FASTANIMATION),
|
||||||
AUTOTOOL(Permission.CHECK_AUTOTOOL);
|
AUTOTOOL(Permission.CHECK_AUTOTOOL);
|
||||||
|
|
||||||
private final Permission permission;
|
private final Permission permission;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public enum Permission {
|
|||||||
CHECK_ITEMSPAM,
|
CHECK_ITEMSPAM,
|
||||||
CHECK_VISUAL,
|
CHECK_VISUAL,
|
||||||
CHECK_FASTINVENTORY,
|
CHECK_FASTINVENTORY,
|
||||||
|
CHECK_FASTANIMATION,
|
||||||
CHECK_AUTOTOOL,
|
CHECK_AUTOTOOL,
|
||||||
|
|
||||||
/* System Nodes */
|
/* System Nodes */
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
# AntiCheat configuration file
|
# AntiCheat configuration file
|
||||||
# Please report any bugs: http://dev.bukkit.org/server-mods/anticheat/
|
# Please report any bugs: http://dev.bukkit.org/server-mods/anticheat/
|
||||||
# Documentation for these values is available at http://gravitydevelopment.net/docs/anticheat/net/h31ix/anticheat/util/Magic.html
|
# Documentation for these values is available at http://gravitydevelopment.net/docs/anticheat/net/h31ix/anticheat/util/Magic.html
|
||||||
ANIMATION_MIN: 200
|
ANIMATION_CHECK: 5
|
||||||
ASCENSION_COUNT_MAX: 8
|
ASCENSION_COUNT_MAX: 8
|
||||||
|
ANIMATION_TIMEMIN: 400
|
||||||
|
ANIMATION_MIN: 200
|
||||||
BLOCK_BREAK_MIN: 0.1
|
BLOCK_BREAK_MIN: 0.1
|
||||||
BLOCK_MAX_DISTANCE: 5.5
|
BLOCK_MAX_DISTANCE: 5.5
|
||||||
BLOCK_MAX_DISTANCE_CREATIVE: 6.0
|
BLOCK_MAX_DISTANCE_CREATIVE: 6.0
|
||||||
|
|||||||
Reference in new issue
Block a user