A lightweight, flexible library for sending customizable announcements to players in Kyori Adventure projects. Notifier lets you define messages in code or external configuration, supports MiniMessage styling, and makes internationalization (i18n) a breeze.
./gradlew publishToMavenLocalrepositories {
mavenLocal()
}
dependencies {
implementation("io.github.carlosdiamon:notifier-core:1.0")
implementation("io.github.carlosdiamon:notifier-configurate-yml:1.0") // Optional - ConfigurateYAML
}// Optional: supply your own MiniMessage instance
Formatter formatter = new AdventureFormatter(myMiniMessage);
Notifier notifier = new DefaultNotifier(formatter);Now to send an advertisement you have to do the following.
Announcement welcome = Announcement.create()
.message("Welcome, <player_name>!")
.actionbar("<gold>Have fun!</gold>")
.build();
TagResolver resolver = TagResolver.resolver("player_name", Tag.inserting(audience.username()));
notifier.send(audience, welcome, resolver);Of course, hard-coding announcements into the code is not ideal. In this example Configurate will be used to load and serialize Announcement:
@ConfigSerializable
public class MessagesConfiguration {
private Announcement welcome = Announcement.message("¡Bienvenido! <player_name>");
// ...
public Announcement getWelcome() {
return welcome;
}
}Announcement welcome = configuration.getWelcome();
notifier.send(audience, welcome, resolver);Use ResourceNotifier to lookup messages by key:
// Implement your lookup logic (e.g., from YAML files per locale)
AnnouncementProvider provider = (audience, key) -> {
// return Announcement for the given key and audience
};
Notifier delegate = new DefaultNotifier(formatter);
ResourceNotifier notifier = new DefaultResourceNotifier(delegate, provider);notifier.send(audience, "messages.welcome", resolver);