Templates

From Citizens Wiki

Revision as of 18:17, 2 January 2025 by Fullwall (talk | contribs) (Example)

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 - the file name is just for helping you organise complicated templates. Let's call the first one 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.