概览
这是一个配置 API,旨在为多种不同的配置库提供兼容性,并便于在多加载器项目设置中使用,主要供我的模组使用。
它采用易于使用的基于注解的语法,使创建新的配置文件变得尽可能简单。
如果你是模组用户,这些信息对你来说可能用处不大。但如果你是模组开发者,并且希望在自己的项目中使用 Lexiconfig,请继续向下滚动至「开发」部分。
目前它尚不支持其他配置库,但随着我持续更新,我将为每个库添加更多兼容支持,以确保它不会与其他库发生冲突,而是能够无缝集成。
以下是当前及计划中针对不同配置库/API 的集成列表:
❌ - 未集成 ✅ - 已集成 ❓ - 进行中
| 状态 | 模组 |
|---|---|
| ❌ | Cloth Config |
| ❌ | oωo config |
| ✅ | Configured |
| ❌ | Forge Config Screens |
开发
本模组包含一个 API,可用于归档新的 lexicons、监听事件等。
依赖
build.gradle
repositories {
maven { url 'https://maven.codinglitch.com/repository/releases' }
}
dependencies {
implementation "com.codinglitch.lexiconfig:lexiconfig-api:API_VERSION_HERE"
}
你可以访问 查看最新的 API 版本。
用法
要归档你自己的 lexicons,首先必须创建一个自己的 Library。这可以通过简单地创建一个继承自 Library 类的新类,并使用 LexiconLibrary 注解来标记它来实现。
@LexiconLibrary
public class MyNewLibrary extends Library {
@Override
public void shelveLexicons() {
}
}
在 Forge 环境下,无需进行其他更改。然而,如果你正在为 Fabric 开发,则需要在你的 fabric.mod.json 中添加此类作为入口点。
fabric.mod.json
//...
"entrypoints": {
"lexiconfig": [
"com.path.to.MyNewLibrary"
]
}
//...
下一步是最终创建并归档你的 lexicons。你可以通过为 lexicon 创建另一个类并提供适当的注解来实现,如下所示:
@Lexicon(name = MY_LEXICON_TITLE) // 建议使用你的模组 ID 作为名称
public class MyLexicon extends LexiconData {
@LexiconEntry(comment = "这是简单字段的注释!")
public String mySimpleField = "content";
@LexiconPage(comment = "这是对全新类别的全新花式注释!")
public MyNewPage myNewPage = new MyNewPage();
public static class MyNewPage extends LexiconPageData {
@LexiconEntry(comment = "此字段位于 lexicon 页面内!")
public Boolean myPageField = true;
}
}
最后一步是归档该 lexicon,这可以通过在 library 中将其实例添加为字段并在给定方法中归档它来实现。
@LexiconLibrary
public class MyNewLibrary extends Library {
public static MyLexicon MY_LEXICON = new MyLexicon();
@Override
public void shelveLexicons() {
LexiconfigApi.shelveLexicon(MY_LEXICON);
}
}
Overview
This is a config API meant to provide compatibility across multiple different other config libraries as well as be easy to use in a multiloader project setup, mainly for use in my mods.
It features a simple to use annotation-based syntax, to make creating new configuration files as easy as possible.
If you are a mod user, this information is likely not very useful to you. If you are a mod developer however, and you would like to use Lexiconfig in your own projects, scroll further to the Development section.
It currently does not have support for other configuration libraries, but as I continue to update it, I will add more compatibilities to each one to ensure that it does not conflict with others and can instead seamlessly integrate between them.
Here is a list of current as well as planned integrations across different config libraries/api:
❌ - Unintegrated ✅ - Integrated ❓ - In Progress
| Status | Mod |
|---|---|
| ❌ | Cloth Config |
| ❌ | oωo config |
| ✅ | Configured |
| ❌ | Forge Config Screens |
Development
This mod contains an api that can be used to shelve new lexicons, listen to events, etc.
Depending
build.gradle
repositories {
maven { url 'https://maven.codinglitch.com/repository/releases' }
}
dependencies {
implementation "com.codinglitch.lexiconfig:lexiconfig-api:API_VERSION_HERE"
}
You can go to to view the latest api version.
Usage
To shelve your own lexicons, you first have to your own Library. This can be done by simply creating a new class extending the Library class, and annotating it with the LexiconLibrary annotation.
@LexiconLibrary
public class MyNewLibrary extends Library {
@Override
public void shelveLexicons() {
}
}
In a Forge setup, no further changes need to be made. However, if you are developing for Fabric, you will have to add this class as an entrypoint in your fabric.mod.json.
fabric.mod.json
//...
"entrypoints": {
"lexiconfig": [
"com.path.to.MyNewLibrary"
]
}
//...
The next step is to finally create and shelve your lexicons. You can do this by simply creating another class for the lexicon, and providing it with the proper annotations, like as follows:
@Lexicon(name = MY_LEXICON_TITLE) // preferably use your mod id as a name
public class MyLexicon extends LexiconData {
@LexiconEntry(comment = "This is a comment for a simple field!")
public String mySimpleField = "content";
@LexiconPage(comment = "This is a fancy new comment on the fancy new category!")
public MyNewPage myNewPage = new MyNewPage();
public static class MyNewPage extends LexiconPageData {
@LexiconEntry(comment = "This field is inside a lexicon page!")
public Boolean myPageField = true;
}
}
The next and last step is to shelve the lexicon, which can be done by simply adding an instance of it as a field in the library and shelving it in the given method.
@LexiconLibrary
public class MyNewLibrary extends Library {
public static MyLexicon MY_LEXICON = new MyLexicon();
@Override
public void shelveLexicons() {
LexiconfigApi.shelveLexicon(MY_LEXICON);
}
}
下载 Lexiconfig
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lexiconfig
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lexiconfig
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lexiconfig
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lexiconfig
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lexiconfig
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lexiconfig
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lexiconfig
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lexiconfig
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lexiconfig
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
- 已更新以支持 1.21.1+
- 已修复 NeoForge 兼容性问题
- 已更新以支持 1.21.1+
- 已修复 NeoForge 兼容性问题
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
AE2:一款流行的自动化与存储模组
模组
那是什么?一个 Waila/Hwyla 的分支。
评论 0
登录后参与评分
还没有评论,来抢沙发吧