Remove an item from villager trade

Discussion in 'Plugin Development' started by JjPwN1, Feb 5, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    JjPwN1

    I've searched far and wide for an answer, but I haven't come up with a solution. I want to make a simple feature that removes any experience bottles from a villager trade menu. So, if a player tries to trade with a villager and that villager's trade menu sells exp bottles, the exp bottle trade will be removed. I'm not experienced in the subject of villager trading so that is why I am asking for a solution here. Thanks for any help!
     
  2. Offline

    Krizeh

    Not tested. [​IMG]
     
  3. Offline

    pie_flavor

    @Krizeh getContents() covers the inventory slots, not the trade slots (what shows the item). He's asking for a way to remove the trade, you're offering a way to remove the result when attempting to trade
     
  4. Offline

    Abs0rbed

    @JjPwN1 Just went through the compiled bukkit server, you should be able to do it through NMS. You could cast the Villager to an EntityVillager, or CraftVillager or whatever it's called and then remove the trade normally (or with reflection I guess). The Object that seems to hold it is EntityVillager#bp which is an instance of a MerchantRecipeList, which extends ArrayList. If you need more information, I suggest looking farther into the server code. That was the stuff I found early on, might be a bit more complex with MerchantRecipes and NBTTags, but shouldn't be too bad, I don't think
     
Thread Status:
Not open for further replies.

Share This Page