mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-07-19 09:24:41 +02:00
Also prevent using item-in-hand or using interacted-block fpor
cancelled interact events.
This commit is contained in:
parent
1d44fe66be
commit
5f5d571264
|
@ -1,7 +1,10 @@
|
|||
package fr.neatmonster.nocheatplus.checks.blockinteract;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
|
@ -9,6 +12,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||
|
||||
import fr.neatmonster.nocheatplus.checks.CheckListener;
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.InteractRayTracing;
|
||||
|
||||
/*
|
||||
* M#"""""""'M dP dP M""M dP dP
|
||||
|
@ -63,7 +68,9 @@ public class BlockInteractListener extends CheckListener {
|
|||
*/
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (event.getAction() != Action.LEFT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_BLOCK){
|
||||
final Action action = event.getAction();
|
||||
|
||||
if (action != Action.LEFT_CLICK_BLOCK && action != Action.RIGHT_CLICK_BLOCK){
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -82,9 +89,12 @@ public class BlockInteractListener extends CheckListener {
|
|||
// Second the direction check
|
||||
if (!cancelled && direction.isEnabled(player) && direction.check(player, block.getLocation()))
|
||||
cancelled = true;
|
||||
|
||||
|
||||
// If one of the checks requested to cancel the event, do so.
|
||||
if (cancelled)
|
||||
event.setCancelled(cancelled);
|
||||
if (cancelled) {
|
||||
event.setUseInteractedBlock(Result.DENY);
|
||||
event.setUseItemInHand(Result.DENY);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user