Checking for Bed Sleep and night passing

Discussion in 'Plugin Development' started by ACTruncale, Apr 10, 2011.

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

    ACTruncale

    Does anyone know the calls to check if players are in the bed sleeping and wake up when day comes?
     
  2. Offline

    Plague

    there have been added some new event for beds in the last few revisions, try searching javadocs, or eclipse autocomplete, I dont remember those exact names.
     
  3. Offline

    R3ality

    To check if a player is in bed you could use: player.isSleeping()
    It will return a Boolean value true if the player is in bed and false if not..

    As for checking if a player has slept and time has skipped to the morning the only easy way I know (without messing with schedulers and player.getSleepTicks()) is this:
    1. Listen for the PLAYER_BED_LEAVE event.
    2. If you catch it, check if the time is morning with server.getTime()

    As players are unable to enter the bed unless it is night time, if they leave the bed it *should* be morning :)
     
  4. Offline

    ACTruncale

    Gotcha! Thanks I'll try both of those.
     
Thread Status:
Not open for further replies.

Share This Page