From 32fa6a62407f44be8a3be8d4309fd8babd547ce6 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sun, 16 Jul 2017 18:44:44 -0500 Subject: [PATCH] Add BroadcastMessageEvent By: BillyGalbreath --- .../event/server/BroadcastMessageEvent.java | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 paper-api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java diff --git a/paper-api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java b/paper-api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java new file mode 100644 index 0000000000..4ddf7eccc1 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java @@ -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 recipients; + private boolean cancelled = false; + + public BroadcastMessageEvent(String message, Set 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 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; + } +}