Pages: Messages

Messages

Colors

You can easily translate color codes by adding .translate() to a string. It supports & color codes, &#RRGGBB hex color codes, and MiniMessage tags.

There are also a few pre-made color methods you can use such as .blue(), .white(), .red(), .green(), .gold(), and more.

Custom tags

On top of the standard MiniMessage tags, SporeAPI adds its own tags so messages share the same look. Use them in any string you turn into a component with .mm().

Colors

TagColor
<s_blue>#1D91FF
<s_red>#F50000
<s_green>#4BFF2F
player.sendMessage("<s_blue>Atlas <white>welcome back!".mm())

Symbols

Symbol tags are replaced by a character, so they don't need a closing tag. They take on the color active at that point in the message.

TagOutput
<s_arrow>»
<s_arrow_left>«
<s_dot>•
<s_pipe>┃
<s_info>Ⓘ
<s_line>━━━━━━━━━━━━━━━━━━━━
player.sendMessage("<s_blue>Staff <s_arrow> <white>Your access has been paused.".mm())
player.sendMessage("<s_dot> <gray>First line<newline><s_dot> <gray>Second line".mm())
player.sendMessage("<gray><s_line>".mm())

Status icons

These icons have a fixed color, so they look the same wherever you use them.

TagOutputColor
<s_check>✔#1D91FF
<s_cross>✘#F50000
<s_warn>⚠#E7FF00
player.sendMessage("<s_check> <white>Account linked.".mm())
player.sendMessage("<s_cross> <white>You don't have permission.".mm())
player.sendMessage("<s_warn> <white>This action cannot be undone.".mm())

Small caps

<s_small_caps> turns the text inside it into small caps. Unlike the symbol tags, it wraps text, so it must be closed.

player.sendMessage("<s_blue><s_small_caps>staff access</s_small_caps> <s_arrow> <white>paused".mm())
// ꜱᴛᴀꜰꜰ ᴀᴄᴄᴇꜱꜱ » paused
  • Other tags inside it keep working, so <s_small_caps>staff <s_red>chat</s_red></s_small_caps> stays colored.
  • Uppercase and lowercase both become small caps, since small caps has no separate capital form.
  • x has no small-cap character and stays a normal x. Digits and symbols are not changed.
  • Everything between the tags is converted, so don't wrap player-written text in it unless you want that.

Escaping player input

Custom tags are parsed like any other MiniMessage tag. If part of a message comes from a player (a reason, a nickname, a chat message), escape it so they can't inject tags:

val reason = MiniMessage.miniMessage().escapeTags(input.take(200))
player.sendMessage("<s_red>Denied <s_arrow> <white>$reason".mm())

Legacy text to MiniMessage

Text that comes from other plugins - LuckPerms prefixes, nicknames, config values - is often written with & color codes (including &#RRGGBB hex). If you drop that straight into a .mm() string, the codes show up as literal text. Convert it first with .legacyToMiniMessage():

val prefix = luckPermsPrefix.legacyToMiniMessage()   // "&c[Admin] " -> "<red>[Admin] "
player.sendMessage("$prefix<white>${player.name}".mm())

Message utility

There are many utility methods for sending messages.

You can call the Message class to access them. Some methods are not shown directly because they are extensions of the Player class.

If you want your success and error messages to start with your plugin name, call Message.init(true) once when your plugin starts.

  • sendBossBar – Send a simple bossbar:

    player.sendBossBar(text, progress)
    

    This shows a blue bossbar. If you want more control (color, style, permissions, auto expiry), check out Boss bars.

  • endTimedBossBar – Send a bossbar that fills up and disappears on its own:

    player.endTimedBossBar(plugin, title, progress, duration)
    
  • sendSuccessMessage – Send a success message with sound:

    player.sendSuccessMessage("Success!")
    // Plays ENTITY_EXPERIENCE_ORB_PICKUP
    
  • sendErrorMessage – Send an error message with sound:

    player.sendErrorMessage("Error!")
    // Plays ENTITY_VILLAGER_NO
    

For actionbars, either use Paper's own player.sendActionBar(message), or use the Action bar helper below if you want to show more than one message at once without them overwriting each other.