This repository was archived by the owner on Aug 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathChannelMessageEvent.java
More file actions
106 lines (94 loc) · 3.06 KB
/
ChannelMessageEvent.java
File metadata and controls
106 lines (94 loc) · 3.06 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
package com.github.rmsy.channels.event;
import com.github.rmsy.channels.Channel;
import com.github.rmsy.channels.ChannelsEvent;
import com.google.common.base.Preconditions;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import javax.annotation.Nullable;
/** Raised when a message is sent to a channel. */
public final class ChannelMessageEvent extends ChannelsEvent implements Cancellable {
/** The handlers for the event. */
private static final HandlerList handlers = new HandlerList();
/** The {@link Channel} to which the message was sent. */
private final Channel channel;
/** The message sender, or null for console. */
private @Nullable final Player sender;
/** The message to be sent. */
private BaseComponent message;
/** Whether or not the event is cancelled. */
private boolean cancelled = false;
/**
* Creates a new ChannelMessageEvent.
*
* @param message The message.
* @param sender The sender, or null for console.
*/
public ChannelMessageEvent(BaseComponent message, @Nullable final Player sender, Channel channel) {
this.message = Preconditions.checkNotNull(message, "message");
this.sender = sender;
this.channel = Preconditions.checkNotNull(channel, "Channel");
}
/**
* Gets the message sender, or null for console.
*
* @return The message sender, or null for console.
*/
public @Nullable Player getSender() {
return this.sender;
}
/**
* Gets the message to be sent.
*
* @return The message to be sent.
*/
public BaseComponent getMessage() {
return message;
}
/**
* Sets the message to be sent.
*
* @param message The message to be sent.
*/
public void setMessage(BaseComponent message) {
this.message = Preconditions.checkNotNull(message, "message");
}
/**
* Gets the {@link Channel} to which this message was sent.
*
* @return The {@link Channel}.
*/
public Channel getChannel() {
return this.channel;
}
/** Gets the handlers for the event. */
@Override
public HandlerList getHandlers() {
return ChannelMessageEvent.handlers;
}
/** Gets the handlers for the event. */
public static HandlerList getHandlerList() {
return ChannelMessageEvent.handlers;
}
/**
* Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still
* pass to other plugins
*
* @return true if this event is cancelled
*/
@Override
public boolean isCancelled() {
return this.cancelled;
}
/**
* Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still
* pass to other plugins.
*
* @param cancel true if you wish to cancel this event
*/
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
}