I just started a small scale anti cheat that has some nifty checks, but I'm confused as to why this isn't working / is really inaccurate:
That should get the MS between every click - but for some reason it is really inaccurate e.g 0ms gap between clicks.
Code:
@EventHandler
public void onClick(PlayerInteractEvent e) {
Long current = System.currentTimeMillis();
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
Player player = e.getPlayer();
if (!lastClick.containsKey(player.getUniqueId())) {
lastClick.put(player.getUniqueId(), current);
return;
}
Long timeBetween = current - lastClick.get(player.getUniqueId());
System.out.println(timeBetween);
lastClick.remove(player.getUniqueId());
lastClick.put(player.getUniqueId(), current);
}
}
That should get the MS between every click - but for some reason it is really inaccurate e.g 0ms gap between clicks.
Last edited:
