> 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/how-to-start.md).

# How to Start

Information of the plugin to work correctly on your server.

## Requirements

#### 1) Spigot

{% hint style="warning" %}
You need Spigot or Paper for the plugin to work. Don't use Craftbukkit.
{% endhint %}

#### 2) PlaceholderAPI

{% hint style="info" %}
This dependency is optional but extremely recommended.\
If you need to verify for some specific conditions you will need to install PlaceholderAPI on your server to get a lot of variables.\
<https://www.spigotmc.org/resources/placeholderapi.6245/>
{% endhint %}

{% hint style="warning" %}
Remember to follow the instructions for downloading variables. If you need to use variables from the **Player** expansion you need to use the following commands to get them to work:&#x20;

* `/papi ecloud download Player`
* `/papi reload`
  {% endhint %}

## Installation

To install the plugin on your server just place the ConditionalEvents file inside your plugins folder and start your server. Examples will be generated in the config.yml file, you can use them as a reference or delete them.

### Config.yml file

This is the main file where you can add new events. To create a new event just add a new configuration section in the config in the "Events" path.&#x20;

### Events folder

You can also create more files inside the **events** folder, where you can add new events. This is a good practice to keep everything more organized. These events should also be created under the "Events" path.

You can even create **subfolders** inside this **events** folder and place event files inside them.

{% hint style="warning" %}
Remember to use a different name for each of the events!
{% endhint %}

## Your first Event

Let's create our first event. What we want to do is to prevent the player from breaking blocks on the world called "spawn".&#x20;

First we must think of the event itself. What do we want to block? What is the player doing? Breaking a block. So, for this event, we can use a [**block\_break**](/conditionalevents/event-types/block-events.md#block-break) event type, that detects everytime a player tries to break a block. Under the "Events" path we can create multiple events, for this one, I will give it the name `event1` and the type will be `block_break` as defined before. You can find all possible events to detect [**HERE**](/conditionalevents/event-types.md).

```yaml
Events:
  event1:
    type: block_break
```

Next, we must think if the event needs to check for conditions. In our case, we want to prevent breaking blocks on a world called "spawn", so our first condition must be to detect the current player's world. For that we can use the [**Player**](https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders#player) expansion from [**PlaceholderAPI**](https://www.spigotmc.org/resources/placeholderapi.6245/) plugin. That expansion provides the `%player_world%` variable, which returns the current world of the player. It is vital that you use the following command to have access to the variable: `/papi ecloud download Player`

Since we have the variable, now we must create a condition following this format: \
`<value> <conditional> <value>`\
The idea is to check if `%player_world%` is equals to `spawn`. The first value will be `%player_world%`, the conditional must be `==`, and the second value, `world`. All conditionals can be found [**HERE**](/conditionalevents/conditions.md#type-of-conditionals).

```yaml
Events:
  event1:
    type: block_break
    conditions:
    - "%player_world% == spawn"
```

Finally, we can add actions to execute when the player tries to break a block on a world called `spawn`. ConditionalEvents provides a lot of actions. In this case it is necessary to stop the player from breaking the block. When we want to block or prevent an event, we use the `cancel_event: true` action. Then, we can send a message telling the player that breaking blocks is not allowed on this world.&#x20;

For the actions to work you need to add the `actions` path, and then a `default` path. The `default` name is in fact an action group. Events can have multiple action groups that can be executed depending on different situations, but that's more advanced that is explained later on the wiki.

```yaml
Events:
  event1:
    type: block_break
    conditions:
    - "%player_world% == spawn"
    actions:
      default:
      - "cancel_event: true"
      - "message: &cYou can't break blocks on this world!"
      
```

The event is ready! Now, players will be unable to break blocks on a world called `spawn`.
