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 !

Last updated