From 0e8f2bd066813f08b3975e5b9d9c571d430c78c6 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Sat, 22 Jan 2022 15:38:59 +0100 Subject: [PATCH] Makes sure to cancel placing events when a permission sign is interacted with --- .../knarcraft/permissionsigns/listener/SignListener.java | 6 ++++-- .../net/knarcraft/permissionsigns/utility/FileHelper.java | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/knarcraft/permissionsigns/listener/SignListener.java b/src/main/java/net/knarcraft/permissionsigns/listener/SignListener.java index 9ac3a5d..357ac2d 100644 --- a/src/main/java/net/knarcraft/permissionsigns/listener/SignListener.java +++ b/src/main/java/net/knarcraft/permissionsigns/listener/SignListener.java @@ -50,7 +50,7 @@ public class SignListener implements Listener { } Sign sign = (Sign) block.getState(); - handleSignClick(sign, player, event.getAction()); + handleSignClick(sign, player, event.getAction(), event); } /** @@ -59,8 +59,9 @@ public class SignListener implements Listener { * @param sign

The clicked sign

* @param player

The player that clicked the sign

* @param action

The hand the player used to interact with the sign

+ * @param event

The player interact event which was triggered

*/ - private void handleSignClick(Sign sign, Player player, Action action) { + private void handleSignClick(Sign sign, Player player, Action action, PlayerInteractEvent event) { //Check if the sign is a registered permission sign PermissionSign permissionSign = SignManager.getSign(sign.getLocation()); if (permissionSign != null) { @@ -72,6 +73,7 @@ public class SignListener implements Listener { return; } if (player.isSneaking()) { + event.setCancelled(true); handlePermissionSignInteract(permissionSign, player); } else { player.sendMessage(getSignInfoText(permissionSign)); diff --git a/src/main/java/net/knarcraft/permissionsigns/utility/FileHelper.java b/src/main/java/net/knarcraft/permissionsigns/utility/FileHelper.java index 4fe271d..54a8b99 100644 --- a/src/main/java/net/knarcraft/permissionsigns/utility/FileHelper.java +++ b/src/main/java/net/knarcraft/permissionsigns/utility/FileHelper.java @@ -9,7 +9,11 @@ import java.nio.charset.StandardCharsets; /** * A helper class for dealing with files */ -public class FileHelper { +public final class FileHelper { + + private FileHelper() { + + } /** * Gets a buffered reader for