Events

This guide will show you how to trigger custom events using the Java SDK.

You can send custom events to Analyse by using the track method of the AnalysePlayer interface, which takes an instance of PlayerEvent (or multiple).

The PlayerEvent class takes an id and an origin as parameters. The ID is a unique identifier for the event, and the origin is the name of the plugin that is sending the event. The origin is used to identify the plugin that is sending the event, and is displayed in the Analyse dashboard.

Example Usage

PlayerEvent playerEvent = new PlayerEvent("kill_mob", "ExamplePlugin")
    .withMetadata("mob_type", "ZOMBIE")
    .withMetadata("mob_name", "Walking Dead")
    .withMetadata("mob_health", 10);
    
player.track(playerEvent);

You can also add metadata to the event by using the withMetadata method. This method takes a key and a value as parameters, returning the PlayerEventinstance - allowing you to chain multiple calls to the method.

Last updated