Add sendGroupedPacket convenience method to PacketGroupingAudience

This commit is contained in:
BuildTools 2021-06-25 20:32:13 +08:00
parent 6526a2658a
commit d84964d55b

View File

@ -14,6 +14,7 @@ import net.minestom.server.adventure.AdventurePacketConvertor;
import net.minestom.server.entity.Player;
import net.minestom.server.message.ChatPosition;
import net.minestom.server.message.Messenger;
import net.minestom.server.network.packet.server.ServerPacket;
import net.minestom.server.network.packet.server.play.*;
import net.minestom.server.utils.PacketUtils;
import org.jetbrains.annotations.NotNull;
@ -44,6 +45,10 @@ public interface PacketGroupingAudience extends ForwardingAudience {
*/
@NotNull Collection<Player> getPlayers();
default void sendGroupedPacket(ServerPacket packet) {
PacketUtils.sendGroupedPacket(this.getPlayers(), packet);
}
@Override
default void sendMessage(@NotNull Identity source, @NotNull Component message, @NotNull MessageType type) {
Messenger.sendMessage(this.getPlayers(), message, ChatPosition.fromMessageType(type), source.uuid());