Package com.winterhavenmc.library.messagebuilder


package com.winterhavenmc.library.messagebuilder
The core package of MessageBuilderLib, a library designed to simplify the dynamic construction and macro-based substitution of messages in Bukkit plugins.

At its core, this library provides a fluent builder API that allows plugin developers to compose rich, type-aware messages that include contextual values, such as player names, world locations, item metadata, and more.

Key Concepts

  • MessageBuilder – The primary entry point into the library, providing the fluent API used to construct and send messages.
  • QueryHandler – A customizable source for message templates and item definitions, often backed by YAML files.
  • MacroObjectMap – A runtime container of objects used to resolve macros into final string values.
  • Macro – Plugin defined Enum that correlates to Placeholders in messages (e.g., {PLAYER_NAME}, {LOCATION}) that are dynamically replaced with values drawn from objects supplied at runtime.

Design Highlights

  • Supports localization and per-player language settings
  • Allows multiple macros to be resolved from a single object via adapters
  • Built-in support for standard Bukkit types like Player, Location, ItemStack, etc.
  • Extensible via custom MacroProcessor, Resolver, or Adapter implementations (planned for a future version)

Typical Usage

Messages are composed fluently using the MessageBuilder API:
messageBuilder.compose(sender, MessageId.WELCOME)
              .setMacro(Macro.PLAYER, player)
              .setMacro(Macro.WORLD, world)
              .send();
This will retrieve the message template for WELCOME, substitute relevant macro values, and send the result to the message recipient derived from the sender parameter.
See Also: