Plugin events
ListingCreatedEvent, ListingRemovedEvent, and TransactionCompletedEvent — non-cancellable Bukkit events.
Based on GrzybcioRynek 1.0.3 and web 0.1.0 source.
Three events in com.example.marketplace.api.event. They extend org.bukkit.event.Event — not Cancellable. You cannot block listing / purchase with a listener.
All are fired via Bukkit.getPluginManager().callEvent on the main thread (MarketManager path).
ListingCreatedEvent
After a successful StorageManager.createListing and the success message. AlertService.checkListing is in the same try.
public MarketListing getListing();Exception in a listener: Błąd po utworzeniu oferty (event/alert): <msg> — the listing stays.
ListingRemovedEvent
public MarketListing getListing();
public String getReason();reason | Source |
|---|---|
"removed" | owner removed (/market remove or GUI) |
"admin-removed" | admin removed (/market admin remove or removeListing without owner) |
"force-expire" | /market admin forceexpire |
Natural expiry (30 min timer) does not emit this event — it goes through the expiry outbox.
TransactionCompletedEvent
Only after committed == true (state COMPLETED, TX saved).
public MarketTransaction getTransaction();Exception: Błąd TransactionCompletedEvent: <msg> — the purchase already completed.
There is no event on FAILED / ROLLED_BACK / refund.
Example
@EventHandler
public void onSold(TransactionCompletedEvent event) {
MarketTransaction tx = event.getTransaction();
getLogger().info("TX " + tx.getId() + " price=" + tx.getPrice());
}Fuller TX field description: Java API and MarketManager.