Skip to content

Requirement

Soreth edited this page Aug 28, 2020 · 14 revisions

The most powerful permission system ever created, you can edit all requirement, basic plugin check for player permission, that's mean each time you try some action, plugin will read all your permission to check if you have required one.

Furthermore, in basic plugin you can't edit permission moreover, on the basic plugins you can not edit the permissions thus creating them unnecessarily. All permissions that all players have are useless and slow down the server. With this system you can make the actions allowed by all players lack of verification.

Finally, the requirements are not necessarily permissions and are compatible with logical expressions.

First step

If you don't need complex requirement or want use only permission, you only need to know this.

In your VPConfig.yml file you have REQUIREMENT_LIST, in this node you can create alias for requirement like this :

...
 #This is your alias
 ADMIN: # Your requirement here

Since we use easy requirement system for now this is more precise :

...
 ADMIN: "group.admin"

With this, every time you want allow admin to use something you just need to do right ADMIN as requirement, it gonna check if you have the group.admin permission, it's useful because if you want change permission for ADMIN you don't need to replace it everywhere.

But you could do simplest than this, you can write group.admin each time instead of ADMIN since ADMIN is an alias for group.admin

Note if you write this : ADMIN: minecraft.command.teleport ADMIN will be the alias of minecraft.command.teleport.

Simple requirement

Still here ?

Yeah I called this "Simple requirement" but they aren't easy for everyone.

First of all, what's simple requirement ?

Good question, the simple requirements are requirements you can’t configure except for the display and who’s always created. Like NICK, so you can always use NICK as alias to try if player is nicknamed or not. As example you can see :

MESSAGE_REQUIREMENT: VP_NICK

That mean if you need to be nicknamed for this action.

Type list

BLOCK ( Powered )

Will try if player is blocking.

FALL ( Powered )

Will try if player fall.

FALSE

Will invalid the requirement, useful if you want to forbid an action.

ONLINE

Will test if player is online.

PICKUP ( Powered )

Will try if player can pickup items ( plugin can edit it or game mode 3 ).

SLEEP ( Powered )

Will try if player is sleeping.

SNEAK ( Powered )

Will try if player sneak.

SPRINT ( Powered )

Will try if player sprint.

VP_NICK

Will try if player is nicknamed.


Custom requirements

You saw simple requirement as well as basic permission requirement but you can create a lot more requirement for your plugin. Note for smaller explanation, all IRequirement in this list have :

FORMAT_PATH is message component's path for the format. Default is FORMAT.REQUIREMENT. + type, example : for currency it's FORMAT.REQUIREMENT.CURRENCY.

PlaceHolder

%state% for the current state.

%state_color% for the current state’s color.

Type list

CURRENCY

This allow you require some money.

ALIAS_ID is the currency id.

KEEP if true just require some money, if false will take you money each time you perform action.

AMOUNT the amount of money required, if less than 0 KEEP is always true.

PlaceHolder

%current% show you current amount of this currency.

%current_name% show you current currency name. ( for singular or plural )

%required% show required amount.

%required_name% show you required currency name. ( for singular or plural )

Example
...
 TYPE: CURRENCY
 ALIAS_ID: coin
 KEEP: false
 AMOUNT: 10000
 #I put '1' because I don't use same format if we keep or not but fell free to use message component's path you want.
 FORMAT_PATH: FORMAT.REQUIREMENT.CURRENCY.1

ITEM ( Powered )

This allow you require some item.

MATERIAL is the item material required.

NAME_PATH is message component's path, allow you to translate name on format.

KEEP if true just require some item, if false will take you item each time you perform action.

META if true special item can be used ( like renamed, enchanted, ... ).

AMOUNT the amount of item required.

DAMAGES the item's damages, if -1 damages are ignored. ( For pre 1.13 it also work for item data )

PlaceHolder

%current% show you current amount of this item.

%required% show required amount.

%name% show item name translated.

Example
...
 TYPE: ITEM
 MATERIAL: wool
 NAME_PATH: MATERIAL.WOOL
 KEEP: false
 META: false
 AMOUNT: 64
 DATA: -1
 #I put '1' because I don't use same message if we keep or not but fell free to use message component's path you want.
 FORMAT_PATH: FORMAT.REQUIREMENT.ITEM.1

ITEM_EXTRA ( Powered )

This allow you require some item.

EXTRA is the EXTRA_TYPE required in item nbt.

NAME_PATH is message component's path, allow you to translate name on format.

KEEP if true just require some item, if false will take you item each time you perform action.

AMOUNT the amount of item required.

PlaceHolder

%current% show you current amount of this item.

%required% show required amount.

%name% show item name translated.

Example
...
 TYPE: ITEM_EXTRA
 EXTRA: "olddiamond"
 NAME_PATH: MATERIAL.olddiamond
 KEEP: false
 AMOUNT: 8
 #I put '1' because I don't use same message if we keep or not but fell free to use message component's path you want.
 FORMAT_PATH: FORMAT.REQUIREMENT.ITEM_EXTRA.1

LANG

This allow you require a specific server language.

LANG is the language code required.

PlaceHolder

%lang% name of language in his own language ( français, english, ... ) .

Example
...
 TYPE: LANG
 LANG: fr_FR
 FORMAT_PATH: FORMAT.REQUIREMENT.LANG

LEVEL ( Powered )

This'll check if your current title is same as required.

AMOUNT is the amount of level required.

KEEP if true just require some level, if false will take you level each time you perform action.

PlaceHolder

%current% show you current amount of this stat.

%required% show required amount.

Example
...
 TYPE: LEVEL
 KEEP: true
 AMOUNT: 255
 FORMAT_PATH: FORMAT.REQUIREMENT.LEVEL.1

RANDOM ( Powered )

This allow add some random on your requirement.

RANDOM is the max value of this random.

AMOUNT is the minimum value required. You have AMOUNT/RANDOM chance to have this requirement.

PlaceHolder

%min% represent AMOUNT field.

%max% represent RANDOM field.

%percent% represent percent of success.

Example
...
 TYPE: RANDOM
 RANDOM: 200
 AMOUNT: 99
 FORMAT_PATH: FORMAT.REQUIREMENT.RANDOM

SESSION_STAT ( Powered )

This'll check if your session stat is enough. The session stat is your state since your load, can change if you edit KEEP_IN_MEMORY in config.yml.

ALIAS_ID is the stat's id.

AMOUNT is the minimum value required.

KEEP if true just require the stat, if false will take you stat each time you perform action.

PlaceHolder

%name% will be replaced by the stat's name.

%current% show you current amount of this session stat.

%required% show required amount.

Example
...
 TYPE: SESSION_STAT
 ALIAS_ID: death
 AMOUNT: 12354 # Why not ?
 KEEP: true
 FORMAT_PATH: FORMAT.REQUIREMENT.SESSION_STAT.1

SLOT ( Powered )

This'll check if you have enough free slot in your inventory.

AMOUNT is the minimum amount required.

PlaceHolder

%current% show you current amount of free slot.

%required% show required amount.

Example
...
 TYPE: SLOT
 AMOUNT: 2
 FORMAT_PATH: FORMAT.REQUIREMENT.SLOT

STAT

This'll check if your stat is enough.

ALIAS_ID is the stat's id.

AMOUNT is the minimum value required.

KEEP if true just require the stat, if false will take you stat each time you perform action.

RESET if KEEP is true this one can't otherwise if this one is true will reset the stat each time you perform action.

PlaceHolder

%name% will be replaced by NAME_PATH's value.

%current% show you current amount of this stat.

%required% show required amount.

Example
...
 TYPE: STAT
 ALIAS_ID: death
 AMOUNT: 12354 # Why not ?
 KEEP: false
 RESET: true
 FORMAT_PATH: FORMAT.REQUIREMENT.STAT.1

TITLE

This'll check if you have a specific title.

ALIAS_ID is the title's id.

KEEP if true just require the title, if false will take you title each time you perform action.

PlaceHolder

%name% will be replaced by title's name.

Example
...
 TYPE: TITLE
 ALIAS_ID: 1
 KEEP: true
 FORMAT_PATH: FORMAT.REQUIREMENT.TITLE.1

TITLE_AMOUNT ( Powered )

This'll check if you have enough title.

LEVEL is the title level required, see titles for more information. If set to 0 count all title.

AMOUNT is the amount of title required.

PlaceHolder

%current% show you current amount of this stat.

%required% show required amount.

Example
...
 TYPE: TITLE_AMOUNT
 LEVEL: 4
 AMOUNT: 2
 FORMAT_PATH: FORMAT.REQUIREMENT.TITLE_AMOUNT

TITLE_CURRENT ( Powered )

This'll check if your current title is same as required.

ALIAS_ID is the title's id.

KEEP if true just require the title, if false will take you title each time you perform action.

PlaceHolder

%name% will be replaced by title's name.

Example
...
 TYPE: TITLE_CURRENT
 ID: 1
 KEEP: true
 FORMAT_PATH: FORMAT.REQUIREMENT.TITLE_CURRENT.1
 

Little further

Still here ? Nice, if you want you can use logical expression for requirement.

If you have this:

REQUIREMENT_LIST:
 ADMIN: "group.admin"
 FONDA: "group.fonda"
 MODO: "group.modo"
 PREMIUM: "group.premium"
 DEV: "group.dev"

And you want add a requirement to check if player is in staff group, you can add a staff permission to each group or create a STAFF alias like this :

...
 STAFF: ADMIN || FONDA || MODO || DEV

What I recommend is if you have lot of group to test or lot of permission in each group, it's better to add the staff permission in each group, but if you improved you permission with this plugin you can do like this.

Complex requirement

Now you know all the basics, you can create complex requirement. To do this you need create node of IRequirement, you also can use simple requirement.

You can add a RULE node to apply some logical expression with nodes as key or alias of already created Requirement, if not set will require all IRequirement in this requirement.

Example :

REQUIREMENT_LIST:
 PREMIUM: "group.premium"
 WHITELIST:
  whl:
   TYPE: CURRENCY
   ID: 2
   KEEP: false
   AMOUNT: 1
   FORMAT_PATH: FORMAT.REQUIREMENT.CURRENCY.1
  coin:
   TYPE: CURRENCY
   ID: 1
   KEEP: false
   AMOUNT: 2000
   FORMAT_PATH: FORMAT.REQUIREMENT.CURRENCY.1
  ADMIN: "group.premium"
  RULE: ADMIN || ( whl && ( PREMIUM || coin ) )

Note, if your ADMIN, since it is the first requirement and it may be the only, you'll not lose currency. Otherwise if you're PREMIUM you'll not pay for coin but still pay for white-list.

Clone this wiki locally