Player data and settings
Addons keep values per player through MachineEngine — Mekanized's radiation dose, for instance. There are three kinds:
- Saved values, kept across restarts (a dose).
- Session values, kept while the player is online (a cooldown).
- Settings, which players change themselves with
/machinesettings(show the radiation display or not).
MachineEngine stores them, saves them and offers the commands and menus; addons declare which values exist.
Where they are saved
players.storage in config.yml (restart to apply):
| Storage | Saved in | Offline players |
|---|---|---|
machineengine:pdc | The player's own data file (world/playerdata). Default. | Cannot be edited. |
machineengine:files | plugins/MachineEngine/players/<ab>/<uuid>.dat, one file per player. | Admins can read and edit them. |
Addons may add other storages. Switching storage does not move existing data.
With machineengine:files, a damaged file is moved aside as .damaged-<time>
instead of being overwritten.
Saving and loading
- Changed data is saved every
players.save-intervalseconds (60), when the player leaves, and when the server stops. - With a storage other than
machineengine:pdc, a joining player waits up toplayers.load-timeoutseconds (5) for their data. When it takes longer, they are refused with a message rather than let in without it.
Settings
Players use /machinesettings (alias /msettings, permission
machineengine.settings, everyone by default):
| Command | Does |
|---|---|
/machinesettings | Opens the player_settings menu (with zMenu), or lists the settings. |
/machinesettings <setting> | Shows one setting. |
/machinesettings <setting> <value> | Changes it. |
/machinesettings <setting> reset | Puts it back to the default. |
Server owners control them in config.yml:
players:
setting-defaults:
'mekanized:radiation_hud': false # default for players who did not choose
locked-settings:
- mekanized:radiation_hud # players cannot change it; they keep the default
The settings menu
menus/player_settings.yml is written at every start with a button per
installed setting, so new settings appear by themselves. To keep your own
version, delete its first line: from then on it is yours and is not
rewritten.
In any zMenu menu:
%zmenu_machineengine_player_<namespace>_<id>%shows a value or setting of the viewer (a/in the id becomes_).- The button type
machineengine_player_setting(setting: <namespace>:<id>) changes a setting: left click forward, right click back.
Admins
/machineengine player <player> lists a player's values and settings; get,
set and reset <key> read and change one (permission machineengine.admin).
Offline players work only with players.storage: machineengine:files.
For addon developers
Values are declared as PlayerDataKeys and settings as PlayerSettings, and
read through MachineEngine.get().players() — see the
Developer API.