generated from srnyx/plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
ExampleListener.java
49 lines (41 loc) · 1.37 KB
/
ExampleListener.java
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
package xyz.srnyx.annoyingexample;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.jetbrains.annotations.NotNull;
import xyz.srnyx.annoyingapi.AnnoyingListener;
import xyz.srnyx.annoyingapi.AnnoyingMessage;
import xyz.srnyx.annoyingapi.events.PlayerDamageByPlayerEvent;
/**
* Example of a {@link AnnoyingListener} implementation
*/
public class ExampleListener implements AnnoyingListener {
/**
* {@link ExamplePlugin} instance
*/
private final ExamplePlugin plugin;
/**
* Constructor for the {@link ExampleListener} class
*
* @param plugin the {@link ExamplePlugin} instance
*/
public ExampleListener(@NotNull ExamplePlugin plugin) {
this.plugin = plugin;
}
@Override @NotNull
public ExamplePlugin getPlugin() {
return plugin;
}
/**
* Called when a player joins a server
*
* @param event the {@link PlayerJoinEvent} event
*/
@EventHandler
public void onPlayerDamageByPlayer(@NotNull PlayerDamageByPlayerEvent event) {
new AnnoyingMessage(plugin, "attack")
.replace("%damager%", event.getDamager().getName())
.replace("%damagee%", event.getDamagee().getName())
.replace("%damage%", event.getDamage())
.broadcast(AnnoyingMessage.BroadcastType.CHAT);
}
}