# Actions

Action allows server owner to do action when an event is triggered.

Actions are stored under the `/plugins/FancyWaystones/actions` directory. You can create your own action YAML file or modify the existing ones.

### Configuration Structure

```yaml
Enable: [true (default)|false]
Event: [event name]
Ignore Cancelled: [true|false (default)]
Action: [action]
```

* Enable: Whether this action is enabled or not. Disabled events are not triggered!
* Event: The event name you want this action to be triggered on.
* Ignore Cancelled: Whether this action should be triggered if the event is cancelled by other action or 3rd party plugin. If this is true, the action will trigger anyway even if the event is cancelled.
* Action: The action itself, what to do on this situation. See configuration structure below.

{% hint style="info" %}
You can see list of available FancyWaystones events at [here](/fancywaystones/fancy-waystones/events.md).
{% endhint %}

### The Action

#### CANCEL\_EVENT

Cancel the event, preventing the plugin from doing the task (i.e. cancelling WaystoneTeleportEvent will prevent the player from teleporting).

```yaml
Type: CANCEL_EVENT
```

#### STOP

Stop the action from doing any further action (in the file).

```yaml
Type: STOP
```

#### CONSOLE\_COMMAND

Executes command as console

```yaml
Type: CONSOLE_COMMAND
Command: "give {player_name} diamond 1"
```

#### COMMAND

Execute command as the player whose involved in the event (e.g. the player that is about to teleport in WaystoneTeleportEvent).

```yaml
Type: COMMAND
Command: "say i'm teleporting! good bye!"
```

#### CANCEL\_AND\_STOP

Mark the event cancelled, and stop the action from doing any further action (in the file).

```yaml
Type: CANCEL_AND_STOP
```

#### COMPOUND

Executes a list of actions.

```yaml
Type: COMPOUND
Actions:
- Type: COMMAND
  Command: "say this command is executed first"
- Type: COMMAND
  Command: "say this command is executed second"
- Type: COMPOUND
  Actions:
  - Type: COMMAND
    Command: "say you can put COMPOUND in another COMPOUND!"
```

#### UNCANCEL\_EVENT

Mark event as un-cancelled.

```yaml
Type: UNCANCEL_EVENT
```

#### CONDITIONAL

Execute action if the condition is true or false

```yaml
Type: CONDITIONAL
Condition:
  Criteria: HAS_PERMISSION
  Permission: "iam.vip"
If True:
  Type: COMMAND
  Command: "say i am vip"
If False:
  Type: CONDITIONAL
  Criteria: IS_CANCELLED
  If True:
    Type: UNCANCEL_EVENT
```

{% hint style="info" %}
You can see list of conditions and criterias [here](/fancywaystones/fancy-waystones/conditions-and-criterias.md).
{% endhint %}

#### MESSAGE

Send message to the player (or console if no player is involved).

```yaml
Type: MESSAGE
Message: "Hello, {player_name}"
```

#### DELAYED

Delay executing an action.

```yaml
Type: DELAYED
Delay: "5m 15s"
Action:
  Type: MESSAGE
  Message: "This action is executed after 5 minutes and 15 seconds"
```

### Example

```yaml
Enable: true
Event: WaystoneBreakEvent
Ignore Cancelled: false
Action:
  Type: COMPOUND
  Actions:
  - Type: COMMAND
    Command: "say I broke a waystone!"
  - Type: CONSOLE_COMMAND
    Command: "minecraft:give {player_name} minecraft:diamond 1"
  - Type: CONDITIONAL
    Condition:
      Criteria: HAS_PERMISSION
      Permission: "waystone.break.notify"
    If True:
      Type: COMMAND
      Command: "say {player_name} has permission to break waystones!"
    If False:
      Type: COMMAND
      Command: "say {player_name} does not have permission to break waystones!"
  - Type: COMPOUND
    Actions:
      - Type: COMMAND
        Command: "say This is the first command in a compound action."
      - Type: CONDITIONAL
        Condition:
          Criteria: HAS_PERMISSION
          Permission: "waystone.break.reward"
        If True:
          Type: CANCEL_EVENT
        If False:
          Type: STOP
      - Type: MESSAGE
        Message: "You have broken a waystone!"
      - Type: DELAYED
        Delay: 1s
        Action:
          Type: COMMAND
          Command: "say This command is executed after a delay of 1 second."

```


---

# 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://septogeddon.gitbook.io/fancywaystones/fancy-waystones/actions.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.
