一个 Paper 插件,允许玩家向 OpenRouter 模型发送提示并接收聊天中的回复。每次 /openrouter 调用都是单次、无状态的请求——该插件不会在消息之间保留对话历史。
功能
- 直接集成 OpenRouter API
- 仅支持单轮提示(消息间无对话记忆)
- 不捆绑任何密钥或 API 密钥
- 提供操作员命令,可从游戏内或服务器控制台保存 API 密钥
- 可配置模型、系统提示词、超时时间和聊天格式
- 区分普通使用与管理操作的权限节点
- 可选的
ops-only-chat 开关,在使用权限基础上额外要求操作员身份
设置
- 从 Releases 下载 jar 文件
- 将其放入服务器的
plugins/ 文件夹
- 重启服务器
- 通过以下任一方式设置你的 OpenRouter API 密钥:
- 配置文件:
plugins/OpenRouterChat/config.yml
- 游戏内(作为 op)或服务器控制台:
/openrouter add-key <your-key>
命令
/openrouter <message> 形式必须由玩家执行,以便将回复发送给该玩家。管理子命令(add-key、clear-key、reload、status)可由拥有 manage 权限的游戏内玩家或服务器控制台执行。
/openrouter <message> — 向配置的 OpenRouter 模型发送提示(仅限玩家)
/openrouter add-key <api-key> — 保存 OpenRouter API 密钥
/openrouter clear-key — 移除已存储的 API 密钥
/openrouter reload — 重新加载配置
/openrouter status — 查看当前状态
别名:
权限
openrouterchat.use
- 允许使用
/openrouter <message>
- 默认值:
op
openrouterchat.manage
- 允许使用
/openrouter add-key、clear-key、reload 和 status
- 默认值:
op
配置
api-key: ""
model: "openai/gpt-4.1-mini"
site-url: ""
site-name: "Paper OpenRouter Chat"
system-prompt: "You are a helpful Minecraft server assistant. Keep answers concise and useful for in-game chat."
max-tokens: 300
temperature: 0.7
timeout-seconds: 45
response-prefix: "&b[OpenRouter] &f"
error-prefix: "&c[OpenRouter] &7"
thinking-message: "&e[OpenRouter] &7&oThinking..."
ops-only-chat: false
ops-only-chat 是在 openrouterchat.use 权限之上的额外限制。当设置为 true 时,即使非 op 玩家被授予了 openrouterchat.use 权限,也只有服务器操作员可以运行 /openrouter <message>。当为 false(默认值)时,仅由权限节点控制访问。
构建
mvn clean package
输出:
target/paper-openrouter-chat-0.1.0.jar
兼容性
- 基于 Paper
1.21.4 编写
- 已在 Paper
26.1.2 上确认可用
- Java
21
A Paper plugin that lets players send a prompt to an OpenRouter model and receive the reply in chat. Each /openrouter invocation is a single, stateless request — the plugin does not keep conversation history between messages.
Features
- Direct OpenRouter API integration
- Single-turn prompts only (no conversation memory between messages)
- No bundled secrets or API keys
- Operator command to save the API key from in-game or the server console
- Configurable model, system prompt, timeout, and chat formatting
- Permission nodes for normal usage vs management
- Optional
ops-only-chat toggle that requires operator status on top of the use permission
Setup
- Download the jar from Releases
- Put it in your server's
plugins/ folder
- Restart the server
- Set your OpenRouter API key using either:
- config file:
plugins/OpenRouterChat/config.yml
- in-game (as op) or from the server console:
/openrouter add-key <your-key>
Commands
The /openrouter <message> form must be run by a player so the response can be delivered to them. The management subcommands (add-key, clear-key, reload, status) can be run from either an in-game player with the manage permission or the server console.
/openrouter <message> — send a prompt to the configured OpenRouter model (player only)
/openrouter add-key <api-key> — save the OpenRouter API key
/openrouter clear-key — remove the stored API key
/openrouter reload — reload config
/openrouter status — view current status
Aliases:
Permissions
openrouterchat.use
- Allows using
/openrouter <message>
- Default:
op
openrouterchat.manage
- Allows
/openrouter add-key, clear-key, reload, and status
- Default:
op
Config
api-key: ""
model: "openai/gpt-4.1-mini"
site-url: ""
site-name: "Paper OpenRouter Chat"
system-prompt: "You are a helpful Minecraft server assistant. Keep answers concise and useful for in-game chat."
max-tokens: 300
temperature: 0.7
timeout-seconds: 45
response-prefix: "&b[OpenRouter] &f"
error-prefix: "&c[OpenRouter] &7"
thinking-message: "&e[OpenRouter] &7&oThinking..."
ops-only-chat: false
ops-only-chat is an extra gate on top of the openrouterchat.use permission. When set to true, only server operators can run /openrouter <message>, even if non-op players have been granted openrouterchat.use. When false (the default), the permission node alone controls access.
Build
mvn clean package
Output:
target/paper-openrouter-chat-0.1.0.jar
Compatibility
- Written for Paper
1.21.4
- Confirmed working on Paper
26.1.2
- Java
21
评论 0
登录后参与评分
还没有评论,来抢沙发吧