Package net.storm.sdk.game
Class Prices
java.lang.Object
net.storm.sdk.game.Prices
Provides static utility methods for retrieving item prices.
This class uses a caching mechanism to efficiently look up item prices,
with prices automatically refreshing after 5 minutes.
Prices are retrieved from the item manager and cached to reduce repeated lookups for the same items. The cache automatically expires entries after 5 minutes to ensure prices stay relatively current.
Example usage:
// Get the price of an item by ID
int dragonScimitarId = 4587;
int price = Prices.getItemPrice(dragonScimitarId);
if (price > 0) {
System.out.println("Dragon scimitar price: " + price + " gp");
} else if (price == -1) {
System.out.println("Failed to fetch price");
}
// Calculate total value of items
int totalValue = 0;
for (Item item : inventory.getItems()) {
int itemPrice = Prices.getItemPrice(item.getId());
if (itemPrice > 0) {
totalValue += itemPrice * item.getQuantity();
}
}
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intgetItemPrice(int id) Gets the Grand Exchange price of an item by its ID.
-
Constructor Details
-
Prices
public Prices()
-
-
Method Details
-
getItemPrice
public static int getItemPrice(int id) Gets the Grand Exchange price of an item by its ID. Prices are cached for 5 minutes to improve performance.The price lookup is performed on the client thread if not already cached, so this method may block briefly on first lookup for a new item.
- Parameters:
id- the item ID to look up- Returns:
- the item price in gold pieces, or
-1if the price could not be retrieved
-