ToolGuardian
当玩家的工具或护甲即将损坏时发出警告——支持可配置的阈值、本地化消息、MiniMessage 格式以及具有持久化的玩家独立开关。
功能
- 监控当前装备:主手、副手、头盔、胸甲、护腿、靴子(可按槽位单独启用/禁用)。
- 可配置百分比阈值(可添加任意数量,每个阈值拥有独立的消息键和可选声音)。
- 使用 MiniMessage 格式的本地化消息(
lang/de.yml、lang/en.yml)。
- 消息中支持占位符:
{item}、{percent}、{remaining}、{max}。
- 防重复触发:在每个物品达到下一个阈值之前,仅针对该阈值触发一次警告。
- 游戏模式过滤:默认仅适用于生存模式/冒险模式。
- 通过命令为每位玩家单独开启/关闭警告,并持久化存储于
toggles.yml。
要求
- Paper (Minecraft 1.21.10)
- Java 21
安装
- 下载发布版 JAR 文件(或从源代码构建,见下文)。
- 将 JAR 放入服务器的
plugins 文件夹中。
- 启动或重启服务器。
- 可选:调整
plugins/ToolGuardian/config.yml 以及位于 plugins/ToolGuardian/lang/ 下的本地化文件。
配置
默认 config.yml(你可以自由添加或删除阈值):
language: de
enabled-gamemodes:
- SURVIVAL
- ADVENTURE
monitor:
main-hand: true
off-hand: true
head: true
chest: true
legs: true
feet: true
thresholds:
- percent: 20
message: warn.medium
- percent: 10
message: warn.low
- percent: 5
message: warn.critical
sound: BLOCK_NOTE_BLOCK_BELL
sound-volume: 1.0
sound-pitch: 1.0
check-interval-ticks: 20
注意:
- 阈值应按
percent 升序排列。
- 仅在对应阈值配置了声音时才会播放声音。
- 插件以固定间隔进行检查(默认为 20 tick = 1秒)。
本地化
提供两种语言文件:lang/de.yml 和 lang/en.yml。示例如下:
warn:
medium: "<yellow><bold>注意:</bold></yellow> {item} 耐久度剩余 <yellow>{percent}%</yellow> (<gray>{remaining}/{max}</gray>)。"
low: "<gold><bold>警告:</bold></gold> {item} 耐久度剩余 <gold>{percent}%</gold> (<gray>{remaining}/{max}</gray>)。"
critical: "<red><bold>危急:</bold></red> {item} 仅剩 <red>{percent}%</red> 耐久度 (<gray>{remaining}/{max}</gray>)!"
toggle:
now-enabled: "<green>ToolGuardian 警告:<bold>已开启</bold></green>"
now-disabled: "<red>ToolGuardian 警告:<bold>已关闭</bold></red>"
usage: "<gray>用法:</gray> <yellow>/toolguardian toggle</yellow>"
no-permission: "<red>你没有权限。</red>"
占位符写作 {item}、{percent}、{remaining}、{max},并可在其周围使用 MiniMessage 标签进行样式设置。插件会在运行时转换这些占位符并解析其值。
命令
/toolguardian toggle (别名 /tg):切换你自己的警告状态。
权限
toolguardian.toggle — 默认:true
工作原理
- 插件定期扫描配置的槽位。如果某件物品具有耐久度且进入配置的阈值区间(例如 20% → 10% → 5%),则玩家会针对该物品的每个阈值阶段收到一条消息。当物品更换或耐久度再次高于最高阈值时,内部状态重置,以便在适当时机继续发出未来警告。
故障排除
- 没有消息?
- 确保你的游戏模式已在
enabled-gamemodes 中启用。
- 检查
monitor 下是否启用了相应槽位(如 main-hand、head)。
- 确认该物品确实具有耐久度。
- 占位符原样显示?
- 确保你在语言文件中保留了花括号占位符(
{item}、{percent}、{remaining}、{max})。
- 避免使用会剥离 MiniMessage 格式的其他聊天格式化器产生冲突。
- 危急状态下没有声音?
- 确保所需阈值的
sound 字段存在,并使用有效的 Bukkit 声音名称。
ToolGuardian
Warn players when their tools or armor are about to break — configurable thresholds, localized messages, MiniMessage formatting, and per-player toggles with persistence.
Features
- Monitor active equipment: main hand, off hand, helmet, chestplate, leggings, boots (toggle per slot).
- Configurable thresholds in percent (add as many as you like, each with its own message key and optional sound).
- Localized messages (
lang/de.yml, lang/en.yml) using MiniMessage formatting.
- Placeholder support in messages:
{item}, {percent}, {remaining}, {max}.
- Anti-spam: warn once per threshold per item until the next threshold is reached.
- Gamemode filter: by default only Survival/Adventure.
- Per-player toggle command with persistent storage (
toggles.yml).
Requirements
- Paper (Minecraft 1.21.10)
- Java 21
Installation
- Download the release JAR (or build from source, see below).
- Put the JAR into your server's
plugins folder.
- Start or restart the server.
- Optional: adjust
plugins/ToolGuardian/config.yml and localization files under plugins/ToolGuardian/lang/.
Configuration
Default config.yml (you can add or remove thresholds freely):
language: de
enabled-gamemodes:
- SURVIVAL
- ADVENTURE
monitor:
main-hand: true
off-hand: true
head: true
chest: true
legs: true
feet: true
thresholds:
- percent: 20
message: warn.medium
- percent: 10
message: warn.low
- percent: 5
message: warn.critical
sound: BLOCK_NOTE_BLOCK_BELL
sound-volume: 1.0
sound-pitch: 1.0
check-interval-ticks: 20
Notes:
- Thresholds should be listed in ascending order by
percent.
- A sound plays only if configured on that threshold.
- The plugin checks at a fixed interval (20 ticks = 1s by default).
Localization
Two language files are provided: lang/de.yml and lang/en.yml. Example:
warn:
medium: "<yellow><bold>Heads up:</bold></yellow> {item} at <yellow>{percent}%</yellow> durability (<gray>{remaining}/{max}</gray>)."
low: "<gold><bold>Warning:</bold></gold> {item} at <gold>{percent}%</gold> durability (<gray>{remaining}/{max}</gray>)."
critical: "<red><bold>CRITICAL:</bold></red> {item} only <red>{percent}%</red> durability left (<gray>{remaining}/{max}</gray>)!"
toggle:
now-enabled: "<green>ToolGuardian warnings: <bold>ON</bold></green>"
now-disabled: "<red>ToolGuardian warnings: <bold>OFF</bold></red>"
usage: "<gray>Usage:</gray> <yellow>/toolguardian toggle</yellow>"
no-permission: "<red>You don't have permission.</red>"
Placeholders are written as {item}, {percent}, {remaining}, {max} and can be styled with MiniMessage tags around them. The plugin converts these placeholders and resolves them at runtime.
Commands
/toolguardian toggle (alias /tg): Toggle warnings for yourself.
Permissions
toolguardian.toggle — default: true
How it works
- The plugin periodically scans configured slots. If an item has durability and enters a configured threshold (e.g., 20% → 10% → 5%), the player receives exactly one message per threshold step for that item. When the item changes or durability goes above the highest threshold again, the internal state resets, allowing future warnings as appropriate.
Troubleshooting
- No messages?
- Ensure your gamemode is enabled in
enabled-gamemodes.
- Check that the slot (e.g.,
main-hand, head) is enabled under monitor.
- Verify the item actually has durability.
- Placeholders appear literally?
- Make sure you kept the curly-brace placeholders (
{item}, {percent}, {remaining}, {max}) in your locale file.
- Avoid conflicting chat formatters that strip MiniMessage formatting.
- No sound at critical?
- Ensure the
sound field exists on the desired threshold and uses a valid Bukkit sound name.
评论 0
登录后参与评分
还没有评论,来抢沙发吧