Templates: Difference between revisions
Created page with "Templates are a simple way to share NPC configuration across NPCs and servers. == Layout == Templates are stored in the plugins/Citizens/templates folder. Each template consists of a '''namespace''' or a folder to group related templates together and a bunch of template files. == Example == Let's build a quick example. Make a folder called plugins/Citizens/templates/awesometemplates. Inside this, create a .yml file. This can have any file name, and the file name i..." |
|||
Line 15: | Line 15: | ||
Inside info.yml, put the following template: | Inside info.yml, put the following template: | ||
{{codebox|height=500px|width=98%||<pre lang="yaml"> | |||
towninfo: | towninfo: | ||
commands: | commands: | ||
on_spawn: | on_spawn: | ||
- say Hello! | - say Hello! | ||
</pre> | |||
}} | |||
Now, we can create an NPC with our desired template using /npc create Helpful Guard --templates awesometemplates:towninfo. | Now, we can create an NPC with our desired template using /npc create Helpful Guard --templates awesometemplates:towninfo. |
Revision as of 18:15, 2 January 2025
Templates are a simple way to share NPC configuration across NPCs and servers.
Layout
Templates are stored in the plugins/Citizens/templates folder.
Each template consists of a namespace or a folder to group related templates together and a bunch of template files.
Example
Let's build a quick example.
Make a folder called plugins/Citizens/templates/awesometemplates.
Inside this, create a .yml file. This can have any file name, and the file name is just for your grouping purposes. The first one is info.yml.
Inside info.yml, put the following template:
Code: |
towninfo:
commands:
on_spawn:
- say Hello!
|
Now, we can create an NPC with our desired template using /npc create Helpful Guard --templates awesometemplates:towninfo.
Other commands
You can generate a copy of another NPC's save data directly using for example /template generate awesometemplates:towninfocopy. This will save it into a file called towninfocopy.yml.
You can apply a template to an existing NPC by using /template apply awesometemplates:towninfo.