-
Notifications
You must be signed in to change notification settings - Fork 63
NFAQ
But we're here to answer them anyways.
We're going to be making a custom misc upgrade that adds permission for players. Thankfully LuckPerms Contextual Permissions make this easier.
- In misc-upgrades.yml we're going to add a new entry.
custom-misc-upgrade: # The name here will be important later for permissions and GUIs
enabled: true
can-be-disabled: true
max-level: 3-
Make a new permission group using /lp creategroup kingdoms. This is where all kingdom related permissions will be defined. It's mostly for organization purposes.
-
We need to install ExtraContexts official LuckPerms addon to work with PlaceholderAPI oriented contexts.
-
Enable placeholder API support in ExtraContexts config.yml and add the a new placeholder for the misc upgrade:
placeholderapi: false
placeholderapi-placeholders:
allowflight: "%player_allow_flight%"
customMiscUpgrade: "%kingdoms_kingdom_upgrade:level type=misc, of=CUSTOM_MISC_UPGRADE%"Here we used a complicated functional placeholder. The of option is determined by the config entry name. We used custom-misc-upgrade. A rule of thumb is that whatever name you used, make all the characters uppercase and replace - with _.
- Add contextual permissions:
/lp group kingdoms permission set kingdoms.misc.custom.1 true customMiscUpgrade=1/lp group kingdoms permission set kingdoms.misc.custom.2 true customMiscUpgrade=2/lp group kingdoms permission set kingdoms.misc.custom.3 true customMiscUpgrade=3
Here we chose kingdoms.misc.custom.x, but really, it could be any permission! customMiscUpgrade is the context which relies on a single integer.
We only added 3 of them, because the max level is 3. If you want more levels, go back to step 1 and change the max-level option.
- Make the default group inherit our newly created group:
/lp group default parent add kingdoms
This will allow all permissions to automatically use this group no matter what. Now, you might be asking, doesn't this give them the permissions right away whether they have the upgrade or not, or even in a kingdom at all? No, it doesn't because we used contextual permissions which is basically a way of saying "you only have this permission if a certain condition is met" and those conditions being our contexts.
If your higher groups (donators ranks, mod, admin, etc) don't inherit the default group for some reasons, you also have to add them to these groups too.
- Finally we can verify that it works:
/lp user <player> permission check kingdoms.misc.custom.1
We can also check what's the current context of the player using /lp user <player> info
Note that contextual permissions are not that perfect. If you for whatever reason needed to check these permission for a player that's offline, it won't work correctly due to performance issues from LuckPerms side.
- Add it to the GUI so players can actually upgrade it.
Just adding it to the
misc-upgrade.ymlis not enough, we need to manually open a slot for it inside misc-upgrades.yml GUI
The GUI's layout is designed to look nice with the default amount of upgrades. So if you want to add it, you should reposition all options.
optionis:
...
custom-misc-upgrade: # We just reused the same name as it is
name: "&2My Custom Misc Upgrade"
material: DIAMOND_BLOCK
lore: |
&7Gives you cool permissions
posx: x
posy: y
...9. Bonus Step: Upgrade Trees & Commands
You can make another upgrade to be only enabled if a certain condition is met, this works for all upgrades as well. Let's say we only want someone to upgrade this permission if they upgraded max members to the maximum level and they have at least 10 members.
custom-misc-upgrade:
enabled: true
can-be-disabled: true
max-level: 3
condition:
"{kingdoms_kingdom_upgrade:level type=misc, of=MAX_MEMBERS} < 10": "miscupgrades.required.max-members"
"kingdoms_members < 10": "miscupgrades.required.members"Here the keys are conditions and the values are paths to the entry to the error message to send to that player and prevent them from upgrading it if that condition is met. These entries are not defined by default and it can be any entry. You have to add them to your language files like en.yml
Terminology - Spigot - Discord - History - Other Info
- ๐ Home
- ๐ฐ Features
- ๐ฅ Installation
- ๐ Setup
- ๐ Compatibility
- โ FAQ
โ๏ธ NFAQ- โ๏ธ Addons
- ๐ฉ Outposts
- โฎ๏ธ Peace Treaties
- ๐บ๏ธ Map Viewers
- ๐ฌ EngineHub
- ๐ Admin Tools
- โ๏ธ Introduction
- โจ๏ธ Commands
- ๐ Permissions
- ๐ฃ Placeholders
- ๐ Config
- ๐ Protection Signs
- โ๏ธ Mails
- ๐ Mechanics
- ๐งฐ Troubleshooting
- ๐ป API
๐น Basics
๐น Turrets & Structures
๐น Metadata
๐น Events
๐น Examples
๐น Addons