org.bukkit.inventory.MerchantInventory Java Examples

The following examples show how to use org.bukkit.inventory.MerchantInventory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NMSHandler.java    From Shopkeepers with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ItemStack[] getUsedTradingRecipe(MerchantInventory merchantInventory) {
	MerchantRecipe merchantRecipe = merchantInventory.getSelectedRecipe();
	List<ItemStack> ingredients = merchantRecipe.getIngredients();
	ItemStack[] recipe = new ItemStack[3];
	recipe[0] = ingredients.get(0);
	recipe[1] = null;
	if (ingredients.size() > 1) {
		ItemStack buyItem2 = ingredients.get(1);
		if (!Utils.isEmpty(buyItem2)) {
			recipe[1] = buyItem2;
		}
	}
	recipe[2] = merchantRecipe.getResult();
	return recipe;
}
 
Example #2
Source File: NMSHandler.java    From Shopkeepers with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ItemStack[] getUsedTradingRecipe(MerchantInventory merchantInventory) {
	MerchantRecipe merchantRecipe = merchantInventory.getSelectedRecipe();
	List<ItemStack> ingredients = merchantRecipe.getIngredients();
	ItemStack[] recipe = new ItemStack[3];
	recipe[0] = ingredients.get(0);
	recipe[1] = null;
	if (ingredients.size() > 1) {
		ItemStack buyItem2 = ingredients.get(1);
		if (!Utils.isEmpty(buyItem2)) {
			recipe[1] = buyItem2;
		}
	}
	recipe[2] = merchantRecipe.getResult();
	return recipe;
}
 
Example #3
Source File: NMSHandler.java    From Shopkeepers with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ItemStack[] getUsedTradingRecipe(MerchantInventory merchantInventory) {
	try {
		InventoryMerchant handle = (InventoryMerchant) ((CraftInventoryMerchant) merchantInventory).getInventory();
		MerchantRecipe merchantRecipe = handle.getRecipe();
		ItemStack[] recipe = new ItemStack[3];
		recipe[0] = merchantRecipe.getBuyItem1() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem1()) : null;
		recipe[1] = merchantRecipe.getBuyItem2() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem2()) : null;
		recipe[2] = merchantRecipe.getBuyItem3() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem3()) : null;
		return recipe;
	} catch (Exception e) {
		return null;
	}
}
 
Example #4
Source File: NMSHandler.java    From Shopkeepers with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ItemStack[] getUsedTradingRecipe(MerchantInventory merchantInventory) {
	try {
		InventoryMerchant handle = (InventoryMerchant) ((CraftInventoryMerchant) merchantInventory).getInventory();
		MerchantRecipe merchantRecipe = handle.getRecipe();
		ItemStack[] recipe = new ItemStack[3];
		recipe[0] = merchantRecipe.getBuyItem1() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem1()) : null;
		recipe[1] = merchantRecipe.getBuyItem2() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem2()) : null;
		recipe[2] = merchantRecipe.getBuyItem3() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem3()) : null;
		return recipe;
	} catch (Exception e) {
		return null;
	}
}
 
Example #5
Source File: NMSHandler.java    From Shopkeepers with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ItemStack[] getUsedTradingRecipe(MerchantInventory merchantInventory) {
	try {
		InventoryMerchant handle = (InventoryMerchant) ((CraftInventoryMerchant) merchantInventory).getInventory();
		MerchantRecipe merchantRecipe = handle.getRecipe();
		ItemStack[] recipe = new ItemStack[3];
		recipe[0] = merchantRecipe.getBuyItem1() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem1()) : null;
		recipe[1] = merchantRecipe.getBuyItem2() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem2()) : null;
		recipe[2] = merchantRecipe.getBuyItem3() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem3()) : null;
		return recipe;
	} catch (Exception e) {
		return null;
	}
}
 
Example #6
Source File: NMSHandler.java    From Shopkeepers with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ItemStack[] getUsedTradingRecipe(MerchantInventory merchantInventory) {
	try {
		InventoryMerchant handle = (InventoryMerchant) ((CraftInventoryMerchant) merchantInventory).getInventory();
		MerchantRecipe merchantRecipe = handle.getRecipe();
		ItemStack[] recipe = new ItemStack[3];
		recipe[0] = merchantRecipe.getBuyItem1() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem1()) : null;
		recipe[1] = merchantRecipe.getBuyItem2() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem2()) : null;
		recipe[2] = merchantRecipe.getBuyItem3() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem3()) : null;
		return recipe;
	} catch (Exception e) {
		return null;
	}
}
 
Example #7
Source File: NMSHandler.java    From Shopkeepers with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ItemStack[] getUsedTradingRecipe(MerchantInventory merchantInventory) {
	try {
		InventoryMerchant handle = (InventoryMerchant) ((CraftInventoryMerchant) merchantInventory).getInventory();
		MerchantRecipe merchantRecipe = handle.getRecipe();
		ItemStack[] recipe = new ItemStack[3];
		recipe[0] = merchantRecipe.getBuyItem1() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem1()) : null;
		recipe[1] = merchantRecipe.getBuyItem2() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem2()) : null;
		recipe[2] = merchantRecipe.getBuyItem3() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem3()) : null;
		return recipe;
	} catch (Exception e) {
		return null;
	}
}
 
Example #8
Source File: NMSHandler.java    From Shopkeepers with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ItemStack[] getUsedTradingRecipe(MerchantInventory merchantInventory) {
	try {
		InventoryMerchant handle = (InventoryMerchant) ((CraftInventoryMerchant) merchantInventory).getInventory();
		MerchantRecipe merchantRecipe = handle.getRecipe();
		ItemStack[] recipe = new ItemStack[3];
		recipe[0] = merchantRecipe.getBuyItem1() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem1()) : null;
		recipe[1] = merchantRecipe.getBuyItem2() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem2()) : null;
		recipe[2] = merchantRecipe.getBuyItem3() != null ? CraftItemStack.asBukkitCopy(merchantRecipe.getBuyItem3()) : null;
		return recipe;
	} catch (Exception e) {
		return null;
	}
}
 
Example #9
Source File: FailedHandler.java    From Shopkeepers with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ItemStack[] getUsedTradingRecipe(MerchantInventory merchantInventory) {
	try {
		Object inventoryMerchant = craftInventoryGetInventory.invoke(merchantInventory);
		Object merchantRecipe = getRecipeMethod.invoke(inventoryMerchant);
		ItemStack[] recipe = new ItemStack[3];
		recipe[0] = asBukkitCopy(getBuyItem1Method.invoke(merchantRecipe));
		recipe[1] = asBukkitCopy(getBuyItem2Method.invoke(merchantRecipe));
		recipe[2] = asBukkitCopy(getBuyItem3Method.invoke(merchantRecipe));
		return recipe;
	} catch (Exception e) {
		return null;
	}
}
 
Example #10
Source File: TradingHandler.java    From Shopkeepers with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isWindow(Inventory inventory) {
	return inventory instanceof MerchantInventory;
}
 
Example #11
Source File: NMSCallProvider.java    From Shopkeepers with GNU General Public License v3.0 votes vote down vote up
public ItemStack[] getUsedTradingRecipe(MerchantInventory merchantInventory);