Class PlayerChangeObjectStatusEvent

All Implemented Interfaces:
Cancellable

public final class PlayerChangeObjectStatusEvent extends PlayerObjectEvent
Called when the player changes the status of an object. For example, when someone opens a door (usually status 0 == closed, status 1 == opened), or turns on a furnace etc.
Example: If a player opens a door, an explosion will be triggered
1@EventMethod
2public void onPlayerChangeObjectStatusEvent(PlayerChangeObjectStatusEvent event){
3 //Get the object
4 ObjectElement o = event.getObject();
5
6 //Get the object definition
7 Objects.ObjectDefiniton definition = o.getDefinition();
8
9 //The definition enables you to find out if the object is a door
10 if(definition.type == Objects.Type.Door){
11 //The door is booby-trapped: we will trigger an explosion
12 World.triggerExplosion(o.getWorldPosition(), true, true);
13 }
14}
  • Method Details

    • getOldStatus

      public byte getOldStatus()
    • getNewStatus

      public byte getNewStatus()
      Gets the new object status.
      Returns:
      the new status.
    • setNewStatus

      public void setNewStatus(byte status)
      Sets the new object status.
      Parameters:
      status - the new status you want to set.
    • getObject

      public ObjectElement getObject()
      Description copied from class: PlayerObjectEvent
      Gets the object element.
      Overrides:
      getObject in class PlayerObjectEvent
      Returns:
      the object element.