[MISC] BetterSleep v0.4.1 - Fastforward night based on number of sleepers [1337]

Discussion in 'Inactive/Unsupported Plugins' started by cyberdude, Sep 24, 2011.

  1. Offline

    cyberdude

    BetterSleep
    v. 0.4.1
    Download
    BetterSleep enables the possibility to fast forward the night depending on how many players are sleeping.

    BetterSleep will calculate the amount of night to be skipped based on the number of players sleeping out of the total number of online players.
    The night is skipped in time slices, so it will basically fast forward the night.
    Multiworld support! Everything is calculated on a per world basis, and per-world configuration supported (v. 0.4.1).

    Config
    Code:
    speed: 20
    
    The speed at which the plugin updates in ticks. 20 ticks is on normal servers equal to 1 second. On slower servers this might not be the same. So default value is to update every 1 second.

    Code:
    min: 0.0
    max: 1.0
    
    The min value is the minimum percentage of players to sleep before BetterSleep triggers.
    The max value is the maximum percentage of players to sleep before BetterSleep skips the entire night (The same as all is sleeping)
    Notice percentage is written as a float value between 0.0 to 1.0 or as a percentage by notation and percentage sign, such as
    [code yaml]
    min: 30%
    max: 80%
    [/code]


    Code:
    scale: true
    
    The scale value is telling the plugin whether to use scaling calculation or not. Read more here

    Broadcast
    There are 6 different broadcast types: join, quit, enterworld, leaveworld, sleep, wakeup

    In the config there are a list of broadcastEnabled option, one for each type. Which enables/disables the individual broadcast message.
    Each type's message can be customized using the broadMessage option for each message.
    Tags can be used which will replaced by the value. The following tags are available:

    %name%, %event%, %world%, %total%, %sleeping%, %percent%

    They are very self explanatory.

    Per-world config
    The default config is located in "plugin.yml".
    You can create a file with the name of the world, e.g. "world.yml" and enter per-world configuration here.
    You only need to specify the values that you want differently from the default. Any values not entered will be read from the default config.

    Examples
    If the min value is 0.3 and the max value is 0.7 and there are 10 people online the following will happen (With scale: false):
    When the first player enters the bed, nothing happens, nether when the second player, because 2/10 = 0.2 which is lower than min value of 0.3. When the 3rd player enters the bed the ratio is 3/10 = 0.3 which is the same as the min value. BetterSleep will activate and do it's thing, thus it will skip 0.3 or 30% of the night. It will do this by adding a calculated amount of time to the world.
    When the 4th player enters the bed, BetterSleep will speed up, and will then skip 40% of the night, when the 5th player enters the bed it will skip 50% of the night thus the night which is normally apprx. 10 minutes long will now only last 5 minutes. So for every second passed, BetterSleep will add another 1 second to the world time in this case. And so on. Until the 7th okayer enters a bed, the ratio will be 7/10 = 0.7 which hits the max value, thus BetterSleep will fastforward to morning.

    Scale
    With Scale enabled the amount of night skipped/fast forwarded is calculated in a scale between the min and max value. The start and full skip is calculated before the scale calculation is applied.
    Example (Same as before, but with scale enabled):
    If the min value is 0.3 and the max value is 0.7 and there are 10 people online the following will happen (With scale: true):
    When the first two players enters the bed, nothing happens. When the 3rd enters the bed, BetterSleep starts working, but it won't do anything yet, because the scaling means that 30% sleeping means 0% skipping, the 0%-100% scale is calculated in side the min and max value, thus when we hit 30% sleeping it scales into 0% skipping, when we hit 70% sleeping (max) it scales into 100% skipping.
    The 4th player then enters the bed, and BetterSleep now skips 25% of the night, and so on.
    In the example here, 4 players sleeping will then be 25%, 5 players will be 50%, 6 players 75% and 7 players will be 100%.

    If take another example of 20 online players, and min of 0.4 max of 0.8 the following will be the case:
    Nothing will happen until 8 players are sleeping, and first when the 9th player enters a bed then 12,5% of the night will be skipped, when the 10th player enters the bed 25% of the night will be skipped and so on. Until the 16th player enters the bed, the entire night will skipped.

    Future
    • Permissions, for exemptions.
    • Admin commands to change settings (and reload).
    • Doesn't really work well with high player servers and/or high speed value, because the amount of ticks to skip will be floating values less than 1, which bukkit doesn't handle, so I need to implement my own time handler on top, that keeps track of the ticks in floating point, and thus can add the single tick skip when needed.
    Changelog

    • v0.4.1
      • Compiled against RB 1337
      • Large rewrite
      • Support for Per world settings
      • Percentage notation, so you can write both 0.4 or 40% they will mean the same.
      • Broadcast message when a player does something that affects the calculation.
      • Different broadcast message for each type of action
      • Config to enable/disabled the individual broadcast messages
      • Broadcast is happening per world.
    • v0.3.3
      • Compiled against CB 1185, no code update.
    • v0.3.2
      • First release
    End note

    Comments, ideas, bugs are very welcome.
    Enjoy!
     
    DrAgonmoray likes this.
  2. Offline

    w4ssup

    very nice :D and first :3
     
  3. @cyberdude How does this behave together with plugins like propertime?
     
  4. Offline

    cyberdude

    I am not really sure, it kinda depends on how propertime is created, but I just read about it, and under normal cirumstances it shouldn't create any problems. However using backwards time from propertime, will probably create some very weird results.
    If you would like to try it out, and give me feedback I would appreciate it.
     
  5. Nice plugin!
     
  6. @cyberdude
    I will do some testing and report back.
     
  7. Offline

    cyberdude

    Thank you :)
     
  8. @cybderdude
    Done some preliminary testing. There are no errors in logs and 3/5 users sleeping with scale reduces night time by 30% (default config).
     
  9. Offline

    cyberdude

    :D...
     
  10. The explaination is a little bit fuzzy and uses alot of examples. Is it so that if you dont use a scale then time skip percentage is based on sleeping player vs online players? And with scale on it scales between min/max value as a percentage?
     
  11. Offline

    cyberdude

    Yes that is correct. I have been thinking about rewriting the description, as I've noticed it is a bit vague, but at the time of writing I couldn't write it better. But yes, essentially without scale on it skips the night based on the percentage of sleeping players vs. online players WITHIN the min/max range. This means that if it is calculated to 30% the night is skipped 30% if the min value allows this. With scale, the percentage is RECALCULATED within the min/max scale. So if your min value is 30% then with scale on and 30% of the players are sleeping it is recalculated to 0%. It is a bit difficult to explain with detailed enough explanation while making it easy for newbies to understand.
     
  12. Offline

    cyberdude

    New version 0.4.1 with Broadcast message, and full multiworld support with per-world configuration.
     
  13. Offline

    GimmeCookie

    Code:
    2011-10-26 17:28:54 [WARNING] Task of 'BetterSleep' generated an exception
    java.lang.NullPointerException
    at net.pb_software.bettersleep.BetterSleepListener.onEventWorld(BetterSleepListener.java:33)
    at net.pb_software.bettersleep.BetterSleepListener.access$1(BetterSleepListener.java:31)
    at net.pb_software.bettersleep.BetterSleepListener$6.doEvent(BetterSleepListener.java:111)
    at net.pb_software.bettersleep.DelayedEventGen.run(DelayedEventGen.java:11)
    at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:137)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:441)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:374)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:417)
    2011-10-26 17:29:04 [WARNING] Task of 'BetterSleep' generated an exception
    java.lang.NullPointerException
    at net.pb_software.bettersleep.BetterSleepListener.onEventWorld(BetterSleepListener.java:33)
    at net.pb_software.bettersleep.BetterSleepListener.access$1(BetterSleepListener.java:31)
    at net.pb_software.bettersleep.BetterSleepListener$6.doEvent(BetterSleepListener.java:112)
    at net.pb_software.bettersleep.DelayedEventGen.run(DelayedEventGen.java:11)
    at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:137)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:441)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:374)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:417) 
    4 player online, only two players counted. standart config.yml
     
  14. Offline

    cyberdude

    T
    Thank you for your report. I haven't seen this happen.
    Can you provide me with information about Bukkit Build and the plugins you have?

    I have a suspension that you are using some form of world manager, that adds the worlds AFTER bettersleep have loaded.
    I'd like to see your plugins list. I will also later (hopefully today) create a quick modified tester that I would need you try for me.
     
  15. Offline

    BooGaLoo90

    From what i have tested so far, this plugin stops mobs from waking players up when sleeping in low lit places. I put a bed in the middle of a desert with no lighting at night time and it sped up the night by 100% and no mobs spawned to wake me up. please fix! possibly delay the time the night speeds up activates to allow for mobs to wake players up. if mob wakes a player up, the speed up time is adjusted before slicing the night.
     
  16. Offline

    cyberdude

    Hmm... I was told this was not possible by respected developers when I first developed this. But I might have an idea, for a fix. I'll just compile it, and give a link here. I don't have time to test right now, but maybe you can help test?

    @BooGaLoo90
    Can you try this out for me, it's not tested, I've not even run it.
    http://dl.dropbox.com/u/3055744/Bukkit/bettersleep/Test/BetterSleep.jar

    Hopefully it works, if it doesn't, I'll try later when I get time.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 19, 2016
  17. Offline

    BooGaLoo90

    This version does not fast forward time at all. i tried sleeping inside a very well lit place and also in the middle of a desert again. nothing wakes me up still and i lay in bed for a few minutes and the moon does not jump forward at all. basically, all it does is the notification in chat when someone goes to sleep (i have the other notifications to false)
     
  18. Offline

    cyberdude

    Okay :)... I'll get to it as soon as I get time for it. Thanks for trying it out for me. :)
     
  19. Offline

    BooGaLoo90

    @cyberdude
    no prob, thanks for a quick version fix attempt =D usually it takes others a couple days to get one out.
     
  20. Offline

    Royalgamer06

    please update to RB 1.0.1-R1
    error log:
    Code:
    20:34:59 [WARNING] Task of 'BetterSleep' generated an exception
    java.lang.NullPointerException
            at net.pb_software.bettersleep.BetterSleepListener.onEventWorld(BetterSl
    eepListener.java:33)
            at net.pb_software.bettersleep.BetterSleepListener.onEvent(BetterSleepLi
    stener.java:28)
            at net.pb_software.bettersleep.BetterSleepListener.access$0(BetterSleepL
    istener.java:26)
            at net.pb_software.bettersleep.BetterSleepListener$1.doEvent(BetterSleep
    Listener.java:69)
            at net.pb_software.bettersleep.DelayedEventGen.run(DelayedEventGen.java:
    11)
            at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(C
    raftScheduler.java:137)
            at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:493)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
    20:35:02 [WARNING] Task of 'BetterSleep' generated an exception
    java.lang.NullPointerException
            at net.pb_software.bettersleep.BetterSleepListener.onEventWorld(BetterSl
    eepListener.java:33)
            at net.pb_software.bettersleep.BetterSleepListener.onEvent(BetterSleepLi
    stener.java:28)
            at net.pb_software.bettersleep.BetterSleepListener.access$0(BetterSleepL
    istener.java:26)
            at net.pb_software.bettersleep.BetterSleepListener$2.doEvent(BetterSleep
    Listener.java:76)
            at net.pb_software.bettersleep.DelayedEventGen.run(DelayedEventGen.java:
    11)
            at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(C
    raftScheduler.java:137)
            at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:493)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
    >
     
  21. Offline

    Royalgamer06

    Please update! Love your plugin!
     
  22. Offline

    Royalgamer06

    PLEASE UPDAAAAAAAAATEEEEE
     
  23. Offline

    norsac321

    Wait so does this mod make it so that when x amount of people sleep it fast forwards the night for ex: if i was smelting iron and x amount of people go to sleep it would be like i stayed up the whole night.....So pretty much The Somnia mod?
     
  24. Offline

    Royalgamer06

    Is this project still alive??? Please update or sum1 take over!
     
  25. Offline

    cyberdude

    Thanks for the feedback everybody. I am very sorry to let you down, but I decided to quit bukkit and bukkitdev a couple of months ago, when I felt bukkit was on the way in the drains. I have had in my thoughts for a long time to update the plugin, but now I can't be bothered when Bukkit is dying anyways. I just don't have time enough on my hands. I will be looking forward for the Spout Server and my development will be there when it's up and running.

    I will meet the requests about releasing the source, I will upload it to Github soon.
     
  26. Offline

    md_5

    Long time no see cyberdude. You will notice that this thread has now been placed into the Inactive Plugin subforum.
    If you wish to revive this plugin, please ensure that you update and test compatibility with the latest recommended Bukkit build before reporting your original post, asking for it to be moved back to the release forum.

    Thanks for your time.
    md_5
     

Share This Page