mirror of https://github.com/Minestom/Minestom.git
Updated Events (markdown)
parent
5e9627f9c3
commit
4e747156e4
15
Events.md
15
Events.md
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue