HttpInfoServer
一个 Fabric 模组,用于收集并向 Minecraft HTTP API server(我的另一个仓库)发送游戏内信息。该项目由 Minecraft Fabric 模组(代理) 和 HTTP API 服务器 组成。本仓库包含 Minecraft Fabric 模组的代码,HTTP API 服务器的代码位于此链接:*link*。请阅读完整手册以正确完成设置。
手册
完整手册请参阅此处:read
构建
建议使用如 IntelliJ IDEA 或 Eclipse 等 IDE。如果您希望在不使用任何 IDE 的情况下生成 .jar 文件,可以在项目根目录使用命令 gradle build(请确保已安装 Java 17 或更高版本)。
安装
请确保您已为所需版本的 Minecraft 安装了 Fabric。通过以下 releases 链接 *link* 选择并下载与您所用 Minecraft 版本(包括补丁版本)匹配的 .jar 文件。通常将下载的文件放入 .mods 文件夹中(路径一般为 %AppData%/.minecraft/mods)。使用启动器中的 Fabric 安装运行 Minecraft。
贡献
如果您能协助本项目开发,我将不胜感激。您可以参与的工作包括:
- 拼写修正。我的英语不太好,因此您可以修正代码注释或文件中的文本(例如 README.md)。
- 代码清理
- 添加新功能或改进现有功能
代码结构:
代码文件位于路径为 src/main/java/com.crocoby 的文件夹中。该文件夹包含以下文件:
HttpInfoServer.java — 包含名为 onInitialize 的入口方法,该方法在 Minecraft 加载时调用并启动。我们在 onInitialize 方法中创建并运行 WebSocket 实例。
WebSocketDoor.java — 本项目使用 TooTallNate/Java-WebSocket 库来构建 WebSocket 客户端。WebSocket 类描述了连接到 WebSocket 服务器(另一个仓库)的 WebSocket 客户端的行为。当服务器发送文本为 "collectData" 的消息时,WebSocket 客户端会使用 InfoCollector 类(此行为在 onMessage 方法中描述)。
InfoCollector.java — 拥有 genJson 函数,用于收集数据并将其转换为 JSON 字符串格式。此方法需要生成响应 WebSocket 服务器的数据。
mixin/WorldJoinMixin.java — 拥有 init 方法,每当玩家加入任何世界(服务器同样适用)时都会调用。当 WebSocket 客户端未连接到 WebSocket 服务器时,它会在游戏聊天中发送一条消息。
HttpInfoServer
Minecraft fabric mod that collects and sends in-game information to Minecraft HTTP API server (another my repo). The project consists of Minecraft fabric mod (agent) and HTTP API server. The code of the Minecraft fabric mod is located in this repo and the HTTP API server code is located by this link: *link*. Read the full manual to get everything set up correctly.
Manual
The full manual you can read here: read
Build
I recommend you use IDEAs like IntelliJ IDEA or Eclipse. But If you would like to generate a .jar file without any IDEA you can use the command gradle build in the project root (be sure Java version 17 and higher is installed).
Installing
Be sure that you already installed the Fabric of a needed version of Minecraft. Follow the link with releases *link*. Choose and download the .jar file needed version of Minecraft (also check the patch version). Put the downloaded file to the .mods folder (it is located by the %AppData%/.minecraft/mods path in most cases). Run Minecraft using fabric installation in your launcher.
Contribution
I will be glad if you can help in the development of this project. What you can do:
- Spelling correction. My English is not good, so you can correct the comments in the code or the text in the files (like README.md).
- Code cleanup
- Add new features or improve old ones
Code structure:
The code files are located in the folder that follows the path: src/main/java/com.crocoby. There are some files in this folder:
HttpInfoServer.java — have an entrance method that is called onInitialize and starts when Minecraft loads. We create and run WebSocket instances in the onInitialize method.
WebSocketDoor.java — The project uses the TooTallNate/Java-WebSocket library to make a WebSocket client. The WebSocket class describes the behavior of the WebSocket client that connects to the WebSocket server (another repo). When the server sends a message with the text "collectData" the WebSocket client uses InfoCollector class (this behavior is described in the onMessage method).
InfoCollector.java — Have the genJson function that collects data and turns it into JSON string format. This method needs to generate a response for the WebSocket server.
mixin/WorldJoinMixin.java — Have the init method that invokes whenever a player joining to any world (server works too). It sends a message in the in-game chat when the WebSocket client is not connected to the WebSocket server.
评论 0
登录后参与评分
还没有评论,来抢沙发吧