Solved EventHandler on placed sign not working

Discussion in 'Plugin Development' started by Alias_Me, Jan 13, 2019.

Thread Status:
Not open for further replies.
  1. Offline

    Alias_Me

    So I wanted to write a simple Eventhandler that triggers when a sign is placed:

    Code:
    public class PlaceSigns implements Listener {
       @EventHandler
       public void signPlaced(BlockPlaceEvent event) {
          Block block = event.getBlock();
          Material material = block.getType();
          if(material.equals(Material.SIGN)) {
             event.getPlayer().sendMessage("works");
          }
       }
    }
    
    But when I place a Sign, no matter if I put text on it or not, the Message doesnt appear. It works on other Blocks though, I switched out Material.SIGN for Material.TNT for instance and the message appeared when I placed TNT.
    Are Signs handled differently in that regard?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Alias_Me Use == instead of equals for enum checks.
    And you have sign and wall sign I believe.
     
  3. Offline

    Alias_Me

    @timtower works great, thank you! Any chance I can make the sign do .getLine() only after something was written on it?
    Cause when the sign just got placed obviously there can`t be anything written on it already.
     
  4. Offline

    timtower Administrator Administrator Moderator

Thread Status:
Not open for further replies.

Share This Page