How to get sign text?

Discussion in 'Plugin Development' started by Raeon, May 18, 2011.

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

    Raeon

    I desperately need to know how to get the text a sign is holding. Could anybody help me please?

    - Raeon
     
  2. Offline

    Lolmewn

    Sign s = (Sign)event.getBlock().getState() if I recall that properly.
    then go s.getLine(0) to get the first line, and so on.
     
  3. Offline

    Raeon

    Thank you very much! I'll try it right away! :D

    EDIT: What do I have to import?
    1. 'Sign' (org.bukkit.Block)
    2. 'Sign' (org.bukkit.Material)
     
  4. The method Lolmewn used is right, but I advise using:
    Code:
    if (event.getBlock().getState() instanceof Sign) {
    //Lolmewn's part
    //rest of the script
    }
    
    to prevent errors in case you try to read from a block that isn't a sign
     
  5. Offline

    Raeon

    Yeah you're right, thanks for reminding me!
    But do I have to import Sign from 'org.bukkit.Block' or 'org.bukkit.Material'?
     
  6. Offline

    GardenGnomer

    Thankyou, I wondered that too!
     
  7. Offline

    Shamebot

    org.bukkit.block.Sign I think
     
  8. Offline

    DreadKyller

    @Shamebot : correct! org.bukkit.block.Sign
     
Thread Status:
Not open for further replies.

Share This Page