Compatibility
Minecraft: Java Edition
Platforms
Tags
Creators
Details
NotifyLib
Плагин для Paper и Leaf, который показывает уведомления в углу экрана: иконка, текст, полоска таймера, плавное появление. Модов игрокам ставить не нужно, всё работает через боссбар и шейдер в серверном ресурспаке.
This plugin required resourcepack
Русский
Как это выглядит
Уведомление выезжает в выбранном углу экрана. Слева у него иконка типа, справа текст, снизу полоска, которая показывает, сколько ему ещё висеть. Если уведомлений несколько, они складываются в стопку. Когда одно уходит, остальные плавно сдвигаются на его место.
На экране одновременно помещается до четырёх уведомлений. Что делать с новыми, когда места нет, решаете вы: поставить их в очередь, заменить самое старое или просто отбросить.
Уведомление может быть в одну строку или в две, с заголовком и текстом. Текст пишется в MiniMessage. Если он не влезает по ширине, плагин аккуратно его обрежет, без переноса посреди слова.
Из коробки есть четыре типа: info, success, warning и error. Свои типы со своей иконкой, цветом и звуком добавляются в config.yml.
Если у игрока не стоит ресурспак, он всё равно получит уведомление, только в action bar или в чат.
Команды
| Команда | Право | Что делает |
|---|---|---|
/notify send <цель> <тип> <сек> <текст> |
notifylib.send |
Отправляет уведомление. Цель: ник, * или селектор вроде @a[...]. Если вставить в текст \n, уведомление станет двухстрочным |
/notify types |
notifylib.admin |
Показывает список типов |
/notify reload |
notifylib.admin |
Перечитывает config.yml и messages.yml, рестарт не нужен |
Настройки игроков
Каждый игрок может выбрать себе угол экрана, выключить уведомления или только звук, скрыть отдельные типы. Своей команды для этого у плагина нет, настройки меняются через API. Удобнее всего сделать для них кнопки в меню вашего плагина.
Без MySQL настройки лежат в данных игрока на самом сервере. С MySQL они общие для всех серверов за прокси: загружаются ещё до входа игрока, а сохраняются в отдельном потоке, чтобы не тормозить сервер.
Конфиг
В config.yml настраивается угол по умолчанию, длительность, размер стопки и очереди, поведение при переполнении и звуки. Параметр new-position решает, куда встаёт новое уведомление: в конец стопки или к самому углу. Там же описываются свои типы, а иконки и полоски для них добавляются в ресурспак.
Все сообщения команд вынесены в messages.yml, их можно переписать под свой сервер.
Если в конфиге ошибка, плагин не упадёт. Он напишет предупреждение в лог и возьмёт значение по умолчанию.
Для разработчиков
ToastApi toasts = NotifyLib.api();
toasts.show(player, ToastTypes.ERROR, "Вас убил <yellow>Steve</yellow>");
toasts.show(player, Toast.builder()
.type(ToastTypes.SUCCESS)
.title("<b>Новый уровень")
.text("Открыты новые киты")
.duration(Duration.ofSeconds(4))
.replaceKey("level") // уведомление с тем же ключом обновится, а не продублируется
.priority(Priority.HIGH)
.build());
API можно вызывать из любого потока. Кроме обычных уведомлений есть бессрочные, которые закрываются вручную, и колбэк на закрытие. Рассылать можно всем сразу, по праву, по миру или по своему условию.
Плагин кидает два события. ToastShowEvent можно отменить или подменить в нём уведомление. ToastCloseEvent срабатывает при закрытии.
Чтобы подключить API, добавьте NotifyLib-API как compileOnly и пропишите depend: [NotifyLib] в plugin.yml.
Нагрузка
Пока на экранах нет ни одного уведомления, плагин вообще ничего не делает на главном потоке, его тик просто останавливается. Текст боссбаров собирается и отправляется через PacketEvents в фоне. Разметка и ширина текста кэшируются, поэтому при рассылке на сотни игроков текст разбирается один раз.
English
What it looks like
A notification slides in from the corner of your choice. It has a type icon on the left, the text next to it, and a thin bar along the bottom that counts down how long it stays. Several notifications form a stack, and when one leaves, the rest slide over to fill the gap.
Up to four fit on screen at once. When there's no room left, you pick what happens to new ones: queue them, replace the oldest, or drop them.
A notification can be one line or two, with a title and text. Text is written in MiniMessage. If it's too wide it gets trimmed cleanly instead of cut off mid-word.
Four types come built in: info, success, warning and error. You can add your own in config.yml, each with its own icon, color and sound.
Players without the resource pack still get the message, just in the action bar or chat.
Commands
| Command | Permission | What it does |
|---|---|---|
/notify send <target> <type> <sec> <text> |
notifylib.send |
Sends a notification. Target can be a name, * or a selector like @a[...]. Put \n in the text to make it two lines |
/notify types |
notifylib.admin |
Lists the types |
/notify reload |
notifylib.admin |
Reloads config.yml and messages.yml without a restart |
Player settings
Each player can choose their own corner, turn off notifications or just the sound, and hide types they don't care about. There's no built-in command for this. Settings go through the API, so the usual way is to add buttons for them to your plugin's menu.
Without MySQL, settings are saved in the player data on that server. With MySQL they're shared across every server behind your proxy. They're loaded before the player even joins and saved on a separate thread so the server doesn't stall.
Config
config.yml covers the default corner, duration, stack and queue size, overflow behavior and sounds. new-position controls where a new notification lands: at the end of the stack or right up against the corner. Custom types go there too, and their icons and bars go into the resource pack.
Every command message lives in messages.yml, so you can reword them for your server.
A typo in the config won't take the plugin down. It logs a warning and uses the default value.
For developers
ToastApi toasts = NotifyLib.api();
toasts.show(player, ToastTypes.ERROR, "You were killed by <yellow>Steve</yellow>");
toasts.show(player, Toast.builder()
.type(ToastTypes.SUCCESS)
.title("<b>Level up")
.text("New kits unlocked")
.duration(Duration.ofSeconds(4))
.replaceKey("level") // a toast with the same key updates in place instead of stacking
.priority(Priority.HIGH)
.build());
You can call the API from any thread. Besides regular toasts there are persistent ones that you close yourself, plus a callback for when a toast closes. You can broadcast to everyone, by permission, by world or with your own filter.
There are two events. ToastShowEvent can be cancelled, or you can swap the toast for a different one. ToastCloseEvent fires when a toast closes.
To use the API, add NotifyLib-API as compileOnly and put depend: [NotifyLib] in your plugin.yml.
Performance
When nobody has a notification on screen, the plugin does no work on the main thread at all, because its tick stops. Boss bar text is built and sent through PacketEvents in the background. Markup and text widths are cached, so a broadcast to hundreds of players only parses the text once.


