Class BlockingEventManager
java.lang.Object
net.storm.sdk.script.blocking_events.BlockingEventManager
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 Summary
ConstructorsConstructorDescriptionConstructs a new BlockingEventManager with default blocking events. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(BlockingEvent event) Adds a new blocking event to the manager.voidaddLoginResponseHandler(LoginEvent.Response response, Function<LoginEvent.Response, Integer> handler) Registers a custom handler for a specific login response.Retrieves the LoginEvent instance from the registered blocking events.booleanremove(Class<? extends BlockingEvent> clazz) Removes all blocking events of the specified class type.voidRemoves a previously registered handler for a specific login response.
-
Constructor Details
-
BlockingEventManager
public BlockingEventManager()Constructs a new BlockingEventManager with default blocking events.By default, the following events are registered:
LoginEvent- Handles automatic loginWelcomeScreenEvent- Handles the welcome/play screenDeathEvent- Handles death and respawn interactions
-
-
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 handlehandler- the handler function that takes the response and returns a sleep duration in milliseconds
-
removeLoginResponseHandler
Removes a previously registered handler for a specific login response.- Parameters:
response- the login response whose handler should be removed
-
getLoginEvent
Retrieves the LoginEvent instance from the registered blocking events.- Returns:
- the
LoginEventinstance, ornullif not found
-
remove
Removes all blocking events of the specified class type.- Parameters:
clazz- the class of the blocking event to remove- Returns:
trueif any events were removed,falseotherwise
-
add
Adds a new blocking event to the manager.- Parameters:
event- the blocking event to add- Returns:
trueif the event was added successfully
-