Class TradeEvent

java.lang.Object
org.bukkit.event.Event
com.olziedev.playertrade.api.events.TradeEvent
All Implemented Interfaces:
Cancellable
Direct Known Subclasses:
ExpansionEvent, PlayerTradeItemEvent, PlayerTradeMenuEvent, TradeUpdateEvent

public abstract class TradeEvent extends Event implements Cancellable
Handles all the basic and common methods for events.
  • Constructor Details

    • TradeEvent

      public TradeEvent()
    • TradeEvent

      public TradeEvent(boolean isAsync)
      Parameters:
      isAsync - If the event is triggered as async.
  • Method Details

    • postEvent

      public void postEvent(Runnable runnable)
      This method is called when the event is finished without having to rely on waiting a tick.
      Parameters:
      runnable - The runnable that is run when the event has finished.
    • postEvent

      public void postEvent()
      Deprecated.
      Internal use only, do not use under any circumstances!
      Runs all the waiting post event callbacks.
    • waitForCallback

      public void waitForCallback(boolean waitForCall)
      This method allows you to wait for the plugins event to continue after you call acceptCallback(). This is useful if you want your event to run async tasks and wait for them to finish before continuing the event.
      Parameters:
      waitForCall - If the event should wait for the callback to be accepted.
    • isWaitingForCallback

      public boolean isWaitingForCallback()
      Returns:
      If the event is waiting for the callback to be accepted, check waitForCallback(boolean).
    • acceptCallback

      public void acceptCallback()
      Accepts the callback, this then lets the event continue.
    • setEventCallback

      public void setEventCallback(Runnable runnable)
      Deprecated.
      Internal use only, do not use under any circumstances!
      Parameters:
      runnable - The callback that is run when acceptCallback() is called.
    • getPlayerTradeAPI

      public PlayerTradeAPI getPlayerTradeAPI()
      Returns:
      The API instance.
    • setCancelled

      public void setCancelled(boolean cancelled)
      Specified by:
      setCancelled in interface Cancellable
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface Cancellable
    • callEvent

      public static <T extends TradeEvent> void callEvent(T event, Consumer<T> callback, boolean runCallEvent)
      Calls the event and runs the callback.
      Type Parameters:
      T - The event type.
      Parameters:
      event - The event to call.
      callback - The callback to run when the event is called.
      runCallEvent - If the event should be called.