[SPIGOT-6316] PlayerBedLeaveEvent implements Cancellable Created: 15/Jan/21  Updated: 30/Jan/21  Resolved: 29/Jan/21

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: lukas of lockless Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: event
Environment:

api
spigot-api-1.16.4-R0.1-SNAPSHOT

server
paper-1.16.4-406


Attachments: File BedEnterBedLeaveEvents.jar    
Version: 1.16.4
Guidelines Read: Yes

 Description   

PlayerEntersBedEvent can be cancelled and has a very informative interface getBedEnterResult()
PlayerLeavesBedEvent on the other hand is lacking in those features. 
imagine a plugin where players can enter a bed and not be immidiately thrown out of it using player.sleep(bed,true);//forces sleep
if the playerleaveevent had some more information on it  with Event.Result, some cases could be caught and the players could sleep any the time.

im attaching a plugin to let those interested see what happens when a player enters a bed during the daytime. the plugin does system.out.println some information about the events.

i hope i didn't mess up following the guidelines or add this in the wrong place.



 Comments   
Comment by lukas of lockless [ 30/Jan/21 ]

this is incredibly informative. thank you for the reply.

Comment by md_5 [ 29/Jan/21 ]

I see, thanks. There was an issue with my previous testing.

Comment by David Mayr [ 28/Jan/21 ]

That is wrong. You can sleep on the day and indeed cancel the sleep stop on the server side. Sending a Sleep Packet during the day puts the player in the bed and keeps him there. The Server does indeed kick him when using .sleep though since it is day but when the Server knows nothing about the player sleeping it works. And strictly ignoring the Client Command Packet with the Type Stop Sleep keeps the player in the bed, and he is unable to leave even with the Button.

Comment by md_5 [ 27/Jan/21 ]

Cancelling is problematic on the client side, since the client leaves the bed before notifying the server

Generated at Tue Apr 22 05:44:26 UTC 2025 using Jira 10.3.5#10030005-sha1:190c783f2bd6c69cd5accdb70f97e48812a78d14.