-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPrivateMessageEvent.java
More file actions
129 lines (111 loc) · 3.25 KB
/
PrivateMessageEvent.java
File metadata and controls
129 lines (111 loc) · 3.25 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package simplexity.simplepms.events;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.Set;
/**
* Called when a private message is sent
*/
@SuppressWarnings("unused")
public class PrivateMessageEvent extends Event implements Cancellable {
private final CommandSender initiator;
private final CommandSender recipient;
private final String messageContent;
private final HashSet<Player> spyingPlayers;
private boolean cancelled;
private static final HandlerList handlers = new HandlerList();
public PrivateMessageEvent(@NotNull CommandSender initiator, @NotNull CommandSender recipient, @NotNull String messageContent, @NotNull Set<Player> spyingPlayers) {
this.initiator = initiator;
this.recipient = recipient;
this.messageContent = messageContent;
this.spyingPlayers = spyingPlayers;
}
/**
* Gets the CommandSender who sent the message.
*
* @return CommandSender
*/
public CommandSender getInitiator() {
return initiator;
}
/**
* Sets which CommandSender will start this message.
* Expected types are either a Player or a ConsoleCommandSender
* Using other types of CommandSender may lead to unexpected and unsupported behavior
*
* @param initiator CommandSender
*/
public void setInitiator(CommandSender initiator) {
this.initiator = initiator;
}
/**
* Gets the CommandSender who is to receive the message
*
* @return CommandSender
*/
public CommandSender getRecipient() {
return recipient;
}
/**
* Sets which CommandSender will receive this message.
* Expected types are either a Player or a ConsoleCommandSender
* Using other types of CommandSender may lead to unexpected and unsupported behavior
*
* @param recipient CommandSender
*/
public void setRecipient(CommandSender recipient) {
this.recipient = recipient;
}
/**
* Gets the message that is going to be sent from this event
*
* @return String message
*/
public String getMessageContent() {
return messageContent;
}
/**
* Gets the list of players who currently have SocialSpy toggled on
*
* @return {@code Set<Player>}
*/
public Set<Player> getSpyingPlayers() {
return Collections.unmodifiableSet(spyingPlayers);
}
/**
* Checks whether this event has been cancelled
*
* @return boolean
*/
public boolean isCancelled() {
return cancelled;
}
/**
* Sets whether this event should be cancelled
*
* @param cancel boolean
*/
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
/**
* Gets the handlerList for this event
*
* @return HandlerList
*/
public @NotNull HandlerList getHandlers() {
return handlers;
}
/**
* Gets the handlerList for this event
*
* @return HandlerList
*/
public static HandlerList getHandlerList() {
return handlers;
}
}