# Preset

## Configuration

Presets are configured in the `Tooltips/presets` folder. To create presets, create a new file in the folder as `<name>.yml`. After that, you can start configuring presets in that file.

### Configuration

All of these, except for `theme` are optional.

```yaml
preset-id:
  priority: 0
  text:
  - 'Test Tooltip'
  - 'Price: 500{default/gem}'
  - '(Click to buy)'
  fade:
    fadein: 20
    stay: 20
    fadeout: 20
  theme: default/three-line
  display:
    color: white
    horizontal-shift: 0
  conditions:
  - gamemode{gm=creative} true
  show:
    reshow: false
    active: true
    cooldown: 0
  actions:
    right-click:
    - 'message Hello!'
  
```

### Minimal Configuration

```yaml
preset-id:
  theme: default-three-line
```

### Properties

`priority` - Highest priority will appear first

Default priority for all presets is 0. \
Presets with a higher priority will be checked first, this is extremely useful in more complex configurations with multiple presets.

#### `text` - Lines of text that will be displayed

```yaml
text:
- 'Regular text, nothing special' # PlaceholderAPI placeholder supported
- '||Centered text||' # Centered text
- '<red>Colored <gradient:red:blue>text' # MiniMessage format
- 'Sofa price: <green>$data(furniture.sofa.price)$' # Functions
- '<typewriter text="Hello there!">' # Animations
```

<div align="left"><figure><img src="https://2056457066-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FO0fJVi4OrBJoOYrP9n9t%2Fuploads%2FL4Ld6Zw6thxzgieS4Q5l%2Ftext.gif?alt=media&#x26;token=41997fa2-349b-4ec8-bec5-35fb569a3969" alt="" width="332"><figcaption></figcaption></figure></div>

#### `fade` - Fade options, just like in titles

```yaml
fade:
    fadein: 20 # 20 ticks = 1 second to fade in
    stay: 100 # 100 ticks to stay, only necessary with active: false
    fadeout: 40 # 40 ticks = 2 seconds to fade out
```

<div align="left"><figure><img src="https://2056457066-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FO0fJVi4OrBJoOYrP9n9t%2Fuploads%2Fw4KqBxh2okHeepHNXu6N%2Ffade.gif?alt=media&#x26;token=24fdf413-a6ec-455f-ae0e-4a090c030482" alt=""><figcaption></figcaption></figure></div>

#### `theme` - The visual theme used for this preset

Set to the ID of a [Theme](https://tooltips.gitbook.io/tooltips/configuration/theme). This is required, otherwise preset wouldn't know what to look like.

#### `display`

Options related to how the tooltip is displayed.

> **`color` - color of the background**
>
> You can specify the color the following ways:

{% hint style="warning" %}
**Gradients generate a larger JSON message than regular color, so tooltips with gradients that have a large background may be laggier!**
{% endhint %}

```yaml
color: 'white'
color: '#fcba03'
color: 'red:green' # gradient from red to green
color: '#ffffff:#00ff19' # gradient from #ffffff to #00ff19
color: '#ffffff:#00ff19:#ffffff' # gradient from #ffffff to #00ff19 and to #ffffff again 
```

<div align="left"><figure><img src="https://2056457066-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FO0fJVi4OrBJoOYrP9n9t%2Fuploads%2FONJYetHlt0a9rvkMjk9j%2Fimage.png?alt=media&#x26;token=fefe5dcd-eae2-46df-9c25-20e82d2d051a" alt="" width="346"><figcaption><p>color: "#ffffff-#ff0000-#ffffff"</p></figcaption></figure></div>

> `horizontal-shift` - shift of the tooltip in pixels

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td>horizontal-shift: 10</td><td></td><td></td><td><a href="https://2056457066-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FO0fJVi4OrBJoOYrP9n9t%2Fuploads%2FTQQ0RXrxWLOJZslytYRL%2Fimage.png?alt=media&#x26;token=e7221667-3aba-4247-b9da-419dc3319fb8">image.png</a></td></tr><tr><td>horizontal-shift: -10</td><td></td><td></td><td><a href="https://2056457066-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FO0fJVi4OrBJoOYrP9n9t%2Fuploads%2Fl1hq8CwsABiaFKTcrgTd%2Fimage.png?alt=media&#x26;token=125706b3-9502-4771-8e1a-5364cddbc58e">image.png</a></td></tr></tbody></table>

#### `conditions` - a list of conditions

Conditions, which have to be fulfilled in often for this preset to be shown. More about conditions:

{% content-ref url="preset/conditions" %}
[conditions](https://tooltips.gitbook.io/tooltips/configuration/preset/conditions)
{% endcontent-ref %}

#### `show` - defines how this preset is shown

Presets can be made to be shown once or have a given cooldown. More about show properties:

{% content-ref url="preset/show" %}
[show](https://tooltips.gitbook.io/tooltips/configuration/preset/show)
{% endcontent-ref %}

#### `actions` - commands tied to actions

Think of this as events, once they happen - a list of commands is ran. More about actions:

{% content-ref url="preset/actions" %}
[actions](https://tooltips.gitbook.io/tooltips/configuration/preset/actions)
{% endcontent-ref %}

## Other Properties

### File Priority

You can define a priority for the entire preset file like so:

```yaml
priority: 10 # At the top of the file

my-preset:
    ...
my-other-preset:
    ...
```

This will add the given priority priorities of all presets. For example if `my-presets` priority is 0, it will be 10 with the file priority. This option is useful to make presets of one file more important than of another file.

### Data

Data is scoped to a single preset file, and can be used by the `$data(key)` function in presets. This is useful to have predefined data, like furniture prices right in your preset files. You can define any sort of valid yaml data after "`data`".

```yaml
data: # At the top of the file
    my-own-key: 1
    debug: true
    prices:
        chair: 100
        table: 50
    lines:
    - 'Hello!'
    - 'My name is %placeholder%'
```

### Parenting

Presets support parenting since plugin version 1.5. Parenting allows you to copy all properties from a "parent" preset into another preset and modify only the required properties. Parents and children are defined like so:

```yaml
parent:
  content:
    text:
    - '&cThe parent!'
  display:
    theme: default-one-line

child:
  parent: parent
  
child-modified:
  parent: parent
  content:
    text:
    - '&aThe second child!'
```

Other children can be parented as well.
