mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-21 05:44:17 +00:00
Add BroadcastMessageEvent
This commit is contained in:
parent
6ed0a976e5
commit
0196df734d
1 changed files with 69 additions and 0 deletions
|
@ -0,0 +1,69 @@
|
||||||
|
package org.bukkit.event.server;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event triggered for {@link org.bukkit.Server#broadcast(String, String)}
|
||||||
|
*/
|
||||||
|
public class BroadcastMessageEvent extends ServerEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private String message;
|
||||||
|
private final Set<CommandSender> recipients;
|
||||||
|
private boolean cancelled = false;
|
||||||
|
|
||||||
|
public BroadcastMessageEvent(String message, Set<CommandSender> recipients) {
|
||||||
|
this.message = message;
|
||||||
|
this.recipients = recipients;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message to broadcast
|
||||||
|
*
|
||||||
|
* @return Message to broadcast
|
||||||
|
*/
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the message to broadcast
|
||||||
|
*
|
||||||
|
* @param message Message to broadcast
|
||||||
|
*/
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a set of recipients that this broadcast message will be displayed to.
|
||||||
|
*
|
||||||
|
* @return All CommandSenders who will see this chat message
|
||||||
|
*/
|
||||||
|
public Set<CommandSender> getRecipients() {
|
||||||
|
return recipients;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancelled) {
|
||||||
|
this.cancelled = cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue