-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathExampleModEvents.java
More file actions
34 lines (25 loc) · 1.13 KB
/
ExampleModEvents.java
File metadata and controls
34 lines (25 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package examplemod.Loaders;
import examplemod.examples.events.ExampleEvent;
import examplemod.examples.events.ExampleLevelEvent;
import necesse.engine.GameEventListener;
import necesse.engine.GameEvents;
import necesse.engine.network.server.ServerClient;
import necesse.engine.registries.LevelEventRegistry;
public class ExampleModEvents {
public static void load() {
// Register our Level Event to the registry
LevelEventRegistry.registerEvent("examplelevelevent", ExampleLevelEvent.class);
// Register our ExampleEvent Listener
GameEvents.addListener(ExampleEvent.class, new GameEventListener<ExampleEvent>() {
@Override
public void onEvent(ExampleEvent event) {
if (event.level == null || !event.level.isServer()) return;
ServerClient client = event.level.getServer().getClient(event.clientSlot);
if (client != null) {
client.sendChatMessage(event.message);
client.sendChatMessage("PONG: this message was sent from the ExampleEvent Listener ");
}
}
});
}
}