Adds a small check to prevent dual clicks when holding an item

This commit is contained in:
Kristian Knarvik 2022-07-10 14:02:15 +02:00
parent dbd4593931
commit 42f82e2357

View File

@ -19,6 +19,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import java.util.Arrays;
import java.util.List;
@ -49,8 +50,10 @@ public class SignListener implements Listener {
}
Sign sign = (Sign) block.getState();
if (event.getHand() == EquipmentSlot.HAND) {
handleSignClick(sign, player, event.getAction(), event);
}
}
/**
* Handles the right-clicking action
@ -64,6 +67,7 @@ public class SignListener implements Listener {
//Check if the sign is a registered permission sign
PermissionSign permissionSign = SignManager.getSign(sign.getLocation());
if (permissionSign != null) {
//Allow creative users to destroy the sign
if (player.getGameMode() == GameMode.CREATIVE && action == Action.LEFT_CLICK_BLOCK) {
return;
}
@ -72,6 +76,7 @@ public class SignListener implements Listener {
return;
}
if (player.isSneaking()) {
//Prevent placement of any blocks
event.setCancelled(true);
handlePermissionSignInteract(permissionSign, player);
} else {