Multification makes it simple to create customizable notifications and messages within large plugins that require handling a high volume of messages (while the setup may not be easy, it’s worthwhile for extensive plugins). It offers a range of features, including:
- 💭 Chat messages
- 📕 Title & Subtitle
- 🎬 ActionBar
- 🍫 BossBar
- 🔊 Sounds
- 🎨 Adventure support
- 🌈 MiniMessage support (including gradients, hex colors, hover, click and more)
- 📥 Placeholders
- 🛠️ Formatter support
- 🌎 Flexible messages providing (easy to implement i18n)
- 📦 Configuration support (CDN, Okaeri Configs)
- Cross-platform support (currently we support Bukkit, but it's easy to add support for other adventure-based platforms)
Messages can be sent to any audience, such as players or the console.
To use the library, you need to add the following repository and dependency to your build.gradle
file:
maven("https://repo.eternalcode.pl/releases")
implementation("com.eternalcode:multification-bukkit:1.1.4")
Note: If you want to use the library with other platforms, then you need to use the
multification-core
dependency.
Then create a new instance of the Multification
class and use it to send notifications:
public class YourMultification extends BukkitMultification<MessagesConfig> {
private final MessagesConfig messagesConfig;
private final AudienceProvider audienceProvider;
private final MiniMessage miniMessage;
public YourMultification(MessagesConfig messagesConfig, AudienceProvider audienceProvider, MiniMessage miniMessage) {
this.messagesConfig = messagesConfig;
this.audienceProvider = audienceProvider;
this.miniMessage = miniMessage;
}
@Override
protected @NotNull TranslationProvider<MessagesConfig> translationProvider() {
return locale -> this.messagesConfig;
}
@Override
protected @NotNull ComponentSerializer<Component, Component, String> serializer() {
return this.miniMessage;
}
@Override
protected @NotNull AudienceConverter<CommandSender> audienceConverter() {
return commandSender -> {
if (commandSender instanceof Player player) {
return this.audienceProvider.player(player.getUniqueId());
}
return this.audienceProvider.console();
};
}
}
Then in init method such as onEnable
,
you can create a new instance of the YourMultification
class and use it to send notifications:
AudienceProvider audienceProvider = BukkitAudiences.create(this);
MiniMessage miniMessage = MiniMessage.miniMessage();
MessagesConfig messagesConfig = new MessagesConfig();
YourMultification multification = new YourMultification(messagesConfig, audienceProvider, miniMessage);
After that, you can use the multification
instance to send notifications:
multification.create()
.player(player.getUniqueId())
.notice(messages -> messages.yourMessage)
.send();
Multification currently supports two configuration libraries:
- CDN Simple and fast property-based configuration library for JVM apps
- Okaeri Configs Simple Java/POJO config library written with love and Lombok
To use the Multification library with one of the configuration libraries, you need to:
implementation("com.eternalcode:multification-cdn:1.1.4")
implementation("net.dzikoysk:cdn:1.14.5")
public class MessagesConfig {
@Description("# My first message")
public Notice firstMessage = Notice.chat("<gradient:red:blue>Multification is awesome!");
}
Cdn cdn = CdnFactory.createYamlLike()
.getSettings()
.withComposer(Notice.class, new MultificationNoticeCdnComposer(multification.getNoticeRegistry()))
.build();
To load and create the config file, use the following code in the init method such as onEnable
:
MessagesConfig messages = new MessagesConfig();
Resource resource = Source.of(this.dataFolder, "messages.yml");
cdn.load(resource, messages)
.orThrow(cause -> cause);
cdn.render(config, resource)
.orThrow(cause -> cause);
Checkout example with CDN! example plugin.
implementation("com.eternalcode:multification-okaeri:1.1.4")
Probably also you will need to add additional dependencies for your platform, e.g. :
implementation("eu.okaeri:okaeri-configs-serdes-commons:5.0.5")
implementation("eu.okaeri:okaeri-configs-serdes-bukkit:5.0.5")
implementation("eu.okaeri:okaeri-configs-yaml-bukkit:5.0.5")
See Okaeri Configs for more information.
public class MessagesConfig extends OkaeriConfig {
@Comment("My first message")
public Notice firstMessage = Notice.chat("<gradient:red:blue>Multification is awesome!");
}
MessagesConfig config = (MessagesConfig) ConfigManager.create(MessagesConfig.class)
.withConfigurer(new MultificationSerdesPack(multification.getNoticeRegistry()))
.withConfigurer(new SerdesCommons(), new YamlBukkitConfigurer(), new SerdesBukkit()) // specify configurers for your platform
.withBindFile(new File(dataFolder, "messages.yml"))
.withRemoveOrphans(true) // automatic removal of undeclared keys
.saveDefaults() // save file if does not exists
.load(true);