mrgeneralq / sleep-most

Control the amount of percentage of sleeping players required to make it day. 100K+ downloads on spigot!
https://www.spigotmc.org/resources/sleep-most-1-14-4-configurable-messages-and-percentage.60623/
30 stars 12 forks source link

Inconsistent night skip check #175

Closed Ad-Blokker closed 9 months ago

Ad-Blokker commented 1 year ago

Describe the bug The check on how many people need to sleep has an inconsistency.

To Reproduce Steps to reproduce the behavior:

  1. Set the players needed percentage to 0.4
  2. Have 3 players in the game, it becomes night, player 1 goes in bed, 1 more player needs to sleep.
  3. Player 3 leaves the game, changing the players needed to 1 but it will not skip the night
  4. Player 2 also goes in the bed, making players needed 2/1 and still not skipping the night
  5. Fixing by either player 3 joining again making 2/2 or player 1 and player 2 going out of the bed and re-entering

Expected behavior Dynamically change the skip amount needed when players leave / join / enter or leave the bed, therefore skipping the night when player amount needed changes

Screenshots N/A

Desktop (please complete the following information):

Additional context N/A

Ad-Blokker commented 1 year ago

3 player in game 1 player sleeping 1/2 players to skip

1


1 Player leaves 2 Players in game 1 Sleeping 1/2 players to skip night

2


2 Players in game 2 Players sleeping 2/1 Players to skip night

Night is not being skipped, even tough more than needed are sleeping and minecraft says sleeping through this night

3


Player 3 joins the game 3 Players in the game 2 Players sleeping Still nothing

Player 1 that first entered the bed leaves the bed and re-enters

Skipping night is successful

4


binarybrain11 commented 9 months ago

In PlayerSleepStateChangeEventListener.java line 99, there is the following code: if(this.sleepService.getSleepersAmount(world) > this.sleepService.getRequiredSleepersCount(world)) and when this evaluates to true, it doesn't register the night skipping task. Shouldn't that be a less than sign so that if the number of sleepers is greater than the number of required sleepers it skips the night?

mrgeneralq commented 9 months ago

In PlayerSleepStateChangeEventListener.java line 99, there is the following code: if(this.sleepService.getSleepersAmount(world) > this.sleepService.getRequiredSleepersCount(world)) and when this evaluates to true, it doesn't register the night skipping task. Shouldn't that be a less than sign so that if the number of sleepers is greater than the number of required sleepers it skips the night?

Hello @binarybrain11 You are right. I don't have time now but Will look into it tomorrow. Feel free to fix it and submit a pr.

Kr mrgeneralQ

mrgeneralq commented 9 months ago

Solved in #179