BetterSleep

BetterSleep

Download v. 0.4.1
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

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.

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

min: 30%
max: 80%
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 30% and the max value is 70% 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 30%. 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.

End note

Comments, ideas, bugs are very welcome.
Enjoy!


Comments

  • To post a comment, please or register a new account.
Posts Quoted:
Reply
Clear All Quotes

About This Project

  • Project ID
    32091
  • Created
    Sep 14, 2011
  • Last Released File
    Oct 22, 2011
  • Total Downloads
    6,726
  • License

Categories

Members

Recent Files

Bukkit