forked from Minestom/Minestom
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathPlayerPluginMessageEvent.java
More file actions
59 lines (50 loc) · 1.39 KB
/
PlayerPluginMessageEvent.java
File metadata and controls
59 lines (50 loc) · 1.39 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
package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.trait.PlayerInstanceEvent;
import net.minestom.server.network.packet.client.common.ClientPluginMessagePacket;
import org.jetbrains.annotations.NotNull;
import java.nio.charset.StandardCharsets;
/**
* Called when a player send {@link ClientPluginMessagePacket}.
*/
public class PlayerPluginMessageEvent implements PlayerInstanceEvent {
private final Player player;
private final String identifier;
private final byte[] message;
public PlayerPluginMessageEvent(@NotNull Player player, @NotNull String identifier, @NotNull byte[] message) {
this.player = player;
this.identifier = identifier;
this.message = message;
}
/**
* Gets the message identifier.
*
* @return the identifier
*/
@NotNull
public String getIdentifier() {
return identifier;
}
/**
* Gets the message data as a byte array.
*
* @return the message
*/
@NotNull
public byte[] getMessage() {
return message;
}
/**
* Gets the message data as a String.
*
* @return the message
*/
@NotNull
public String getMessageString() {
return new String(message, StandardCharsets.UTF_8);
}
@Override
public @NotNull Player getPlayer() {
return player;
}
}