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