Help, simple issue. :)

Discussion in 'Plugin Development' started by Desle, Jul 19, 2013.

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

    Desle

    How do i get the lines of a sign that i just rightclicked? detected using PlayerInteractEvent.
     
  2. Offline

    CubieX

    Make sure the action was a right click on a block.
    Then check if this block is a WALL_SIGN or a SIGN_POST, and if so,
    cast the block to a sign.
    Then you can do "mySign.getLines()" or mySign.getLine(linenumber).
    Line numbers are 0 to 3.
     
  3. Offline

    ChrisixStudios

    You would make sure that your are right clicking a block by using the PlayerInteractEvent.getAction(). The you would get the block that was clicked (PlayerInteractEvent.getClickedBlock()). Then check if the block is a sign by using...

    Code:java
    1. if(e.getClickedBlock().getState().getData() instanceof Sign)


    Then using the cast it to a Sing and use getLines(). :) Hope that helps
     
  4. Offline

    Desle


    What do i need to cast to (Sign)? I'm getting errors when i try.
     
  5. Offline

    ChrisixStudios

    Code:java
    1. Sign s = (Sign) e.getClickedBlock().getState().getData();


    Don't put e put the event name. and if your still getting errors post the code.
     
  6. Offline

    Desle


    ERROR: org.bukkit.material.sign cannot be cast to org.bukkit.block.sign.

    Code:
                if (event.getClickedBlock().getType().equals(Material.WALL_SIGN)) {
                    Sign sm = (Sign) event.getClickedBlock().getState().getData();
                    String l1 = sm.getLine(1);
                    String l2 = sm.getLine(2);
                    String l3 = sm.getLine(3);
                    String l4 = sm.getLine(4);
     
  7. Offline

    CubieX

    Import the following path: org.bukkit.block.sign
    And as I said, the lines of the sign are indexed with 0 to 3 and not 1 to 4.
     
  8. Offline

    ChrisixStudios



    try casting e.getClickedBlock().getState() to sign
     
Thread Status:
Not open for further replies.

Share This Page