Implement sign editing

This commit is contained in:
Gabriel Tofvesson 2021-07-24 21:38:06 +02:00
parent f4cb5f58e5
commit 7c9bf21ced
2 changed files with 22 additions and 0 deletions

View File

@ -130,6 +130,7 @@ public final class InvTweaksPlugin extends JavaPlugin {
), this); ), this);
pluginManager.registerEvents(new PlayerMoveRenderListener(chestManager), this); pluginManager.registerEvents(new PlayerMoveRenderListener(chestManager), this);
pluginManager.registerEvents(new ChestBreakListener(chestManager), this); pluginManager.registerEvents(new ChestBreakListener(chestManager), this);
pluginManager.registerEvents(new SignEditListener(), this);
} }
/** /**

View File

@ -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());
}
}
}