/** * Gets the sell value of the item. * * @param item The item that is being checked. * @return The value of the item. */ public int sellValue(int item) { if (!type.equals(ShopType.BUY_AND_SELL)) { return -1; } else { return payment.sellValue(item); } }
/** * Buys a item from the store. * * @param player The player. * @param item The item to buy. */ public void buyItem(Player player, SlottedItem item) { if (player.getInventory().freeSlots() >= item.getItem().getAmount()) { if (payment.buyItem(player, item)) { player.getInventory().add(item.getItem()); player.send(new UpdateItemsEvent(3823, player.getInventory().getItems())); if (!type.equals(ShopType.UNLIMITED_BUY_ONLY)) { items.remove(item.getItem()); } } } else { player.getInventory().forceCapacityExceeded(); } }
/** * Sells a item to the store. * * @param player The player that is selling this item. * @param slot The item slot. * @param item The item. */ public void sellItem(Player player, Item item) { if (type.equals(ShopType.BUY_AND_SELL)) { if (player.getInventory().contains(item)) { if (payment.sellItem(player, item)) { player.getInventory().remove(item); player.send(new UpdateItemsEvent(3823, player.getInventory().getItems())); items.add(item); } } } else { player.sendMessage("You cannot sell items in this shop."); } }