Java models, HTTP client, and websocket helpers for the Event Alerts API.
gg.eventalerts.sdk:corefor shared models, JSON helpers, and common utilitiesgg.eventalerts.sdk:httpfor the HTTP client and endpoint wrappersgg.eventalerts.sdk:websocketfor the websocket client, handlers, and message envelopes
GSONProvider.GSONincludes adapters forDate,UUID,ObjectId, enums, primitive wrappers, and sets- API models live under
gg.eventalerts.sdk.object EAHTTPwraps the API's HTTP endpointsEAWebSockethandles websocket connection setup, event dispatch, and action sending- Typed websocket envelopes are available through
SocketEvent<T>andSocketAction<T>
Use the smallest module that matches your use case:
dependencies {
implementation("gg.eventalerts.sdk:core:1.0.0")
}dependencies {
implementation("gg.eventalerts.sdk:http:1.0.0")
}dependencies {
implementation("gg.eventalerts.sdk:websocket:1.0.0")
}dependencies {
implementation("gg.eventalerts.sdk:http:1.0.0")
implementation("gg.eventalerts.sdk:websocket:1.0.0")
}core is brought in transitively by http and websocket, so most consumers do not need to declare it directly.
- Java 8
A small example project layout you can copy into your own repository:
repositories {
mavenCentral()
maven("https://repo.srnyx.com/releases/")
maven("https://repo.srnyx.com/snapshots/")
}
dependencies {
implementation("gg.eventalerts.sdk:core:1.0.0")
implementation("gg.eventalerts.sdk:http:1.0.0")
implementation("gg.eventalerts.sdk:websocket:1.0.0")
}public class Main {
public static void main(String[] args) {
// JSON round-trip example
final EAEvent original = EAEvent.getExample();
final String json = GSONProvider.GSON.toJson(original);
final EAEvent parsed = GSONProvider.GSON.fromJson(json, EAEvent.class);
System.out.println("Round-trip title: " + parsed.title);
// HTTP example
final EAHTTP http = new EAHTTP.Builder("EventAlertsExample/1.0").build();
System.out.println(http.events.retrieveMany());
// Websocket example
final EAWebSocket socket = new EAWebSocket.Builder("EventAlertsExample/1.0")
.retry(false)
.handler(new EventPostedHandler() {
@Override
public void onMessage(@NotNull SocketEvent<EAEvent> object) {
System.out.println("Received: " + object.event);
System.out.println("Sequence: " + object.sequence);
System.out.println("Timestamp: " + object.timestamp);
System.out.println("Title: " + object.data.title);
}
})
.build()
.connectBlocking();
socket.send(SocketActionName.PLAYER_CONNECTION, new EAPlayerConnectionAction(
UUID.fromString("00000000-0000-0000-0000-000000000000"),
"srnyx",
new Date(),
EAPlayerConnectionAction.Type.JOIN));
}
}Provides the shared GSONProvider.GSON instance used throughout the SDK. It is configured with adapters for the common API types used by the library.
Contains the common API models used by the Event Alerts API:
EACrossBanEAEventEAEventThreadMessageEAFamousEventEAPartnerServerEAPlayerEAServerApplication
Contains EAHTTP and the typed endpoint wrappers:
EACrossBansEAEventsEAPartnerServersEAPlayersEAServerApplications
Contains the websocket client, event/action enums, and typed handlers.
EAWebSocket automatically updates subscriptions when the socket opens, routes incoming events to registered handlers, and can send typed actions back to the API.
Event handlers extend SocketHandler<T> and receive a typed SocketEvent<T>.
Built-in handler base classes:
BoosterPassGivenHandlerCrossBanHandlerEventCancelledHandlerEventChatHandlerEventPostedHandlerFamousEventPostedHandlerLinkHandlerServerEditedHandlerServerEnabledHandler
Action names are sent directly through EAWebSocket.send(...) using SocketActionName values.
Built-in action names:
PLAYER_CONNECTIONUPDATE_SUBSCRIPTION
Each event envelope contains:
eventsequencetimestampdata
Each action envelope contains:
actiondata
- Serialize or deserialize API models through
GSONProvider.GSON - Use
EAHTTPwhen you want REST endpoints - Use
EAWebSocketwhen you want streaming event handlers - Subclass a built-in websocket handler when you need custom behavior
- Add event handlers to
EAWebSocket.Builder - Connect with
build(),connect(), orbuildThenConnect() - Use
subscribe(...)andunsubscribe(...)to update subscriptions manually - Use
updateSubscriptions()to automatically update based onSocketHandler.shouldSubscribe() - Use
send(...)when you need to push actions