diff --git a/src/dev/w1zzrd/invtweaks/InvTweaksPlugin.java b/src/dev/w1zzrd/invtweaks/InvTweaksPlugin.java index cfec8e3..2d09d57 100644 --- a/src/dev/w1zzrd/invtweaks/InvTweaksPlugin.java +++ b/src/dev/w1zzrd/invtweaks/InvTweaksPlugin.java @@ -130,6 +130,7 @@ public final class InvTweaksPlugin extends JavaPlugin { ), this); pluginManager.registerEvents(new PlayerMoveRenderListener(chestManager), this); pluginManager.registerEvents(new ChestBreakListener(chestManager), this); + pluginManager.registerEvents(new SignEditListener(), this); } /** diff --git a/src/dev/w1zzrd/invtweaks/listener/SignEditListener.java b/src/dev/w1zzrd/invtweaks/listener/SignEditListener.java new file mode 100644 index 0000000..7b0ceca --- /dev/null +++ b/src/dev/w1zzrd/invtweaks/listener/SignEditListener.java @@ -0,0 +1,21 @@ +package dev.w1zzrd.invtweaks.listener; + +import dev.w1zzrd.spigot.wizcompat.packet.Players; +import org.bukkit.block.Sign; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; + +import java.util.Objects; + +public class SignEditListener implements Listener { + @EventHandler + public void onSignClick(final PlayerInteractEvent event) { + if(event.getAction() == Action.RIGHT_CLICK_BLOCK && + Objects.requireNonNull(event.getClickedBlock()).getState() instanceof Sign && + event.getPlayer().isSneaking()) { // Sneak-right-click to edit sign + Players.openSignEditor(event.getPlayer(), event.getClickedBlock().getLocation()); + } + } +}