66 SubCreator
ME1312 edited this page 2021-11-06 11:38:05 -04:00

SubCreator is the program that creates SubServers for you. This page goes over how to use it.

Using SubCreator

SubCreator can create a subserver for you in 3-5 arguments:
/sub create <Name> <Host> <Template> [Version] [Port]
Name - Name of the new server
Host - Host to create it on
Template - Template to use
Version - Minecraft Version to create (may be optional)
Port - Port number to use (optional)

If your template can provide it,
SubCreator can update a subserver for you in 1-2 arguments:
/sub update <Subservers> [Version]
Subservers - Name of existing server(s)
Version - Minecraft Version to update to (may be optional)

SubCreator Templates

SubCreator Templates are pre-made server folders with some special properties. To create a template, all you need to do is create a new folder inside the Templates directory and drop whatever files you need inside. On the SubCreator side of things, below is documentation on an optional file you can use to customize the installation.

/template.yml

This is a YAML file on the root folder, used to modify SubCreator's default configuration. This is its full contents:

Template:
  Enabled: true
  Internal: false
  Display: 'Example'
  Icon: 'minecraft:redstone_torch'
  Build:
    Import:
    - OtherTemplate
    Replace:
    - '/myfile.yml'
    Replacements:
      'example': 'My Cool Variable!'
    Server-Type: 'CUSTOM'
    Use-Cache: true
    Install-Client: true
    Require-Version: false
    Can-Update: false
    Update-Files: false
    Update-Settings: false
    Executable: 'bash build.sh'
    Run-On-Finish: true
  Settings:
    Motd: 'Example Setting'
    Executable: 'java -jar myfile.jar'

Template [Object]: Settings container for this template. All of these values are optional unless otherwise specified. See Configuration for more info on the value types and modifiers used here.
    Enabled [Boolean]: Set whether this template is enabled
    Internal [Boolean]: Mark this template for internal use only (effectively making it Import only)
    Display [String]: Set the display name of this template
    Icon [Item]: Set the item icon of this template
    Build [Object]: SubCreator build options
        Import [Enum Value List]: Import and run other templates by name
        Replace [File Path List]: Select files to replace variables in (How?)
        Replacements [Object]: Define custom variables for this build
        Server-Type [Enum Value]: Set which ServerType this template will build
        Use-Cache [Boolean]: Creates and forwards a valid cache directory to the build script
        Install-Client [Boolean]: Toggles whether SubServers.Client will be installed
        Require-Version [Boolean]: Switches the [Version] field from optional to required
        Can-Update [Boolean]: Signals that this template can update servers created by it
        Update-Files [Boolean]: Replaces files that differ from the template files
        Update-Settings [Boolean]: Replaces settings in servers.yml that differ from the template's settings
        Executable [File Path/String]: A command to execute or the path to a script to execute.
        Run-On-Finish [Boolean]: Whether this subserver will be started after SubCreator finishes
    Settings [Object]: Sets the default options for the subserver. Any setting from the Servers section of the main configuration is valid here. Additionally, you can use variables for this object's strings using this format: $variable$.

Default Variables:
The following default variables are available for use in the Settings section, Executable build option, File replacements, and in your build script:
-> player: The UUID of the player who created this server (empty for CONSOLE)
-> name: The name of the new server
-> host: The name of the host that was selected
-> template: The name of the template being used
-> type: The ServerType the template will create
-> version: The minecraft version requested (may be empty)
-> address: The bind address of the host
-> port: The port number of the new server

Scripting Variables:
The following variables are also available for use in the Executable build option and your build script in addition to the system's own variables:
-> java: The full path of the current java executable
-> mode: The build mode requested (CREATE, UPDATE, or SWITCH)
-> sp_version: The sponge build parsed by SubCreator (FORGE and SPONGE servers only)
-> mcf_version: The forge build parsed by SubCreator (FORGE servers only)
-> cache: The caching directory (only when Use-Cache is true)
-> source: The template directory from which this server was copied

Using Variables in Other Files

As you may have seen in the previous section, it is possible for SubCreator to make replacements for variables in completely unrelated files included with your template. Here are some things to note:

  • Aside from /server.properties, you have to opt-in a file to make replacements in it
  • Variables in these files use this format: SubServers::variable

File Selection Format

That's great, you may be thinking to yourself, but how do you opt-in a file? Well, SubCreator uses the Replace build option and a format very similar to that of .gitignore files to accomplish this task.

!: Negate a previous inclusion statement
%: Select using a Regular Expression (Advanced)
/: Select a full file path, not just the end of one

Inclusion statement modifiers. Use these at the beginning of a statement to determine how its contents will be used when selecting files.

\: Used to escape a character with special meaning
[A-Z]: Used to select a single character in the specified range (RegEx style)
?: Used to select any single character, not including /
*: Used to select any number of characters, but not /
**: Used to select any number of characters, including /, at the start or end of a line

Special characters available for use in basic inclusion statements.

Examples:

/permissions.yml

Selects permissions.yml on the root folder only.

config.yml

Selects all files named config.yml

!/plugins/ProblemPlugin/config.yml

Deselects the specific config.yml that exists in /plugins/ProblemPlugin/