Class MarketEvent

java.lang.Object
org.bukkit.event.Event
com.olziedev.nightmarket.api.events.MarketEvent
All Implemented Interfaces:
Cancellable
Direct Known Subclasses:
ExpansionEvent, NightMarketItemEvent, NightMarketMenuEvent

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

    • MarketEvent

      public MarketEvent()
    • MarketEvent

      public MarketEvent(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.
    • getNightMarketAPI

      public NightMarketAPI getNightMarketAPI()
      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 MarketEvent> 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.