message-api
Universal API for message handling on Fabric servers. Provides support for localized messages with placeholder substitution functionality through PlaceholderAPI, allowing easy text customization by end users.
Key Features
- Placeholder support through PlaceholderAPI
- Simple customization of in-game messages
- Multi-language localization support
- Easy integration into existing projects
Usage
Adding Dependency
To use message-api in your mod, add the following lines to your build.gradle file:
repositories {
maven { url "https://maven.nucleoid.xyz/" }
maven { url "https://api.modrinth.com/maven" }
}
dependencies {
include(modImplementation("maven.modrinth:message-api:[TAG]"))
include(modImplementation("eu.pb4:placeholder-api:[TAG]"))
}
Adding Messages
Create a messages folder in the resources directory. Create a JSON file with the appropriate language code as shown in the test mod example. Add your messages to the file, ensuring to use your mod ID as prefix in message identifiers to avoid conflicts.
Creating Messages
Use any of the provided methods in LocalizedMessage to obtain text instances that work similar to regular vanilla text instances!
ServerPlayerEntity player;
player.sendMessageToClient(LocalizedMessage.localized("modid.some.message.id"));
User Configuration
To modify messages, edit the JSON file at path ./config/<modid>/<languageid>.json. This will change the language file for the specified mod.
Credits
Special thanks to PlaceholderAPI for providing the parsing functionality.