Quill Notifications
一款小型库模组,用于以优雅的方式向在线和离线玩家发送通知!
用法
此模组需要 Fabric API 和 SQLib。
使用 Adventure API 不是必需的,但推荐使用。
一旦模组安装在你的服务器上,首次启动后会生成一个配置文件。请务必编辑该配置文件并将其指向文件路径或 MySQL 数据库。
对于开发者
开始使用
要在项目中包含此模组,只需将其添加为依赖项:
repositories {
maven { url "https://api.modrinth.com/maven" }
// adventure api is not strictly necessary but is helpful and will allow you to use Component messages
maven {
name = "sonatype-oss-snapshots1"
url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
mavenContent { snapshotsOnly() }
}
}
dependencies {
modImplementation("maven.modrinth:quill:1.2.3")
// adventure api is not strictly necessary but is helpful and allow you to use Component messages
modImplementation include("net.kyori:adventure-platform-fabric:6.4.0")
}
一般用法
Notification notification = NotificationBuilder.Notification(receiverUUID) // 初始化一个新的待发送通知
.setMessage(message) // setMessage() 接受 String、MutableText 或 Component 变量(注意:通知仅保存最后设置的消息)
.setStyle(Scribe.INFO) // setStyle() 仅对 String 消息有效
.setMetadata(jsonData) // 将 JSON 数据注入消息中,以便与事件系统配合使用
.setSound(SoundEvents.BLOCK_BELL_USE) // 设置收到通知时播放的声音事件
.setCommands(commandString, commandString2) // 设置收到通知时运行的命令
.setCommandDelay(10, TimeUnit.SECONDS) // 设置通知发送后命令执行的延迟时间(你也可以只传入一个数字来表示毫秒数作为延迟量)
.setExpiry(15, TimeUnit.MINUTES) // 设置消息的过期时间,如果玩家在过期时间到来前未上线,则不会发送该通知(你也可以只传入一个数字来表示直到过期的毫秒数)
.build();
Pigeon.send(notification); // 向玩家发送通知
for (Notification message: QuillNotifications.getNotifications(receiverUUID)) { // 获取玩家的所有待处理通知(通知按从旧到新的顺序排列)
if (notification.getMessage().toString().equals("Test message plz delete")) message.cancel() // 在通知发送给玩家之前取消它
}
事件系统
// 事件系统允许你在通知发送前修改通知数据
QuillEvents.PRE_SEND_NOTIFICATION.register((notification) -> {
System.out.println(notification.getPlayerEntity().getName().getString());
// 返回 true 允许消息发送,返回 false 将阻止消息被看到
return true;
// 利用 metadata 或其他变量做一些酷炫的事情,具体由你决定。
});
Quill Notifications
A small Library mod to handle sending notifications to players both online and offline with style!
Usage
This mod requires both Fabric API, and SQLib.
Use of Adventure API is not required but encouraged.
Once the mod is installed on your server, a config will be generated after the first launch. Be sure to edit this config and point it to a file path or a my sql database.
For Developers
Getting Started
To include this mod in your project simply add it as a dependency:
repositories {
maven { url "https://api.modrinth.com/maven" }
// adventure api is not strictly necessary but is helpful and will allow you to use Component messages
maven {
name = "sonatype-oss-snapshots1"
url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
mavenContent { snapshotsOnly() }
}
}
dependencies {
modImplementation("maven.modrinth:quill:1.2.3")
// adventure api is not strictly necessary but is helpful and allow you to use Component messages
modImplementation include("net.kyori:adventure-platform-fabric:6.4.0")
}
General Usage
Notification notification = NotificationBuilder.Notification(receiverUUID) // Initalize a new notification to be sent
.setMessage(message) // setMessage() accepts String, MutableText, or Component variables (note that the notification will only save the last message set)
.setStyle(Scribe.INFO) // setStyle() only works for String messages
.setMetadata(jsonData) // inject json data into a message to be used with the event system
.setSound(SoundEvents.BLOCK_BELL_USE) // set a soundevent to be played when notification is received
.setCommands(commandString, commandString2) // set commands to be run when the notification is received
.setCommandDelay(10, TimeUnit.SECONDS) // set a delay that your commands will delayed for after the notification is sent (you can also pass in just a number for the ammount of millies to delay by)
.setExpiry(15, TimeUnit.MINUTES) // set a time from a message to expire, if the player doesnt come online before the expiry time elapes the notificaion will not be sent (you can also pass in just a number for the ammount of millies till expiry)
.build();
Pigeon.send(notification); // send the notification to the player
for (Notification message: QuillNotifications.getNotifications(receiverUUID)) { // get all pending notifications for a player (notifications are in order of oldest to newest)
if (notification.getMessage().toString().equals("Test message plz delete")) message.cancel() // cancel a notification before it gets sent to the player
}
Event System
//the event system gives you a notification object to modify the notification data before it gets sent
QuillEvents.PRE_SEND_NOTIFICATION.register((notification) -> {
System.out.println(notification.getPlayerEntity().getName().getString());
//returning true allows the message to be sent, returning false will stop the
//returning false will stop the message from being seen
return true;
// Do cool things with metadata or the other varibles idk the event system is your oyster.
});
下载 Quill Notifications
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Quill Notifications
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Quill Notifications
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Quill Notifications
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Quill Notifications
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Quill Notifications
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Quill Notifications
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Quill Notifications
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Quill Notifications
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Quill Notifications
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
已更新至 1.21.5(虽然已准备好适配 1.21.8,但冒险 API 尚未更新)
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
一个用于收集生物掉落物的多区块模组。
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
AE2:一款流行的自动化与存储模组
评论 0
登录后参与评分
还没有评论,来抢沙发吧