一个基于 TabooLib 的 Bukkit 插件,用于检测和移除物品上的违禁 NBT 标签。
/nbtprohibition
(别名: /nbtp
, /nbtpro
)
/nbtp reload
nbtprohibition.command.reload
/nbtp check
nbtprohibition.command.check
nbtprohibition.command
nbtprohibition.command.reload
nbtprohibition.command.check
插件支持以下 NBT 路径格式:
简单路径
# 直接匹配顶层NBT
Unbreakable: true
# 配置: "Unbreakable"
嵌套路径
# 使用点号访问嵌套的NBT
display:
Name: "物品名称"
# 配置: "display.Name"
数组索引
# 使用方括号访问数组特定位置
ench: [
{id: 0s, lvl: 1s},
{id: 1s, lvl: 1s}
]
# 配置: "ench[0].id" - 匹配第一个附魔的id
# 配置: "ench[*].id" - 匹配所有附魔的id
值匹配
# 使用冒号匹配特定值
CustomPotionEffects: [
{Id: 6, Amplifier: 1}
]
# 配置: "CustomPotionEffects[0].Id:6"
组合使用
# 以上规则可以组合使用
ench: [
{id: 1s, lvl: 5s},
{id: 34s, lvl: 3s}
]
# 配置: "ench[0].id:1s" - 匹配第一个附魔且其id为1s
# 配置: "ench[*].id:1s" - 匹配任意位置id为1s的附魔
# NBT Prohibition Configuration
# 调试模式会输出更多信息
debug: false
# 这里列出所有需要限制的NBT
# 支持以下格式:
# 1. 简单路径: "Unbreakable" - 直接匹配顶层NBT
# 示例: "Unbreakable" 会匹配 {Unbreakable:1b}
#
# 2. 嵌套路径: "display.Name" - 使用点号访问嵌套的NBT
# 示例: "display.Name" 会匹配 {display:{Name:"物品名称"}}
#
# 3. 数组索引: "ench[0].id" - 使用方括号访问数组特定位置
# 示例: "ench[0].id" 会匹配 {ench:[{id:0s,lvl:1s},{id:1s,lvl:1s}]} 中的第一个附魔
# 示例: "ench[*].id" 会匹配所有附魔的id
#
# 4. 值匹配: "ench.id:1s" - 使用冒号匹配特定值
# 示例: "CustomPotionEffects[0].Id:6" 会匹配ID为6的药水效果
#
# 5. 组合使用: "ench[0].id:1s" - 以上规则可以组合使用
# 示例: "ench[0].id:1s" 会匹配第一个附魔且其id为1s的情况
# 示例: "ench[*].id:1s" 会匹配任意位置id为1s的附魔
restricted-nbts:
# 基础NBT限制
- "Unbreakable" # 无限耐久
- "AttributeModifiers" # 属性修饰符
- "HideFlags" # 隐藏标签
# 显示相关
- "display.Name" # 物品名称
- "display.Lore" # 物品描述
# 附魔相关
- "ench[*]" # 移除所有旧版附魔
- "Enchantments[*]" # 移除所有新版附魔
- "ench[0].id:0s" # 移除第一个附魔且其id为0的情况
- "ench[*].id:0s" # 移除任意位置id为0的附魔
# 药水效果
- "CustomPotionEffects[*]" # 移除所有自定义药水效果
- "CustomPotionEffects[0].Id:6" # 移除第一个药水效果且其ID为6的情况
- "CustomPotionEffects[*].Id:6" # 移除任意位置ID为6的药水效果
# 自定义数据
- "custom.damage" # 自定义伤害
- "custom.abilities" # 自定义能力
- "custom.data.special" # 深层嵌套的自定义数据
- "custom.effects[*].power" # 所有效果的能力值
# 当NBT被移除时执行的脚本
remove-scripts:
# 全局脚本会在任何NBT被移除时执行
global:
- "tell player '&c你的物品中含有违禁NBT,已被移除!'"
- "sound ENTITY_VILLAGER_NO by player"
- "actionbar player '&c物品已被清理'"
# 针对特定NBT的脚本
Unbreakable:
- "tell player '&c无限耐久已被移除!'"
- "sound BLOCK_ANVIL_BREAK by player"
"display.Name":
- "tell player '&c非法物品名称已被移除!'"
"display.Lore":
- "tell player '&c非法物品描述已被移除!'"
"ench[0].id:0s":
- "tell player '&c检测到违规附魔(id:0s),已移除!'"
- "sound ENTITY_EXPERIENCE_ORB_PICKUP by player"
AttributeModifiers:
- "tell player '&c属性修饰符已被移除!'"
- "broadcast &4警告:玩家 {player} 使用了非法物品!"
- "console 'kick {player} 使用非法物品'"
CustomPotionEffects:
- "tell player '&c自定义药水效果已被移除!'"
- "effect give player BLINDNESS 3 1"
# 可以使用通配符匹配所有custom前缀的NBT
"custom.*":
- "tell player '&c自定义NBT已被移除!'"
- "log 玩家{player}使用了自定义NBT物品"
@EventHandler
fun onNBTRestrictRemove(e: EntityNBTRestrictRemoveEvent) {
val player = e.player // 执行移除的玩家
val item = e.item // 被移除NBT的物品
val removedNBT = e.removedNBT // 被移除的NBT路径
}
在 config.yml
中启用调试模式可以看到详细的 NBT 处理信息:
# 调试模式会输出更多信息
debug: true
调试信息包括: