# ConditionalEvents Wiki

## Description

This plugin allows you to add different conditions to certain events. If these conditions are acomplished, then custom actions will be executed. The possibilities of what you can do with the plugin are endless. To understand the plugin in a simpler way here some examples:

{% tabs %}
{% tab title="Example 1" %}
If a player press a button (or any block) in certain coordinates, you can execute some actions for the player, like executing a command, sending him a message, applying some potion effects, and many other actions.

```yaml
example1:
    type: block_interact
    conditions:
    - '%block_x% == 20'
    - '%block_y% == 60'
    - '%block_z% == 20'
    - '%block_world% == lobby'
    - '%block% == STONE_BUTTON'
    - '%action_type% == RIGHT_CLICK'
    actions:
      default:
      - "message: &aYou''ve received $500!"
      - "console_command: eco give %player% 500"
      - "playsound: ENTITY_PLAYER_LEVELUP;10;2"
```

{% endtab %}

{% tab title="Example 2" %}
If a player damages another player with a certain item, there is a small chance of giving the victim a poison potion effect.

```yaml
example2:
    type: player_attack
    conditions:
    - '%victim% == PLAYER'
    - '%item% == DIAMOND_SWORD'
    - '%item_name% == VIP Sword'
    - '%random_1_10% >= 8'
    actions:
      default:
      - 'message: &aYour diamond sword poison effect was activated!'
      - 'to_target: give_potion_effect: POISON;120;1'
      - 'to_target: message: &cYou were poisoned by &e%player%&c!'
```

{% endtab %}

{% tab title="Example 3" %}
With ConditionalEvents you can block commands, kick the players who use them or play them a sound.

```yaml
example3:
    type: player_command
    conditions:
    - '%command% startsWith //calc or %command% startsWith //solve or %command% startsWith
      //eval'
    actions:
      default:
      - 'cancel_event: true'
      - 'kick: &cWhat are you trying to do?'
    ignore_with_permission: conditionalevents.ignore.example3
```

{% endtab %}

{% tab title="Example 4" %}
You can cancel events like breaking or placing blocks in certain worlds.

```yaml
example4:
    type: block_break
    conditions:
    - '%block_world% == spawn'
    actions:
      default:
      - "cancel_event: true"
      - "message: &cYou can''t break blocks on this world."
      - "playsound: BLOCK_NOTE_BLOCK_PLING;10;0.1"
    ignore_with_permission: conditionalevents.ignore.event4
```

{% endtab %}

{% tab title="Example 5" %}
You can teleport the player to different places after they die depending on which world they are.

```yaml
example5:
    type: player_respawn
    conditions:
    - '%player_world% equals pvp1 or %player_world% equals pvp2'
    actions:
      default:
      - "teleport: lobby;0;60;0;90;0"
      - "message: &cYou died. Teleporting you back to the PvP Lobby..."
```

{% endtab %}

{% tab title="Example 6" %}
You can constantly check if a player enters an area and execute some actions for him.

```yaml
example6:
    type: repetitive
    repetitive_time: 10
    conditions:
    - '%player_world% equals spawn'
    - '%worldguard_region_name% equals survival_entrance'
    actions:
      default:
      - "console_command: warp %player% Survival"
```

{% endtab %}

{% tab title="Example 7" %}
You can give money to the player who kills another player, depending on its rank.

```yaml
example7:
    type: player_kill
    conditions:
    - '%victim% == PLAYER'
    - '%target:vault_rank% == vip execute actions1'
    - '%target:vault_rank% == admin execute actions2'
    actions:
      default:
      - "message: &6You've killed &e%target:player%"
      - "message: &7You receive: &a$100"
      - "console_command: eco give %player% 100"
      actions1:
      - "message: &6You've killed &e%target:player%"
      - "message: &7Since it's a &bVIP &7player you get: &a$500"
      - "console_command: eco give %player% 500"
      actions2:
      - "message: &6You've killed &e%target:player%"
      - "message: &7Since it's an &4Admin &7player you get: &a$1000"
      - "console_command: eco give %player% 1000"
```

{% endtab %}

{% tab title="Example 8" %}
You can create a command to check another player level.

```yaml
example8:
    type: player_command
    conditions:
    - "%main_command% == /checklevel"
    - "%args_length% < 1 execute error1"
    - "%parseother_{arg_1}_{player_online}% == no execute error2"
    actions:
      default:
      - "cancel_event: true"
      - "message: &aLevel of &e%arg_1% &ais: &e%otherplayer_level_{arg_1}%"
      error1:
      - "cancel_event: true"
      - "message: &cYou must use &7/checklevel <player>"
      error2:
      - "cancel_event: true"
      - "message: &cThat player is not online."
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ajneb97.gitbook.io/conditionalevents/master.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
