cn.nukkit.event.player.PlayerChatEvent Maven / Gradle / Ivy
package cn.nukkit.event.player;
import cn.nukkit.Player;
import cn.nukkit.Server;
import cn.nukkit.command.CommandSender;
import cn.nukkit.event.Cancellable;
import cn.nukkit.event.HandlerList;
import cn.nukkit.permission.Permissible;
import java.util.HashSet;
import java.util.Set;
public class PlayerChatEvent extends PlayerMessageEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlers() {
return handlers;
}
protected String format;
protected Set recipients = new HashSet<>();
public PlayerChatEvent(Player player, String message) {
this(player, message, "chat.type.text", null);
}
public PlayerChatEvent(Player player, String message, String format, Set recipients) {
this.player = player;
this.message = message;
this.format = format;
if (recipients == null) {
for (Permissible permissible : Server.getInstance().getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_USERS)) {
if (permissible instanceof CommandSender) {
this.recipients.add((CommandSender) permissible);
}
}
} else {
this.recipients = recipients;
}
}
/**
* Changes the player that is sending the message
*
* @param player messenger
*/
public void setPlayer(Player player) {
this.player = player;
}
public String getFormat() {
return this.format;
}
public void setFormat(String format) {
this.format = format;
}
public Set getRecipients() {
return this.recipients;
}
public void setRecipients(Set recipients) {
this.recipients = recipients;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy