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
conditions:
- '%item_name% !contains %player_name%'conditions:
- '%command% equals /test-kills'
- '%statistic_player_kills% >= %statistic_deaths%*2'
conditions:
- '%player_x% == (%player_z%*3)-1000'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:
example:
type: player_join
conditions:
- '%vault_rank% equals admin execute actions1'
- '%vault_rank% equals vip execute actions2'
actions:
default:
- 'to_all: message: &a%player% &ejoined the game.'
actions1:
- 'to_all: message: &4&lADMIN &c%player% &ejoined the game.'
actions2:
- 'to_all: message: &b&lVIP &a%player% &ejoined the game.'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:
example:
type: player_join
conditions:
- '%vault_rank% equals admin execute actions1'
- '%vault_rank% equals vip and %player_level% > 20 execute actions2'
actions:
default: []
actions1:
- 'to_all: message: &4&lADMIN &c%player% &ejoined the game.'
actions2:
- 'to_all: message: &b&lVIP &a%player% &ejoined the game.'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:
# 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_command
conditions:
- "%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:
vip_rank:
type: player_command
conditions:
- "%main_command% == /vip"
- "%player_has_permission_conditionalevents.admin% != yes execute error_action{%error_message%=&cYou don't have permissions}"
- "%args_length% < 1 execute error_action{%error_message%=&cYou must use &7/vip <player>}"
actions:
default:
- "cancel_event: true"
- "player_command: lp user %arg_1% parent set vip"
error_action:
- "cancel_event: true"
- "centered_message: &c&m &r &c&lERROR! &c&m "
- "centered_message: "
- "centered_message: %error_message%"
- "centered_message: "
- "centered_message: &c&m "
- "playsound: BLOCK_NOTE_BLOCK_PLING;10;0.1"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:
example1:
type: player_attack
conditions:
- '%victim% == PLAYER'
- '%item% == DIAMOND_SWORD'
- '%item_name% == Super Sword'
- '%random_1_10% >= 8'
actions:
default:
- 'message: &aYour diamond sword poison effect was activated!'
- 'to_target: give_potion_effect: POISON;120;1'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_interact
conditions:
- '%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_interact
conditions:
- '%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_command
allow_math_formulas_in_conditions: true
conditions:
- '%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".
example5:
type: player_chat
conditions:
- "%message% matches (.*)h+e+l+l+o+(.*)"
actions:
default:
- "message: &8[&7Server&8] &eHello %player%!"Last updated
Was this helpful?