StockAPI
Package: com.skyblockexp.ezshops.api
Overview
StockAPI exposes programmatic access to the EzShops stock market: price queries, programmatic price updates, and player holdings management. Methods are documented as thread-safe.
Constructors
public StockAPI(StockMarketManager stockMarketManager)- created by the plugin when the stock component is enabled.
Key methods
double getStockPrice(String productId)- get current price; validates inputvoid setStockPrice(String productId, double price)- set/override price (price validated)void updateStockPrice(String productId, int demand)- adjust price by demandint getPlayerStockAmount(Player player, String productId)- query player holdingsboolean addPlayerStock(Player player, String productId, int amount)- add to holdingsboolean removePlayerStock(Player player, String productId, int amount)- remove from holdingsList<String> getPlayerOwnedStocks(Player player)- list player’s productsSet<String> getAllProductIds()- list tradable product ids
Usage (short)
StockAPI stock = EzShopsAPI.getInstance().getStockAPI();
if (stock != null) {
double price = stock.getStockPrice("DIAMOND");
stock.updateStockPrice("DIAMOND", 5);
}
Notes
- Methods throw
IllegalArgumentExceptionfor invalid inputs (null/empty productId, null player, non-positive amounts). - Designed to be safe in async contexts; prefer async tasks for bulk operations.