Skip to content
Crypto Morin edited this page Jul 6, 2023 · 43 revisions

Not Frequently Asked Questions

But we're here to answer them anyways.

Table of Contents


Making custom misc upgrades

We're going to be making a custom misc upgrade that adds permission for players. Thankfully LuckPerms Contextual Permissions make this easier.

  1. 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
  1. 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.

  2. We need to install ExtraContexts official LuckPerms addon to work with PlaceholderAPI oriented contexts.

  3. 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 _.

  1. 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.

  1. 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.

  1. 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.

  1. Add it to the GUI so players can actually upgrade it. Just adding it to the misc-upgrade.yml is 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"
   lore: |
     &7Gives you cool permissions
   posx: x
   posy: y
 ...

Basics

Advanced

Others

Clone this wiki locally