koishi-plugin-minecraft-adapter 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +4 -3
- package/lib/index.js +35 -22
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -174,9 +174,10 @@ export interface ServerConfig {
|
|
|
174
174
|
};
|
|
175
175
|
/** RCON 配置(用于执行服务器命令,与 WebSocket 并行工作) */
|
|
176
176
|
rcon?: {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
enabled?: boolean;
|
|
178
|
+
host?: string;
|
|
179
|
+
port?: number;
|
|
180
|
+
password?: string;
|
|
180
181
|
timeout?: number;
|
|
181
182
|
};
|
|
182
183
|
/** ChatImage 图片显示配置(仅对此服务器生效) */
|
package/lib/index.js
CHANGED
|
@@ -136,16 +136,18 @@ class MinecraftAdapter extends koishi_1.Adapter {
|
|
|
136
136
|
this.bots.push(bot);
|
|
137
137
|
const connectTasks = [];
|
|
138
138
|
// RCON(用于执行服务器命令,与 WebSocket 并行工作)
|
|
139
|
-
if (serverConfig.rcon
|
|
139
|
+
if (serverConfig.rcon?.enabled) {
|
|
140
140
|
connectTasks.push((async () => {
|
|
141
141
|
try {
|
|
142
|
+
const rconHost = serverConfig.rcon.host || '127.0.0.1';
|
|
143
|
+
const rconPort = serverConfig.rcon.port || 25575;
|
|
142
144
|
if (this.debug) {
|
|
143
|
-
logger.info(`[DEBUG] Connecting RCON for server ${serverConfig.selfId} to ${
|
|
145
|
+
logger.info(`[DEBUG] Connecting RCON for server ${serverConfig.selfId} to ${rconHost}:${rconPort}`);
|
|
144
146
|
}
|
|
145
147
|
const rcon = await rcon_client_1.Rcon.connect({
|
|
146
|
-
host:
|
|
147
|
-
port:
|
|
148
|
-
password: serverConfig.rcon.password,
|
|
148
|
+
host: rconHost,
|
|
149
|
+
port: rconPort,
|
|
150
|
+
password: serverConfig.rcon.password || '',
|
|
149
151
|
timeout: serverConfig.rcon.timeout || 5000,
|
|
150
152
|
});
|
|
151
153
|
this.rconConnections.set(serverConfig.selfId, rcon);
|
|
@@ -161,14 +163,8 @@ class MinecraftAdapter extends koishi_1.Adapter {
|
|
|
161
163
|
})());
|
|
162
164
|
}
|
|
163
165
|
else {
|
|
164
|
-
logger.warn(`RCON not configured for server ${serverConfig.selfId} — server commands (executeCommand) will not be available`);
|
|
165
166
|
if (this.debug) {
|
|
166
|
-
|
|
167
|
-
logger.info(`[DEBUG] RCON config incomplete for server ${serverConfig.selfId}, skipping (need host, port, password)`);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
logger.info(`[DEBUG] No RCON config for server ${serverConfig.selfId}`);
|
|
171
|
-
}
|
|
167
|
+
logger.info(`[DEBUG] RCON not enabled for server ${serverConfig.selfId}`);
|
|
172
168
|
}
|
|
173
169
|
}
|
|
174
170
|
// WebSocket(用于事件接收和消息发送)
|
|
@@ -1004,16 +1000,33 @@ const serverSchema = koishi_1.Schema.object({
|
|
|
1004
1000
|
accessToken: koishi_1.Schema.string().description('访问令牌(需与鹊桥 config.yml 中的 access_token 一致)'),
|
|
1005
1001
|
extraHeaders: koishi_1.Schema.dict(koishi_1.Schema.string()).description('额外请求头'),
|
|
1006
1002
|
}).description('WebSocket 配置(用于事件接收和消息发送)').required(),
|
|
1007
|
-
rcon: koishi_1.Schema.
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1003
|
+
rcon: koishi_1.Schema.intersect([
|
|
1004
|
+
koishi_1.Schema.object({
|
|
1005
|
+
enabled: koishi_1.Schema.boolean().description('启用 RCON 远程命令执行').default(false),
|
|
1006
|
+
}),
|
|
1007
|
+
koishi_1.Schema.union([
|
|
1008
|
+
koishi_1.Schema.object({
|
|
1009
|
+
enabled: koishi_1.Schema.const(true).required(),
|
|
1010
|
+
host: koishi_1.Schema.string().description('RCON 主机地址').default('127.0.0.1'),
|
|
1011
|
+
port: koishi_1.Schema.number().description('RCON 端口').default(25575),
|
|
1012
|
+
password: koishi_1.Schema.string().description('RCON 密码(留空表示无密码)'),
|
|
1013
|
+
timeout: koishi_1.Schema.number().description('RCON 超时时间(ms)').default(5000),
|
|
1014
|
+
}),
|
|
1015
|
+
koishi_1.Schema.object({}),
|
|
1016
|
+
]),
|
|
1017
|
+
]).description('RCON 配置(用于执行服务器命令,与 WebSocket 并行工作)'),
|
|
1018
|
+
chatImage: koishi_1.Schema.intersect([
|
|
1019
|
+
koishi_1.Schema.object({
|
|
1020
|
+
enabled: koishi_1.Schema.boolean().description('启用 ChatImage CICode 图片发送(需客户端安装 ChatImage Mod)').default(false),
|
|
1021
|
+
}),
|
|
1022
|
+
koishi_1.Schema.union([
|
|
1023
|
+
koishi_1.Schema.object({
|
|
1024
|
+
enabled: koishi_1.Schema.const(true).required(),
|
|
1025
|
+
defaultImageName: koishi_1.Schema.string().description('图片在聊天栏中的默认显示名称').default('图片'),
|
|
1026
|
+
}),
|
|
1027
|
+
koishi_1.Schema.object({}),
|
|
1028
|
+
]),
|
|
1029
|
+
]).description('ChatImage 图片显示配置(仅对此服务器生效)'),
|
|
1017
1030
|
});
|
|
1018
1031
|
(function (MinecraftAdapter) {
|
|
1019
1032
|
MinecraftAdapter.Config = koishi_1.Schema.object({
|
package/package.json
CHANGED