### Gradle Dependency for YetAnotherMessagesLibrary Source: https://github.com/mythic-projects/yetanothermessageslibrary/blob/master/README.md Example of how to include a specific module of YetAnotherMessagesLibrary as a dependency in your Gradle project. Replace '[module]' and '[version]' with the desired artifact and version number. ```groovy dependencies { implementation 'dev.peri.yetanothermessageslibrary:[module]:[version]' } ``` -------------------------------- ### Maven Dependency for YetAnotherMessagesLibrary Source: https://github.com/mythic-projects/yetanothermessageslibrary/blob/master/README.md Example of how to include a specific module of YetAnotherMessagesLibrary as a dependency in your Maven project. Replace '[module]' and '[version]' with the desired artifact and version number. ```xml dev.peri.yetanothermessageslibrary [module] [version] ``` -------------------------------- ### Simple SendableMessage YAML Serialization Source: https://github.com/mythic-projects/yetanothermessageslibrary/blob/master/repository/okaeri/FORMAT.md Complete example demonstrating all supported message types (chat, actionbar, title, bossbar, sound) in a single YAML structure. Shows the full serialization format with multiple messages, title fade timings, bossbar colors/overlays, and sound properties. This represents the most comprehensive form of a SendableMessage. ```yaml example: chat: - Example Chat - console: true message: Example Console Only actionbar: Example ActionBar title: title: Example Title subtitle: Example SubTitle fade-in: 10 stay: 20 fade-out: 10 bossbar: - name: Example BossBar color: GREEN overlay: PROGRESS progress: 0.5 stay: 20 - name: Example BossBar2 color: GREEN overlay: PROGRESS flags: - DARKEN_SCREEN progress: 0.5 stay: 20 sound: name: minecraft:ui.button.click source: MASTER volume: 1.0 pitch: 1.0 ``` -------------------------------- ### MessageService - Core Message Repository Access Source: https://context7.com/mythic-projects/yetanothermessageslibrary/llms.txt The MessageService interface provides methods to retrieve messages from locale-specific repositories with automatic locale resolution and placeholder replacement. This example demonstrates creating a message repository, registering locale-specific implementations, and retrieving messages with placeholder substitution. ```java import dev.peri.yetanothermessageslibrary.MessageService; import dev.peri.yetanothermessageslibrary.MessageRepository; import dev.peri.yetanothermessageslibrary.SimpleMessageService; import dev.peri.yetanothermessageslibrary.locale.LocaleProvider; import dev.peri.yetanothermessageslibrary.replace.replacement.Replacement; import java.util.Locale; // Define your message repository public class MyMessages implements MessageRepository { public String welcomeMessage = "Welcome, {player}!"; public List helpMessages = Arrays.asList( "Command /help - Show help", "Command /info - Show info" ); } // Create and configure the message service MessageService messageService = new SimpleMessageService() {}; // Register repositories for different locales MyMessages englishMessages = new MyMessages(); englishMessages.welcomeMessage = "Welcome, {player}!"; messageService.registerDefaultRepository(Locale.ENGLISH, englishMessages); MyMessages polishMessages = new MyMessages(); polishMessages.welcomeMessage = "Witaj, {player}!"; messageService.registerRepository(Locale.forLanguageTag("pl"), polishMessages); // Get message with automatic locale resolution String message = messageService.get(player, config -> config.welcomeMessage); // Get message with placeholder replacement String message = messageService.get(player, config -> config.welcomeMessage, Replacement.of("{player}", player.getName()) ); // Get list of messages with replacements List helpList = messageService.getList(player, config -> config.helpMessages, Replacement.of("{prefix}", "[MyPlugin]") ); ``` -------------------------------- ### SendableMessage Builder - Composing Multi-Component Messages Source: https://context7.com/mythic-projects/yetanothermessageslibrary/llms.txt The SendableMessage.Builder creates complex messages combining chat, action bars, titles, boss bars, and sounds into a single sendable unit. This example demonstrates building comprehensive messages with MiniMessage formatting, multiple component types, timing configurations, and sound effects for cross-platform Minecraft servers. ```java import dev.peri.yetanothermessageslibrary.message.SendableMessage; import net.kyori.adventure.bossbar.BossBar; import net.kyori.adventure.sound.Sound; // Build a complex message with multiple components SendableMessage complexMessage = SendableMessage.builder() // Add chat messages (supports MiniMessage format) .chat("&aWelcome to the server!") .chat("Enjoy your stay!") // Add console-only message .chat(true, "&7[LOG] Player joined") // Add action bar .actionBar("&eHealth: {health} | Hunger: {hunger}") // Add title with timing (fadeIn, stay, fadeOut in ticks) .title( "Welcome!", "&7Server v1.0", 10, // fade in 40, // stay 10 // fade out ) // Add boss bar with configuration .bossBar( "Quest Progress", 0.75f, // progress (0.0 to 1.0) BossBar.Color.GREEN, // color BossBar.Overlay.NOTCHED_10, // overlay style Arrays.asList(BossBar.Flag.DARKEN_SCREEN), // flags 100 // stay time in ticks (-1 for permanent) ) // Add sound effect .sound( "minecraft:entity.player.levelup", Sound.Source.MASTER, 1.0f, // volume 1.2f // pitch ) .build(); // Send the message directly to a viewer complexMessage.send(locale, viewer, replacements); ``` -------------------------------- ### Gradle Repositories for YetAnotherMessagesLibrary Source: https://github.com/mythic-projects/yetanothermessageslibrary/blob/master/README.md Configuration for Gradle to access both release and snapshot versions of the YetAnotherMessagesLibrary. Add these repositories to your project's build.gradle file. ```groovy repositories { // Releases maven { name = "titanvale-releases" url = "https://repo.titanvale.net/releases" } // Snapshots maven { name = "titanvale-snapshots" url = "https://repo.titanvale.net/snapshots" } } ``` -------------------------------- ### Maven Repositories for YetAnotherMessagesLibrary Source: https://github.com/mythic-projects/yetanothermessageslibrary/blob/master/README.md Configuration for Maven to access both release and snapshot versions of the YetAnotherMessagesLibrary. Ensure these repositories are added to your project's pom.xml to fetch dependencies. ```xml titanvale-releases https://repo.titanvale.net/releases titanvale-snapshots https://repo.titanvale.net/snapshots ``` -------------------------------- ### Cross-Platform Velocity Plugin Integration in Java Source: https://context7.com/mythic-projects/yetanothermessageslibrary/llms.txt Demonstrates setting up YetAnotherMessagesLibrary in a Velocity proxy plugin with consistent API across platforms. Shows plugin initialization, message service creation, and message sending with placeholder replacement. Illustrates how the same messaging API works uniformly across Bukkit, BungeeCord, and Velocity platforms. ```java import com.velocitypowered.api.plugin.Plugin; import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.proxy.Player; import dev.peri.yetanothermessageslibrary.VelocityMessageService; import dev.peri.yetanothermessageslibrary.SendableMessageService; import java.util.Locale; @Plugin(id = "myplugin", name = "MyPlugin", version = "1.0") public class MyVelocityPlugin { private final ProxyServer server; private SendableMessageService messageService; @Inject public MyVelocityPlugin(ProxyServer server) { this.server = server; } @Subscribe public void onProxyInitialization(ProxyInitializeEvent event) { this.messageService = new VelocityMessageService<>(server); MyMessages messages = loadMessages(); this.messageService.registerDefaultRepository(Locale.ENGLISH, messages); } @Subscribe public void onPlayerJoin(PostLoginEvent event) { Player player = event.getPlayer(); this.messageService.getMessage(config -> config.welcomeMessage) .receiver(player) .with("{player}", player.getUsername()) .with("{server}", player.getCurrentServer() .map(s -> s.getServerInfo().getName()) .orElse("Unknown")) .send(); } } ``` -------------------------------- ### BukkitMessageService - Initialize and Register Messages (Java) Source: https://context7.com/mythic-projects/yetanothermessageslibrary/llms.txt Demonstrates the initialization of BukkitMessageService, including setting up the Adventure platform, registering a locale provider for automatic player locale detection, and loading/registering message repositories for different languages. ```java import dev.peri.yetanothermessageslibrary.BukkitMessageService; import dev.peri.yetanothermessageslibrary.SendableMessageService; import dev.peri.yetanothermessageslibrary.locale.BukkitPlayerLocaleProvider; import dev.peri.yetanothermessageslibrary.message.BukkitMessageDispatcher; import net.kyori.adventure.platform.bukkit.BukkitAudiences; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; public class MyPlugin extends JavaPlugin { private BukkitAudiences adventure; private SendableMessageService> messageService; @Override public void onEnable() { // Initialize Adventure platform this.adventure = BukkitAudiences.create(this); // Create message service this.messageService = new BukkitMessageService<>(this, this.adventure); // Register locale provider for automatic player locale detection this.messageService.registerLocaleProvider(new BukkitPlayerLocaleProvider()); // Load and register message repositories MyMessages englishMessages = loadMessages("messages_en.yml"); this.messageService.registerDefaultRepository(Locale.ENGLISH, englishMessages); MyMessages polishMessages = loadMessages("messages_pl.yml"); this.messageService.registerRepository(Locale.forLanguageTag("pl"), polishMessages); } @Override public void onDisable() { this.adventure.close(); } // Example usage in command or listener public void sendWelcomeMessage(Player player) { this.messageService.getMessage(config -> config.welcomeMessage) .receiver(player) .with("{player}", player.getName()) .with("{world}", player.getWorld().getName()) .send(); } } ``` -------------------------------- ### MessageDispatcher - Fluent API for Sending Messages (Java) Source: https://context7.com/mythic-projects/yetanothermessageslibrary/llms.txt Illustrates the usage of the MessageDispatcher API for constructing and sending messages. It covers sending to single and multiple receivers, applying filters with predicates, handling placeholder replacements (including dynamic ones), and executing actions upon sending. ```java import dev.peri.yetanothermessageslibrary.message.MessageDispatcher; import dev.peri.yetanothermessageslibrary.replace.replacement.Replacement; import org.bukkit.entity.Player; // Get message dispatcher from service BukkitMessageDispatcher dispatcher = messageService.getMessage(config -> config.welcomeMessage); // Simple send to single receiver dispatcher .receiver(player) .with("{player}", player.getName()) .send(); // Send to multiple receivers with filtering dispatcher .receivers(Bukkit.getOnlinePlayers()) .predicate(Player::hasPlayedBefore) // Only send to returning players .with("{player}", player -> player.getName()) .send(); // Conditional sending based on type and custom predicate dispatcher .receivers(Bukkit.getOnlinePlayers()) .predicate(Player.class, p -> p.getWorld().getName().equals("spawn")) .with("{count}", Bukkit.getOnlinePlayers().size()) .action(player -> player.sendMessage("Action executed!")) .send(); // Advanced: Type-specific replacements with fallback dispatcher .receiver(player) .with(Player.class, (p, locale, fields) -> Replacement.of("{health}", p.getHealth()), (sender, locale, fields) -> Replacement.of("{health}", "N/A") // fallback for console ) .field("custom_data", someValue) // Store custom data for replacement suppliers .send(); ``` -------------------------------- ### Simple and Supplier-Based Placeholder Replacement in Java Source: https://context7.com/mythic-projects/yetanothermessageslibrary/llms.txt Demonstrates basic and lazy-evaluated placeholder replacement using the Replacement class. Supports static replacements with direct values and supplier-based replacements for dynamic content like timestamps. Useful for simple text substitution without complex nested structures. ```java import dev.peri.yetanothermessageslibrary.replace.replacement.Replacement; // Simple replacement Replacement simple = Replacement.of("{player}", player.getName()); // Supplier-based replacement (lazy evaluation) Replacement lazy = Replacement.of("{time}", () -> new SimpleDateFormat("HH:mm:ss").format(new Date()) ); ``` -------------------------------- ### YAML Message Configuration with okaeri-configs (Java) Source: https://context7.com/mythic-projects/yetanothermessageslibrary/llms.txt Configure messages in YAML files with full SendableMessage serialization support using the okaeri-configs integration. This Java code defines a configuration class and a method to load messages from a YAML file, enabling serialization of complex message structures. ```java import dev.peri.yetanothermessageslibrary.MessageRepository; import dev.peri.yetanothermessageslibrary.config.serdes.SerdesMessages; import dev.peri.yetanothermessageslibrary.message.SendableMessage; import dev.peri.yetanothermessageslibrary.message.holder.impl.ChatHolder; import eu.okaeri.configs.ConfigManager; import eu.okaeri.configs.OkaeriConfig; import eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer; import java.io.File; // Define configuration class public class MessageConfiguration extends OkaeriConfig implements MessageRepository { public SendableMessage welcomeMessage = ChatHolder.message("&aWelcome, {player}!"); public SendableMessage questComplete = SendableMessage.builder() .chat("&aQuest completed!") .actionBar("&eReward: {reward}") .title("Quest Complete!", "", 10, 40, 10) .sound("minecraft:ui.toast.challenge_complete", Sound.Source.MASTER, 1.0f, 1.0f) .build(); } // Load configuration from YAML file private MessageConfiguration loadMessages(File file) { return ConfigManager.create(MessageConfiguration.class, config -> { config.withConfigurer(new YamlBukkitConfigurer()); config.withSerdesPack(new SerdesMessages()); // Enable SendableMessage serialization config.withBindFile(file); config.saveDefaults(); config.load(true); }); } ``` ```yaml welcomeMessage: "&aWelcome, {player}!" questComplete: chat: - "&aQuest completed!" actionbar: "&eReward: {reward}" title: title: "Quest Complete!" subtitle: "" fade-in: 10 stay: 40 fade-out: 10 sound: name: minecraft:ui.toast.challenge_complete source: MASTER volume: 1.0 pitch: 1.0 # Simple string messages errorMessage: "&cAn error occurred!" # List of chat messages helpMessages: - "&7=== Help ===" - "&e/help - Show this help" - "&e/info - Show server info" # Console-only message logMessage: console: true message: "&7[LOG] {message}" # Complex message with multiple components joinMessage: chat: - "&aPlayer {player} joined!" - console: true message: "&7[JOIN] {player} from {ip}" actionbar: "&eWelcome back, {player}!" bossbar: - name: "Server Status: Online" color: GREEN overlay: PROGRESS progress: 1.0 stay: 60 ``` -------------------------------- ### Custom Replaceable Implementation in Java Source: https://context7.com/mythic-projects/yetanothermessageslibrary/llms.txt Provides a pattern for creating custom replaceable implementations by extending the Replaceable interface. Supports both text-based and Adventure API Component-based replacements, allowing replacement of multiple placeholders related to player state (health, location, world). Demonstrates integration with Adventure API for component text manipulation. ```java import dev.peri.yetanothermessageslibrary.replace.Replaceable; import net.kyori.adventure.text.Component; import java.util.Locale; public class PlayerReplaceable implements Replaceable { private final Player player; public PlayerReplaceable(Player player) { this.player = player; } @Override public String replace(Locale locale, String text) { return text .replace("{player}", player.getName()) .replace("{health}", String.valueOf(player.getHealth())) .replace("{world}", player.getWorld().getName()) .replace("{x}", String.valueOf(player.getLocation().getBlockX())) .replace("{y}", String.valueOf(player.getLocation().getBlockY())) .replace("{z}", String.valueOf(player.getLocation().getBlockZ())); } @Override public Component replace(Locale locale, Component component) { return component.replaceText(builder -> builder.matchLiteral("{player}") .replacement(Component.text(player.getName())) ); } } // Use custom replaceable messageService.getMessage(config -> config.locationMessage) .receiver(player) .with(new PlayerReplaceable(player)) .send(); ``` -------------------------------- ### Nested Placeholder Replacement in Java Source: https://context7.com/mythic-projects/yetanothermessageslibrary/llms.txt Enables hierarchical placeholder replacement where replacements can contain additional placeholders that are resolved in sequence. Allows composing complex messages with multiple levels of substitution and dependency management. ```java import dev.peri.yetanothermessageslibrary.replace.replacement.Replacement; // Nested replacements Replacement nested = Replacement.of( "{message}", "Welcome {player}!", Replacement.of("{player}", "Steve") ); ``` -------------------------------- ### Chat-Only Message YAML Serialization Source: https://github.com/mythic-projects/yetanothermessageslibrary/blob/master/repository/okaeri/FORMAT.md Simplified YAML formats for chat-only messages supporting three patterns: plain string, list of strings, and console-only messages. Demonstrates backward compatibility with older string and list formats, including mixed console/public message delivery. ```yaml # simple string example: Example Chat # or list of strings example: - Example Chat 1 - Example Chat 2 # or if we want to send message only to console example: console: true message: Example Console Only # or if we want to send some message to console only and other to everyone example: - Example Chat - console: true message: Example Console Only ``` -------------------------------- ### Locale Providers - Automatic Locale Detection (Java) Source: https://context7.com/mythic-projects/yetanothermessageslibrary/llms.txt Implement LocaleProvider to automatically detect player locales from various sources. This Java code demonstrates registering built-in, custom, and static locale providers to manage player language preferences. ```java import dev.peri.yetanothermessageslibrary.locale.LocaleProvider; import dev.peri.yetanothermessageslibrary.locale.Locale; import org.bukkit.entity.Player; import java.util.Locale; // Assume messageService and myDatabase are initialized elsewhere // MessageService messageService; // Database myDatabase; // Bukkit player locale provider (built-in) // messageService.registerLocaleProvider(new BukkitPlayerLocaleProvider()); // Custom locale provider implementation public class DatabaseLocaleProvider implements LocaleProvider { private final Database database; public DatabaseLocaleProvider(Database database) { this.database = database; } @Override public boolean supports(Class clazz) { return Player.class.isAssignableFrom(clazz); } @Override public Locale getLocale(Player player) { String localeCode = database.getPlayerLocale(player.getUniqueId()); return localeCode != null ? Locale.forLanguageTag(localeCode) : null; // Falls back to default locale } } // Register custom locale provider // messageService.registerLocaleProvider(new DatabaseLocaleProvider(myDatabase)); // Static locale provider for testing // messageService.registerLocaleProvider(LocaleProvider.staticProvider(Locale.FRENCH)); ``` -------------------------------- ### Single Holder YAML Serialization Source: https://github.com/mythic-projects/yetanothermessageslibrary/blob/master/repository/okaeri/FORMAT.md Format for serializing a single holder of a specific message type as an object. When only one bossbar, title, actionbar, or sound exists, it is represented as a direct object rather than a list, simplifying the YAML structure. ```yaml example: bossbar: name: Example BossBar color: GREEN overlay: PROGRESS progress: 0.5 stay: 20 ``` -------------------------------- ### Multiple Holders YAML Serialization Source: https://github.com/mythic-projects/yetanothermessageslibrary/blob/master/repository/okaeri/FORMAT.md Format for serializing multiple holders of the same message type as a list of objects. When two or more bossbars, titles, actionbars, or sounds exist, they are represented as a YAML list with individual object properties for each holder. ```yaml example: bossbar: - name: Example BossBar color: GREEN overlay: PROGRESS flags: - DARKEN_SCREEN progress: 0.5 stay: 20 - name: Example BossBar2 color: GREEN overlay: PROGRESS progress: 0.5 stay: 20 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.