message-api
一个用于 Fabric 的简易服务端消息 API。它支持可翻译的消息,并使用 PlaceholderAPI 进行文本解析,最终用户可以轻松自定义。
功能
- 使用 PlaceholderAPI 的特殊文本解析
- 易于自定义的游戏内消息
- 语言本地化支持
- 易于集成
用法
添加依赖
要在你的模组中使用 message-api,请将以下内容添加到你的 build.gradle 文件中:
message-api 不捆绑 placeholder-api,你还需要捆绑其兼容版本。将 [TAG] 替换为相应的版本号。
repositories {
maven { url "https://maven.nucleoid.xyz/" }
maven { url "https://api.modrinth.com/maven" }
}
dependencies {
include(modImplementation("maven.modrinth:message-api:[TAG]"))
include(modImplementation("eu.pb4:placeholder-api:[TAG]"))
}
添加消息
在你的资源文件夹中创建一个 messages 文件夹。创建一个 JSON 文件,文件名为你想要添加的语言代码(参见 语言代码),例如 testmod 示例。
将你的消息添加到该文件中(确保消息 ID 前缀为你的模组 ID,以避免冲突)。
创建消息
使用 LocalizedMessage 中提供的任何方法来获取你的文本实例,其工作方式与其他原版文本实例相同!
ServerPlayerEntity player;
player.sendMessageToClient(LocalizedMessage.localized("modid.some.message.id"));
Mojang 官方映射
ServerPlayer player;
player.sendSystemMessage(LocalizedMessage.localized("modid.some.message.id"));
用户配置
要更改消息,请编辑 ./config/<modid>/<languageid>.json 中的 JSON 文件。这将更改指定 modid 模组对应的语言文件。
致谢
特别感谢 PlaceholderAPI 提供了文本解析功能。
message-api
A simple server-side message API for Fabric. It allows for translatable messages, with text parsing using PlaceholderAPI , which can be customized with ease by end users.
Features
- Special text parsing with PlaceholderAPI
- Easy customizable in-game messages
- Language localization support
- Easy to integrate
Usage
Adding the dependency
To use message-api in your mod, add the following to your build.gradle file:
Message-api doesn't bundle placeholder-api, you have to bundle a compatible of it as well.
Replace [TAG] with the respective versions.
repositories {
maven { url "https://maven.nucleoid.xyz/" }
maven { url "https://api.modrinth.com/maven" }
}
dependencies {
include(modImplementation("maven.modrinth:message-api:[TAG]"))
include(modImplementation("eu.pb4:placeholder-api:[TAG]"))
}
Adding messages
Create a messages folder in your resource folder. Create a JSON file with
the language code you would like to add, like
the testmod example.
Add your message to the file (make sure to prefix the message id with your mod id, to avoid conflicts).
Creating messages
Use any of the provided methods in LocalizedMessage to get your text instance, which works like any other vanilla text instance!
ServerPlayerEntity player;
player.sendMessageToClient(LocalizedMessage.localized("modid.some.message.id"));
Official Mojang Mappings
ServerPlayer player;
player.sendSystemMessage(LocalizedMessage.localized("modid.some.message.id"));
User configuration
To change messages, edit the JSON file in ./config/<modid>/<languageid>.json. This will change the language file for
the mod with the specified modid.
Credits
Special thanks to PlaceholderAPI for providing the parsing functionality.
下载 message-api
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 message-api
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 message-api
下载 message-api
下载 message-api
下载 message-api
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 message-api
下载 message-api
下载 message-api
下载 message-api
暂无更新日志
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
一个用于收集生物掉落物的多区块模组。
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
查看物品与配方
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
适用于 MC 1.18+ 的 Effekseer 加载器
模组
添加区块认领和玩家组队功能,并与 Xaero's Minimap 和 World Map 集成
评论 0
登录后参与评分
还没有评论,来抢沙发吧