# Quests Example

This example will show you a conversation that will start and finish a Quests for the player using the plugin [**QUESTS**](https://www.spigotmc.org/resources/quests.3711/).

The quest will consist on bringing an iron ingot to the NPC. I will use an empty quest called `bob_the_king`. What I mean by an empty quest is that it will have an empty stage, the quest itself will be managed by my plugin Interactions because we want something simple.&#x20;

{% hint style="info" %}
Since we will be using some PlaceholderAPI variables remember to download the following expansions: `CheckItem` and `Quests`\
\&#xNAN;*/papi ecloud download CheckItem (*[*https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders#checkitem*](https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders#checkitem)*)*\
*/papi ecloud download Quests (*[*https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders#quests*](https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders#quests)*)*
{% endhint %}

## Config

```yaml
name: '{centered}&c&lBob'
starts_with:
- NPC named Bob
block_movement: true
slow_effect: false
save_conversation_progress: false
start_conversation_radius: 0
end_conversation_radius: 5
requires_permission: false
conversation:
  conversation1:
    dialogue:
      dialogue1:
        text:
        - '{centered}&c&lBob &f:'
        - '{centered}&7Hello, can you help me with something?'
        time: 2
        show_name: false
        conditional_dialogue:
          conditional_dialogue1:
            requires:
            - '%quests_player_has_completed_quest_bob_the_king% == true'
            start_conversation: conversation6
          conditional_dialogue2:
            requires:
            - '%quests_player_has_current_quest_bob_the_king% == Yes'
            start_conversation: conversation4
    options:
      option1:
        text: '&eSure.'
        start_conversation: conversation2
      option2:
        text: '&eNot now.'
        start_conversation: conversation3
    random_dialogue: false
  conversation2:
    dialogue:
      dialogue1:
        text:
        - '{centered}&c&lBob &f:'
        - '{centered}&7Could you bring me an iron ingot please?'
        - ' '
        - ' '
        time: 2
        show_name: false
      dialogue2:
        text:
        - '{centered}&eQUEST STARTED!'
        - '{centered}&f&nBob the King'
        - '{centered}'
        - '{centered}&6Objective:'
        - '{centered}&7Bring x1 Iron Ingot to Bob on Kryngel city.'
        time: 2
        actions:
        - 'title: 20;40;20;&6QUEST STARTED!;&fBob the King'
        - 'console_command: questadmin give %player% bob_the_king'
        show_name: false
        save_dialogue_to_player: true
    random_dialogue: false
  conversation3:
    dialogue:
      dialogue1:
        text:
        - '{centered}&c&lBob &f:'
        - '{centered}&7Ok no problem.'
        time: 2
        show_name: false
    random_dialogue: false
  conversation4:
    dialogue:
      dialogue1:
        text:
        - '{centered}&c&lBob &f:'
        - '{centered}&7I don''t see an iron ingot with you.'
        - '{centered}&7Please hurry!'
        time: 2
        show_name: false
        conditional_dialogue:
          conditional_dialogue1:
            requires:
            - '%checkitem_mat:IRON_INGOT,amt:1% == yes'
            start_conversation: conversation5
    random_dialogue: false
  conversation5:
    dialogue:
      dialogue1:
        text:
        - '{centered}&c&lBob &f:'
        - '{centered}&7You have the iron ingot? Perfect, thanks!'
        time: 2
        actions:
        - 'remove_item: IRON_INGOT;1'
        - 'console_command: questadmin finish %player% bob_the_king'
        show_name: false
        actions_after_dialogue: true
    random_dialogue: false
  conversation6:
    dialogue:
      dialogue1:
        text:
        - '{centered}&c&lBob &f:'
        - '{centered}&7Thank you again for the iron ingot. Have'
        - '{centered}&7a nice day.'
        time: 2
        show_name: false
    random_dialogue: false

```

## Explanation

We have 6 different conversations, I will explain what each of them does.

{% tabs %}
{% tab title="conversation1" %}
The first time the player speaks with this NPC, it will ask for help and show 2 options. The first option will send the player to conversation2 and the second option to conversation3.\
\
If the player has already completed the quest `bob_the_king` , conversation6 will be started instead. If the player is currently doing the quest, conversation4 will be started.\
\
These conditions/requirements are managed by the conditional dialogues. In the case of the plugin Quests each variable will return something else (it's king of weird)\
`%quests_player_has_completed_quest_<quest>%` should return `true` or `false`.\
`%quests_player_has_current_quest_<quest>%` should return `Yes` or `No`.<br>
{% endtab %}

{% tab title="conversation2" %}
The player wants to help the NPC so conversation2 starts and a console\_command action is defined, which will start the quest executing this command from the console:\
`questadmin give %player% <quest>`
{% endtab %}

{% tab title="conversation3" %}
The player doesn't want to help the NPC so nothing happens and the conversation ends.
{% endtab %}

{% tab title="conversation4" %}
This conversation will start when the player is currently doing the quest and speaks again with this NPC. First, the conditional dialogue will be verified. If the player has at least x1 Iron Ingot in its inventory, conversation5 will start.\
\
If the player doesn't have x1 iron ingot a dialogue will be sended telling that the player doesn't have the iron ingot and the conversation ends.
{% endtab %}

{% tab title="conversation5" %}
This conversation will start when the player speaks with the NPC having an iron ingot. The following command will be executed, finishing the quest:\
`questadmin finish %player% bob_the_king`

It is important also to remove the iron ingot from the player's inventory using the remove\_item action: `remove_item: IRON_INGOT;1`<br>
{% endtab %}

{% tab title="conversation6" %}
This conversation will start when the player speaks with the NPC having already finished the quest. We don't want the player to access the quest again so we just send a new dialogue that ends the conversation.
{% endtab %}
{% endtabs %}

## Interactions Quests Module

You can also create quests that require to "start conversation" and "end conversation" objectives to your Quests plugin. For that you will need the following plugin: <https://www.spigotmc.org/resources/interactions-quests-module.92421/>
