GrzybcioRynek

MarketAPI (for developers)

Public Java plugin API — listing reads and mutations only from the main thread.

Compatible with: GrzybcioRynek 1.0.3Minecraft 26.2Web 0.1.0

Based on GrzybcioRynek 1.0.3 and web 0.1.0 source.

com.example.marketplace.api.MarketAPI is the only public API for other plugins. Init: MarketAPI.init(this) at the end of finishEnable(). HTTP does not exist.

Full method list: Java MarketAPI. Events: Events.

Readiness

java
if (!MarketAPI.isReady()) {
    // plugin == null or !plugin.isEnabled()
}

Every method except isReady() and getCategories() calls ensure():

text
IllegalStateException: GrzybcioRynek API nie jest gotowe

getCategories() returns MarketCategory.values() without ensure() — works even when the plugin is not ready.

Mutations — main thread

removeListing(int, Player) and sellItem(Player, ItemStack, double) call ensureMainThread():

text
IllegalStateException: MarketAPI mutacje muszą być wywoływane z głównego wątku serwera

Reads (getListings, search, getTransaction, …) do not assert the thread, but should still run on the main thread — storage is not meant for free multi-threading.

Mapping to the core

MarketAPIImplementation
getListings()StorageManager.getAllListings() (list copy)
getListing(int)StorageManager.getListing
getListingsBySeller(UUID)StorageManager.getListingsBySeller
search(String)ListingQueryService.query — category ALL, sort NEWEST
removeListingMarketManager.removeListing
sellItemMarketManager.sellItem (item must be in hand)
getCompletedTransactions()ExtendedDataStore — only COMPLETED
getTransaction(String)map by UUID-string
getActiveListingsCount()StatsManager.getActiveListings()
getMarketVolume()StatsManager.getTotalVolume() (sum of completed price)
Example
java
if (MarketAPI.isReady()) {
    MarketListing listing = MarketAPI.getListing(12);
    boolean ok = MarketAPI.removeListing(12, admin);
}

No methods for: buy, refund, mailbox, alerts, ratings. Those stay in MarketManager / services.