forked from Nukkit/ExamplePlugin
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathExamplePlugin.java
More file actions
64 lines (55 loc) · 2.13 KB
/
ExamplePlugin.java
File metadata and controls
64 lines (55 loc) · 2.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.nukkitx.exampleplugin;
import com.nukkitx.api.Server;
import com.nukkitx.api.event.Listener;
import com.nukkitx.api.event.player.PlayerJoinEvent;
import com.nukkitx.api.event.server.ServerInitializationEvent;
import com.nukkitx.api.event.server.ServerShutdownEvent;
import com.nukkitx.api.event.server.ServerStartEvent;
import com.nukkitx.api.message.TextFormat;
import com.nukkitx.api.message.TipMessage;
import com.nukkitx.api.plugin.Plugin;
import com.nukkitx.api.plugin.PluginDescription;
import com.nukkitx.exampleplugin.generator.DiscoChunkGenerator;
import org.slf4j.Logger;
import javax.inject.Inject;
import java.nio.file.Path;
@Plugin(id = "ExamplePlugin", authors = {"NukkitX Team"}, version = "1.0.0")
public class ExamplePlugin {
private final Logger logger;
private final PluginDescription description;
private final Path dataFolder;
private final Server server;
@Inject
private ExamplePlugin(Logger logger, PluginDescription description, Path dataFolder, Server server) {
this.logger = logger;
this.description = description;
this.dataFolder = dataFolder;
this.server = server;
}
/*
* This event is called before the server has fully loaded.
*/
@Listener
public void onInitialization(ServerInitializationEvent event) {
logger.info(TextFormat.DARK_GREEN + description.getId() + " initialization!");
server.getGeneratorRegistry().register("DISCO", DiscoChunkGenerator::new);
}
/*
* This event is called after the server is fully loaded.
*/
@Listener
public void onStart(ServerStartEvent event) {
logger.info(TextFormat.GREEN + description.getId() + " started!");
}
/*
* This event is called before the server has fully shuts down.
*/
@Listener
public void onShutdown(ServerShutdownEvent event) {
logger.info(TextFormat.DARK_RED + description.getId() + " shutting down!");
}
@Listener
public void onJoin(PlayerJoinEvent event) {
event.setJoinMessage(new TipMessage("Welcome to the test server! This is experimental server software so there may be bugs."));
}
}