VillagerAPI Reloaded 2016-04-18

An easy way to spawn villager / add trades for villagers.

  1. Nawaf
    Tested Minecraft Versions:
    • 1.7
    • 1.8
    • 1.9
    Description:
    I've recently made a merchant plugin using villagers. I spent a very long time figuring out how to add custom trades to villagers. After I figured out how I decided to make an Api for all you developers out there struggling the same way I did while finding out how to do this. This Api lets you both clear a villager's trades and add new trades. I will add more features in the future. I just don't know what to add at the moment so please feel free to suggest new features down below!

    How to use:
    1: Install the Api
    First you add the api to your plugins folder like you would do with any other plugin.
    [​IMG]

    [​IMG]

    [​IMG]

    2: The coding:
    Clear trades:

    VillagerAPI.clearTrades(villager);

    Note: You don't have to clear the trades before adding new ones.

    Spawn villager:

    VillagerAPI.spawnVillager(Player p, "villagerName", canMove(true,false), Profession ProfessionType);

    Example:

    VillagerAPI.spawnVillager(player, "Spigot villager", false, Profession.BLACKSMITH);

    Add trades:


    VillagerTrade trade = new VillagerTrade(itemstack1, itemstack2, reward);

    VillagerAPI.addTrade(villager, trade);

    Note: item2 is optional!

    Example:
    Villager villager = (Villager) event.getEntity();

    VillagerAPI.clearTrades(villager);

    ItemStack item1 = new ItemStack(Material.GOLD_NUGGET, 10);

    ItemStack item2 = new ItemStack(Material.APPLE);

    ItemStack reward = new ItemStack(Material.DIAMOND_HOE);

    VillagerTrade trade = new VillagerTrade(item1, item2, reward);

    VillagerAPI.addTrade(villager, trade);


    Source: http://dev.bukkit.org/bukkit-plugins/villager-trade-api/

Recent Reviews

  1. IxReFeZx_
    IxReFeZx_
    5/5,
    Version: 2016-04-18
    ---------------------------------------------------------------------------


    Good plugin go ahead my friend

    ---------------------------------------------------------------------------
  2. MrVenenoZHacks
    MrVenenoZHacks
    5/5,
    Version: 2016-04-18
    Good api to create a different styles of Villager to minecraft :D, continue create plugins and apis
  3. DomeDD
    DomeDD
    1/5,
    Version: 2016-04-18