Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // We're inside the PlayerInteractEvent, make sure to check if event.getAction() is LEFT_CLICK_BLOCK or whatever it's called
- /*
- * NoBreakDelay
- */
- if (!player.getGameMode().equals(GameMode.CREATIVE)) {
- // Make sure that the currently clicked block and the last destroyed block aren't blocks that you can destroy instantly or almost instantly
- if (event.getClickedBlock() != null && stats.getLastBlock() != null && Useful.isSemiSolid(event.getClickedBlock()) && Useful.isSolid(stats.getLastBlock())) {
- // Get the difference of now and the last broken block time
- // Pretty much results in the time from breaking the last block and clicking a new block
- double diff = System.currentTimeMillis() - stats.getBlockDestroyHook();
- DelayCheck:
- if (diff <= 50) {
- // Make sure his item doesn't have efficiency
- // I believe the Haste Potion effect alone does not create false positives, but you might want to double check that
- ItemStack hand = player.getItemInHand();
- if (hand != null) {
- if (hand.containsEnchantment(Enchantment.DIG_SPEED) && hand.getEnchantmentLevel(Enchantment.DIG_SPEED) >= 3) {
- break DelayCheck;
- }
- }
- // Threshold stuff
- stats.setClickDelayLevel(stats.getClickDelayLevel() + 5);
- if (stats.getClickDelayLevel() > 10) {
- // DangerLevel stuff
- stats.setBuildDangerLevel(stats.getBuildDangerLevel() + 50);
- if (stats.getBuildDangerLevel() > 200) {
- stats.setBlockDestroying(1000);
- }
- getOwner().alert(player, player.getName() + ": Tried to click block too quickly after breaking another one (" + diff + ")", null, AlertPriority.LOW, stats.getBuildDangerLevel(), DetectionType.CLICK_DELAY);
- event.setCancelled(true);
- stats.setClickDelayLevel(10);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment