Package co.crystaldev.alpinecore.util
Class Messaging
java.lang.Object
co.crystaldev.alpinecore.util.Messaging
Utility for sending recipients Adventure components.
- Since:
- 0.3.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
actionBar
(@NotNull org.bukkit.command.CommandSender sender, @NotNull net.kyori.adventure.text.Component component) Sends an action bar message to a CommandSender.static void
attemptSend
(@NotNull Collection<org.bukkit.OfflinePlayer> players, @NotNull Function<@NotNull org.bukkit.entity.Player, @Nullable net.kyori.adventure.text.Component> componentFunction) Sends messages to a collection of OfflinePlayers, each customized by a function, if they are currently online.static void
attemptSend
(@NotNull org.bukkit.OfflinePlayer sender, @NotNull net.kyori.adventure.text.Component... components) Sends a message consisting of multiple components to an OfflinePlayer if they are currently online.static void
attemptSend
(@NotNull org.bukkit.OfflinePlayer sender, @Nullable net.kyori.adventure.text.Component component) Sends a message to an OfflinePlayer if they are currently online.static void
broadcast
(@NotNull Collection<org.bukkit.command.CommandSender> senders, @NotNull net.kyori.adventure.text.Component component) Broadcasts a message to a specified collection of CommandSenders.static void
broadcast
(@NotNull net.kyori.adventure.text.Component... components) Broadcasts a message consisting of multiple components to all online players and the console.static void
broadcast
(@NotNull net.kyori.adventure.text.Component component, @NotNull Predicate<org.bukkit.entity.Player> playerPredicate) Broadcasts a message to all online players and the console, with an option to filter recipients.static void
broadcast
(@Nullable net.kyori.adventure.text.Component component) Broadcasts a message to all online players and the console.static void
send
(@NotNull Collection<org.bukkit.command.CommandSender> senders, @NotNull Function<@NotNull org.bukkit.command.CommandSender, @Nullable net.kyori.adventure.text.Component> componentFunction) Sends messages to a collection of CommandSenders, each customized by a function.static void
send
(@NotNull org.bukkit.command.CommandSender sender, @NotNull net.kyori.adventure.text.Component... components) Sends a message consisting of multiple components to the specified CommandSender.static void
send
(@NotNull org.bukkit.command.CommandSender sender, @Nullable net.kyori.adventure.text.Component component) Sends a message to the specified CommandSender.static void
title
(@NotNull org.bukkit.command.CommandSender sender, @NotNull net.kyori.adventure.text.Component title, @NotNull net.kyori.adventure.text.Component subtitle) Sends a title and subtitle to a CommandSender.static @NotNull net.kyori.adventure.audience.Audience
wrap
(@NotNull org.bukkit.command.CommandSender sender) Wraps a CommandSender in an Audience, enabling advanced messaging features.
-
Constructor Details
-
Messaging
public Messaging()
-
-
Method Details
-
send
public static void send(@NotNull @NotNull org.bukkit.command.CommandSender sender, @Nullable @Nullable net.kyori.adventure.text.Component component) Sends a message to the specified CommandSender.- Parameters:
sender
- the recipient of the messagecomponent
- the message to send
-
send
public static void send(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull net.kyori.adventure.text.Component... components) Sends a message consisting of multiple components to the specified CommandSender.- Parameters:
sender
- the recipient of the messagecomponents
- the components to send
-
send
public static void send(@NotNull @NotNull Collection<org.bukkit.command.CommandSender> senders, @NotNull @NotNull Function<@NotNull org.bukkit.command.CommandSender, @Nullable net.kyori.adventure.text.Component> componentFunction) Sends messages to a collection of CommandSenders, each customized by a function.- Parameters:
senders
- the recipients of the messagescomponentFunction
- a function that supplies the message for each sender
-
attemptSend
public static void attemptSend(@NotNull @NotNull org.bukkit.OfflinePlayer sender, @Nullable @Nullable net.kyori.adventure.text.Component component) Sends a message to an OfflinePlayer if they are currently online.- Parameters:
sender
- the intended recipient of the messagecomponent
- the message to send; can be null
-
attemptSend
public static void attemptSend(@NotNull @NotNull org.bukkit.OfflinePlayer sender, @NotNull @NotNull net.kyori.adventure.text.Component... components) Sends a message consisting of multiple components to an OfflinePlayer if they are currently online.- Parameters:
sender
- the intended recipient of the messagecomponents
- the components to send
-
attemptSend
public static void attemptSend(@NotNull @NotNull Collection<org.bukkit.OfflinePlayer> players, @NotNull @NotNull Function<@NotNull org.bukkit.entity.Player, @Nullable net.kyori.adventure.text.Component> componentFunction) Sends messages to a collection of OfflinePlayers, each customized by a function, if they are currently online.- Parameters:
players
- the intended recipients of the messagescomponentFunction
- a function that supplies the message for each player
-
title
public static void title(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull net.kyori.adventure.text.Component title, @NotNull @NotNull net.kyori.adventure.text.Component subtitle) Sends a title and subtitle to a CommandSender.- Parameters:
sender
- the recipient of the title and subtitletitle
- the title componentsubtitle
- the subtitle component
-
actionBar
public static void actionBar(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull net.kyori.adventure.text.Component component) Sends an action bar message to a CommandSender.- Parameters:
sender
- the recipient of the action bar messagecomponent
- the message to send
-
broadcast
public static void broadcast(@Nullable @Nullable net.kyori.adventure.text.Component component) Broadcasts a message to all online players and the console.- Parameters:
component
- the message to broadcast; can be null
-
broadcast
public static void broadcast(@NotNull @NotNull net.kyori.adventure.text.Component... components) Broadcasts a message consisting of multiple components to all online players and the console.- Parameters:
components
- the components to broadcast
-
broadcast
public static void broadcast(@NotNull @NotNull net.kyori.adventure.text.Component component, @NotNull @NotNull Predicate<org.bukkit.entity.Player> playerPredicate) Broadcasts a message to all online players and the console, with an option to filter recipients.- Parameters:
component
- the message to broadcastplayerPredicate
- a predicate to determine which players should receive the message
-
broadcast
public static void broadcast(@NotNull @NotNull Collection<org.bukkit.command.CommandSender> senders, @NotNull @NotNull net.kyori.adventure.text.Component component) Broadcasts a message to a specified collection of CommandSenders.- Parameters:
senders
- the recipients of the messagecomponent
- the message to broadcast
-
wrap
@NotNull public static @NotNull net.kyori.adventure.audience.Audience wrap(@NotNull @NotNull org.bukkit.command.CommandSender sender) Wraps a CommandSender in an Audience, enabling advanced messaging features.- Parameters:
sender
- the CommandSender to wrap- Returns:
- an Audience representing the wrapped CommandSender
-