Detecting a sleep cycle

Discussion in 'Plugin Development' started by limdingwen, May 28, 2012.

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

    limdingwen

    Hi there Bukkit Community:

    I am currently developing a plugin called RealSleep. I was almost at the end of the developer build line when alas, I ran into a problem. After googling, searching, I had no idea how to detect a sleep cycle so I could restore a player's sleep. :( If someone can help I will be very grateful! :)

    Thanks in advance! :p
     
  2. what do you mean whit sleepcycle>?
     
  3. Offline

    limdingwen

    What I mean is like from night to morning (when all players go to sleep).
     
  4. you can catch the player interact events mayby
     
  5. Offline

    Father Of Time

    There is no sleep cycle, it's a long range. I believe a minecraft day consist of 24000L ticks (although I have no idea as I've never had to use it). There is no "sleep cycle" but simple a range within the 24000 that is considered "night"

    So if say 8pm to 6am was considered night it would be (the following is complete pseudo code):

    Code:
    long timeofday = server.<noideawhatgetstime>;
    if( timeofday >= 20000 && timeofday <= 6000 )
    {
    //time is between 8pm and 6am
    }
    
    I have no idea how close I am as I've never worked with world time, but from what I've seen from around the forums I think I am in the ballpark.

    Good luck!
     
Thread Status:
Not open for further replies.

Share This Page