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.
For example, in this case a Player Attack event has 3 conditions. The victim must be another player AND the item used must be a Diamond Sword AND the name of this item should be "Super Sword":
You can also use 'and' separator in the same line, to accomplish the same as above.
conditions:- '%victim% == PLAYER and %item% == DIAMOND_SWORD and %item_name% == Super Sword'
You can also check for 'or' condition separator, meaning that a condition line will be approved if one of many conditions in the same line is accomplished. For example, in this Player Command event there is just one condition. The command should start with //calc OR start with //solve OR start with //eval:
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
You can also compare two variables in one condition line.
Finally, you can even compare variables with math formulas. If you want to do so, remember to set the following option on the event:
allow_math_formulas_in_conditions: true
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:
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:
# This event will check when a player uses the /vip <player> command # and set the specified player to the vip rank. # An error will show when the player doesn't have permissions. Another# error will show when the player doesn't use arguments.vip_rank:type:player_commandconditions: - "%main_command% == /vip" - "%player_has_permission_conditionalevents.admin% != yes execute error_action1" - "%args_length% < 1 execute error_action2"actions:default: - "cancel_event: true" - "player_command: lp user %arg_1% parent set vip"error_action1: - "cancel_event: true" - "centered_message: &c&m &r &c&lERROR! &c&m " - "centered_message: " - "centered_message: &cYou don't have permissions" - "centered_message: " - "centered_message: &c&m " - "playsound: BLOCK_NOTE_BLOCK_PLING;10;0.1"error_action2: - "cancel_event: true" - "centered_message: &c&m &r &c&lERROR! &c&m " - "centered_message: " - "centered_message: &cYou must use &7/vip <player>" - "centered_message: " - "centered_message: &c&m " - "playsound: BLOCK_NOTE_BLOCK_PLING;10;0.1"
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:
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:
example2:type:block_interactconditions: - '%block_x% == 40' - '%block_y% == 60' - '%block_z% == 40' - '%block_world% equals lobby' - '%block% equals STONE_BUTTON' - '%action_type% equals RIGHT_CLICK' - '%statistic_jump% < 1000 execute actions2'actions:default: - "message: &aYou''ve received $5000!" - 'console_command: eco give %player% 5000'actions2: - 'message: &cYou need at least 1000 jumps to use this button.'
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:
example3:type:item_interactconditions: - '%item_name% startsWith Axe of' - '%item_name% !contains %player_name%'actions:default: - "message: &cThis is not your axe so you can''t use it." - 'cancel_event: true'
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:
example4:type:player_commandallow_math_formulas_in_conditions:trueconditions: - '%command% equals /test-kills' - '%statistic_player_kills% >= %statistic_deaths%*2 execute actions1'actions:actions1: - 'message: &aYou have a lot of kills, congrats!' - 'cancel_event: true'default: - 'message: &cYou need to have AT LEAST 2 times more kills than deaths' - 'message: &cto use this command. Currently these are your stats:' - 'message: &7Kills: &6%statistic_player_kills%' - 'message: &7Deaths: &6%statistic_deaths%' - 'cancel_event: true'
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".