Skip to content

🔔 A library for sending announcements to players using Kyori Adventure components.

Notifications You must be signed in to change notification settings

carlosleondev/Notifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔔 Notifier

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.


🚶‍♂️‍➡️ Quick Start

1. Publish to your local Maven

./gradlew publishToMavenLocal

2. Add to your project

repositories { 
	mavenLocal()
}

dependencies {
	implementation("io.github.carlosdiamon:notifier-core:1.0")
	implementation("io.github.carlosdiamon:notifier-configurate-yml:1.0") // Optional - ConfigurateYAML
}

🥶 Basic Usage

// 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);

🌐 Internationalization (i18n)

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);

About

🔔 A library for sending announcements to players using Kyori Adventure components.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages