Package org.bukkit.event.player

# Class PlayerBedEnterEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
org.bukkit.event.player.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.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static enum`
`PlayerBedEnterEvent.BedEnterResult`
Represents the default possible outcomes of this event.

## Nested classes/interfaces inherited from class org.bukkit.event.Event

`Event.Result`

## Field Summary

### Fields inherited from class org.bukkit.event.player.PlayerEvent

`player`

## Constructor Summary

Constructors
Constructor
Description
`PlayerBedEnterEvent(@NotNull Player who, @NotNull Block bed)`
Deprecated.
`PlayerBedEnterEvent(@NotNull Player who, @NotNull Block bed, @NotNull PlayerBedEnterEvent.BedEnterResult bedEnterResult)`

## Method Summary

Modifier and Type
Method
Description
`@NotNull Block`
`getBed()`
Returns the bed block involved in this event.
`@NotNull PlayerBedEnterEvent.BedEnterResult`
`getBedEnterResult()`
This describes the default outcome of this event.
`static @NotNull HandlerList`
`getHandlerList()`
`@NotNull HandlerList`
`getHandlers()`
`boolean`
`isCancelled()`
Gets the cancellation state of this event.
`void`
`setCancelled(boolean cancel)`
Sets the cancellation state of this event.
`void`
`setUseBed(@NotNull Event.Result useBed)`
Sets the action to take with the interacted bed.
`@NotNull Event.Result`
`useBed()`
This controls the action to take with the bed that was clicked on.

### Methods inherited from class org.bukkit.event.player.PlayerEvent

`getPlayer`

### Methods inherited from class org.bukkit.event.Event

`callEvent, getEventName, isAsynchronous`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### PlayerBedEnterEvent

public PlayerBedEnterEvent(@NotNull @NotNull Player who, @NotNull @NotNull Block bed, @NotNull @NotNull PlayerBedEnterEvent.BedEnterResult bedEnterResult)

### PlayerBedEnterEvent

@Deprecated public PlayerBedEnterEvent(@NotNull @NotNull Player who, @NotNull @NotNull Block bed)
Deprecated.

## Method Details

### getBedEnterResult

@NotNull 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

### 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 `getBedEnterResult()`.

Returns:
  the action to take with the interacted bed
See Also:
  - `setUseBed(org.bukkit.event.Event.Result)`

### 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 `getBedEnterResult()`.
`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 `getBedEnterResult()`.

Parameters:
  `useBed` - the action to take with the interacted bed
See Also:
  - `useBed()`

### 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

### setCancelled

public void setCancelled(boolean cancel)
Sets the cancellation state of this event. A canceled 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

### getBed

@NotNull public @NotNull Block getBed()
Returns the bed block involved in this event.

Returns:
  the bed block involved in this event

### getHandlers

@NotNull public @NotNull HandlerList getHandlers()

Specified by:
  `getHandlers` in class `Event`

### getHandlerList

@NotNull public static @NotNull HandlerList getHandlerList()