MessageBuilder

A builder class for creating and sending messages with various types, including chat, action bars, titles, and boss bars.

This class allows for building complex messages with conditional filters, chat messages, success/error messages, action bar messages, titles, and even broadcasting messages to all players. You can customize the message's format, apply color, and use placeholders to dynamically replace parts of the message.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
Link copied to clipboard
var target: CommandSender?

Functions

Link copied to clipboard
fun actionbar(message: String): Unit?

Sends an action bar message to the target player.

Link copied to clipboard

Adds a custom text to the message.

fun add(component: TextComponent): MessageBuilder

Adds a custom TextComponent to the message.

Link copied to clipboard
fun bossBar(message: String, color: BarColor = BarColor.BLUE, style: BarStyle = BarStyle.SOLID): BossBar

Creates and returns a BossBar for the target player.

Link copied to clipboard
fun broadcast(message: String)

Sends a broadcast message to all online players.

Link copied to clipboard

Sends a broadcast action bar message to all online players.

Link copied to clipboard
fun broadcastBossBar(message: String, color: BarColor = BarColor.BLUE, style: BarStyle = BarStyle.SOLID): BossBar

Sends a broadcast boss bar message to all online players.

Link copied to clipboard
fun broadcastError(message: String)

Sends a broadcast error message to all online players.

Link copied to clipboard
fun broadcastSuccess(message: String)

Sends a broadcast success message to all online players.

Link copied to clipboard
fun broadcastTitle(title: String, subtitle: String = "", fadeIn: Int = 10, stay: Int = 70, fadeOut: Int = 20)

Sends a broadcast title message to all online players.

Link copied to clipboard
fun chat(message: String): Unit?

Sends a regular chat message to the target.

Link copied to clipboard
fun error(message: String): Unit?

Sends an error message to the target.

Link copied to clipboard
fun filter(predicate: (Player) -> Boolean): MessageBuilder

Adds a filter to only apply the message to players who meet the condition specified in the predicate.

Link copied to clipboard
fun hasGamemode(gamemode: GameMode): MessageBuilder

Adds a filter to only apply the message to a player with the specified game mode.

Link copied to clipboard

Adds a filter to only apply the message to players with the specified permission.

Link copied to clipboard
fun hasPermissions(vararg permissions: String): MessageBuilder

Adds a filter to only apply the message to players who have all specified permissions.

Link copied to clipboard
fun isInWorld(world: World): MessageBuilder

Adds a filter to only apply the message to a player in the specified world.

Link copied to clipboard

Adds a filter to only apply the message to a player with the specified name.

Link copied to clipboard
fun placeholder(message: String, vararg args: Any): String

Replaces placeholders in the message with corresponding values from the arguments.

fun placeholder(message: String, map: Map<String, String>): String

Replaces placeholders in the message with corresponding values from the map.

Link copied to clipboard
fun send()

Sends the constructed message to the target.

Link copied to clipboard
fun success(message: String): Unit?

Sends a success message to the target.

Link copied to clipboard
fun title(title: String, subtitle: String = "", fadeIn: Int = 10, stay: Int = 70, fadeOut: Int = 20): Unit?

Sends a title message to the target player.

Link copied to clipboard
fun to(sender: CommandSender): MessageBuilder

Sets the target of the message to a specific sender (could be player or console).

fun to(player: Player): MessageBuilder

Sets the target of the message to a specific player.