Bukkit/Bukkit — pull request #1077 by gabizou (2014-06-20 01:54:45+00:00)
Title: Add Merchant Trade API - Adds BUKKIT-5663

**The Issue:**

There is no way to modify Villager trades through the Bukkit API.

**Justification**

Without the API to allow for modifications being made on a Merchant's offers list, plugins have no Bukkit API way to affect trades, leading to messy uses of NMS classes and modified CraftBukkit classes, which can cause plugins to break or the server to crash. With an API, all plugin developers will be able to safely modify merchant trades (which as of current writing is only implemented through Villagers).

**PR Breakdown:**

The API adds the ability to retrieve current trades offered by a Merchant, add trades, remove trades and modify trades. There is also the added ability to influence event specific trades such that modified trades added to the MerchantTradeEvent do not alter the more permanent TradeOffers supplied by the Merchant.
In this sense: A MerchantTradeEvent's offers are a copy of the Merchant's offers that do not affect the Merchant's offers. However, the Merchant is still able to have their trades altered, but the MerchantTradeEvent will not be affected.

**Testing Results / Materials:**

Plugin code used to test: https://github.com/gabizou/TradeAPITest
Compiled Binary: https://dl.dropboxusercontent.com/u/9058563/TradingTest.jar

Steps to test:
- Spawn villager
- Interact with villager to bring up the Trade window

Console shows the debugging text

**Associated PRs**
Bukkit PR:
CraftBukkit PR:

** Relevant PRs**
Closed Bukkit PR: https://github.com/Bukkit/Bukkit/pull/921
Closed Bukkit PR: https://github.com/Bukkit/Bukkit/pull/833
Closed Bukkit PR: https://github.com/Bukkit/Bukkit/pull/832
Closed CraftBukkit PR: https://github.com/Bukkit/CraftBukkit/pull/1240
Closed CraftBukkit PR: https://github.com/Bukkit/CraftBukkit/pull/1111

**JIRA Tickets**

Main ticket: https://bukkit.atlassian.net/browse/BUKKIT-5663
Subsequent (duplicate) tickets
https://bukkit.atlassian.net/browse/BUKKIT-3935
https://bukkit.atlassian.net/browse/BUKKIT-2138