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

# Conditions

**Conditions:**

Conditions enable implementing various checks to ensure a treasure is only executed when all specified conditions are met. Starting with version 1.4.0, it's also possible to use conditions within each reward.

{% tabs %}
{% tab title="01" %}

<pre class="language-yaml" data-line-numbers><code class="lang-yaml">&#x3C;treasure name>:
<strong>  conditions:
</strong><strong>    &#x3C;condition 01>:
</strong><strong>      type: &#x3C;type>
</strong><strong>    &#x3C;condition 02>:
</strong><strong>      type: &#x3C;type>
</strong><strong>    &#x3C;condition 03>:
</strong><strong>      type: &#x3C;type>
</strong></code></pre>

{% endtab %}

{% tab title="02" %}

<pre class="language-yaml" data-line-numbers data-full-width="false"><code class="lang-yaml">conditions-treasures:
  chance: 10.0
<strong>  conditions:
</strong><strong>    worlds:
</strong><strong>      type: WORLD
</strong><strong>      method: BLACKLIST
</strong><strong>      values:
</strong><strong>      - "world_nether"
</strong>	  
    blocks:
      type: BLOCK
      method: BLACKLIST
      values:
      - "BEDROCK"
      - "DIRT:0"
      - "DIRT:4"
	  
    biomes:
      type: BIOME
      method: BLACKLIST
      values:
      - "JUNGLE"
	  
    items:
      type: ITEM          
      material: 'DIRT:1'  
      amount: 1           
      name: "&#x26;cLucky Dirt"
      lores:             
      - "&#x26;4Cool lore"
      - "&#x26;4Cool other line"
      options:
        name_ignorecase: true
        lores_ignorecase: true
        name_contains: true
        lores_contains: true
        in_armor: false
        in_inventory: false
        in_hotbar: false
        in_hand: true
        in_offhand: true
      metadatas:
        '1':
          type: '>='
          key: "test"
          value: 3
		  
    'string conditions':
      type: 'NOT_CONTAINS'
      input: "%player_world%"
      output: "end"

    number-conditions:
      type: '>='
      input: "%vault_eco_balance_fixed%"
      output: 0.0

    ignore-player-placed-blocks:
      type: PLACED
      ignore: true
</code></pre>

{% endtab %}

{% tab title="03" %}
{% code lineNumbers="true" fullWidth="false" %}

```yaml

conditions-in-rewards-treasures:
  ...
  sections:
    'COOL NAME':
      rewards:
        '1':
          # Conditions section: defines the conditions for the treasure to appear based on worlds, blocks, biomes, strings, or numbers.
          # - OPTIONAL
          conditions:
            # Blocks condition: Specifies which blocks are restricted or allowed for the treasure.
            # - type: BLOCK (Defines if the condition applies to specific blocks)
            # - method: BLACKLIST or WHITELIST (BLACKLIST excludes, WHITELIST includes the specified blocks)
            # - values: List of blocks to apply the condition to.
            blocks:
              type: BLOCK
              method: WHITELIST
              values:
              - "stone"
          chance: 50.0
          exp: '1~70'
          commands:
          - "[ACTIONBAR] &eYou break a stone!"
          - "[MESSAGE] &6[Treasure] &7- &7You break a stone!"
```

{% endcode %}
{% endtab %}
{% endtabs %}

***

### **WORLD:**

Specifies the **worlds** where the treasure can or cannot be found.

* **`type`**: WORLD
* **`method`**: BLACKLIST or WHITELIST
* **`values`**: List of world names.

**Example**:

{% code lineNumbers="true" %}

```yaml
  worlds:
    type: WORLD
    method: BLACKLIST
    values:
    - "world_nether"
```

{% endcode %}

***

### **BLOCK:**

Specifies the **blocks** that are restricted or permitted for the treasure.

* **`type`**: BLOCK
* **`method`**: BLACKLIST or WHITELIST
* **`values`**: List of blocks.

**Example**:

{% code lineNumbers="true" %}

```yaml
  blocks:
    type: BLOCK
    method: BLACKLIST
    values:
    - "BEDROCK"
    - "DIRT:0"
    - "DIRT:4"
```

{% endcode %}

***

### **BIOME:**

Specifies the **biomes** where the treasure can or cannot appear.

* **`type`**: BIOME
* **`method`**: BLACKLIST or WHITELIST
* **`values`**: List of biomes.

**Example**:

{% code lineNumbers="true" %}

```yaml
  biomes:
    type: BIOME
    method: BLACKLIST
    values:
    - "JUNGLE"
```

{% endcode %}

***

### **ITEM:**

Specifies the **items** associated with the treasure. This can include:

* **`type`**: ITEM
* **`material`**: Material of the item (e.g., `'DIRT:1'`).
* **`amount`**: Quantity of the item.
* **`name`**: Name of the item.
* **`lores`**: List of lore texts associated with the item.
* **`options`**: Additional options to refine the condition, such as:
  * **`name_ignorecase`**: Ignore case for the name.
  * **`lores_ignorecase`**: Ignore case for the lores.
  * **`name_contains`**: Check if the name contains specific text.
  * **`lores_contains`**: Check if any lore contains specific text.
  * **`in_armor`**: Check if the item is in armor slots.
  * **`in_inventory`**: Check if the item is in inventory.
  * **`in_hotbar`**: Check if the item is in the hotbar.
  * **`in_hand`**: Check if the item is in the main hand.
  * **`in_offhand`**: Check if the item is in the offhand.
* **`metadatas`**: Additional item data, such as:
  * **`type`**: Comparison type (`>`, `<`, `==`, ...).
  * **`key`**: Metadata key (e.g., custom tag).
  * **`value`**: Value for comparison.

**Example**:

{% code lineNumbers="true" %}

```yaml
  items:
    type: ITEM
    material: 'DIRT:1'
    amount: 1
    name: "&cLucky Dirt"
    lores:
    - "&4Cool lore"
    - "&4Cool other line"
    options:
      name_ignorecase: true
      lores_ignorecase: true
      name_contains: true
      lores_contains: true
      in_armor: false
      in_inventory: false
      in_hotbar: false
      in_hand: true
      in_offhand: true
    metadatas:
      '1':
        type: '>='
        key: "test"
        value: 3
      '2':
        type: 'EQUALS'
        key: "test2"
        value: "txt"
```

{% endcode %}

***

### **STRING CONDITION:**

Defines a **string condition** that compares a value within the game. This includes:

* **`type`**:
  * `CONTAINS`
  * `EQUALS`
  * `EQUALS_IGNORE_CASE`
  * `NOT_CONTAINS`
  * `NOT_EQUALS`
  * `NOT_EQUALS_IGNORE_CASE`
* **`input`**: Value to be compared, such as a placeholder (e.g., `%player_world%`).
* **`output`**: Expected value for comparison.

**Example**:

{% code lineNumbers="true" %}

```yaml
  my-world-placeholder-check:
    type: 'NOT_CONTAINS'
    input: "%player_world%"
    output: "end"
```

{% endcode %}

***

### **NUMBER CONDITION:**

Defines a **numeric condition** based on a comparison operator. This includes:

* **`type`**:
  * `>`
  * `>=`
  * `==`
  * `!=`
  * `<`
  * `<=`
* **`input`**: Numeric value to be compared, such as a placeholder (e.g., `%vault_eco_balance_fixed%`).
* **`output`**: Value to compare the `input` against.

**Example**:

{% code lineNumbers="true" %}

```yaml
  my-balance-placeholder-check:
    type: '>='
    input: "%vault_eco_balance_fixed%"
    output: 0.0
```

{% endcode %}

***

### **PLACED:**

Ignores blocks placed by the player.

* **`type`**: `PLACED`
* **`ignore`**: Specifies whether player-placed blocks should be ignored (`true` or `false`).

**Example**:

{% code lineNumbers="true" %}

```yaml
  ignore-player-placed-blocks:
    type: PLACED
    ignore: true
```

{% endcode %}
