If sign is waxed (not editable) then no check is required

This commit is contained in:
tastybento 2023-06-24 10:31:51 -07:00
parent 0856d48470
commit b50063685f

View File

@ -7,6 +7,7 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Tag; import org.bukkit.Tag;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.block.data.Waterlogged; import org.bukkit.block.data.Waterlogged;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
@ -33,7 +34,7 @@ public class BlockInteractionListener extends FlagListener
* *
* @param e - event * @param e - event
*/ */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteract(final PlayerInteractEvent e) public void onPlayerInteract(final PlayerInteractEvent e)
{ {
// We only care about the RIGHT_CLICK_BLOCK action. // We only care about the RIGHT_CLICK_BLOCK action.
@ -43,7 +44,7 @@ public class BlockInteractionListener extends FlagListener
} }
// Check clicked block // Check clicked block
this.checkClickedBlock(e, e.getPlayer(), e.getClickedBlock().getLocation(), e.getClickedBlock().getType()); this.checkClickedBlock(e, e.getPlayer(), e.getClickedBlock());
// Now check for in-hand items // Now check for in-hand items
if (e.getItem() != null && !e.getItem().getType().equals(Material.AIR)) if (e.getItem() != null && !e.getItem().getType().equals(Material.AIR))
@ -85,11 +86,12 @@ public class BlockInteractionListener extends FlagListener
* *
* @param e - event called * @param e - event called
* @param player - player * @param player - player
* @param loc - location of clicked block * @param block - block being clicked or used
* @param type - material type of clicked block
*/ */
private void checkClickedBlock(Event e, Player player, Location loc, Material type) private void checkClickedBlock(Event e, Player player, Block block)
{ {
Material type = block.getType();
Location loc = block.getLocation();
// Handle pots // Handle pots
if (type.name().startsWith("POTTED")) if (type.name().startsWith("POTTED"))
{ {
@ -133,7 +135,8 @@ public class BlockInteractionListener extends FlagListener
return; return;
} }
if (Tag.SIGNS.isTagged(type)) { if (Tag.SIGNS.isTagged(type) && block instanceof Sign sign && sign.isEditable()) {
// If waxed, then sign cannot be edited otherwise check
this.checkIsland(e, player, loc, Flags.SIGN_EDITING); this.checkIsland(e, player, loc, Flags.SIGN_EDITING);
return; return;
} }
@ -232,7 +235,7 @@ public class BlockInteractionListener extends FlagListener
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent e) public void onBlockBreak(final BlockBreakEvent e)
{ {
this.checkClickedBlock(e, e.getPlayer(), e.getBlock().getLocation(), e.getBlock().getType()); this.checkClickedBlock(e, e.getPlayer(), e.getBlock());
} }