Floyd-Backpack
概述
Floyd-Backpack 是一款基于 PaperMC 的服务端背包插件,为每位玩家提供独立的 54 格存储空间。该插件基于 Floyd-Core 框架开发,支持数据持久化、通过工具物品快速访问背包,以及二次确认机制以防止误操作。
功能特性
- 54 格背包:每位玩家拥有独立的双箱容量存储空间,按 UUID 隔离
- 背包工具:玩家加入服务器或重生时会自动获得一个工具物品(末影之眼);右键点击即可打开背包;为防止误操作,该工具物品无法存入背包中
- 数据持久化:玩家退出时自动保存,服务器关闭时批量持久化至 JSON 文件
- 清空功能:一键清空背包,具备二次确认机制和可配置的超时时间
- 国际化:内置英文和简体中文,可通过配置文件切换;背包标题会随语言动态更新
- 热重载:支持无需重启服务器即可重新加载配置
- 线程安全:背包数据使用
ReentrantLock 确保线程安全
命令
| 命令 |
别名 |
权限节点 |
描述 |
/backpack |
/bp |
floydbackpack.open |
打开个人背包(默认操作) |
/backpack open |
- |
floydbackpack.open |
打开个人背包 |
/backpack clear |
- |
floydbackpack.clear |
清空背包(需要二次确认) |
/backpack clear confirm |
- |
floydbackpack.clear |
确认清空背包 |
/backpack clear cancel |
- |
floydbackpack.clear |
取消清空操作 |
/backpack reload |
- |
floydbackpack.reload |
重新加载配置 |
/backpack help |
- |
floydbackpack.help |
显示帮助信息 |
控制台无法执行与背包相关的命令。
使用示例
# 打开背包
/bp
# 或使用完整命令
/backpack
# 清空背包(触发二次确认)
/bp clear
# 确认清空(不可逆操作)
/bp clear confirm
# 取消清空
/bp clear cancel
# 重新加载配置
/bp reload
# 查看帮助
/bp help
清空操作流程
- 输入
/bp clear,系统显示确认消息和倒计时
- 输入
/bp clear confirm 确认清空(不可逆)
- 输入
/bp clear cancel 取消操作
- 如果在超时时间内未确认,操作将自动过期
权限
| 权限节点 |
默认值 |
描述 |
floydbackpack.open |
true (所有人) |
允许玩家打开背包 |
floydbackpack.clear |
op (管理员) |
允许玩家清空背包 |
floydbackpack.reload |
op (管理员) |
允许重新加载配置 |
floydbackpack.help |
true (所有人) |
显示帮助信息 |
背包工具
当玩家加入服务器或重生时,如果其物品栏中没有工具物品,系统将自动发放一个 末影之眼 作为背包工具。
- 获取方式:玩家加入/重生时自动发放
- 使用方法:手持工具物品时右键点击以打开背包
- 锁定保护:通过点击、拖拽、Shift+移动或快捷键等方式,无法将该工具物品放入背包界面,防止意外存储
- 识别机制:通过
PersistentDataContainer 标签进行识别,支持多语言环境;同时也保留了基于物品类型和附魔的向后兼容识别方式
- 替代方法:也可以使用
/bp 命令来打开背包
配置
配置文件位置:plugins/FloydBackpack/config.yml。
完整配置项
logging:
file:
enable: true # 是否启用文件日志记录
level: INFO # 日志级别
command:
backpack:
clear:
enable: true # 是否启用背包清空命令
need-confirm: true # 清空前是否需要二次确认
confirm-interval: 30000 # 二次确认超时时间(毫秒)
i18n:
locale: en # 语言设置,选项:en / zh_cn
配置项说明
| 路径 |
类型 |
默认值 |
描述 |
logging.file.enable |
boolean |
true |
是否输出日志到文件 |
logging.level |
string |
INFO |
日志输出级别 |
command.backpack.clear.enable |
boolean |
true |
是否启用 /bp clear 命令 |
command.backpack.clear.need-confirm |
boolean |
true |
清空背包前是否需要二次确认 |
command.backpack.clear.confirm-interval |
long |
30000 |
二次确认超时时间(毫秒) |
i18n.locale |
string |
en |
语言区域设置 |
热重载
修改配置文件后,无需重启服务器。执行以下命令即可应用更改:
/bp reload
国际化
插件包含两个内置语言文件:
| 语言 |
文件名 |
配置值 |
| 英文 |
language/en.yml |
en |
| 简体中文 |
language/zh_cn.yml |
zh_cn |
切换语言后执行 /bp reload 即可生效。背包界面标题会随语言设置动态更新。已打开的旧界面将在下次操作时使用新语言标题重建,且不会丢失物品内容。
自定义语言文件
要添加内置之外的语言(例如日语),您可以手动创建语言文件:
- 在
plugins/FloydBackpack/language/ 目录下创建一个新的 YAML 文件(如果目录不存在,请手动创建)
- 参考内置语言文件的结构,翻译所有的消息键。例如,创建一个日语文件
language/ja.yml:
command:
backpack:
console-not-allowed: "§c无法从控制台执行此命令。"
reload:
start: "§a正在重新加载配置..."
success: "§a重新加载完成 ({0}ms)。"
failure: "§c重新加载失败。请检查控制台。"
help:
line1: "§b[Floyd-Backpack] §a§l帮助"
line2: "§6§n>> 命令"
line3: "§3/bp open §e- §7打开背包"
line4: "§3/bp clear §e- §7清空背包"
line5: "§3/bp reload §e- §7重新加载配置"
line6: "§e详情: §f§nhttps://github.com/codeNoob2281/Floyd-Backpack"
clear:
feature-disabled: "§c清空背包功能已禁用。"
pending-operation-exists: "§e存在待处理的确认操作。请继续。"
confirm-delete: "§a确定要清空背包吗?此操作不可撤销。"
confirm-timeout: "§9请在剩余 {0} 秒内确认。"
no-active-operation: "§e没有有效的确认操作。"
operation-cancelled: "§e清空背包操作已取消。"
cleared: "§a背包已清空。§c{0}§a 个物品被删除。"
tip-confirm: "§6输入 §c/bp clear confirm §6以确认"
tip-cancel: "§6输入 §c/bp clear cancel §6以取消"
operation-expired: "§e[Floyd-Backpack] §6上一次操作已过期。"
chest-ui:
backpack-title: "§6{0}的背包"
backpack-tool:
item-name: "§b[Floyd-Backpack]§6 右键点击打开背包"
lore-line1: "§a手持此物品右键点击可打开背包"
lore-line2: "§a或使用 /bp 命令"
- 修改
config.yml 中的语言配置:
i18n:
locale: ja
- 执行
/bp reload 使新语言生效
语言文件必须与内置文件保持相同的 YAML 结构和键名,否则插件可能无法正常加载。如果插件无法自动读取外部语言文件,请将文件放置在源代码 src/main/resources/language/ 目录中并重新构建。
数据存储
玩家背包数据的存储位置:
plugins/FloydBackpack/backpack/<player-UUID>.json
- 每个玩家的背包数据独立保存,使用 UUID 命名
- 保存时机:玩家退出服务器时自动保存;服务器关闭时批量保存所有在线玩家的数据
- 加载方式:首次打开背包时从磁盘加载,后续操作使用内存缓存
- 容错机制:如果 JSON 数据损坏,会自动备份为
.bak.<timestamp> 文件,并为玩家创建一个新的空背包
- 线程安全:每个背包实例持有
ReentrantLock,确保多线程环境下的数据安全
使用说明
- 清空背包是不可逆操作;开启二次确认后,请务必在执行前进行确认
- 控制台无法执行任何背包命令
- Floyd-Core 作为 Maven 依赖嵌入到插件中,无需额外安装
- 背包工具物品不能存储在背包界面中;这可以防止误存导致无法打开背包的情况
- 切换语言后,请执行
/bp reload 使新的语言设置生效
- 建议定期备份
plugins/FloydBackpack/backpack/ 目录中的数据文件
Floyd-Backpack
Overview
Floyd-Backpack is a PaperMC server backpack plugin that provides each player with an independent 54-slot storage space. The plugin is developed based on the Floyd-Core framework and supports data persistence, internationalization, quick backpack access via tool items, and secondary confirmation to prevent accidental operations.
Features
- 54-Slot Backpack: Each player has independent double-chest capacity storage space, isolated by UUID
- Backpack Tool: Players automatically receive a tool item (Eye of Ender) when joining or respawning; right-click to open the backpack; to prevent accidental operations, the tool item cannot be stored in the backpack
- Data Persistence: Automatically saves when players quit, and batch persists to JSON files when the server shuts down
- Clear Function: One-click backpack clearing with secondary confirmation mechanism and configurable timeout
- Internationalization: Built-in English and Simplified Chinese, switchable via configuration file; backpack title updates dynamically with language
- Hot Reload: Supports reloading configuration without restarting the server
- Thread Safety: Backpack data uses
ReentrantLock to ensure thread safety
Commands
| Command |
Alias |
Permission |
Description |
/backpack |
/bp |
floydbackpack.open |
Open personal backpack (default action) |
/backpack open |
- |
floydbackpack.open |
Open personal backpack |
/backpack clear |
- |
floydbackpack.clear |
Clear backpack (requires secondary confirmation) |
/backpack clear confirm |
- |
floydbackpack.clear |
Confirm backpack clearing |
/backpack clear cancel |
- |
floydbackpack.clear |
Cancel clearing |
/backpack reload |
- |
floydbackpack.reload |
Reload configuration |
/backpack help |
- |
floydbackpack.help |
Display help information |
Console cannot execute backpack-related commands.
Usage Examples
# Open backpack
/bp
# Or full command
/backpack
# Clear backpack (triggers secondary confirmation)
/bp clear
# Confirm clearing (irreversible operation)
/bp clear confirm
# Cancel clearing
/bp clear cancel
# Reload configuration
/bp reload
# View help
/bp help
Clear Operation Flow
- Enter
/bp clear, the system displays confirmation message and countdown
- Enter
/bp clear confirm to confirm clearing (irreversible)
- Enter
/bp clear cancel to cancel the operation
- If not confirmed within timeout, the operation automatically expires
Permissions
| Permission Node |
Default Value |
Description |
floydbackpack.open |
true (everyone) |
Allows players to open backpack |
floydbackpack.clear |
op (administrators) |
Allows players to clear backpack |
floydbackpack.reload |
op (administrators) |
Allows reloading configuration |
floydbackpack.help |
true (everyone) |
Display help information |
Backpack Tool
When players join the server or respawn, if there is no tool item in their inventory, they will automatically receive an Eye of Ender as the backpack tool.
- Acquisition Method: Automatically issued when players join/respawn
- Usage Method: Right-click while holding the tool item to open the backpack
- Lock Protection: The tool item cannot be placed into the backpack interface through clicking, dragging, Shift-moving, or hotkeys, preventing accidental storage
- Recognition Mechanism: Identified via
PersistentDataContainer tags, supporting multi-language environments; also maintains backward-compatible recognition based on item type and enchantments
- Alternative Method: Can also use
/bp command to open the backpack
Configuration
Configuration file location: plugins/FloydBackpack/config.yml.
Complete Configuration Items
logging:
file:
enable: true # Whether to enable file logging
level: INFO # Log level
command:
backpack:
clear:
enable: true # Whether to enable backpack clear command
need-confirm: true # Whether secondary confirmation is required before clearing
confirm-interval: 30000 # Secondary confirmation timeout (milliseconds)
i18n:
locale: en # Language setting, options: en / zh_cn
Configuration Item Descriptions
| Path |
Type |
Default Value |
Description |
logging.file.enable |
boolean |
true |
Whether to output logs to file |
logging.level |
string |
INFO |
Log output level |
command.backpack.clear.enable |
boolean |
true |
Whether to enable /bp clear command |
command.backpack.clear.need-confirm |
boolean |
true |
Whether secondary confirmation is required before clearing backpack |
command.backpack.clear.confirm-interval |
long |
30000 |
Timeout for secondary confirmation (milliseconds) |
i18n.locale |
string |
en |
Language locale setting |
Hot Reload
After modifying the configuration file, there is no need to restart the server. Execute the following command to apply changes:
/bp reload
Internationalization
The plugin includes two built-in language files:
| Language |
Filename |
Config Value |
| English |
language/en.yml |
en |
| Simplified Chinese |
language/zh_cn.yml |
zh_cn |
Execute /bp reload after switching languages to take effect. The backpack interface title will dynamically update with the language setting. Old interfaces that are already open will be rebuilt with the new language title on next operation, without losing item contents.
Custom Language Files
To add languages not built-in (such as Japanese), you can manually create language files:
- Create a new YAML file in the
plugins/FloydBackpack/language/ directory (create the directory manually if it doesn't exist)
- Refer to the structure of built-in language files and translate all message keys. For example, create a Japanese file
language/ja.yml:
command:
backpack:
console-not-allowed: "§cコンソールからこのコマンドを実行できません。"
reload:
start: "§a設定を再読み込み中..."
success: "§a再読み込みが完了しました ({0}ms)。"
failure: "§c再読み込みに失敗しました。コンソールを確認してください。"
help:
line1: "§b[Floyd-Backpack] §a§lヘルプ"
line2: "§6§n>> コマンド"
line3: "§3/bp open §e- §7バックパックを開く"
line4: "§3/bp clear §e- §7バックパックを空にする"
line5: "§3/bp reload §e- §7設定を再読み込み"
line6: "§e詳細: §f§nhttps://github.com/codeNoob2281/Floyd-Backpack"
clear:
feature-disabled: "§cバックパックを空にする機能は無効です。"
pending-operation-exists: "§e保留中の確認操作があります。続行してください。"
confirm-delete: "§6バックパックを空にしてもよろしいですか?この操作は元に戻せません。"
confirm-timeout: "§9残り {0} 秒以内に確認してください。"
no-active-operation: "§e有効な確認操作がありません。"
operation-cancelled: "§eバックパックを空にする操作はキャンセルされました。"
cleared: "§aバックパックを空にしました。§c{0}§a 個のアイテムを削除。"
tip-confirm: "§6確認するには §c/bp clear confirm §6を入力"
tip-cancel: "§6キャンセルするには §c/bp clear cancel §6を入力"
operation-expired: "§e[Floyd-Backpack] §6前回の操作は期限切れです。"
chest-ui:
backpack-title: "§6{0}のバックパック"
backpack-tool:
item-name: "§b[Floyd-Backpack]§6 右クリックでバックパックを開く"
lore-line1: "§aこのアイテムを持って右クリックでバックパックを開く"
lore-line2: "§aまたは /bp コマンドを使用"
- Modify the language configuration in
config.yml:
i18n:
locale: ja
- Execute
/bp reload to make the new language effective
Language files must maintain the same YAML structure and key names as built-in files, otherwise the plugin may fail to load correctly. If the plugin cannot automatically read external language files, place the file in the source code src/main/resources/language/ directory and rebuild.
Data Storage
Player backpack data storage location:
plugins/FloydBackpack/backpack/<player-UUID>.json
- Each player's backpack data is saved independently with UUID naming
- Save Timing: Automatically saved when players quit the server; batch saves all online player data when the server shuts down
- Loading Method: Loaded from disk when opening the backpack for the first time, subsequent operations use memory cache
- Fault Tolerance: If JSON data is corrupted, it is automatically backed up as
.bak.<timestamp> file, and a new empty backpack is created for the player
- Thread Safety: Each backpack instance holds a
ReentrantLock, ensuring data safety in multi-threaded environments
Usage Notes
- Clearing the backpack is an irreversible operation; with secondary confirmation enabled, be sure to confirm before executing
- Console cannot execute any backpack commands
- Floyd-Core is embedded in the plugin as a Maven dependency, no additional installation required
- Backpack tool items cannot be stored in the backpack interface; this prevents accidental storage that would make it impossible to open the backpack
- After switching languages, execute
/bp reload to make the new language settings effective
- It is recommended to regularly backup the data files in the
plugins/FloydBackpack/backpack/ directory
评论 0
登录后参与评分
还没有评论,来抢沙发吧