Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6542

Sleeping doesn't work properly when players have setSleepingIgnored(true)

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • None
    • Ubuntu 20.04, built using java 8 (maven wouldn't run otherwise), server running in java 17.

      Not sure that specs are necessary but here goes:

      i5 4570

      8GB ram (2GB allocated)

    • git-Spigot-66f9d3c-3fa79d3 (MC:1.17) (Implementing API version 1.17-R0.1-SNAPSHOT)
    • None, problem is in Spigot (although the bug was discovered while using EssentialsX, due to that setting setSleepingIgnored(true) by default)
    • Yes

    Description

      Players are currently counted incorrectly for sleeping purposes if they have the setSleepingIgnored(true) tag. This means that it is not possible to skip the nights in servers on which everyone has this tag set (This has only been tested on a server with 1 person, but I think it extends to servers with many people all of which have setSleepingIgnored(true), and possibly other cases).

      I have tested that this bug is not present in the latest 1.16.5 version, and is present in the 1.17 version above.

      I've attached a patch that (I think) should fix this issue.

       

      My reasoning for the changes is as follows:

      • We want to count players who are fauxSleeping in activePlayers, because they are indeed active
      • We want to count players who are fauxSleeping in sleepingPlayers, because if we don't then the "a(int)" function above will always be false, meaning a single player on a server can never sleep the night
      • In the "a(List)" function, we want to make sure that we return true only when at least one player is actually sleeping, to avoid false positives when the entire server has setSleepingIgnored(true)
      • in the "a(int, List)" function, we want to make sure that at least one player is in deep sleep (rather than just having setSleepingIgnored), to avoid a situation where the night always instantly passes

       

      Let me know if this is helpful and whether there's anything I've missed out or anything else you'd like me to provide

      Attachments

        Activity

          People

            Unassigned Unassigned
            NamelessFTW Ivan R
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: