# Item Provider

On this page you will learn how to add an item provider into DungeonMMO. The goal of this process is to let players use custom items from your plugin into DungeonMMO either for chest loots or mob drops.

## Step 1 - Add DungeonMMO as soft dependency

Into your plugin.yml file, add this line to load your plugin after DungeonMMO

```
softdepend: [DungeonMMO]
```

## Step 2 - Register your item provider

Now you want to register the item provider. Your provider will be called every time a DungeonCustomItem with the provider name corresponding to the first parameter of the method *registerItemProvider* will need to spawn. If the itemTag is invalid, the method *generateItem* must return null.

```
@Override
public void onEnable() {
    DungeonMMOAPI.getInstance().registerItemProvider("your_plugin_name", new ItemProvider() {
                @Override
                public ItemStack generateItem(String itemTag) {
                    if(tag.equalsIgnoreCase("stone")) {
                        return new ItemStack(Material.STONE);
                    }
                    ... // Provide any item you want according to the tag
                    return null;
                }
            });
}
```

## Step 3 - Test your provider

Into the chests.yml or mob\_drops.yml, add a DungeonCustomItem with the item provider corresponding to the one you created earlier. The item\_tag value must be a valid value for your provider.

```
items:
- ==: DungeonCustomItem
  item_provider: your_plugin_name
  item_tag: stone
  probability: 1.0
  amount_max: 1
  amount_min: 1
```

Now save your file, launch the server and join a dungeon instance. You should be able to find your items into the chests !


---

# Agent Instructions: 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://alex-plugins.gitbook.io/dungeonmmo/api/item-provider.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.
