Skip to content

Commit

Permalink
add events.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jumpingpxl committed Jul 3, 2024
1 parent e1472f2 commit 1e51056
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
43 changes: 43 additions & 0 deletions docs/pages/server/events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
When using an official platform-implementation of the LabyMod Server API, you can listen to the following events that
are fired by the API:

## LabyModPlayerJoinEvent

The `LabyModPlayerJoinEvent` is fired after a player has sent
the [VersionLoginPacket](/pages/server/labymod/moderation/labymod-version/) to the server.

???+ danger "Important Note"

The `LabyModPlayer` object of the player is not available before this event is fired. It is fired **after** the join event of the respective server platform (f.e. `PlayerJoinEvent` on Bukkit).

The following methods are available in this event:

- `#labyModPlayer()` - Returns the `LabyModPlayer` object of the player.
- `#protocolService()` - Returns the `LabyModProtocolService` instance.

## LabyModPacketSentEvent

The `LabyModPacketSentEvent` is fired **after** a packet has been sent to a player.

The following methods are available in this event:

- `#packet()` - Returns the packet that has been sent.
- `#protocolService()` - Returns the `LabyModProtocolService` instance.
- `#protocol()` - The protocol that the packet has been sent with.
- `#getReceiver()` - Returns the unique id player that the packet has been sent to.
- `#getLabyModPlayer()` - Returns the `LabyModPlayer` object of the player that the packet has been sent to. **Can
be `null` if it's not a LabyMod player.**

## LabyModPacketReceiveEvent

The `LabyModPacketReceiveEvent` is fired **after** a packet has been received from a player (and after all registered
packet handlers have handled the packet).

The following methods are available in this event:

- `#packet()` - Returns the packet that was sent by the player.
- `#protocolService()` - Returns the `LabyModProtocolService` instance.
- `#protocol()` - The protocol that the packet was received on.
- `#getSender()` - Returns the unique id player that has sent the packet.
- `#getLabyModPlayer()` - Returns the `LabyModPlayer` object of the player that has sent the packet. **Can be `null` if
it's not a LabyMod player.**
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ nav:
- Working with Protocols: pages/server/protocols.md
- Creating Packets: pages/server/packets.md
- Creating Integrations: pages/server/integrations.md
- Events: pages/server/events.md
- LabyMod Protocol:
- Overview: pages/server/labymod/overview.md
- Server Displays:
Expand Down

0 comments on commit 1e51056

Please sign in to comment.