> For the complete documentation index, see [llms.txt](https://battlepass.advancedplugins.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://battlepass.advancedplugins.net/developer-api/developer-api-creating-your-own-quest-types.md).

# Creating Your Own Quest Types

With BattlePass v4, creating your own quest types is quick and simple but there are still a few steps.

1\) Make sure you depend on BattlePass (or soft depend). If you're soft depending, remember to check if the plugin is enabled.

2\) Make a class for your quest and have it extend `ExternalActionContainer`. Use your IDE to automatically implement the required constructor.

3\) Do whatever you wish and use the execute method to actually trigger the event with all the values with wish.

Use this example to explain the rest (most should be explained just by viewing available inputs anyway):

**Don't forget to change `your_plugin_name` and `quest_name`**

```java
public class BlockBreakQuest extends ExternalActionContainer {

    public BlockBreakQuest(JavaPlugin plugin) {
        super(plugin, "your_plugin_name");
    }

    @EventHandler(ignoreCancelled = true)
    public void onBlockBreak(BlockBreakEvent event) {
        Player player = event.getPlayer();
        Block block = event.getBlock();

        super.executionBuilder("quest_name") // Create execution
                .player(player) // Set player
                .root(block) // Set root
                .progressSingle() // Add 1 progress
                .buildAndExecute();  // Execute
    }
}

```

\*\*This example will create quest with type `your_plugin_name_quest_name` \*\*

4\) Now you need to actually register the quest. To do this, you first need to get the quest registry as such:

```java
ActionRegistry actionRegistry = BattlePlugin.getPlugin().getActionRegistry();
```

5\) Now, you can use the `quest` method to register the quest. If it depends on an external plugin, use the `hook` method (checks if the plugin is enabled).

Internal:

```java
actionRegistry.quest(BlockBreakQuest::new);
```

External:

```java
actionRegistry.hook("pluginname", BlockBreakQuest::new);
```

## Useful `ActionExecutionBuilder` methods

* `player(Player player)` - Set player
* `overrideUpdate()` - Set progress to override entire progress
* `canBeAsync()` - Execute asynchronously (don't use when root/subroot uses blocks,items or entities)

***

* `root(String root)` - Set root to string
* `root(Block root)` - Set root to block
* `root(ItemStack root)` - Set root to itemstack
* `root(Entity root)` - Set root to entity
* `root(Material root)` - Set root to material
* `root(Predicate<Object> root)` - Manually create root checking method which takes String, ItemStack, Entity or Material as parameter and returns true if root is correct or false.

***

* `subRoot(String key, String value)` - Add subroot with string
* `subRoot(String key, Material value)` - Add subroot with material
* `subRoot(String key, ItemStack value)` - Add subroot with itemstack
* `subRoot(String key, Block value)` - Add subroot with block
* `subRoot(String key, Entity value)` - Add subroot with entity
* `subRoot(String key, Predicate<Object> value)` - Manually create subroot checking method which takes String, ItemStack, Entity or Material as parameter and returns true if root is correct or false.
* `subRoot(ItemStack itemStack)` - Add `item` subroot with itemstack

***

* `progressSingle()` - Add 1 progress
* `progress(BigInteger progress)` - Add progress
* `progress(int progress)` - Add progress
* `progress(double progress)` - Add progress


---

# 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://battlepass.advancedplugins.net/developer-api/developer-api-creating-your-own-quest-types.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.
