Variables and Bootstrapping
In server.toml
, you can define variables like so:
When you build your server, any config file with common extensions (yml
, json
, toml
, txt
etc.) will be bootstrapped - their contents will be replaced with variables using the variable syntax.
Bootstrapping is essentially copying the file and doing a complex find-and-replace.
The syntax for variables are ${name}
where name
is the name of the variable. A colon can be used to set a default value: ${MOTD:Hi, im a Minecraft Server!}
Using environment variables
If your variables are sensitive (such as discord bot tokens) you can use environment variables:
Environment variables can be accessed just like other variables.
Examples
Environment variable: TOKEN=asdf
server.toml
name = "funnies"
[variables]
PORT = "25500"
MOTD = "welcome to funnies"
WEBSITE = "https://example.com/"
Prefix = "[funnies]"
server.properties
plugins/someplugin/config.yml
Network Variables
See Networks/Variables for more info.
Special Variables
There are some special variables:
SERVER_NAME
:name
property fromserver.toml
SERVER_VERSION
:mc_version
property fromserver.toml
SERVER_PORT
andSERVER_IP
: See Networks/VariablesPLUGIN_COUNT
/MOD_COUNT
: the number of plugins or modsWORLD_COUNT
: the number of defined worldsCLIENTSIDE_MOD_COUNT
: the number of client-side mods
There are also some special variables for networks which can be found here
When exporting to mrpack or packwiz, these variables from server.toml
are used:
Variable Name | mrpack - modrinth.index.json |
packwiz - pack.toml |
---|---|---|
MODPACK_NAME |
name |
name |
MODPACK_SUMMARY |
summary |
description |
MODPACK_AUTHORS |
nothing | author |
MODPACK_VERSION |
nothing | version |
:3