-
Notifications
You must be signed in to change notification settings - Fork 13
5. Advanced Template Management
Sometimes, one needs files in all server/proxy templates. TimoCloud has a feature for that: the Global Templates are 2 directories, one for server groups and one for proxy groups, that will be copied to every starting server/proxy, regardless of its group. For example, you might need your permission system in every server. Simply put your files into these directories in order to get them copied to every starting server/proxy:
core/templates/server/Global/
core/templates/proxy/Global/
This works for both, static and non-static servers/proxies. For non-static instances, the global templates will be copied to the temporary server/proxy directory before the group-specific template. That means, if a file exists in both, the global and group template, the one from the group template will overwrite the one from the global template. For static instances, only files that do not exist in the static server/proxy directory will be copied from the global template.
TimoCloud has the ability to start servers of the same group with different templates. This is useful if you want servers with different maps. In order to use this feature, you simply need to create additional template directories, called GROUPNAME_MAPNAME. For example, if you want to have different maps for your BedWars servers, you can create the following template folders in core/templates/server/:
BedWars
BedWars_Castle
BedWars_Garden
BedWars_Village
All files from the group's default template (BedWars in this example) will be copied to the temporary directory first. Then, if existing, a map directory will be chosen randomly (the maps will be balanced though, so that no second BedWars_Garden server will be started before any BedWars_Castle server has been started, for example) and also be copied to the temporary directory, overwriting the group template. Thus, if a file exists in both, the group and map template, the one from the map template will finally be in the temporary directory.
The map name can be displayed on the lobby signs using the placeholder %map%. There is also an API method to get a server's map: ServerObject#getMap().
The following illustration shows how the whole template system works. It consists of two parts. The upper part (over the line) shows the different template directories. The lower part (under the line) shows how the final temporary server directory will look like with the templates above.
There are 3 columns, each representing one file (a.txt, b.txt and c.txt). In the sample illustration, the Global template contains the files a.txt, b.txt and c.txt, all with the content "1". These three files will be copied to the temporary BedWars-1 directory first. Next, the files b.txt and c.txt with the content "2" will be copied from the BedWars template, overwriting the files that have been copied from the Global directory. Finally, the file c.txt with the content "3" will be copied to the temporary directory from the randomly chosen map directory BedWars_Village, overwriting the file that has been copied from the BedWars template in the previous step. Thus, the final version of the BedWars-1 temporary directory will contain the file a.txt with the content "1", b.txt with the content "2" and c.txt with the content "3".
If you have any questions, please read the FAQ, contact us via support@timo.cloud or join our Discord
