org.bukkit.material.Door Java Examples

The following examples show how to use org.bukkit.material.Door. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlockTransformListener.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
private void handleDoor(BlockTransformEvent event, Door door) {
  BlockFace relative = door.isTopHalf() ? BlockFace.DOWN : BlockFace.UP;
  BlockState oldState = event.getOldState().getBlock().getRelative(relative).getState();
  BlockState newState = event.getBlock().getRelative(relative).getState();
  BlockTransformEvent toCall;
  if (event instanceof ParticipantBlockTransformEvent) {
    toCall =
        new ParticipantBlockTransformEvent(
            event, oldState, newState, ((ParticipantBlockTransformEvent) event).getPlayerState());
  } else if (event instanceof PlayerBlockTransformEvent) {
    toCall =
        new PlayerBlockTransformEvent(
            event, oldState, newState, ((PlayerBlockTransformEvent) event).getPlayerState());
  } else {
    toCall = new BlockTransformEvent(event, oldState, newState);
  }
  callEvent(toCall, true);
}
 
Example #2
Source File: Observing.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onEvent(InventoryClickEvent event) {
  super.onEvent(event);

  if (!(event.getClickedInventory() instanceof PlayerInventory) || event.getCursor() == null)
    return;

  ItemStack item = event.getCursor();
  if (BAD_TYPES.contains(item.getType()) || item.getData() instanceof Door) {
    event.setCancelled(true);
  }
}
 
Example #3
Source File: BlockTransformListener.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
private void callEvent(final BlockTransformEvent event, boolean checked) {
  if (!checked) {
    MaterialData oldData = event.getOldState().getMaterialData();
    MaterialData newData = event.getNewState().getMaterialData();
    if (oldData instanceof Door) {
      handleDoor(event, (Door) oldData);
    }
    if (newData instanceof Door) {
      handleDoor(event, (Door) newData);
    }
  }
  logger.fine("Generated event " + event);
  currentEvents.put(event.getCause(), event);
}
 
Example #4
Source File: VersionHelper18.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public void toggleDoor(Block b) {
    BlockState state = b.getState();
    if (state instanceof Door) {
        Door op = (Door) state.getData();
        if (!op.isOpen())
            op.setOpen(true);
        else
            op.setOpen(false);
        state.setData(op);
        state.update();
    }
}
 
Example #5
Source File: VersionHelper112.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public void toggleDoor(Block b) {
    BlockState state = b.getState();
    if (state instanceof Door) {
        Door op = (Door) state.getData();
        op.setOpen(!op.isOpen());
        state.setData(op);
        state.update();
    }
}
 
Example #6
Source File: VersionHelper113.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public void toggleDoor(Block b) {
    BlockState state = b.getState();
    if (state instanceof Door) {
        Door op = (Door) state.getData();
        if (!op.isOpen())
            op.setOpen(true);
        else
            op.setOpen(false);
        state.setData(op);
        state.update();
    }
}