Updated Events (markdown)

TheMode 2020-05-04 11:21:23 +02:00
parent 5e9627f9c3
commit 4e747156e4
1 changed files with 14 additions and 1 deletions

@ -1,3 +1,5 @@
## Listen to events
Events are everywhere, they are as simple as
```java
player.addEventCallback(EVENT_CLASS, event -> {
@ -16,7 +18,18 @@ for example
});
```
Basics events are listed [here](https://github.com/Minestom/Minestom/tree/master/src/main/java/net/minestom/server/event) but nothing prevents you from creating your own.
Basics events are listed [here](https://github.com/Minestom/Minestom/tree/master/src/main/java/net/minestom/server/event)
The recommended way of how and where to put the listeners is by using ConnectionManager#addPlayerInitialization, it is basically called just after the player object to be created
```java
connectionManager.addPlayerInitialization(player -> {
// Do what you want with the player
// player.addEventCallback ...
});
```
## Create a custom event
In order to do so, you need a class which extends Event or CancellableEvent and finally call it by doing
```java