Conditions
Basic functionalities
This option will add some conditions for this event. If the conditions are accomplished, then the default actions will be executed.
Every line of the conditions list refers to a condition that MUST be true. You can use all kind of variables, even PlaceholderAPI or ConditionalEvents variables. Use the variables previously show in the Event Types page or the ones in the Variables page.
conditions:
- '%victim% == PLAYER'
- '%item% == DIAMOND_SWORD'
- '%item_name% == Super Sword'conditions:
- '%victim% == PLAYER and %item% == DIAMOND_SWORD and %item_name% == Super Sword'conditions:
- '%command% startsWith //calc or %command% startsWith //solve or %command% startsWith //eval'You can only use a condition separator of one type in the same line. Meaning you can't mix ORs and ANDs in one condition line.
Advanced functionalities
Type of Conditionals
For Text
equals, ==
!equals, !=
equalsIgnoreCase
!equalsIgnoreCase
startsWith
!startsWith
contains
!contains
endsWith
!endsWith
matches (For regex)
!matches (For regex)
For Numbers
equals, ==
!equals, !=
>=
<=
>
<
Execute Option
Sometimes you will want to execute different actions depending on which conditions the player accomplishes or not. For example:
This event will check when a player joins the server. If the rank of the player is admin, then the actions from "actions1" will execute. The same will happen if the rank of the player is vip, this case "actions2" will execute. Finally, if no "execute" conditions are met, the default actions will be executed.
If an "execute" condition is not accomplished it will continue to the next condition. If no more conditions are defined below an "execute" condition, the default actions will be executed. You can create as many sets of actions you want.
AND Conditions on Execute Option
The 'and' condition is very useful in some cases when using the execute option. For example, let's think you want to do something similar as above, sending a message to the whole server when a player with certain rank joins the server. But this time, the player must also have a certain level:
Parameters
On execute conditions you can add optional parameters that allows you to reduce the amount of action groups in some cases and reuse the same action group with different parameters.
For example, imagine we have the following event:
As you can see, error_action1 and error_action2 action groups are very similar, the only difference is the error message. We can simplify this event by using just one error_action action group by using parameters.
Parameters are specified after the action group name on the execute option, using brackets { }.
The idea is to create parameters as temporal variables that can be used in the action group. You can create multiple parameters by using ;. If we use parameters in the previous example, the result is this:
We use the %error_message% variable and assign a value in both conditions. Then, in the error_action we can use this variable wherever we want.
Examples
Here is a full config example of a player attack event:
In this case, the plugin will check when a player attacks another player with a diamond sword called "Super Sword". A random number will be generated. If this number equals 8 or is greater than 8, then a message will be sended to the player and the target player will be affected by a poison effect.
Here is another example of the "execute" option:
In this case, the player must press a button in certain coordinates. But the last condition says that if he doesn't has more than 1000 jumps then the actions from "actions2" will be executed instead of the default actions.
Here is an example of a conditional comparing two variables:
Imagine there is an item in your server called "Axe of <player>". Every player has an axe with their name on it. In this case, the plugin will check if the playing is interacting with an item that starts with the name "Axe of". Then, if the item name DOESN'T contains the player name, it will cancel the event and tell the player that the item is not theirs.
Here is an example of a condition including a math formula:
In this example we are creating the following command: /test-kills. When the player executes the command, the plugin will check if the player has at least 2 more kills than deaths. A player with 40 kills and 20 deaths would be able to use the command, since 40 >= 20*2
Here is an example of the "matches" conditional, checking if the player wrote a word similar to "Hello".
Last updated
Was this helpful?