Eventy API
Trzy nieanulowalne eventy Bukkit — utworzenie oferty, usunięcie i zakończona transakcja.
Kompatybilne z: GrzybcioRynek 1.0.3Minecraft 26.2Web 0.1.0
Na podstawie kodu GrzybcioRynek 1.0.3 i web 0.1.0.
Pakiet: com.example.marketplace.api.event. Standardowe Bukkit Event + HandlerList. Żaden nie jest Cancellable.
ListingCreatedEvent
Emisja: po udanym wystawieniu w MarketManager.sellItem.
java
public MarketListing getListing();ListingRemovedEvent
Emisja: removeListing i forceExpire.
java
public MarketListing getListing();
public String getReason();Powody w kodzie:
reason | Kiedy |
|---|---|
"removed" | usunął właściciel |
"admin-removed" | usunął admin |
"force-expire" | /market admin forceexpire |
Timer wygaśnięć (30 min) nie woła tego eventu.
TransactionCompletedEvent
Emisja: tylko po commicie zakupu (COMPLETED).
java
public MarketTransaction getTransaction();Brak eventów dla FAILED, ROLLED_BACK i refundu (error = REFUND:<timestamp>).
Rejestracja
Example
java
public final class MarketListener implements Listener {
@EventHandler
public void onCreate(ListingCreatedEvent event) {
int id = event.getListing().getId();
}
@EventHandler
public void onRemove(ListingRemovedEvent event) {
String reason = event.getReason();
}
@EventHandler
public void onDone(TransactionCompletedEvent event) {
String txId = event.getTransaction().getId();
}
}Wyjątek w listenerze nie cofa oferty ani zakupu — plugin loguje warning i idzie dalej.