# Sleep

The night is skipped once a percentage of eligible players sleeps. The percentage depends on the weather (clear, rain, thunderstorm), [AFK](afk.html) players can be excluded. The plugin controls the skip itself and overrides the vanilla gamerule `playersSleepingPercentage`.

## Commands

| Command | Syntax | Permission | Default | Description |
|---|---|---|---|---|
| `/sleep info` | `/sleep info` | `sleep.info` | `true` | World status: sleepers, eligible players, required count, weather, settings |
| `/sleep reload` | `/sleep reload` | `sleep.admin` | `false` | Reloads the sleep configuration |

## Additional permissions

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

**Eligible** players are in the world in survival/adventure mode, not vanished, not AFK (with active AFK exclusion) and not exempted via `sleep.bypass`. The required count is always rounded up, at least 1.

> **Tip:** `/sleep info` shows admins immediately why the night is not being skipped (too many AFK players, wrong world, threshold not reached).

> **Tip:** On very large servers (200+ players) set `skip-speed` lower (40 to 60) so the time lapse does not stutter.

## Configuration (modules/sleep.yml)

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

sleep:
  # Secondary switch for sleep processing.
  enabled: true
  # Required percentage of eligible players in beds, per weather.
  # Example at 35: 3 players online = 2 must sleep (rounded up).
  normal-percentage: 35
  rain-percentage: 40
  storm-percentage: 50
  # Time lapse speed of the night skip (10 to 200). In the morning the
  # weather is cleared and all sleepers woken up. If a player leaves the
  # bed early and the threshold is no longer met, the skip cancels.
  skip-speed: 80
  # Progress bar in the action bar during the skip.
  actionbar-progress: true
  afk:
    # Excludes AFK players from the calculation.
    enabled: false
    # timer = built-in AFK system (recommended), permission = external
    # AFK marker of another plugin, essentials = Essentials AFK status.
    method: timer
    # Only for method timer: seconds until a player counts as AFK.
    timeout-seconds: 300
  # blacklist = sleep everywhere except the listed worlds.
  # whitelist = sleep only in the listed worlds.
  world-mode: blacklist
  worlds: []
```

## Complete example config

```yaml
enabled: true

sleep:
  enabled: true
  normal-percentage: 30
  rain-percentage: 25
  storm-percentage: 20
  skip-speed: 60
  actionbar-progress: true
  afk:
    enabled: true
    method: timer
    timeout-seconds: 180
  world-mode: blacklist
  worlds:
    - world_nether
    - the_end
```
