Class MessageSender
- Direct Known Subclasses:
PaperMessageSender
,SpigotMessageSender
Allows definition of a plugin prefix, Message color, Error color.
Allows sending of messages, error messages, titles.
Allows sending of automatically localized messages in combination with a created localizer.
- Since:
- 1.0.0
-
Constructor Summary
ConstructorDescriptionMessageSender
(Plugin plugin, net.kyori.adventure.text.minimessage.MiniMessage miniMessage, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver messageTagResolver, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver errorTagResolver, net.kyori.adventure.text.Component prefix) -
Method Summary
Modifier and TypeMethodDescriptionprotected net.kyori.adventure.text.Component
applyPrefix
(net.kyori.adventure.text.Component component) abstract net.kyori.adventure.audience.Audience
asAudience
(Player player) abstract void
static MessageSenderBuilder
protected net.kyori.adventure.text.minimessage.tag.resolver.TagResolver
static MessageSender
getPluginMessageSender
(@NotNull Class<? extends Plugin> plugin) Get the message sender created for this plugin.static MessageSender
getPluginMessageSender
(@NotNull Plugin plugin) Get the message sender created for this plugin.abstract void
hideBossBar
(Player player, net.kyori.adventure.bossbar.BossBar bossBar) boolean
protected net.kyori.adventure.text.minimessage.tag.resolver.TagResolver
net.kyori.adventure.text.minimessage.MiniMessage
protected Plugin
plugin()
net.kyori.adventure.text.Component
prefix()
static void
register
(MessageSender messageSender) abstract void
sendActionBar
(Player player, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) Send a localized action bar to a playerabstract net.kyori.adventure.bossbar.BossBar
sendBossBar
(Player player, String message, float progress, net.kyori.adventure.bossbar.BossBar.Color color, net.kyori.adventure.bossbar.BossBar.Overlay overlay, Set<net.kyori.adventure.bossbar.BossBar.Flag> flags) abstract void
sendBossBar
(Player player, net.kyori.adventure.bossbar.BossBar bossBar) void
sendError
(CommandSender sender, IMessageComposer composer) Sends an error to a sendervoid
sendError
(CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) Sends an error to a senderabstract void
sendErrorActionBar
(Player player, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) Send a localized action bar to a playervoid
sendMessage
(CommandSender sender, IMessageComposer composer) Send a message to a sendervoid
sendMessage
(CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) Send a message to a senderabstract void
sendMessage
(CommandSender sender, net.kyori.adventure.text.Component component) void
sendTitle
(Player player, String title, String subtitle, net.kyori.adventure.title.Title.Times times, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) Send a localized title to a playerabstract void
Send a title to a playerprotected net.kyori.adventure.text.Component
serialize
(CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver resolver, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) net.kyori.adventure.text.Component
serializeError
(@Nullable CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) net.kyori.adventure.text.Component
serializeError
(String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) net.kyori.adventure.text.Component
serializeMessage
(@Nullable CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) net.kyori.adventure.text.Component
serializeMessage
(String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) translatePlain
(@Nullable CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... replacements) translatePlain
(String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... replacements)
-
Constructor Details
-
MessageSender
public MessageSender(Plugin plugin, net.kyori.adventure.text.minimessage.MiniMessage miniMessage, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver messageTagResolver, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver errorTagResolver, net.kyori.adventure.text.Component prefix)
-
-
Method Details
-
register
-
getPluginMessageSender
Get the message sender created for this plugin.- Parameters:
plugin
- plugin- Returns:
- message sender of plugin or default sender if plugin is null
-
builder
-
getPluginMessageSender
public static MessageSender getPluginMessageSender(@NotNull @NotNull Class<? extends Plugin> plugin) Get the message sender created for this plugin.- Parameters:
plugin
- plugin- Returns:
- message sender of plugin or default sender if plugin is null
-
sendMessage
public void sendMessage(CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) Send a message to a senderThe message will be localized if a localizer is available and a locale code is detected.
The message can be a simple locale code in the format "code.code....".
- Parameters:
sender
- receiver of the messagemessage
- message with optional color codes
-
sendMessage
Send a message to a senderThe message will be localized if a localizer is available and a locale code is detected.
The message can be a simple locale code in the format "code.code....".
- Parameters:
sender
- receiver of the messagecomposer
- message composer
-
sendError
public void sendError(CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) Sends an error to a senderThe message will be localized if a localizer is available and a locale code is detected.
The message can be a simple locale code in the format "code.code....".
- Parameters:
sender
- receiver of the messagemessage
- message with optional color codes
-
sendError
Sends an error to a senderThe message will be localized if a localizer is available and a locale code is detected.
The message can be a simple locale code in the format "code.code....".
- Parameters:
sender
- receiver of the messagecomposer
- message composer
-
sendMessage
public abstract void sendMessage(CommandSender sender, net.kyori.adventure.text.Component component) -
broadcast
-
sendTitle
public void sendTitle(Player player, String title, String subtitle, net.kyori.adventure.title.Title.Times times, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) Send a localized title to a player- Parameters:
player
- player to sendtitle
- title to send
-
sendTitle
Send a title to a player- Parameters:
player
- player to sendtitle
- title to send
-
sendActionBar
public abstract void sendActionBar(Player player, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) Send a localized action bar to a player- Parameters:
player
- player to sendmessage
- message to send
-
sendErrorActionBar
public abstract void sendErrorActionBar(Player player, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) Send a localized action bar to a player- Parameters:
player
- player to sendmessage
- message to send
-
sendBossBar
-
sendBossBar
-
hideBossBar
-
serialize
protected net.kyori.adventure.text.Component serialize(CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver resolver, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) -
prefix
public net.kyori.adventure.text.Component prefix() -
applyPrefix
protected net.kyori.adventure.text.Component applyPrefix(net.kyori.adventure.text.Component component) -
translatePlain
-
translatePlain
public String translatePlain(@Nullable @Nullable CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... replacements) -
serializeMessage
public net.kyori.adventure.text.Component serializeMessage(String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) -
serializeMessage
public net.kyori.adventure.text.Component serializeMessage(@Nullable @Nullable CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) -
serializeError
public net.kyori.adventure.text.Component serializeError(String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) -
serializeError
public net.kyori.adventure.text.Component serializeError(@Nullable @Nullable CommandSender sender, String message, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... placeholder) -
miniMessage
public net.kyori.adventure.text.minimessage.MiniMessage miniMessage() -
isAnonymous
public boolean isAnonymous() -
messageTagResolver
protected net.kyori.adventure.text.minimessage.tag.resolver.TagResolver messageTagResolver() -
errorTagResolver
protected net.kyori.adventure.text.minimessage.tag.resolver.TagResolver errorTagResolver() -
plugin
-
asAudience
-