Solved Check if sign is placed on block

Discussion in 'Plugin Development' started by mike0631, Jan 2, 2013.

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

    mike0631

    In the event onBlockBreak(BlockBreakEvent event).
    How do I check if a sign is placed on it and how can I get the first line of the sign?
     
  2. Offline

    keelar

    You can check if the block above the broken block is a sign by doing:
    Code:
    Block block = e.getBlock();
     
    if(block.getRelative(BlockFace.UP).getType().equals(Material.SIGN_POST)){
        //do something
    }
     
    mike0631 likes this.
  3. Offline

    Tirelessly

    if(block.getRelative(BlockFace.UP).getType().equals(Material.SIGN)){

    Sign sign = (Sign)block.getRelative(BlockFace.UP).getState();
    sign.getLine(0);
     
    mike0631 likes this.
  4. Offline

    mike0631

    Thank you guys.
     
  5. Offline

    keelar

    No problem. Keep in mind that Material.SIGN and Material.SIGN_POST are two different items.
     
  6. Offline

    mike0631

    Thanks, Figured that out myself already. :)
     
Thread Status:
Not open for further replies.

Share This Page