update docs to add playerpreloginevent

This commit is contained in:
sylvessa 2026-03-29 13:05:06 -05:00
parent da2aaf1247
commit 16f01fecc0

View file

@ -10,6 +10,37 @@ Events that implement \ref Minecraft.Server.FourKit.Event.Cancellable "Cancellab
@section player_events Player Events
@subsection playerpreloginevent PlayerPreLoginEvent
\ref Minecraft.Server.FourKit.Event.Player.PlayerPreLoginEvent "PlayerPreLoginEvent" is fired before a player is allowed to join the server. You can inspect the players name and IP address, and cancel the event to prevent them from joining (such as for bans, whitelists, etc).
```csharp
[EventHandler]
public void onPreLogin(PlayerPreLoginEvent e)
{
// block by name
if (e.getName() == "Dumb")
{
e.setCancelled(true);
}
// block by ip
if (e.getAddress().getHostAddress() == "127.0.0.1")
{
e.setCancelled(true);
}
}
```
| Method | Description |
|--------|-------------|
| `getName()` | The player's username attempting to join. |
| `getAddress()` | The \ref Minecraft.Server.FourKit.Net.InetSocketAddress "InetSocketAddress" of the connection. |
| `isCancelled()` | Whether the login is cancelled. |
| `setCancelled(bool)` | Cancel or allow the login. |
> **Cancellable:** Yes
@subsection playerjoinevent PlayerJoinEvent
\ref Minecraft.Server.FourKit.Event.Player.PlayerJoinEvent "PlayerJoinEvent" is fired when a player joins the server. You can read or change the join message that is broadcast to all online players.