nkomarn / harbor

Harbor is a plugin that redefines sleep within your Spigot server!
https://bstats.org/plugin/bukkit/Harbor
MIT License
97 stars 33 forks source link

[Feature request] Stop night skipping if someone got out of bed #98

Open VladOliinyk opened 2 years ago

VladOliinyk commented 2 years ago

I guess it is quite an important feature to stop night “scrolling” if someone got out of bed, and the number of sleepers is less than necessary.

So, from my experience, I can guess that it is not a big deal to implement it from a code logic perspective. If I understand right, we have a sort of “scrollTheNight()” function, which is scrolling the night instantly or with a configured delay.

So, I think it is needed to just add a boolean variable, that will be a rule that reflects could the night be scrolled or not, in other words, “are enough players sleeping?”.

And in the mentioned “scrollTheNight()” function, each cycle of “adding in-game time value” we should check for our new rule variable.

And, each time sleepers counter updates, we should update that variable that affects on night skipping process.

Here is my pseudo-code, and

I see the logic this way:

while (there is still night outside) { If (enough players still sleep) { do skip iteration } else { bruh, go to bed } }

I’m not sure does this whole speech makes any sense, but I just have a mood to express it all. Hope it helps, and most importantly I hope it will be implemented soon!

p.s. writing this from phone was pretty painfull.

Mobmaker55 commented 2 years ago

Just from a standpoint of how Minecraft works in general, once the required number of people are sleeping (in vanilla, 100%), getting out of bed does not change skipping to day, once the system starts. Granted, the time for sunrise is much faster in vanilla than with Harbor, so it's much less likely people will leave bed, but it's still a native vanilla feature.

Also, the average time going from night to day in Harbor from starting night skip is less than 15 seconds iirc, so why are you punishing all of your players if someone gets out 10 seconds earlier? At that point, people may just start leaving so that way the required sleep count is lower, and then rejoining once it's day.