EliteRename 是一款轻量级的、基于状态驱动的项元数据操作插件,专为 Paper 1.21 设计。它通过利用持久化数据存储和严格的组件重建机制,绕过了原版客户端渲染的僵化限制,赋予用户对物品显示名称、描述文本数组、附魔显示和属性修饰符的完全控制权。
-
核心渲染与格式化管道
MiniMessage 集成:摒弃了旧版字符串格式化方式,转而采用 Adventure API 的 MiniMessage,支持复杂的 RGB 渐变、十六进制颜色以及丰富的文本组件(, <bold>),并安全地解析为原生 Component 对象。
动态描述文本重建:使用一个管道(rebuildLoreOnMeta)作为物品可见描述文本数组的唯一事实来源。它会即时拼接自定义附魔标签和用户定义的描述文本,确保 UI 更新与底层数据结构保持同步。
-
数据持久化 (PDC)
隔离存储:插件并未将自定义数据存储在脆弱的基于字符串的描述文本行中,而是使用 Gson 将状态序列化为 JSON 数组和对象,并直接存储在物品的 PersistentDataContainer (PDC) 中。
命名空间键:使用专用键(KEY_ENCHANT_LABELS, KEY_USER_LORE)来分离由插件管理的数据与原版 NBT 数据或其他插件的修改,防止冲突,并允许在编辑外来物品时优雅降级。
-
客户端 UI 混淆与模拟
附魔伪造 (/enchlabel):应用 ItemFlag.HIDE_ENCHANTS 以抑制硬编码的客户端工具提示。随后,它将用户定义的、非斜体的灰色文本前置到描述文本数组中,完美模仿原版的附魔显示效果,同时允许自定义命名(例如,将 "Sharpness" 改为 "Blade of Doom")。
属性注入 (/renameattr):应用 ItemFlag.HIDE_ATTRIBUTES 以隐藏默认的武器/工具修饰符。它读取物品的 AttributeModifiers(如果不存在则回退到材质对应的原版默认值),结合基础玩家实体统计信息(例如 1.0 基础伤害,4.0 基础速度),并将数学上准确、视觉上与原版的 "When in Main Hand:" 工具提示完全一致的副本直接注入到 PDC 描述文本数组中。这将硬编码的客户端属性转化为完全可变的文本。
-
状态管理(遗憾机器)
基于会话的撤销栈:维护一个瞬时的、按 UUID 映射的每玩家 Deque<ItemStack>。
LIFO 记忆:在任何变异发生之前立即捕获 ItemStack 的深度克隆。该栈在每个会话中限制为最多 5 个状态,以防止内存泄漏,并充当后进先出(LIFO)的回滚机制,在恢复 ItemMeta 之前验证物品类型是否匹配。
-
实用功能与生活便利
身份窃取 (/rename steal):一种上下文感知的克隆方法,读取副手物品的 ItemMeta,提取其显示名称和 PDC 存储的用户描述文本(对于外来物品回退到原始描述文本),并在保留主手物品原生附魔的同时覆盖主手物品。
上下文 Tab 补全:命令路由器具有深度的 Tab 补全功能,能够实时查询物品的当前内部状态。例如,输入 /setlore 1 会动态序列化并建议当前位于第 1 行的确切 MiniMessage 字符串,从而允许快速进行就地拼写错误修正。
commands:
rename:
description: 重命名手持物品,重置它,撤销更改,或从你的副手窃取身份。
usage: /rename [reset | undo | steal | <text...>]
permission: elr.rename.player
setlore:
description: 设置或替换特定的描述文本行。
usage: /setlore <line> <text...>
permission: elr.lore
addlore:
description: 追加新的描述文本行。
usage: /addlore <text...>
permission: elr.lore
removelore:
description: 通过编号移除特定的描述文本行。
usage: /removelore <line>
permission: elr.lore
clearlore:
description: 清除手持物品上的所有用户描述文本。
usage: /clearlore
permission: elr.lore
enchlabel:
description: 对特定附魔应用自定义视觉标签。
usage: /enchlabel <enchant> [<text...> | reset]
permission: elr.enchant
iteminfo:
description: 查看手持物品的元数据详情。
usage: /iteminfo [field]
permission: elr.info
renameattr:
description: 隐藏原版属性并将其转换为可编辑的描述文本。
usage: /renameattr <true|false>
permission: elr.renameattr
permissions:
elr.rename.player:
description: 允许普通玩家使用 /rename 命令。
default: true
elr.rename:
description: 明确授予管理员使用 /rename 命令的权限。
default: op
elr.lore:
description: 允许使用 /setlore, /addlore, /removelore 和 /clearlore。
default: op
elr.enchant:
description: 允许使用 /enchlabel 命令。
default: op
elr.info:
description: 允许使用 /iteminfo 读取物品元数据。
default: true
elr.renameattr:
description: 允许使用 /renameattr 隐藏原版属性并将其转换为可编辑的描述文本。
default: true
elr.admin:
description: 完全访问所有 EliteRename 命令和功能。
default: op
版本 1.0(窃取功能尚未达到我期望的效果,它可以工作,但由于其按需匹配的方式,感觉不够……侵入性)
EliteRename is a lightweight, state-driven item metadata manipulation plugin designed for Paper 1.21. It bypasses rigid vanilla client-side rendering by utilizing persistent data storage and strict component recreation, granting users total control over item display names, lore arrays, enchantment displays, and attribute modifiers.
-
Core Rendering & Formatting Pipeline
MiniMessage Integration: Drops legacy string formatting in favor of the Adventure API’s MiniMessage, allowing for complex RGB gradients, hex colors, and rich text components (, <bold>) parsed safely into native Component objects.
Dynamic Lore Reconstruction: Utilizes a pipeline (rebuildLoreOnMeta) that acts as a single source of truth for the item's visible lore array. It concatenates custom enchant labels and user-defined lore on the fly, ensuring that UI updates remain synchronized with underlying data structures.
-
Data Persistence (PDC)
Isolated Storage: Rather than storing custom data in fragile string-based lore lines, the plugin serializes state into JSON arrays and objects using Gson and stores them directly in the item's PersistentDataContainer (PDC).
Namespaced Keys: Uses dedicated keys (KEY_ENCHANT_LABELS, KEY_USER_LORE) to separate plugin-managed data from vanilla NBT data or foreign plugin modifications, preventing collisions and allowing foreign items to degrade gracefully when edited.
-
Client UI Obfuscation & Emulation
Enchantment Faking (/enchlabel): Applies ItemFlag.HIDE_ENCHANTS to suppress the hardcoded client tooltip. It then prepends user-defined, non-italic gray text to the lore array, perfectly mimicking the vanilla enchantment display while allowing custom naming (e.g., changing "Sharpness" to "Blade of Doom").
Attribute Injection (/renameattr): Applies ItemFlag.HIDE_ATTRIBUTES to hide default weapon/tool modifiers. It reads the item's AttributeModifiers (or falls back to the material's vanilla defaults), factors in the base player entity stats (e.g., 1.0 base damage, 4.0 base speed), and injects a mathematically accurate, visually identical replica of the vanilla "When in Main Hand:" tooltip directly into the PDC lore array. This transforms hardcoded client attributes into fully mutable text.
-
State Management (The Regret Machine)
Session-Based Undo Stack: Maintains a transient, per-player Deque<ItemStack> mapped by UUID.
LIFO Memory: Captures deep clones of the ItemStack immediately prior to any mutation. The stack is capped at 5 states per session to prevent memory leaks and acts as a Last-In-First-Out rollback mechanism, verifying item types match before restoring ItemMeta.
-
Utility & Quality of Life
Identity Theft (/rename steal): A context-aware cloning method that reads the ItemMeta of the offhand item, extracts its display name and PDC-stored user lore (falling back to raw lore for foreign items), and overwrites the main-hand item while preserving the main-hand's native enchantments.
Contextual Tab-Completion: The command router features deep tab-completion that queries the item's current internal state in real-time. For example, typing /setlore 1 dynamically serializes and suggests the exact MiniMessage string currently sitting on line 1, allowing for rapid in-place typo corrections.
commands:
rename:
description: Rename held item, reset it, undo a change, or steal identity from your offhand.
usage: /rename [reset | undo | steal | <text...>]
permission: elr.rename.player
setlore:
description: Set or replace a specific lore line.
usage: /setlore <line> <text...>
permission: elr.lore
addlore:
description: Append a new lore line.
usage: /addlore <text...>
permission: elr.lore
removelore:
description: Remove a specific lore line by number.
usage: /removelore <line>
permission: elr.lore
clearlore:
description: Strip all user lore from the held item.
usage: /clearlore
permission: elr.lore
enchlabel:
description: Apply a custom visual label to a specific enchantment.
usage: /enchlabel <enchant> [<text...> | reset]
permission: elr.enchant
iteminfo:
description: View metadata details for the held item.
usage: /iteminfo [field]
permission: elr.info
renameattr:
description: Hides vanilla attributes and converts them into editable lore.
usage: /renameattr <true|false>
permission: elr.renameattr
permissions:
elr.rename.player:
description: Allows regular players to use the /rename command.
default: true
elr.rename:
description: Explicit admin grant for the /rename command.
default: op
elr.lore:
description: Allows the use of /setlore, /addlore, /removelore, and /clearlore.
default: op
elr.enchant:
description: Allows the use of the /enchlabel command.
default: op
elr.info:
description: Allows reading item metadata using /iteminfo.
default: true
elr.renameattr:
description: Allows Hiding of vanilla attributes and converts them into editable lore using /renameattr.
default: true
elr.admin:
description: Full access to all EliteRename commands and features.
default: op
Version 1.0 (Steal feature not yet working how I would prefer, it does work it just feels not... intrusive enough due to it looking at matching as needed)
评论 0
登录后参与评分
还没有评论,来抢沙发吧