Solved Kicking a player off a bed

Discussion in 'Plugin Development' started by YoloSanta, Jan 12, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    YoloSanta

    is it possible to remove the kicking of a player off the bed so they can stay in the bed as long as they want (ignore the factor about day time)
     
  2. Offline

    Zombie_Striker

    @YoloSanta
    Players are kicked out of bed because of the day cycle, and it is controlled on the client's side.

    To get around this, continuously send time-change packets to the players that are sleeping. If you do this, even if the server's time changes, the client will not see the change and will not be kicked out of bed.
     
  3. Offline

    RunsWithShovels

    Not really sure, but you could mess around with PlayerBedLeaveEvent though in the docs it doesn't appear to be cancellable.
     
  4. Offline

    Zombie_Striker

    @RunsWithShovels
    That only detects that it happens, not that it has any control over it, which is why the time-change is required.
     
  5. Offline

    YoloSanta

    How would I go about this? I’m not to experienced with Packet sending
     
  6. Offline

    Zombie_Striker

    @YoloSanta
    Two options:
    1. Use Player#setPlayerTime to change the time at the moment bukkit calls a time change (not sure if there is an event for this. You may need to check every tick and send the packet the moment it turns to day)
    2. Use ProtocolLib. Listen for the TimeChange packet, and if the time change is sent to a player that is sleeping, cancel the packet.
     
  7. Offline

    YoloSanta

    I've decided to go with option 2, do you happen to know how to use this API? I've never dealt with packet reading/writing
     
  8. Offline

    Zombie_Striker

    YoloSanta likes this.
Thread Status:
Not open for further replies.

Share This Page