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

# Presets

Presets allow you to define reusable prompts and post-commands in a `presets.json` file (located in the plugin's data folder) and reference them using their `id`.

***

## Prompts

All prompt definitions must include:

* `id` (String): Unique identifier.
* `type` (String): The prompt UI type (`chat`, `anvil`, `player_ui`, `sign`, or `dialog`).
* `sanitize` (Boolean, optional): Strips color codes from player input if `true`. Defaults to `true`.

### Chat Prompt (`"type": "chat"`)

* `prompt_text` (String): The text displayed to the player.
* `cancel` (Object): Configuration for prompt cancellation:
  * `send` (Boolean): Whether to send a cancellation message.
  * `message` (String): The cancellation message.
  * `clickable` (Boolean): Whether the cancellation text is clickable.
  * `hover_message` (String): Hover tooltip for the cancellation message.

### Anvil Prompt (`"type": "anvil"`)

* `title` (String): Title of the Anvil GUI.
* `prompt_text` (String): Pre-filled text in the text field.
* `left_button` / `right_button` (Object): Left/Right item slot configuration:
  * `show` (Boolean): Whether to display the button.
  * `button_text` (String): Display name of the item.
  * `button_icon` (String): Material name (e.g., `BARRIER`).
  * `button_hover_text` (String): Item lore.
  * `custom_model_data` (Integer): Custom model data ID.

### Player UI Prompt (`"type": "player_ui"`)

* `prompt_text` (String): Title of the inventory GUI.
* `filter` (String, optional): Filter logic (e.g., `w` for current world).
* `cancel_button` / `previous_button` / `next_button` (Object): Control buttons configuration:
  * `show` (Boolean), `slot` (Integer), `button_text` (String), `button_icon` (String), `button_hover_text` (String), `custom_model_data` (Integer).

### Sign Prompt (`"type": "sign"`)

* `prompt_text` (String): Instructions sent to the player in chat.
* `default_lines` (Array of Strings): Up to 4 lines pre-filled on the sign.

### Dialog Prompt (`"type": "dialog"`)

* `title` (String): Title of the dialog inventory.
* `base` (Object):
  * `body` (Array of Objects): Elements in the GUI (`type`: `"plain_message"` or `"item"`, `content`, `material`, `amount`).
  * `inputs` (Array of Objects): User input fields (`label`, `input_type`: `"text"`, `"number"`, or `"choice"`, `constraints`).
* `dialog_type` (Object): Layout configuration (`multi_action` or `confirmation`).

***

## Post-Commands

Post-commands define actions executed when a prompt session completes or is cancelled.

* `id` (String): Unique identifier.
* `command` (String): Command to execute (without the leading `/`).
* `execution_policy` (String): When to execute (`on_complete` or `on_cancel`).
* `execute_as` (String): Executor context (`console` or `player`).
* `delay_ticks` (Integer, optional): Execution delay in server ticks. Defaults to `0`.

### Placeholders

* `{input}` / `{input:1}`: User input from the first prompt in the sequence.
* `{input:2}`, `{input:3}`, etc.: User input from subsequent prompts.
* `{player}`: Name of the player who triggered the prompt.
* Supports PlaceholderAPI (`%...%`).

***

## JSON Example

```json
{
  "prompts": [
    {
      "type": "chat",
      "id": "reason_prompt",
      "prompt_text": "Please enter a reason:",
      "sanitize": true,
      "cancel": {
        "send": true,
        "message": "Cancelled reason input.",
        "clickable": false,
        "hover_message": "Action aborted"
      }
    },
    {
      "type": "anvil",
      "id": "rename_item_prompt",
      "title": "Rename your item",
      "prompt_text": "New Name",
      "sanitize": false,
      "left_button": {
        "show": true,
        "button_text": "Cancel",
        "button_icon": "BARRIER",
        "button_hover_text": "Click to cancel",
        "custom_model_data": 0
      },
      "right_button": {
        "show": true,
        "button_text": "Confirm",
        "button_icon": "PAPER",
        "button_hover_text": "Click to confirm",
        "custom_model_data": 0
      }
    }
  ],
  "post_commands": [
    {
      "id": "log_reason",
      "command": "discord broadcast {player} punished {input:1} for: {input:2}",
      "execution_policy": "on_complete",
      "execute_as": "console"
    },
    {
      "id": "refund_fee",
      "command": "eco give {player} 100",
      "execution_policy": "on_cancel",
      "execute_as": "console",
      "delay_ticks": 20
    }
  ]
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://cyr1en.gitbook.io/commandprompter/configuration/presets.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
