Skip to main content

For servers

Server behavior

The mod respects the vanilla playerSleepingPercentage gamerule.

If this value is set below 100%, only players who actually slept during the night will receive:

  • the Rested effect
  • the night summary

Players who did not sleep will not receive these rewards.


Rest counter handling

The config includes the following option:

"server": {
"resetPhantomTimerForNonSleepers": true
}

This setting controls how the phantom rest timer (timeSinceLastRest) is reset when the night is skipped.

  • The rest timer is reset for all players
  • Even players who did not sleep will have their counter reset
tip

Prevents situations where players who didn't participate in skipping the night are still targeted by phantoms later.


Version matching

The mod syncs config and content between server and client over its own network channel, and that channel carries a protocol version.

warning

Client and server must run the same mod version. A mismatched client is rejected at connect time with a clear message rather than joining and misbehaving later.

Install the same jar on the server and on every client and there is nothing else to configure.


Server-authoritative settings

When a player joins, the server sends its own config, and that copy is used for the session. Overlay timings, opacity, comfort weights and thresholds, the default theme and the HUD toggles are therefore identical for everyone, regardless of what each player has in their local file.

tip

The one thing a player keeps is their personal summary theme, chosen with the gear button. Everything else follows the server.

Changes take effect without a restart:

/midnightthoughts reload config

The file is re-read, validated, and pushed to everyone currently online. See commands for the full list.


The sleeping players plate

While anyone is asleep, a small plate in the corner shows how many players are sleeping out of how many are online — for example Sleeping 2/5. It updates as players get in and out of bed, and also when someone joins or leaves, so the denominator never goes stale.

"ui": {
"hideSleepingPlayersHud": false
}

Set it to true to hide the plate entirely. It is off by default, meaning the plate is shown.

note

On a single-player world the plate is not particularly useful, but it is not hidden automatically — some players like the confirmation that the night is being skipped.


Data safety

Two things get written to disk regularly: the config and per-player statistics.

Both are written atomically — the mod writes a temporary file and swaps it into place, so a crash or a power cut during a save leaves the previous version intact instead of a truncated file.

Statistics are held in memory while the server runs and flushed when a player disconnects and on shutdown, rather than being re-read for every access.

tip

If a stats or config file is ever damaged from the outside, the mod renames it with a .broken suffix, regenerates a clean one, and logs what it did. Nothing is silently deleted.


Performance

Comfort scans are the only meaningful per-player work, and results are cached per player, per position, for a short window — so walking around does not re-scan on every tick, and the scan only actually runs when a player interacts with a bed.

note

In profiling on a live server, the mod accounts for a fraction of a percent of the server tick. Raising scanRadius to its maximum of 8 increases the scanned volume noticeably; if you run a large server and want to be careful, that is the one number worth watching.


Extending behaviour

Server owners who want custom rules — a dimension that is always uncomfortable, a reward when someone becomes MVP, a debuff after a nightmare — can script it with KubeJS without writing a mod, or hook the Java API from an existing one.