### Load Messages from ConfigLib - Java
Source: https://github.com/xlevitate/hive-chat/blob/main/README.md
This Java code demonstrates how to integrate HiveChat with ConfigLib to load messages from a configuration file. It shows how to import a map of messages or load an entire configuration section directly into the HiveChat message registry.
```Java
// Assuming you have a ConfigLib Messages class
Messages messages = new Messages();
messages.load();
// Import messages into the registry
HiveChat.getMessageRegistry().importMessages(ConfigLibLoader.createMessageMap(messages, "messages"));
// Alternative: Load an entire configuration section
ConfigLibLoader.loadFromConfig(messages, HiveChat.getMessageRegistry(), "messages", getLogger());
// Now you can use them by key
HiveChat.sendRegistered("messages.welcome", player);
```
--------------------------------
### Create Message Chains - Java
Source: https://github.com/xlevitate/hive-chat/blob/main/README.md
This Java code demonstrates how to build a sequence of messages and actions using `HiveChat.createChain()`. The chain allows sending multiple messages, action bars, or titles with specified delays (`thenWait`) between them, providing timed sequences.
```Java
HiveChat.createChain()
.then("First message")
.thenWait(20) // Wait 1 second (20 ticks)
.then("Second message")
.thenWait(20)
.then("Action bar message")
.thenWait(20)
.then("
Title|Subtitle")
.send(player);
```
--------------------------------
### Initialize HiveChat Library - Java
Source: https://github.com/xlevitate/hive-chat/blob/main/README.md
This Java snippet demonstrates how to initialize the HiveChat library within a Minecraft plugin's main class, typically in the `onEnable` method. It passes the plugin instance to the static `init` method.
```Java
@Override
public void onEnable() {
HiveChat.init(this);
}
```
--------------------------------
### Define Universal Placeholders - Java
Source: https://github.com/xlevitate/hive-chat/blob/main/README.md
This Java code demonstrates how to add universal placeholders using `HiveChat.addUniversalPlaceholder()` for static values or `HiveChat.addDynamicPlaceholder()` for values determined at runtime based on context (like a player). These placeholders are automatically available in all subsequent messages.
```Java
// Add a static universal placeholder
HiveChat.addUniversalPlaceholder("prefix", "[MyServer] ");
// Add a dynamic placeholder based on player context
HiveChat.addDynamicPlaceholder("health", player -> String.valueOf(player.getHealth()));
// Now all messages can use {prefix} and {health} without explicitly defining them
HiveChat.send(player, "{prefix} Your health: {health}");
```
--------------------------------
### Add HiveChat Dependency (Gradle) - Kotlin
Source: https://github.com/xlevitate/hive-chat/blob/main/README.md
This snippet shows how to add the HiveChat library as a dependency in a Gradle project using the Kotlin DSL. It requires adding the JitPack repository and the library implementation dependency.
```Kotlin
repositories {
maven("https://jitpack.io")
}
dependencies {
implementation("com.github.xLevitate:hive-chat:1.2.0")
}
```
--------------------------------
### Use Custom Placeholders in Messages - Java
Source: https://github.com/xlevitate/hive-chat/blob/main/README.md
This Java snippet illustrates how to create `Placeholder` objects with a key and value, and then pass them to the `HiveChat.send()` method along with the message string. Placeholders are replaced in the message using the `{key}` syntax.
```Java
// Create placeholders
Placeholder namePlaceholder = Placeholder.of("name", player.getName());
Placeholder scorePlaceholder = Placeholder.of("score", 100);
// Use placeholders in messages
HiveChat.send(player, "Hello, {name}! Your score is {score}.", namePlaceholder, scorePlaceholder);
```
--------------------------------
### Send Basic Messages - Java
Source: https://github.com/xlevitate/hive-chat/blob/main/README.md
This Java code shows how to send basic text messages to a player or a command sender using `HiveChat.send()`. It supports plain text and MiniMessage formatting for colors and styles.
```Java
// Send a simple message
HiveChat.send(player, "Hello, world!");
// Add color using MiniMessage format
HiveChat.send(player, "This message is red");
// Send to a command sender (player or console)
HiveChat.send(sender, "Command executed successfully!");
```
--------------------------------
### Send a List of Messages - Java
Source: https://github.com/xlevitate/hive-chat/blob/main/README.md
This Java snippet shows how to send a predefined list of message strings to a player using `HiveChat.sendList()`. Each string in the list is sent as a separate message.
```Java
List messages = Arrays.asList(
"First message",
"Second message",
"Third message"
);
HiveChat.sendList(player, messages);
```
--------------------------------
### Send Advanced Components (Titles, Action Bars, etc.) - Java
Source: https://github.com/xlevitate/hive-chat/blob/main/README.md
This Java snippet shows how to use HiveChat to send advanced in-game components. It utilizes specific MiniMessage tags like ``, ``, ``, and `` within the message string to trigger these effects on the target player.
```Java
// Title with subtitle
HiveChat.send(player, "Main Title|This is the subtitle");
// Title with custom timing (fadeIn:stay:fadeOut in ticks)
HiveChat.send(player, "Custom Timing|Fade in, stay, fade out");
// Action bar
HiveChat.send(player, "This appears above the hotbar");
// Action bar with duration (in ticks)
HiveChat.send(player, "This stays for 3 seconds");
// Boss bar (format: color:style:progress:duration)
HiveChat.send(player, "Boss Message");
// Sound effects (format: sound:volume:pitch)
HiveChat.send(player, " You leveled up!");
```
--------------------------------
### Add HiveChat Dependency (Maven) - XML
Source: https://github.com/xlevitate/hive-chat/blob/main/README.md
This snippet shows how to add the HiveChat library as a dependency in a Maven project. It requires adding the JitPack repository and the library dependency with the specified groupId, artifactId, and version.
```XML
jitpack.io
https://jitpack.io
com.github.xLevitate
hive-chat
1.2.0
```
--------------------------------
### Broadcast Messages - Java
Source: https://github.com/xlevitate/hive-chat/blob/main/README.md
This Java code demonstrates how to broadcast messages to all online players using `HiveChat.broadcast()`. It also shows an overload that allows broadcasting only to players within a specified radius around a location.
```Java
// Broadcast to all online players
HiveChat.broadcast("Server restarting in 5 minutes!");
// Broadcast to players within a radius
HiveChat.broadcast(50, centralLocation, "Event starting nearby!");
```
--------------------------------
### Register and Send Messages by Key - Java
Source: https://github.com/xlevitate/hive-chat/blob/main/README.md
This Java snippet shows how to register a message string with a unique key using `HiveChat.registerMessage()`. Once registered, the message can be sent later using `HiveChat.sendRegistered()` by referencing its key, optionally providing placeholders.
```Java
// Register a message
HiveChat.registerMessage("welcome", "Welcome to the server, {player}!");
// Send the registered message
HiveChat.sendRegistered("welcome", player, Placeholder.of("player", player.getName()));
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.