> For the complete documentation index, see [llms.txt](https://ajneb97.gitbook.io/conditionalevents/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ajneb97.gitbook.io/conditionalevents/global-variables.md).

# Variables

## Global Variables

These variables can be used in any event.

* **%player%** *(player name)*
* **%random\_min\_max%** *(will select a random number between "min" and "max". For example: %random\_1\_10% will choose a random number between 1 and 10)*&#x20;
* **%random\_last%** *(returns the latest generated random number using %random\_min\_max% variable)*
* **%playerarmor\_\<type>%** *(material of the armor the player is wearing. Replace \<type> with: helmet, chestplate, leggings or boots)*&#x20;
* **%playerarmor\_name\_\<type>%** *(name of the armor the player is wearing)*
* **%block\_at\_\<x>\_\<y>\_\<z>\_\<world>%** *(material of the block at certain location)*
* **%block\_data\_at\_\<x>\_\<y>\_\<z>\_\<world>%** *(it will return a numerical value on 1.8-1.12 and a text with several block properties on 1.13+. For example, a stairs block has a facing property, or a wheat block has an age property)*
* **%playerblock\_below\_\<distance>%** *(material of the block below the player with a certain distance. Example: %playerblock\_below\_1% will return the block just below the player)*
* **%playerblock\_above\_\<distance>%** *(material of the block above the player with a certain distance. Example: %playerblock\_above\_5% will return the block 5 blocks above the player)*
* **%playerblock\_inside%** *(material of the block the player is inside,* like water or some special blocks, like when standing on a head/sla&#x62;*)*
* **%player\_is\_outside%** *(will check if the player is outside or has no blocks above. It will return 'true' or 'false')*
* **%player\_attack\_cooldown%** *(returns the current cooldown for the player's hand)*
* **%random\_player%** *(selects a random player connected to the server. It will return 'none' if no player is found)*
* **%random\_player\_\<world>%** *(selects a random player from a specific world. It will return 'none' if no player is found)*
* **%randomword\_\<word1>-\<word2>-\<wordN>%** *(will select a random word of the provided list. Each word should be separated by a '-')*
* **%is\_nearby\_\<x>\_\<y>\_\<z>\_\<world>\_\<radius>%** *(will check if a player is nearby certain coordinates. It will return 'true' or 'false')*
* **%world\_time\_\<world>%** *(time of the world in ticks)*
* **%world\_is\_raining%** (*will check if it is raining in the world the player is in. It will return 'true' or 'false'*)
* **%is\_number\_\<variable>%** (*allows to check whether a certain variable is a number or not. It will return 'true' or 'false'. For example in a player\_command event: %is\_number\_{arg\_1}%*)
* **%empty%** *(special variable that will return an empty text. You can use this variable on conditions where other variables return an empty value as well)*
* **%player\_location\_\<coord>\_\<front\_value>\_\<side\_value>\_\<up\_value>%** (will obtain the \<coord> location value relative to the player's direction)
  * \<front\_value>: Possitive values mean front, negative values mean behind.
  * \<side\_value>: Possitive values mean right, negative values mean left.
  * \<up\_value>: Possitive values mean above, negative values mean below.
  * Example: These 3 variables will allow you to obtain the location just in front of the player.`%player_location_x_1_0_0%, %player_location_y_1_0_0%, %player_location_z_1_0_0%`
* **%format\_remove\_\<text>%** *(will remove mini message and legacy color codes from a text or variable. For example in a player\_command event: %format\_remove\_{args\_substring\_1-99}%)*

You can also use PlaceholderAPI variables for the conditions and actions of all events:\
<https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders>

## Item Variables

These variables can be used in multiple item-related events.

* **%item%** *(type of the item. All types on this link:* [*https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html*](https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html)*)*
* **%item\_durability%** *(datavalue of the item)*
* **%item\_amount%** *(amount of the item)*
* **%item\_name%** *(custom name of the item without color codes)*
* **%item\_color\_format\_name%** *(custom name of the item including color codes)*
* **%item\_lore%** *(description of the item)*
* **%item\_color\_format\_lore%** *(description of the item including color codes)*
* **%item\_lore\_line\_X%** *(the X line of the description of the item)*
* **%item\_color\_format\_lore\_line\_X%** *(the X line of the description of the item including color codes)*
* **%item\_custom\_model\_data%** *(the custom model data value of the item,* only works on 1.16-1.21.&#x33;*)*
* **%item\_model%** *(model of the item, only works on 1.21.4+)*
* **%item\_meta%** *(text that provides more extensive information of the item, for example, potion effects. Requires `item_meta_variable_enabled` option enabled in the config.yml file)*

Plugin related variables:

* **%item\_itemsadder\_id%** *(ItemsAdder id if it is an IA item. Requires ItemsAdder)*

For other events like [**Player Offhand**](/conditionalevents/event-types/player-events.md#player-offhand) or [**Player Click Inventory**](/conditionalevents/event-types/player-events.md#player-click-inventory) you can also get all the previous variables from the offhand or cursor as specified in the event. For example:

* **%offhand:item%**
* **%offhand:item\_lore%**
* **%cursor:item\_name%**

## Block Variables

These variables can be used in multiple block-related events.

* **%block%** *(type of the block. All types on this link:* [*https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html*](https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html)*)*
* **%block\_x%** *(x coordinate of the block)*
* **%block\_y%** *(y coordinate of the block)*
* **%block\_z%** *(z coordinate of the block)*
* **%block\_world%** *(world of the block)*
* **%block\_head\_texture%** *(texture id of a head block, it will return and empty text if not valid)*
* **%block\_data%** *(it will return a numerical value on 1.8-1.12 and a text with several block properties on 1.13+. For example, a stairs block has a facing property, or a wheat block has an age property)*&#x20;
* **%block\_below\_\<distance>%** (*type of the block below the original event block, with a certain distance. Example: %block\_below\_1% will return the block just below the original event block*)
* **%block\_above\_\<distance>%** (*type of the block above the original event block, with a certain distance. Example: %block\_above\_1% will return the block just above the original event block*)

## Entity Variables

These variables can be used in multiple entity-related events.

* **%entity%** *(type of the entity. All types on this link:* [*https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/EntityType.html*](https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/EntityType.html)*)*
* **%entity\_name%** *(name of the entity without color codes)*
* **%entity\_color\_format\_name%** *(name of the entity including color codes)*
* **%entity\_x%** *(x coordinate of the entity)*
* **%entity\_y%** *(y coordinate of the entity)*
* **%entity\_z%** *(z coordinate of the entity)*
* **%entity\_world%** *(world of the entity)*
* **%entity\_uuid%** *(uuid of the entity)*

## Victim Variables

These variables can be used in multiple victim-related events.

* **%victim%** *(type of the victim entity. All types on this link:* [*https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/EntityType.html*](https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/EntityType.html)*)*
* **%victim\_name%** *(name of the victim entity without color codes)*
* **%victim\_color\_format\_name%** *(name of the victim including color codes)*
* **%victim\_block\_x%** *(x coordinate of the victim entity)*
* **%victim\_block\_y%** *(y coordinate of the victim entity)*
* **%victim\_block\_z%** *(z coordinate of the victim entity)*
* **%victim\_block\_world%** *(world of the victim entity)*
* **%victim\_uuid%** *(uuid of the victim entity)*
* **%victim\_health%** *(health of the victim entity)*

## "Target" Variable

In somes cases like the [`player_attack`](/conditionalevents/event-types/player-events.md#player-attack) , [`player_kill`](/conditionalevents/event-types/player-events.md#player-kill) , [`entity_interact`](/conditionalevents/event-types/other-events.md#entity-interact) and [`player_fish`](/conditionalevents/event-types/player-events.md#player-fish) events you will want to obtain a variable from the target player instead. For this to work you just need to add **"target:"** before the real variable.&#x20;

* For example, if you want to obtain the target's player name, instead of using **%player%** you need to use **%target:player%.**
* If you need need to obtain the rank of the targeted player, instead of using **%vault\_rank%** use **%target:vault\_rank%**

Here is a full example:

```yaml
example:
    type: player_attack
    conditions:
    - '%victim% equals PLAYER'
    - '%item% equals DIAMOND_SWORD'
    - '%item_name% equals Poison Sword'
    actions:
      default:
      - 'message: &aApplying poison to: &e%target:player%'
      - 'to_target: give_potion_effect: POISON;120;1'
      - 'to_target: message: &cYou were poisoned by &e%player%&c!'
```

## "To" Variable

When using [**"To" Actions**](/conditionalevents/actions/to-actions.md), you can obtain variables directly from the selected player instead. For this to work you just need to add **"to:"** before the real variable.

* For example, if you want to obtain the selected player name, instead of using **%player%** (which is the original player who executed the event), you need to use **%to:player%**.

Here some examples:

```yaml
example:
  type: call
  actions:
    default:
    - "console_message: &7Sending a welcome message to all players"
    - "to_all: message: &eHello &c%to:player%, &ewelcome to the server!"

example2:
  type: player_command
  conditions:
  - "%main_command% == /hello"
  actions:
    default:
    - "cancel_event: true"
    - "to_range: 10;false: message: &6%player% says: &7Hello %to:player%!"
```

## Variables inside variables

On some specific cases you will need to obtain a result using multiple variables, placing a variable inside another. As an example, using the Math expansion from PlaceholderAPI you can create a formula using multiple ConditionalEvents variables.

For example, if you want to obtain the time of the world the player's in, you need to use the `%world_time_<world>%` variable (From ConditionalEvents) and inside \<world> the variable `%player_world%` (From PlaceholderAPI). This can be done using brackets "{ }":

* **%world\_time\_{player\_world}%**

Here is a full example:

```yaml
# Checks the time of the world you are in.
# Remember to download the Player expansion using
# /papi ecloud download Player
example:
    type: player_command
    conditions:
    - "%command% == /world-time"
    actions:
      default:
      - "cancel_event: true"
      - "message: Time in your current world: %world_time_{player_world}%"
```

Another example:

```yaml
# Gets the IP of another player by command.
# Remember to download the OtherPlayer expansion using
# /papi ecloud download OtherPlayer
example2:
    type: player_command
    conditions:
    - "%command% == /ip or %command% startsWith /ip "
    - "%player_has_permission_conditionalevents.admin% == no execute error1"
    - "%args_length% < 1 execute error2"
    actions:
      default:
      - "cancel_event: true"
      - "message: &7IP of &a%arg_1% &7is: %otherplayer_ip_{arg_1}%"
      error1:
      - "cancel_event: true"
      - "message: &cYou don't have permissions."
      error2:
      - "cancel_event: true"
      - "message: &cYou must use /ip <player>"
```

{% hint style="info" %}
You can add as many variables inside variables you need. For this to work enable **variable\_replacement** option in the config.

An example that returns the block beneath the player using the PlaceholderAPI Math/Player expansions:

```
%block_at_{player_x}_{math_0:0_{player_y}-1}_{player_z}_{player_world}%
```

{% endhint %}
