ItemStackAPI

ItemStack Price API

This document describes the new API methods for getting sell prices of items using ItemStacks.

Overview

The new API provides methods to:

  • Find ShopItems by ItemStack

  • Get sell prices for ItemStacks

  • Check if items can be sold

  • Get prices with or without player multipliers

Quick Start

// Get the API instance
BShopAPI api = BShopAPI.getInstance();

// Get the price API for easy access
PriceAPI priceAPI = api.getPriceAPI();

// Get sell price for an ItemStack
ItemStack diamond = new ItemStack(Material.DIAMOND);
double sellPrice = priceAPI.getSellPrice(player, diamond, 64);

API Methods

PriceAPI Class

The PriceAPI class provides convenient methods for getting prices:

Getting Sell Prices

Finding Items

Utility Methods

ShopAPI Class

The ShopAPI class provides methods for finding items:

TransactionAPI Class

The TransactionAPI class provides methods for getting prices:

Item Matching

Items are matched based on:

  1. Material: The item type (e.g., DIAMOND, IRON_INGOT)

  2. Custom Model Data: If the shop item has custom model data, the ItemStack must also have the same custom model data

Example Matching

Usage Examples

Basic Price Check

Find Best Price

Get Shop Information

Error Handling

All methods return safe defaults when items are not found:

  • Price methods return 0.0 when item is not found

  • Find methods return Optional.empty() or empty lists when item is not found

  • No exceptions are thrown for missing items

Performance Notes

  • Item matching is done by iterating through all shop items

  • For large shops, consider caching results if called frequently

  • The API uses the existing shop caching system for performance

Example

Last updated