Openable.setOpen(boolean) doesn't work

Discussion in 'Plugin Development' started by Kiwi7, Dec 26, 2013.

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

    Kiwi7

    Hey guys,
    I'm trying to develop a plugin that will open a door under a condition.
    This is a part of my code:
    Code:java
    1. BlockState state = block.getState();
    2. MaterialData data = state.getData();
    3. Openable openable = (Openable) data;
    4. if(openable.isOpen()) {
    5. player.sendMessage("The door is alerady open.");
    6. } else {
    7. openable.setOpen(true);
    8. }

    If the door is open, my plugin says "The door is alerady open", but if the door's closed, it doesn't open it.
    Please help me deal with this problem.
     
  2. Offline

    pope_on_dope

    update the door.
     
  3. Offline

    Kiwi7

    Thanks, it worked!
    In case somebody else sees this thread, I found BlockState.update() in the JavaDocs. I changed the code:
    Code:java
    1. if(openable.isOpen()) {
    2. player.sendMessage("The door is alerady open.");
    3. } else {
    4. openable.setOpen(true);
    5. state.update();
    6. }
     
    riebie likes this.
  4. Kiwi7 Can we see the whole code (might be a bit useful)
     
Thread Status:
Not open for further replies.

Share This Page