if(event.isCancelled())
return;
boolean cancelled = false;
final NoCheatPlayer player = plugin.getPlayer(event.getPlayer());
final BlockBreakConfig cc = BlockBreakCheck.getConfig(player);
final BlockBreakData data = BlockBreakCheck.getData(player);
// Remember the location of the block that will be broken
data.brokenBlockLocation.set(event.getBlock());
// Only if the block got damaged directly before, do the check(s)
if(!data.brokenBlockLocation.equals(data.lastDamagedBlock)) {
// Something caused a blockbreak event that's not from the player
// Don't check it at all
data.lastDamagedBlock.reset();
return;
}
// Now do the actual checks, if still needed. It's a good idea to make
// computationally cheap checks first, because it may save us from
// doing the computationally expensive checks.
// First NoSwing: Did the arm of the player move before breaking this
// block?
if(cc.noswingCheck && !player.hasPermission(Permissions.BLOCKBREAK_NOSWING)) {
cancelled = noswingCheck.check(player, data, cc);
}
// Second Reach: Is the block really in reach distance
if(!cancelled && cc.reachCheck && !player.hasPermission(Permissions.BLOCKBREAK_REACH)) {
cancelled = reachCheck.check(player, data, cc);
}
// Third Direction: Did the player look at the block at all
if(!cancelled && cc.directionCheck && !player.hasPermission(Permissions.BLOCKBREAK_DIRECTION)) {
cancelled = directionCheck.check(player, data, cc);
}
// At least one check failed and demanded to cancel the event
if(cancelled)