ChatSocket
一个提供 WebSocket 连接以发送和接收聊天消息/命令的简单模组。专为在后台运行 Minecraft 而玩其他游戏或进行开发的用户设计。
配置
通过 owo-config(也可通过 mod-menu 访问)提供游戏内配置。您可以在其中配置以下内容:
- 端口(默认值:8080)
- 主机地址(默认值:127.0.0.1)
- 启用状态(默认值:true)
- 通信类型(默认值:PLAIN_TEXT)
使用方法
出于测试目的,建议使用类似 Weasel Websocket 的浏览器扩展。一旦连接到 WebSocket(ws://127.0.0.1:8080),您将立即收到消息并能够发送一些消息。
针对不同的用途,目前有两种模式:PLAIN_TEXT 和 JSON。
PLAIN_TEXT 模式
在此模式下,消息以纯文本形式发送和接收。不包含任何 JSON 数据。
此模式旨在用于 IntelliJ 的 WebSocket 插件或其他无法解析 JSON 的工具。
请注意,communicationType 更新事件仍会以 JSON 对象的形式发送。
JSON 模式
为了提供更灵活性,提供了 JSON 模式。在此模式下,消息以 JSON 对象的形式发送和接收。
以下 JSON 对象会被发送:
传入消息
聊天消息
{
"type": "chat",
"messageString": "Hello World",
"gameProfile": {
"uuid": "8661e1be-bbf5-4cd6-86ba-60cc35f8f7e0",
"name": "AriVanHouten"
},
"timestamp": "2011-12-03T10:15:30Z"
}
游戏消息
// 大多数情况下这些由服务器发送
{
"type": "game",
"messageString": "Hello World",
"overlay": false,
}
通信类型变更
// 无论处于何种模式都会发送
{
"type": "communicationType",
"communicationType": "PLAIN_TEXT" // 或 "JSON"
}
错误
// 无论处于何种模式都会发送
{
type: "error",
"error": "Error message"
}
传出消息
发送聊天消息
{
"type": "chat", // 可选值: 'command' => 仅会在消息前添加斜杠
"message": "Hello World",
}
ChatSocket
A simple mod providing a web socket connection for sending and receiving chat messages / commands. Made for lazy people having Minecraft in the background while
playing other games or developing.
Config
Ingame Config is available via owo-config (also accessible via mod-menu). There you can configure
- port (default: 8080)
- host: (default: 127.0.0.1)
- enabled: (default: true)
- communication type: (default: PLAIN_TEXT)
Usage
For testing purposes, I recommend using a browser extension like Weasel Websocket. Once you connected
to the websocket (ws://127.0.0.1:8080), you will already receive messages and be able to send some.
For different purposes, there are currently two modes: PLAIN_TEXT and JSON.
PLAIN_TEXT Mode
In this mode, messages are being sent and received in full plain text. No json whatsoever.
This is intended for IntelliJ websocket plugins or other tools that are not able to parse JSON.
Mind that the communicationType update event is still being sent as a json object.
JSON Mode
To provide more flexibility, the JSON mode is available. In this mode, messages are being sent and received as JSON objects.
The following JSON objects are being sent:
Incoming messages
Chat Message
{
"type": "chat",
"messageString": "Hello World",
"gameProfile": {
"uuid": "8661e1be-bbf5-4cd6-86ba-60cc35f8f7e0",
"name": "AriVanHouten"
},
"timestamp": "2011-12-03T10:15:30Z"
}
Game Message
// most of the time these are being sent by the server
{
"type": "game",
"messageString": "Hello World",
"overlay": false,
}
CommunicationType Change
// Will be sent regardless of the mode
{
"type": "communicationType",
"communicationType": "PLAIN_TEXT" // or "JSON"
}
Error
// Will be sent regardless of the mode
{
type: "error",
"error": "Error message"
}
Outgoing messages
Sending a chat message
{
"type": "chat", // Alternatively: 'command' => will only prepend a slash to the message
"message": "Hello World",
}
评论 0
登录后参与评分
还没有评论,来抢沙发吧