Listening for Events
AdvancedServerList provides some events that your plugin can listen to.
These events are structurally the same across all platforms, yet still require the usage of Platform-specific APIs due to how some events are registered and handled on some platforms.
The plugin currently offers the following events:
PreServerListSetEvent¶
This event is executed before AdvancedServerList tries to modify the player list.
Methods¶
The following methods are available to use:
Method | Description |
---|---|
getEntry() |
Returns the ProfileEntry that AdvancedServerList should use. |
setEntry(ProfileEntry) |
Sets the ProfileEntry that should be used. |
isCancelled() |
Returns wether this event was cancelled or not. |
setCancelled(boolean) |
Sets the event's cancelled state. |
Notes¶
- Providing
null
as theProfileEntry
forsetEntry(ProfileEntry)
is not allowed. Also, a copy of the providedProfileEntry
is made and used.
PostServerListSetEvent¶
This event is executed after AdvancedServerList completed the server list modifications.
Methods¶
Method | Description |
---|---|
getEntry() |
Returns the ProfileEntry that AdvancedServerList used. |
Notes¶
- The returned
ProfileEntry
is not an actual representation of what is being displayed to the player and rather an instance of values the plugin received. The returned value may also benull
should the Ping Event be cancelled due to things such as an invalid Protocol or thePreServerListSetEvent
being cancelled.
Registering the Events¶
To register an event, please refer to our platforms documentation on how to do this.
What is a ProfileEntry?¶
Both events provide and use a so called ProfileEntry
.
The ProfileEntry
is a record, representing the values of a Server List Profile, meaning all values you can set in the profile configuration (Except condition and priority) will be available as a ProfileEntry
.
It is important to note, that the ProfileEntry
can be a representation of the profiles
option, the global options or a mixture of both.
If you want to create your own instance, you'll need to use the ProfileEntry.Builder
class as the ProfileEntry
is unmodifiable.
A convenience method in the form of builder()
exists to create a Builder instance of the ProfileEntry with its values already pre-set.