Spyglass
通过 Discord 管理你的服务器,并实时查看每一条输入的命令。
在单个配置块中定义你自己的斜杠命令。无需编写代码,不向外部回传数据。
功能特性
- 自定义斜杠命令:配置键即命令名,因此
/ban 仅需三行配置
- 实时命令流:游戏中执行的每条命令都会镜像到你指定的 Discord 频道
- 约 85 个占位符:支持玩家、位置、世界、生命值、延迟、命令、Discord 用户、服务器统计等
- 智能过滤器:支持带通配符的忽略列表、仅包含白名单、忽略特定玩家、权限绕过
- 密码安全:默认忽略
login、register 和私聊命令
- 防速率限制:消息会被分批合并为一条发送(每隔几秒),避免刷屏 Discord
- 自解释的配置错误:文件损坏时会提示具体的行号、列号和修复方法,且不会应用任何更改
- MiniMessage 格式支持:渐变、悬停文本和可点击命令均可在
messages.yml 中实现
- 注入防护:名为
<red> 的玩家无法给管理员频道上色或植入可点击命令
- 一键命令设置检查:运行
/spyglass test 即可一次性验证令牌、频道 ID 和机器人权限
- 零遥测数据:无更新检查器,无分析工具,唯一的外部连接是 Discord
你的命令,你的配置
配置键同时充当命令名称及其签名。以下是一个能正常工作的 /ban 命令的全部配置:
commands:
"ban {username}":
discord-command-description: "用于封禁成员"
minecraft-command: "/ban {username}"
当某个选项需要接收整句话时,请在最后一个参数后添加三个点,并利用 Discord 自动补全功能从实时在线玩家列表中选择:
"kick {username} {reason...}":
discord-command-description: "将玩家踢出服务器"
minecraft-command: "/kick {username} {reason}"
arguments:
username:
suggest-online-players: true
reason:
required: false
一个斜杠命令可以按顺序执行多个 Minecraft 命令,锁定特定角色、用户或频道,设置冷却时间,以控制台身份或玩家身份运行,并回复私信。
参数类型包括:string(字符串)、integer(整数)、number(数字)、boolean(布尔值)、user(用户)、channel(频道)、role(角色),并支持可选的固定选项。
监视每条命令
command-monitor:
enabled: true
channel-id: "1234567890123456789"
format: "{username}: {command}"
所有占位符均适用于该格式,你可以选择在 Discord 中显示多少详细信息:
format: "`{time}` **{username}** ran `{command}`"
format: "[{world}] {username} ({x}, {y}, {z}) ran {command}"
玩家、控制台、RCON 以及来自 Discord 的命令均被涵盖。来自 Discord 的命令会归因于对应的 Discord 用户,而非控制台。
配置出错时告诉你如何修复
两个文件在应用任何更改之前都会被解析。语法错误不会改变当前状态,正在运行的设置保持生效,你会看到如下信息而不是堆栈跟踪:
[Spyglass] config.yml could not be loaded - it has a YAML syntax error.
[Spyglass] Line 83, column 22: mapping values are not allowed here
[Spyglass] 83 | text: Now playing: survival mode
[Spyglass] | ^
[Spyglass] Fix: this value contains a colon. Wrap the whole value in "double quotes"
它能识别未加引号的冒号、Tab 缩进、缩进不对齐、未闭合的引号、重复的键以及以花括号开头的键。
命令
| 命令 |
描述 |
/spyglass reload |
重载 config.yml 和 messages.yml |
/spyglass status |
查看 Discord 连接状态、监控统计、配置警告 |
/spyglass commands |
列出所有已配置的 Discord 命令 |
/spyglass test |
向监控频道发送一行测试消息 |
/spyglass help |
在游戏中显示命令列表 |
/sg |
/spyglass 的别名 |
/glass |
/spyglass 的别名 |
权限
| 权限节点 |
默认值 |
描述 |
| spyglass.admin |
op |
完全访问所有子命令 |
| spyglass.reload |
op |
使用 /spyglass reload |
| spyglass.status |
op |
使用 /spyglass status |
| spyglass.commands |
op |
使用 /spyglass commands |
| spyglass.test |
op |
使用 /spyglass test |
| spyglass.monitor.bypass |
false |
该玩家的命令永远不会被转发 |
谁可以使用斜杠命令是在 config.yml 中通过 Discord 角色、用户或频道设置的,而不是通过 Minecraft 权限。
安装步骤
- 将 jar 包放入
plugins/ 目录并启动服务器一次
- 在 Discord 开发者门户创建机器人,打开 Bot 选项卡,点击 Reset Token
- 通过 OAuth2 > URL Generator 邀请它,勾选
bot 和 applications.commands
- 在 Discord 中开启 Developer Mode(开发者模式),然后右键点击以 Copy ID(复制 ID)
- 将你的令牌和服务器 ID 填入
config.yml
- 运行
/spyglass reload,然后运行 /spyglass test
无需启用特权意图。
要求
- Bukkit / Spigot / Paper / Purpur 1.21 至 26.2
- Java 21+
- 一个 Discord 机器人令牌
Spyglass 仅使用标准的 Bukkit API,因此同一个 jar 包可以在上述四种服务端软件上无需修改地运行。
Spyglass
Run your server from Discord, and watch every command typed on it.
Define your own slash commands in one block of config. No coding, no phoning home.
Features
- Your own slash commands : the config key is the command, so
/ban takes three lines
- Live command feed : every command run in game, mirrored to a Discord channel you pick
- Around 85 placeholders : player, location, world, health, ping, command, Discord user, server stats
- Smart filters : ignore lists with wildcards, an only-these whitelist, ignored players, bypass permission
- Password safe :
login, register and private message commands are ignored out of the box
- Rate limit proof : lines are batched into one message every few seconds instead of spamming Discord
- Config errors that explain themselves : a broken file gives you the line, column and the fix, and nothing gets applied
- MiniMessage formatting : gradients, hover text and clickable commands, all from
messages.yml
- Injection safe : a player named
<red> cannot recolour your staff channel or plant a clickable command
- One command setup check :
/spyglass test verifies token, channel ID and bot permissions at once
- Zero telemetry : no update checker, no analytics, the only connection it makes is to Discord
Your commands, your config
The config key doubles as the command name and its signature. This is the whole setup for a working /ban:
commands:
"ban {username}":
discord-command-description: "Used to ban members"
minecraft-command: "/ban {username}"
Add three dots to the last option when it should take a whole sentence, and let Discord autocomplete from your live player list:
"kick {username} {reason...}":
discord-command-description: "Kick a player off the server"
minecraft-command: "/kick {username} {reason}"
arguments:
username:
suggest-online-players: true
reason:
required: false
One slash command can run several Minecraft commands in order, lock to specific roles, users or channels, carry a cooldown, run as console or as a player, and reply privately.
Argument types: string, integer, number, boolean, user, channel, role, with optional fixed choices.
Watch every command
command-monitor:
enabled: true
channel-id: "1234567890123456789"
format: "{username}: {command}"
Every placeholder works in the format, so you choose how much detail lands in Discord:
format: "`{time}` **{username}** ran `{command}`"
format: "[{world}] {username} ({x}, {y}, {z}) ran {command}"
Players, console, RCON, and commands that came from Discord are all covered. Discord ones are credited to the Discord user rather than to the console.
Broken config tells you how to fix it
Both files are parsed before anything is applied. A syntax error changes nothing, your running settings stay live, and you get this instead of a stack trace:
[Spyglass] config.yml could not be loaded - it has a YAML syntax error.
[Spyglass] Line 83, column 22: mapping values are not allowed here
[Spyglass] 83 | text: Now playing: survival mode
[Spyglass] | ^
[Spyglass] Fix: this value contains a colon. Wrap the whole value in "double quotes"
It knows unquoted colons, tab indentation, misaligned indentation, unclosed quotes, duplicate keys, and keys that start with a brace.
Commands
| Command |
Description |
/spyglass reload |
Reload config.yml and messages.yml |
/spyglass status |
Discord connection, monitor stats, config warnings |
/spyglass commands |
List every configured Discord command |
/spyglass test |
Post a test line to the monitor channel |
/spyglass help |
Show the command list in game |
/sg |
Alias for /spyglass |
/glass |
Alias for /spyglass |
Permissions
| Permission |
Default |
Description |
| spyglass.admin |
op |
Full access to every sub-command |
| spyglass.reload |
op |
Use /spyglass reload |
| spyglass.status |
op |
Use /spyglass status |
| spyglass.commands |
op |
Use /spyglass commands |
| spyglass.test |
op |
Use /spyglass test |
| spyglass.monitor.bypass |
false |
This player's commands are never relayed |
Who may use a slash command is set in config.yml by Discord role, user or channel, not by Minecraft permissions.
Setup
- Drop the jar in
plugins/ and start the server once
- Create a bot at the Discord developer portal, open Bot, press Reset Token
- Invite it from OAuth2 > URL Generator with
bot and applications.commands ticked
- Turn on Developer Mode in Discord, then right click to Copy ID
- Put your token and server ID in
config.yml
- Run
/spyglass reload, then /spyglass test
No privileged intents to enable.
Requirements
- Bukkit / Spigot / Paper / Purpur 1.21 to 26.2
- Java 21+
- A Discord bot token
Spyglass only uses standard Bukkit API, so the same jar runs unmodified on all four.
评论 0
登录后参与评分
还没有评论,来抢沙发吧