Need help with error BlockState cannot be cast to Sign

Discussion in 'Plugin Development' started by desup, Feb 26, 2012.

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

    desup

    Hi everyone,
    Everytime , when I worked with Sign lines, something like this code worked:
    Code:
    Sign s;
    BlockState st =b.getState();
                if(st instanceof Sign){
                      s = (Sign)st;
                }
    s.setLine(0, "Red: " + reds.size());
                s.setLine(1, "Blue: " + blues.size());
                s.update();
    (b is a block and reds and blues are ArrayLists)
    But now, I am getting an error:
    Whats wrong with my code?
    Thankx :)
     
  2. Offline

    nisovin

    Have you imported the wrong Sign?
     
  3. Offline

    desup

    nisovin
    I have imported import org.bukkit.block.Sign; because with Material, Im getting error om setLine()
     
  4. Offline

    Muddr

    could try something like this.

    Code:Java
    1. if (b != null) {
    2. BlockState st =b.getState();
    3. if (st instanceof Sign) {
    4. Sign s = (Sign) st;
    5. s.setLine(0, "herp");
    6. s.update();
    7. }
    8. }


    EDIT: Updated the code.. had an error.
     
  5. Offline

    desup

    I don't understand how, and I dont understand why, but it started to work, when I adden Muddr 's statement.
    Thank you really much
     
Thread Status:
Not open for further replies.

Share This Page