> For the complete documentation index, see [llms.txt](https://questlib.themelvin.nl/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://questlib.themelvin.nl/docs/master.md).

# Home

## Contents

Welcome to the **QuestLib** wiki, please choose a subject below or in the sidebar to continue.

* [Getting started](/docs/guide/installation.md)
* [Storage](/docs/guide/storage.md)
* [Rewards](/docs/guide/reward.md)

## Features

* Built-in YAML or MySQL storage.
* Custom reward types.
* Multiple custom objectives.
* Easily configurable.
* Customisable to your own wishes.
* Extensive API.

## Usage

To use QuestLib, either:

* Put it in the `plugins` folder of your server, add it to your dependencies in your `plugin.yml` (e.g. `depend: [QuestLib]`) and add it to the dependencies in your IDE.
* Put it inside your plugin jar, and initiate the library.

You can download the latest version on the [Releases page](https://github.com/MinusKube/SmartInvs/releases) on Github.

You can also use a build system:

### Gradle

{% code title="build.gradle" %}

```groovy
repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    compile 'com.github.TheMelvinNL:QuestLib:<version>'
}
```

{% endcode %}

### Maven

{% code title="pom.xml" %}

```markup
<repository>
  <id>jitpack.io</id>
  <url>https://jitpack.io</url>
</repository>

<dependency>
  <groupId>com.github.TheMelvinNL</groupId>
  <artifactId>QuestLib</artifactId>
  <version>version-number</version>
</dependency>
```

{% endcode %}

## Example

#### Quest

{% code title="BreakQuest.java" %}

```java
public class BreakQuest extends Quest {

    public BreakQuest() {

        this.setName("Break Quest");
        this.setDescription("Break different kind of blocks");

        this.setStartMessage("&bQuest started: " + this.getName());
        this.setCompleteMessage("&bQuest finished: " + this.getName());

        this.setReward(new MultiReward(new ItemReward(new ItemStack(Material.EMERALD, 2)), new ItemReward((new ItemStack(Material.IRON_INGOT, 10)))));

        this.addObjective(new CobblestoneObjective());

    }

}
```

{% endcode %}

#### Objective

{% code title="CobblestoneObjective.java" %}

```java
public class CobblestoneObjective extends QuestObjective {

    public CobblestoneObjective() {

        this.setName("Cobblestone objective");
        this.setDescription("Break 5 cobblestone blocks.");
        this.setReward(new ItemReward(new ItemStack(Material.DIAMOND, 1), "&6You received &e1x Diamond &6as a reward."));

        this.setStartMessage("&b" + this.getName() + ": " + this.getDescription());
        this.setCompleteMessage("&aYou finished this objective.");

    }

    @EventHandler
    public void blockBreak(BlockBreakEvent event) {

        // This check is neccessary, as QuestLib is not able to recognise events.
        if(!this.isFrom(event.getPlayer())) return;

        if(event.getBlock().getType() != Material.COBBLESTONE) {
            return;
        }

        this.incrementData("count", 1);

        if(this.getDataNumber("count") >= 5) {
            this.complete();
        }

    }

}
```

{% endcode %}

As you can see, with QuestLib you're able to easily create new objectives and register them in your quest. QuestLib also saves all the data you provide using `setData()` or `incrementData()` (for integers).

If you want more examples, have a look at the [Example repository](https://github.com/TheMelvinNL/QuestLib-Example).


---

# 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:

```
GET https://questlib.themelvin.nl/docs/master.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.
