ME1312 / SubServers-2

SubServers – The Minecraft Server Management Platform
Apache License 2.0
91 stars 23 forks source link

How to use variables in other files? #78

Closed ajh123 closed 2 years ago

ajh123 commented 2 years ago

Currently I want to replace a plugin's config variable that is loaded from a master template, like this.

\Templates
├───A
│       template.yml
│
├───B
│       template.yml
│
└───Master
    │   template.yml
    │
    └───plugins
        └───LuckPerms
                config.yml

In A and B's template I have

Template:
...
  Build:
...
    Import:
    - Master
    Replace:
    - '/plugins/LuckPerms/config.yml' # This comes from the 'Master' template
    Replacements:
      'luckperms_server': 'bedwars' # the value will be different on both A and B

In the LuckPerm's config.yml I have tried

server: $luckperms_server$
server: luckperms_server

Also I have tried to change the A and B's replacements to

    Replacements:
      'server': 'bedwars'

but it still seems like the server value is not being updated when I run /sub update aServer A and yes, the A template

Template:
  Enabled: true
...
  Build:
...
    Can-Update: true
    Update-Files: true
    Update-Settings: true

Also I tried to delete the generated SubServer's LuckPerm config but the same problem persists.

ME1312 commented 2 years ago

Variable names prefixed with SubServers:: are searched for within the specified files. See if this correction fixes the problem.

Also, for this type of use-case, you might want to consider using the dynamic variable SubServers::name instead of constant server names.

ajh123 commented 2 years ago

That worked! The SubServers::name wouldn't work well for me because I may have multiple A severs under different names. Maybe have a SubServers::template which would match the name of the template?

ME1312 commented 2 years ago

That one also exists, actually.