# Reward

{% hint style="warning" %}
Please, keep on mind, that reward is **NOT** only one item in the game. It is a **collection** of economy amounts, commands and items, which will be given to player at claiming.
{% endhint %}

## What does reward consist of? <a href="#what-does-reward-consist-of" id="what-does-reward-consist-of"></a>

* `Key` - **Unique** name of the reward. It is used at assigment to the specific day.
* `Name` - Real, **human readable**, name of the reward. Visible after claiming at opened window.
* `Description` - Optional. Visible only for staff at Reward Repository for better orientation.
* `Icon` - Item representing reward. For example, **Diamond Pickaxe**. Used at LuckyWheel.
* `Economy Amounts` - Amounts of **Money/Experiences** given to player at claiming the reward.
* `Items` - **Collection** of items given to player at claiming the reward.
* `Commands` - **Collection** of commands executed to player at claiming the reward.

## How to create reward <a href="#how-to-create-reward" id="how-to-create-reward"></a>

There are two options how to create reward. By in-game **Reward UI** or **Manually** in the confiuration file. Both have some restrictions, so if you want use some advanced methods you will need to use combination of them.

### **Using in-game Reward UI**

{% hint style="info" %}
To open **Reward UI** type `/AdventSeason Settings`
{% endhint %}

<figure><img src="https://1976143074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLJoFzkAGLhrcX9C4iXwD%2Fuploads%2FfKMGc8G7r365XsZrgmOP%2FSettings%20-%202.X.png?alt=media&#x26;token=1ef0ea42-6b5e-4231-9b38-8ee7779b1c61" alt=""><figcaption><p>Reward settings</p></figcaption></figure>

Then you need to get into **Reward Repository**.

<figure><img src="https://1976143074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLJoFzkAGLhrcX9C4iXwD%2Fuploads%2FAqNxEZtZjYGXKAz7rnGj%2FRewardRepository.png?alt=media&#x26;token=03f36831-8725-40eb-b297-b643161c87a3" alt=""><figcaption><p>Reward repository with rewards</p></figcaption></figure>

{% hint style="warning" %}
**Before we start!** To save any value using UI, just click on `Back` item. The value will be automatically saved.
{% endhint %}

Now, we can create reward. At first you have to choose **Reward Key**.

Click on the item `Create new reward` at the bottom of the UI, on the left side next to `Basic information`. You will be asked to input **Reward Key**, write it there and confirm it.

<figure><img src="https://1976143074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLJoFzkAGLhrcX9C4iXwD%2Fuploads%2Fq6EVFqd0XIUgo0gSAqn2%2FRewardKeyInput.PNG?alt=media&#x26;token=bfd33a4d-c283-4f09-8fd3-552ae5c6c72f" alt=""><figcaption><p>Choosing the key of the reward</p></figcaption></figure>

{% hint style="warning" %}
**Reward Key** consist only from `Alphanumeric` characters and `_`.
{% endhint %}

{% hint style="info" %}
To confirm action, click on **Redstone Dust** at the right side of the UI.
{% endhint %}

If you inserted correct Reward Key, you can see detail of the reward.

<figure><img src="https://1976143074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLJoFzkAGLhrcX9C4iXwD%2Fuploads%2FrHpNcAGGOA3houtFo5uP%2FRewardDetail.png?alt=media&#x26;token=49dfaea1-b41d-456a-b20a-7f8a8d513995" alt=""><figcaption><p>Detail of the reward</p></figcaption></figure>

And here, you can manage the whole reward. All the key feature of the reward, its Name, Description, Icon, Items etc.

**Text areas**

Usage is the same, you will be asked to input some text, write it there and confirm it.

> At `Name`, `Description`, `Icon's HeadName` and `Icon's Lore` you can use **Color** codes. (`&` or `§`)

#### Icon

To set new Icon of the reward, at first prepare it before opening the UI and place it into your inventory.

* Click on the item named `Icon` in the UI.
* Move the new icon to **free slot** in the UI.
* To save it click on the `Back` item.

<figure><img src="https://1976143074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLJoFzkAGLhrcX9C4iXwD%2Fuploads%2FO5zCCClkJOBRgyqY3Fsw%2FSettingIcon.png?alt=media&#x26;token=bf21c327-ca38-4f63-92c0-42ee08a36de9" alt=""><figcaption><p>Setting icon of the reward</p></figcaption></figure>

Optionally, you can aplly Enchantment on this icon.

> If the choosen Icon have not got HeadName, it is recommended to create one.

#### **Economy Amounts**

Simple UI, where you can set amounts, which will be given to player at claiming the reward.\
Follow instructions showed at `Basic information` item.

#### **Items**

Again, you need to prepare these items before opening the UI.

In the appropriate UI, click on the item `Create new element`. You will be asked to move **up to 9** items to the free slots. Than save it.\
Repeat, how much times you need.

> Here, you can place whatever you want. Heads with Texture, Enchanted Items and Custom Items(Crate Keys).

#### Commands

Throuh commands you can give additional addons, wich cannot be given to player as item. For example, Give money from plugin, which does not support Vault. Or you can apply VIP here.

The usage is the same as above at Items. But you will be asked to input command instead of placing the item.

Example of executable command

* `tell {player} Merry Christmas!`

{% hint style="warning" %}
**Input UI** is limited for lenght of the command! If you need to input more complicated command, you have to use configuration file.
{% endhint %}

### **Manually in the file**

Configuration file `RewardRepository.yml` is located at folder `Reward`.

#### **Template for the one reward**

```yaml
UniqueRewardKey:
  Name: '&5Name of the reward using color codes!'
  Description: 'Optional Description'
  Icon:
    Material: STONE #Material of the Icon
    MaterialData: 0 #Used for items, where the plugin runs on the version from 1.8.8 to 1.12.X. Here you can specify color of the material.
    Enchantment: false #Flag if the enchantment is applied on the Icon
    HeadName: '&5HeadName of the Icon' #Used at LuckyWheel
    Lore: [] #Desciption. Used at LuckyWheel
    Color: "255:255:255" #RGB Color format of leather armor
    ItemFlags: #Flags applied on the Icon
    - HIDE_ENCHANTS
    - HIDE_ATTRIBUTES
    CustomModelData: 0 # Only versions 1.14 and above
    Probability: 100.0 #Working only at ChoiceType QUICK__CHANCE or LUCKY_WHEEL__CHANCE
  Reward:
    Amount:
      Vault: 0
      PlayerPoint: 0
      Experience: 0
    ItemList: [] #Cannot be set upped here.
    CommandList: []
```

#### Lore example

```yaml
Lore:
- "&7The first line of the icon description."
- "&7The second line of the icon description."
```

#### List of commands example

```yaml
CommandList:
- "money give {player} 100"
- "set VIP {player} 30Day"
```

### Probability

You can manage which reward has higher chance to be claimed from system. Something legendary has lower chance than common pickaxe.

{% hint style="danger" %}
Summary of probability at assinged rewards has to be **100.0**! Otherwise, system won't work correctly!
{% endhint %}

The best way is to configure it manually in configuration file at `RewardAssignment.yml` file(See [section](#manually-in-the-file-1) below).

### Testing the reward

At **detail** of the Reward, at **bottom** of the UI, there is a `Redstone Dust`. By click on it, you can **test** the reward. All Economy Amounnts, Items and Commands will be given to you. (No Database query/update will be executed.)

{% hint style="info" %}
Available through **Settings** and **Reward Repository**.
{% endhint %}

<figure><img src="https://1976143074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLJoFzkAGLhrcX9C4iXwD%2Fuploads%2FDPU9ZZGAiOubyH5RqnNO%2FRewardTesting.PNG?alt=media&#x26;token=8fdf554a-ac26-40ba-b855-8184cd269fa6" alt=""><figcaption><p>Testing, if reward contains all staf you assigned</p></figcaption></figure>

## How to assign reward to the specific day <a href="#how-to-assign-reward-to-the-specific-day" id="how-to-assign-reward-to-the-specific-day"></a>

Again, there are two options how to assign them. By in-game RewardAssigment UI or Manually in the confiuration file.

> Personally, I recommend to use exclusively RewardAssigment UI.

### **Using in-game Reward UI**

{% hint style="info" %}
To open RewardAssigment UI type /AdventSeason Settings
{% endhint %}

Then you need to get into Reward Day Assigment section.

<figure><img src="https://1976143074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLJoFzkAGLhrcX9C4iXwD%2Fuploads%2FBjGcfYlBasVbzaXEXf5p%2FAssignment%20.png?alt=media&#x26;token=40b51863-fb70-44cf-b15b-765b494020a7" alt=""><figcaption><p>Assignment of the reward to calendar's window</p></figcaption></figure>

Each item in slot represents one day of the season. Also, it is symbolized by amount of items at this slot.

#### **Usage**

To assign rewards to the day **1**.

* **Left Click** on this item.
* Here you can see **list** of all rewards.
* **Choose**, which rewards you want to assign to this day.
  * On the Selected reward is applied **enchantment**. Also at the description, you can see that reward is selected.
  * To manage **probability**, right click on selected item
* To save click on **Back** item.

<figure><img src="https://1976143074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLJoFzkAGLhrcX9C4iXwD%2Fuploads%2FwegE11WxalONJoht7v1j%2FDayAssignment.png?alt=media&#x26;token=bcd475b0-59ef-4a46-b47c-d71f059c937b" alt=""><figcaption></figcaption></figure>

To change RewardChoiceType for day **1**.

* **Right Click** on this item.
* Here you can see **list** of all types.
* **Choose**, which type you want to use at this day.
* To save click on **Back** item.

<figure><img src="https://1976143074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLJoFzkAGLhrcX9C4iXwD%2Fuploads%2Fhwu586nFHRb4UnHdMztm%2FChoiceType.png?alt=media&#x26;token=b694c7a9-c2aa-4d37-bbb5-347c567f5ab5" alt=""><figcaption></figcaption></figure>

### **Manually in the file**

Configuration file `RewardAssignment.yml` is located at folder `Reward`.

One day is represented by following block:

```yaml
DAY_1: #Unique Key, not recommended to change it, if you do not know how it works.
  AssignmentType: "ADVENT_CALENDAR__WINDOW" #Type of assignment (See below).
  Day: 1 #Day of the season
  ChoiceType: "QUICK__BASE" #Optional variable, if not set, default value will be used.
  Reward: [ ] #List of assigned rewards
```

#### **Usage**

Imagine we have prepared **3** rewards with RewardKey `DiamondTools`, `MoneyPocket` and `ChristmasCandy`.

For the **first** day of the season, we want to give players `ChristmasCandy` and for the **second** day, we will give them remaining two rewards.

For the third day, we will use **probability**. `DiamondTools` has 90% chance, `MoneyPocket` has 10% chance to win.&#x20;

Grinch's loot probability can be overwritten for specific day.

{% hint style="danger" %}
Summary of probability at assinged rewards has to be **100.0**! Otherwise, system won't work correctly!
{% endhint %}

<pre class="language-yaml"><code class="lang-yaml">DAY_1:
  AssignmentType: "ADVENT_CALENDAR__WINDOW"
  Day: 1
  ChoiceType: "QUICK__BASE"
  Grinch:
    Loot:
      Probability: 25.0
  Reward:
  - ChristmasCandy
<strong>DAY_2:
</strong>  AssignmentType: "ADVENT_CALENDAR__WINDOW"
  Day: 2
  ChoiceType: "LUCKY_WHEEL"l
  Reward:
  - DiamondTools
  - MoneyPocket
DAY_3:
  AssignmentType: "ADVENT_CALENDAR__WINDOW"
  Day: 3
  ChoiceType: "QUICK__CHANCE"
  Reward:
  - DiamondTools:90.0
  - MoneyPocket:10.0
</code></pre>

**Extending to more days**

Predefined configuration contains 24 block representing duration of the season from the 1st of December to 24th of December. If you want to give rewards for a longer period, you need to add next blocks manually.

```yaml
DAY_25:
  AssignmentType: "ADVENT_CALENDAR__WINDOW"
  Day: 25
  Reward: [ ]
```

#### Benefit

Benefit has own assignment type and does not contain `Day` variable.

```yaml
BENEFIT:
  AssignmentType: "ADVENT_CALENDAR__BENEFIT"
  ChoiceType: "QUICK__BASE" #Optional variable, if not set, default value will be used.
  Reward: [ ]
```

**St. Nicholas's gift**

Gift can contain only one reward key, others are ignored. Also `ChoiceType` is ignored here.

```yaml
GIFT:
  AssignmentType: "SAINT_NICHOLAS__GIFT"
  Reward: [ ]
```

## Finally

After successful setting up of the rewards, you need to reload the plugin to load new rewards.

{% hint style="info" %}
To reload the whole plugin type `/AdventSeason Reload`
{% endhint %}

## UI Flow

<figure><img src="https://1976143074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLJoFzkAGLhrcX9C4iXwD%2Fuploads%2Fhh2kGvgl8UKTDXY43edq%2FReward%20Settings%20-%20Flow%202.X.png?alt=media&#x26;token=316710de-6087-447f-94c9-9427915378fe" alt=""><figcaption><p>Flow, how to setup rewards</p></figcaption></figure>
