MULTIFICATION / GUIDE

Advanced Features

i18n, custom formatters, and platform adapters

Edit on GitHub

Internationalization (i18n)#

public class MyMultification extends PaperMultification<BaseMessages> {
    private final Map<Locale, BaseMessages> translations;

    @Override
    protected TranslationProvider<BaseMessages> translationProvider() {
        return locale -> translations.getOrDefault(locale, translations.get(Locale.ENGLISH));
    }

    @Override
    protected LocaleProvider<CommandSender> localeProvider() {
        return viewer -> viewer instanceof Player p ? p.locale() : Locale.ENGLISH;
    }
}

// Load translations
Map<Locale, BaseMessages> translations = new HashMap<>();
translations.put(Locale.ENGLISH, loadConfig("messages_en.yml"));
translations.put(new Locale("pl"), loadConfig("messages_pl.yml"));

Global Replacer#

Apply transformations to all messages:

@Override
protected Replacer<CommandSender> globalReplacer() {
    return (viewer, text) -> {
        text = text.replace("{server}", "MyServer");

        // PlaceholderAPI integration
        if (viewer instanceof Player player) {
            text = PlaceholderAPI.setPlaceholders(player, text);
        }

        return text;
    };
}

Custom Notice Types#

Define Content

public class HologramContent implements NoticeContent {
    private final String text;
    private final Location location;
    // ...
}

Create Resolver

public class HologramResolver implements NoticeResolver<HologramContent> {
    private static final NoticeKey<HologramContent> KEY =
        new NoticeKeyImpl<>("hologram", HologramContent.class);

    @Override
    public void send(Audience audience, ComponentSerializer<?, ?, String> serializer, HologramContent content) {
        // Create hologram
    }

    @Override
    public NoticeSerdesResult serialize(HologramContent content) { ... }

    @Override
    public Optional<HologramContent> deserialize(NoticeSerdesResult result) { ... }
}

Register

this.noticeRegistry.registerResolver(new HologramResolver());

Performance Tips#

// ✅ Batch sending
multification.create()
    .players(playerList)
    .notice(config -> config.message)
    .send();

// ❌ Individual sends
for (UUID uuid : players) {
    multification.create().player(uuid).notice(...).send();
}

// ✅ Async for heavy operations
multification.create()
    .all()
    .notice(config -> config.heavyMessage)
    .sendAsync();