To create an event, you create a new class and implement Event. You can then add as man variables and methods to interact with the event as you like!
Example
/** * Represents a simple ping event. * This is used as an example. */publicclassPingEventextendsEvent {private @NotNullString serverName; /** * Used to create a ping event. * * @param serverName The server that the ping was sent from. */publicPingEvent(@NotNullString serverName) {this.serverName= serverName; } /** * Used to get the name of the server * the event was sent from. * * @return The name of the server. */public @NotNullStringgetServerName() {returnthis.serverName; }}
Listening to Events
When a client calls a PingEvent it will be sent here.
You can also make categories of events with inheritance and listen to the inherited event class!
Calling Events
This event will be sent to all clients. You can then wait for the results the clients have returned.
CompletableResultSet<PingEvent> resultCollection = client.callEvent(newPingEvent("Computer Name"));// Wait for the final result.List<PingEvent> result =resultCollection.waitForFinalResult();