Class PlayerBedEnterEvent

All Implemented Interfaces:
Cancellable

public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable
This event is fired when the player is almost about to enter the bed.
Since:
1.0.0
  • Constructor Details

  • Method Details

    • getBed

      @NotNull public @NotNull Block getBed()
      Returns the bed block involved in this event.
      Returns:
      the bed block involved in this event
      Since:
      1.0.0
    • getBedEnterResult

      @NotNull @Obsolete(since="1.21.11") public @NotNull PlayerBedEnterEvent.BedEnterResult getBedEnterResult()
      This describes the default outcome of this event.
      Returns:
      the bed enter result representing the default outcome of this event
      Since:
      1.13.2
      API Note:
      This enum has been replaced with a system that better represents how beds work. See enterAction
    • enterAction

      @NotNull public @NotNull BedEnterAction enterAction()
      This describes the default outcome of this event.
      Returns:
      the action representing the default outcome of this event
      Since:
      1.21.11
    • useBed

      @NotNull public @NotNull Event.Result useBed()
      This controls the action to take with the bed that was clicked on.

      In case of Event.Result.DEFAULT, the default outcome is described by enterAction().

      Returns:
      the action to take with the interacted bed
      Since:
      1.13.2
      See Also:
    • setUseBed

      public void setUseBed(@NotNull @NotNull Event.Result useBed)
      Sets the action to take with the interacted bed.

      Event.Result.ALLOW will result in the player sleeping, regardless of the default outcome described by enterAction().
      Event.Result.DENY will prevent the player from sleeping. This has the same effect as canceling the event via setCancelled(boolean).
      Event.Result.DEFAULT will result in the outcome described by enterAction().

      Parameters:
      useBed - the action to take with the interacted bed
      Since:
      1.13.2
      See Also:
    • isCancelled

      public boolean isCancelled()
      Gets the cancellation state of this event. Set to true if you want to prevent the player from sleeping.

      Canceling the event has the same effect as setting useBed() to Event.Result.DENY.

      For backwards compatibility reasons this also returns true if useBed() is Event.Result.DEFAULT and the default action is to prevent bed entering.

      Specified by:
      isCancelled in interface Cancellable
      Returns:
      boolean cancellation state
      Since:
      1.0.0
    • setCancelled

      public void setCancelled(boolean cancel)
      Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.

      Canceling this event will prevent use of the bed.

      Specified by:
      setCancelled in interface Cancellable
      Parameters:
      cancel - true if you wish to cancel this event
      Since:
      1.0.0
    • getHandlers

      @NotNull public @NotNull HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
      Since:
      1.1.0
    • getHandlerList

      @NotNull public static @NotNull HandlerList getHandlerList()
      Since:
      1.1.0