# Sleep

The night runs faster as soon as players sleep, and the more sleep, the faster it runs. Nobody has to wait until everyone is in bed: one sleeper out of ten already speeds the night up a little, every further one adds to it, and when everyone sleeps the rest of the night goes at once. A boss bar (or a title) shows everyone in the world how many sleep, what time it is and how fast time runs right now.

## Commands

| Command | Syntax | Permission | Default | Description |
|---|---|---|---|---|
| `/sleep info` | `/sleep info` | `sleep.info` | `true` | Status of the world: sleepers, countable players, threshold, current speed, weather, time |
| `/sleep reload` | `/sleep reload` | `sleep.admin` | op | Reloads the sleep configuration |

## Additional permissions

| Permission | Default | Description |
|---|---|---|
| `sleep.use` | `true` | Counts when sleeping |
| `sleep.bypass` | false | Excluded from the calculation (like AFK) |

## How it works

- **Speed:** `base-speed` is the pace with everyone asleep (100 = time runs 100 times faster). The actual speed is `base-speed × sleepers / countable players`, never below `min-speed`. Example with 100 and 5: one sleeper of ten gives 10x, five of ten 50x, one of 50 the minimum 5x.
- **Threshold:** `min-before-speeding` says how many have to sleep before the speed-up starts: a number (`3`) or a share of the countable players (`25%`, rounded up, at least 1).
- **Countable** are players in the world in survival or adventure mode who are not [AFK](afk.md) (with the exclusion on), not vanished and not exempt via `sleep.bypass`. Whoever lies down always counts as a sleeper, operators included; exemption and AFK only take awake players out of the calculation.
- **Everyone asleep:** the rest of the night is skipped at once (as in vanilla) with the title "Skipping the entire night". Can be switched off via `full-sleep-skips-instantly`.
- **Morning:** at sunrise the speed-up ends and rain and thunder clear (`clear-weather`). If someone gets up earlier and the threshold is no longer met, time simply stands still again, without a message.
- **Display:** `info-type` `bossbar` (default) shows "Sleeping 2/8 | 21:30 | 25x speed" with the night's progress as the bar, `title` shows the time big with "2/8 (25x)" underneath, `none` shows nothing. With too few sleepers everyone gets an action bar "2 of 4 sleeping" when a bed is entered or left (`inform`, at most every `inform-delay` seconds).
- The plugin controls the skip itself and overrides the vanilla gamerule `playersSleepingPercentage` for that.

> **Tip:** `/sleep info` shows admins right away why the night is not running faster (too many AFK players, wrong world, threshold not met) and how fast it runs at the moment.

## Configuration (modules/sleep.yml)

```yaml
# Enables or disables the sleep module.
enabled: true

sleep:
  # Secondary switch for sleep handling.
  enabled: true
  # Pace with everyone asleep: 100 = time runs 100 times faster.
  # Actual speed: base-speed x sleepers / countable players, never below min-speed.
  base-speed: 100
  min-speed: 5
  # Sleepers needed before the night speeds up: a number ("3") or a share ("25%").
  min-before-speeding: 1
  # Only speed up at night (from 13000 ticks to sunrise).
  only-during-night: true
  # Every countable player asleep: the rest of the night at once, like vanilla.
  full-sleep-skips-instantly: true
  # Clear rain and thunder at the morning.
  clear-weather: true
  # Display for the world's players: none, title or bossbar.
  info-type: bossbar
  bossbar:
    # PINK, BLUE, RED, GREEN, YELLOW, PURPLE or WHITE.
    color: YELLOW
    # PROGRESS, NOTCHED_6, NOTCHED_10, NOTCHED_12 or NOTCHED_20.
    style: NOTCHED_20
  # Action bar "x of y sleeping" on bed changes while the threshold is not
  # met, at most every inform-delay seconds.
  inform: true
  inform-delay: 30
  afk:
    # Excludes AFK players from the countable players.
    enabled: true
    # timer = the built-in AFK module, permission = an AFK marker of another
    # plugin, essentials = the Essentials AFK state.
    method: timer
    timeout-seconds: 300
  # blacklist = sleep everywhere except in the listed worlds,
  # whitelist = only in the listed worlds. An empty list means every overworld.
  world-mode: blacklist
  worlds: []
```

## Complete example config

```yaml
enabled: true

sleep:
  enabled: true
  base-speed: 120
  min-speed: 8
  min-before-speeding: "25%"
  only-during-night: true
  full-sleep-skips-instantly: true
  clear-weather: true
  info-type: title
  bossbar:
    color: YELLOW
    style: NOTCHED_20
  inform: true
  inform-delay: 20
  afk:
    enabled: true
    method: timer
    timeout-seconds: 180
  world-mode: blacklist
  worlds:
    - world_nether
    - the_end
```
