GrzybcioRynek

Java MarketAPI

All MarketAPI 1.0.3 methods, exceptions, and main-thread restriction.

Compatible with: GrzybcioRynek 1.0.3Minecraft 26.2Web 0.1.0

Based on GrzybcioRynek 1.0.3 and web 0.1.0 source.

Class: com.example.marketplace.api.MarketAPI (final, private constructor). Code comment: all methods should be called from the Bukkit main thread.

Lifecycle

java
public static void init(MarketPlace marketPlace)  // called by the plugin, do not call from outside
public static boolean isReady()                   // plugin != null && plugin.isEnabled()

Reads

MethodReturnsSource
getListings()List<MarketListing>copy of active listings
getListing(int id)MarketListing or nullby ID
getListingsBySeller(UUID)List<MarketListing>seller listings
search(String query)List<MarketListing>BrowseContext ALL + query + SortMode.NEWEST
getCompletedTransactions()List<MarketTransaction>only state COMPLETED
getTransaction(String id)MarketTransaction or nullUUID-string TX
getActiveListingsCount()intactive listing count
getMarketVolume()doublesum of completed TX price
getCategories()MarketCategory[]MarketCategory.values()without ensure()

search uses ItemSearchUtil (material, pretty name, display, lore, nexo/oraxen ID, seller nick, #id).

Mutations (main thread)

java
public static boolean removeListing(int id, Player actor)
public static boolean sellItem(Player player, ItemStack item, double price)

removeListing — owner or player with market.admin (check in MarketManager). sellItem requires an item in the main hand similar to the passed stack; applies limits, cooldown, listing fee.

There is no buyItem in the API.

Exceptions

text
IllegalStateException: GrzybcioRynek API nie jest gotowe
IllegalStateException: MarketAPI mutacje muszą być wywoływane z głównego wątku serwera

First: every method except isReady() and getCategories(). Second: mutations only.

Example

Example
java
if (!MarketAPI.isReady()) {
    return;
}
List<MarketListing> diamond = MarketAPI.search("diamond");
double volume = MarketAPI.getMarketVolume();
int active = MarketAPI.getActiveListingsCount();

Bukkit events: API events.