Community GuidesEgg Creation

Egg Variables

Let users and administrators change a server's settings without editing its startup command.

Introduction

Variables are per-server settings, such as the game version or the maximum number of players. Each becomes an environment variable in the server's container, usable in the startup command, install script, and configuration files.

Manage them on the egg's Variables tab. The Panel also sets some variables for every server; see Built-In Variables.

Creating a Variable

Click Create Variable and fill in:

  • Name: A friendly name users see, such as Max Players.
  • Description: Tells users what the variable does.
  • Environment Variable: The name inside the container, such as MAX_PLAYERS. Letters, numbers, and underscores only. Wings passes the name in uppercase, so use uppercase names to avoid confusion.
  • Default Value: The value new servers start with.
  • Users Can View: Whether users see the variable on their server's Startup page.
  • Users Can Edit: Whether users may change the value.
  • Input Rules: Laravel validation rules that every value must pass.

Click Create Variable to save it.

Hiding a variable from users does not make it secret. Its value is still in the server's environment, where the server's processes can read it. Do not use variables for secrets users must not see.

Using a Variable

Refer to a variable by its environment variable name. The syntax depends on where you use it:

WhereHowExample
Startup command{{NAME}}--max-players {{MAX_PLAYERS}}
Install script$NAME or ${NAME}echo "players=${MAX_PLAYERS}"
Configuration files{{env.NAME}}"max-players": "{{env.MAX_PLAYERS}}"

Users see the startup command with values filled in for {{SERVER_MEMORY}}, {{SERVER_IP}}, {{SERVER_PORT}}, and the egg's own variables, and [hidden] for variables they cannot view. Placeholders are case-sensitive; any other placeholder stays as written.

Input Rules

Separate rules with |. The most common:

RuleMeaning
requiredA value must be given.
nullableThe value may be empty.
stringThe value is text.
numericThe value is a number.
integerThe value is a whole number.
booleanThe value is 1 or 0. Values arrive as text, so true fails.
between:1,64A number from 1 to 64, or text of 1 to 64 characters.
max:20A number up to 20, or text of up to 20 characters.
in:survival,creativeOne of the listed values.
regex:/^[\w.-]+\.jar$/Matches a regular expression.

For example, required|string|max:20 requires text of at most 20 characters. New variables start with these rules.

Details that decide whether a value passes:

  • between, max, and min compare the number only when the rules also include integer or numeric. Otherwise they count characters, so required|max:128 accepts 500.
  • Values are trimmed at both ends, and an empty value reaches the rules as null. Without nullable, rules such as string fail on it.
  • Rules are split at every |, so a | inside a regular expression cuts it in two. Leave | out of patterns.

The rules also set how the variable appears on the Startup page:

  • boolean, in:0,1, or in:true,false shows a switch. If its rules also include string, the switch saves true or false; otherwise it saves 1 or 0. The boolean rule rejects true and false, so pair string with in:true,false instead.
  • Any other in: rule shows a list of the allowed values.
  • Everything else shows a text field.

Startup command playground

Startup command

Memory (MiB)

Allocation IP

Allocation port

Try:

On the Startup page

What users see as the startup command
java -Xms128M -Xmx4096M -jar paper.jar
built invariablehidden or emptyrejected or not filled in

Variables

Name

Environment variable

Default value

Value a user saves

Input rules

savesrequiredregex:/^([\w\d._-]+)(\.jar)$/

Name

Environment variable

Default value

Value a user saves

Input rules

savesnullablestringmax:20

Name

Environment variable

Default value

Value a user saves

Input rules

savesrequiredstringmax:20
In the container: 11 environment variables

Wings does not fill in the placeholders. It passes the command as written in STARTUP, next to these variables, and leaves running it to the image's entrypoint. Hidden variables are here too.

NameValueSet by
TZUTCWings
STARTUPjava -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}

The command as written, placeholders included.

Wings
SERVER_MEMORY4096Wings
SERVER_IP192.168.1.10Wings
SERVER_PORT25565Wings
SERVER_JARFILEpaper.jarEgg variable
MINECRAFT_VERSIONlatestEgg variable
BUILD_NUMBERlatestEgg variable
P_SERVER_LOCATIONus1Panel
P_SERVER_UUID6d1f7929-5c2e-4cd4-99af-924dacb15537Panel
P_SERVER_ALLOCATION_LIMIT1.000000Panel

Reserved Names

These environment variable names are reserved in any letter case:

SERVER_MEMORY, SERVER_IP, SERVER_PORT, ENV, HOME, USER, STARTUP, SERVER_UUID, and UUID.

Built-In Variables

Every server's container gets these variables, whatever its egg:

VariableValueExample
STARTUPThe startup command, with variables not yet filled in.java -jar {{SERVER_JARFILE}}
SERVER_MEMORYThe server's memory limit, in MiB.1024
SERVER_IPThe primary allocation's IP address. Wings replaces 127.0.0.1 with the Docker network interface.192.168.1.10
SERVER_PORTThe primary allocation's port.25565
TZThe node's time zone. Wings detects it, or you can set system.timezone in Wings' configuration.Europe/London
P_SERVER_UUIDThe server's UUID.6d1f7929-5c2e-4cd4-99af-924dacb15537
P_SERVER_LOCATIONThe node location's short code.us1
P_SERVER_ALLOCATION_LIMITHow many allocations the server may have. Written with decimals, and empty when there is no limit.1.000000

Wings sets TZ, STARTUP, SERVER_MEMORY, SERVER_IP, and SERVER_PORT first and skips an egg variable with any of those names.

The official Docker images also set USER=container and HOME=/home/container.

Changing a Server's Variables

Users change the variables they may edit on their server's Startup page. Administrators can change all of a server's variables on its Startup tab in the admin area. New values apply on the next start.

Edit on GitHub

Last updated on

On this page