SPIGOT-2272: Add API for virtual Merchants
By: Lukas Hennig <lukas@wirsindwir.de>
This commit is contained in:
@@ -3,6 +3,7 @@ package org.bukkit.entity;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.MainHand;
|
||||
import org.bukkit.inventory.Merchant;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
@@ -117,6 +118,19 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, Permissible, Inv
|
||||
*/
|
||||
public InventoryView openMerchant(Villager trader, boolean force);
|
||||
|
||||
/**
|
||||
* Starts a trade between the player and the merchant.
|
||||
*
|
||||
* Note that only one player may trade with a merchant at once. You must use
|
||||
* the force parameter for this.
|
||||
*
|
||||
* @param merchant The merchant to trade with. Cannot be null.
|
||||
* @param force whether to force the trade even if another player is trading
|
||||
* @return The newly opened inventory view, or null if it could not be
|
||||
* opened.
|
||||
*/
|
||||
public InventoryView openMerchant(Merchant merchant, boolean force);
|
||||
|
||||
/**
|
||||
* Force-closes the currently open inventory view for this player, if any.
|
||||
*/
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package org.bukkit.entity;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.MerchantRecipe;
|
||||
import org.bukkit.inventory.Merchant;
|
||||
|
||||
/**
|
||||
* Represents a villager NPC
|
||||
*/
|
||||
public interface Villager extends Ageable, NPC, InventoryHolder {
|
||||
public interface Villager extends Ageable, NPC, InventoryHolder, Merchant {
|
||||
|
||||
/**
|
||||
* Gets the current profession of this villager.
|
||||
@@ -24,48 +23,6 @@ public interface Villager extends Ageable, NPC, InventoryHolder {
|
||||
*/
|
||||
public void setProfession(Profession profession);
|
||||
|
||||
/**
|
||||
* Get a list of trades currently available from this villager.
|
||||
*
|
||||
* @return an immutable list of trades
|
||||
*/
|
||||
List<MerchantRecipe> getRecipes();
|
||||
|
||||
/**
|
||||
* Set the list of trades currently available from this villager.
|
||||
* <br>
|
||||
* This will not change the selected trades of players currently trading
|
||||
* with this villager.
|
||||
*
|
||||
* @param recipes a list of recipes
|
||||
*/
|
||||
void setRecipes(List<MerchantRecipe> recipes);
|
||||
|
||||
/**
|
||||
* Get the recipe at a certain index of this villager's trade list.
|
||||
*
|
||||
* @param i the index
|
||||
* @return the recipe
|
||||
* @throws IndexOutOfBoundsException
|
||||
*/
|
||||
MerchantRecipe getRecipe(int i) throws IndexOutOfBoundsException;
|
||||
|
||||
/**
|
||||
* Set the recipe at a certain index of this villager's trade list.
|
||||
*
|
||||
* @param i the index
|
||||
* @param recipe the recipe
|
||||
* @throws IndexOutOfBoundsException
|
||||
*/
|
||||
void setRecipe(int i, MerchantRecipe recipe) throws IndexOutOfBoundsException;
|
||||
|
||||
/**
|
||||
* Get the number of trades this villager currently has available.
|
||||
*
|
||||
* @return the recipe count
|
||||
*/
|
||||
int getRecipeCount();
|
||||
|
||||
/**
|
||||
* Gets this villager's inventory.
|
||||
* <br>
|
||||
@@ -77,21 +34,6 @@ public interface Villager extends Ageable, NPC, InventoryHolder {
|
||||
@Override
|
||||
Inventory getInventory();
|
||||
|
||||
/**
|
||||
* Gets whether this villager is currently trading.
|
||||
*
|
||||
* @return whether the villager is trading
|
||||
*/
|
||||
boolean isTrading();
|
||||
|
||||
/**
|
||||
* Gets the player this villager is trading with, or null if it is not
|
||||
* currently trading.
|
||||
*
|
||||
* @return the trader, or null
|
||||
*/
|
||||
HumanEntity getTrader();
|
||||
|
||||
/**
|
||||
* Gets this villager's riches, the number of emeralds this villager has
|
||||
* been given.
|
||||
|
||||
Reference in New Issue
Block a user