Class BlockingEventManager

java.lang.Object
net.storm.sdk.script.blocking_events.BlockingEventManager

public class BlockingEventManager extends Object
Manages a collection of blocking events and their handlers.

The BlockingEventManager maintains a list of BlockingEvent instances and provides methods to add, remove, and customize event handling. By default, it includes handlers for login, welcome screen, and death events.

Custom login response handlers can be registered to handle specific login server responses (e.g., account disabled, world full, etc.).

See Also:
  • Constructor Details

    • BlockingEventManager

      public BlockingEventManager()
      Constructs a new BlockingEventManager with default blocking events.

      By default, the following events are registered:

  • Method Details

    • addLoginResponseHandler

      public void addLoginResponseHandler(LoginEvent.Response response, Function<LoginEvent.Response,Integer> handler)
      Registers a custom handler for a specific login response.

      When the login process encounters the specified response, the provided handler function will be invoked instead of the default behavior.

      Parameters:
      response - the login response to handle
      handler - the handler function that takes the response and returns a sleep duration in milliseconds
    • removeLoginResponseHandler

      public void removeLoginResponseHandler(LoginEvent.Response response)
      Removes a previously registered handler for a specific login response.
      Parameters:
      response - the login response whose handler should be removed
    • getLoginEvent

      public LoginEvent getLoginEvent()
      Retrieves the LoginEvent instance from the registered blocking events.
      Returns:
      the LoginEvent instance, or null if not found
    • remove

      public boolean remove(Class<? extends BlockingEvent> clazz)
      Removes all blocking events of the specified class type.
      Parameters:
      clazz - the class of the blocking event to remove
      Returns:
      true if any events were removed, false otherwise
    • add

      public boolean add(BlockingEvent event)
      Adds a new blocking event to the manager.
      Parameters:
      event - the blocking event to add
      Returns:
      true if the event was added successfully