ModularPacks
适用于 Paper 服务器的可配置模块化背包。
具有持久化存储、便携工作台、被动自动化和共享物品的实体背包。支持原版客户端,可选资源包视觉效果,并通过公共 API 支持自定义模块。
目录
功能特性 · 背包 · 模块 · 服务器设置 · 控制键 · 参考
功能特性
| 能力 |
支持情况 |
| 背包存储 |
可配置的层级、分页物品栏、排序以及堆叠容量倍率。 |
| 装备与放置 |
独立于胸甲装备的虚拟背部槽位、可穿戴模型以及可放置的背包。 |
| 模块 |
便携工作台、物品收集、自动补货、喂食、流体和经验存储,以及自动合成。 |
| 共享物品栏 |
支持托管和加入背包共享,并配有可配置的共享限制。 |
| 服务器配置 |
自定义合成配方、模块安装限制、插入限制、渲染效果和本地化菜单。 |
| 管理与集成 |
SQLite 持久化存储、检查与恢复命令、虚空掉落日志,以及自定义模块 API。 |
背包
默认生存模式的层级定义在 backpacks.yml 中。每种类型的存储容量、模块槽位、配方和外观均可配置。
| 背包 |
存储行数 |
存储格数 |
模块槽位 |
| Leather |
2 |
18 |
1 |
| Copper |
3 |
27 |
1 |
| Iron |
4 |
36 |
2 |
| Gold |
6 |
54 |
3 |
| Diamond |
8 |
72 |
4 |
| Netherite |
10 |
90 |
5 |
存储行数不包含导航行,该行在所有背包中始终可用。更大的背包使用最多 45 个存储格的页面,同时保留其全部容量。
自定义层级与 Creative 背包
这些是 backpacks.yml 中的默认设置;服务器管理员可以更改它们或添加新类型。仅通过命令使用的 Creative 背包提供 30 个存储行(270 个格),且没有模块槽位。
模块
模块定义位于 modules.yml 下的 Upgrades: 部分。以下 ID 用于命令、合成材料配方和配置。大多数升级合成配方使用 ModuleTemplate;执行 /backpack recipe module <id> 可查看已配置的合成配方。
实用工具
| 模块 ID |
行为 |
Everlasting |
使背包不可破坏。 |
Magnet |
收集附近掉落的物品。 |
Feeding |
自动从背包内容物中为玩家喂食。 |
Restock |
从背包存储中为玩家物品栏补货。 |
Void |
删除过滤掉的物品,并提供管理恢复日志。 |
Quiver |
从背包存储中供应箭矢。 |
Jukebox |
播放音乐唱片并支持播放列表控制。 |
储罐与泵
| 模块 ID |
行为 |
FluidTank |
存储桶装流体。 |
Pump |
在物品栏水桶和 Fluid Tank 之间移动流体。 |
ExperienceTank |
存储和发放经验值。 |
ExpPump |
转移经验值或维持目标等级,可选附魔修补(Mending)支持。 |
便携工作台
| 模块 ID |
工作台 |
Crafting |
合成台。 |
Autocrafting |
按可配置间隔自动合成。 |
Smelting · Blasting · Smoking |
熔炉、高炉或烟熏炉。 |
Stonecutter |
切石机。 |
Anvil |
铁砧。 |
Smithing |
锻造台。 |
堆叠升级
| 模块 ID |
堆叠容量倍率 |
IronStack |
×2 |
GoldStack |
×4 |
DiamondStack |
×8 |
NetheriteStack |
×16 |
倍率可叠加:Iron + Gold 提供 ×8 的正常堆叠容量。它们也适用于通常不可堆叠的物品。
安装限制与模块配置
堆叠升级默认共享三个组合的限制,受可用模块槽位数量制约。默认情况下还允许两个 Fluid Tanks、两个 Experience Tanks,以及各三个 Smelting、Blasting、Smoking 和 Autocrafting。
模块配方、外观、限制和行为位于 modules.yml 下的 Upgrades: 部分。MaxInstalled 控制安装限制;InstallGroup 在不同模块类型间共享限制。传统的混合 Tank 模块默认处于禁用状态。
服务器设置
要求: Paper 1.21.10+ 和 Java 21;请使用您所选 Paper 版本所需的 Java 版本。无需客户端模组。
将 JAR 文件从 Modrinth 或 GitHub Releases 安装到 plugins/ 目录中,然后启动服务器以生成配置文件。
文件生成于 plugins/ModularPacks/ 目录下:
| 文件 |
自定义内容 |
config.yml |
全局行为、渲染、共享、更新检查以及资源包。 |
backpacks.yml |
背包层级、容量、配方和外观。 |
modules.yml |
模块配方、限制和行为。 |
lang/en_us.yml |
消息、菜单文本及模块说明。 |
修改后运行 /backpack reload all,或针对翻译修改运行 /backpack reload lang。背包数据存储在 backpacks.db 中。
资源包分发、默认图层、必要资源包行为以及更新检查均在 config.yml 的 modularpacks.ResourcePack 下进行配置。玩家通过 背包设置 → 资源包 选择并应用图层。
在进行重大更新或迁移之前,请备份插件数据文件夹,包括 backpacks.db。命令、配方预览、打开、放置和拾取的权限默认对玩家启用;管理权限和重载权限默认仅限操作员(operators)。完整列表请参阅 Commands and permissions。
控制方式
| 操作 |
按键 |
| 打开手持背包 |
右键点击。 |
| 装备或卸下 |
在背包设置中使用 Equip / Unequip。 |
| 打开已装备的背包 |
潜行 + 交换手(默认为 Shift+F)。适用于生存、冒险和创造模式。 |
| 放置手持背包 |
潜行 + 右键点击方块。 |
| 打开已放置的背包 |
右键点击它。 |
| 拾取已放置的背包 |
潜行 + 双手空着时右键点击。 |
| 切换可切换的模块 |
Shift + 左键点击其已安装的图标。 |
| 移除模块 |
Shift + 右键点击其已安装的图标。 |
将鼠标悬停在已安装的模块上可查看其特定操作,包括屏幕和次要控制方式。
其他库存手势与交互规则
在普通的生存/冒险模式库存界面中,在库存窗口外 350 毫秒内连续两次左键点击即可打开已装备的背包。两次点击均要求光标为空。此功能不适用于物品栏、容器或插件菜单。
虚拟背部槽位优先于胸甲槽位。在不潜行或未装备背包时,正常的手部交换功能保持不变。已装备的背包不会因潜行+右键点击而打开。
若手中持有物品,潜行状态会绕过对已放置背包的交互,从而允许执行原版的物品使用或放置手持背包的操作。
参考
背包物品携带持久化的 UUID;内容、模块状态和共享数据存储在 SQLite 数据库中。管理员工具可以检查存储的背包、恢复背包物品,并还原由 Void 模块记录的物品。
完整的命令语法、配置示例、持久化细节和 API 集成文档如下。
Commands and permissions
命令
基础命令为:
/backpack
帮助
/backpack help
/backpack help <command>
根据发送者的权限显示可用命令。
给予背包和模块
/backpack give type <typeId> [player] [amount]
/backpack give module <upgradeId> [player] [amount]
示例:
/backpack give type Leather Steve 1
/backpack give module Magnet Steve 1
预览配方
/backpack recipe backpack <typeId> [variantId]
/backpack recipe module <upgradeId>
示例:
/backpack recipe backpack Iron
/backpack recipe backpack Iron 2
/backpack recipe module Magnet
配方预览对玩家很有用,因为 ModularPacks 的配方可能包含背包或模块材料,而不仅仅是原版材料。
列出背包
/backpack list [playerName [menu] | unowned]
示例:
/backpack list
/backpack list Steve
/backpack list Steve menu
/backpack list unowned
这允许管理员检查存储的背包记录,如果服务器缓存了离线玩家的 UUID,还可以查看离线玩家拥有的背包。
如果在玩家名称后添加 menu,ModularPacks 将打开一个 GUI 显示该玩家存储的背包,而不是在聊天中打印列表。当玩家拥有多个背包且管理员需要快速检查或打开其中一个时,这非常有用。
以管理员身份打开背包
/backpack open <uuid>
/backpack open <player> <Type#N>
示例:
/backpack open Steve Netherite#1
这对于审核、恢复和支持工作很有用。
更改手中背包的类型
/backpack settype <typeId> [--force]
这会改变您当前主手所持背包的层级/类型。
请谨慎使用。当将背包更改为更小的类型时,ModularPacks 通常会检查新尺寸之外是否存在任何物品,如果这些槽位被占用,则阻止更改。
--force 标志会绕过该保护机制,强制调整背包大小。如果新类型的存储槽位较少,超出新大小的物品可能会被截断并丢失。这仅应由了解风险的管理员使用,最好在检查背包内容或进行数据库备份之后。
重载配置
/backpack reload [config|lang|recipes|all]
示例:
/backpack reload
/backpack reload config
/backpack reload lang
/backpack reload recipes
/backpack reload all
重新加载 ModularPacks 的特定部分,无需完全重启服务器。
config 重新加载 config.yml、背包类型、升级项、已放置背包的渲染以及更新检查器设置。
lang 重新加载语言文件。
recipes 重新加载并重新注册背包和模块配方。
all 重新加载所有内容。
不带参数运行 /backpack reload 的行为等同于 all。
恢复工具
/backpack recover backpack <player> <backpackUuid>
/backpack recover void <player|uuid> list [limit] [all]
/backpack recover void <player|uuid> <id|latest> [receiver]
void recovery 命令与 voided_items 数据库表配合使用。当 Void 模块删除物品时,ModularPacks 会存储足够的物品数据,以便管理员稍后将其恢复。
权限
| 权限 |
默认值 |
描述 |
modularpacks.command |
true |
允许使用基础 /backpack 命令 |
modularpacks.recipe |
true |
允许配方预览命令 |
modularpacks.open |
true |
允许玩家打开背包 |
modularpacks.place |
true |
允许玩家将背包放置在世界中 |
modularpacks.pickup |
true |
允许玩家拾取已放置的背包 |
modularpacks.reload |
op |
允许重载配置、语言和配方 |
modularpacks.admin |
op |
允许使用管理员级别的背包工具 |
modularpacks.update.notify |
op |
启用时接收更新通知 |
服务器管理员在发布服务器之前应审查这些默认设置。面向玩家的权限默认启用,而管理权限仅限操作员使用。
配置和数据
配置
主配置文件:
plugins/ModularPacks/config.yml
配置分布在三个文件中:
config.yml → modularpacks: 用于全局插件行为
backpacks.yml → BackpackTypes: 用于背包定义
modules.yml → Upgrades: 用于模块定义
全局设置
重要的全局设置包括:
modularpacks:
Enabled: true
ResizeGUI: true
AutoCloseOnTeleport: true
AllowShulkerBoxes: false
AllowBundles: false
BackpackInsertBlacklist: []
ResizeGUI 控制背包页面是动态调整大小还是保持固定大小。
每个背包都包含一个用于设置、排序和模块槽位的导航行,
即使 UpgradeSlots 为零也是如此。Rows 仅计算存储容量:Rows: 2 提供
18 个存储槽位加上导航行。拥有超过五个存储行的背包会使用最多 45 个存储槽位的分页,
以保留其完整的配置容量。
AutoCloseOnTeleport 会在玩家传送时关闭打开的背包菜单。
AllowShulkerBoxes 和 AllowBundles 控制是否可以将嵌套存储物品放置在背包内。
BackpackInsertBlacklist 阻止将特定材质插入背包。Magnet 模块也会尊重此列表。
更新检查器
UpdateChecker:
Enabled: true
ShowChangeLog: true
CheckOnStartup: true
PeriodicCheck: true
CheckIntervalHours: 24
NotifyPermission: modularpacks.update.notify
ReleaseApiUrl: https://api.github.com/repos/tootertutor/ModularPacks/releases/latest
当有新的 GitHub 版本可用时,更新检查器可以通知控制台和拥有权限的玩家。您可以禁用启动检查、定期检查、更改日志输出或整个更新检查器。
调试点击日志
Debug:
ClickLog: false
启用后,ModularPacks 会将背包和模块库存的点击或拖拽事件写入:
plugins/ModularPacks/click-events.log
这主要用于调试库存排序模组、意外的 GUI 行为或可能的复制漏洞报告。除非您正在积极排查问题,否则请保持禁用状态。
GUI 材质
NavPageButtons: ARROW
NavBorderFiller: GRAY_STAINED_GLASS_PANE
ModuleSlotMaterial: WHITE_STAINED_GLASS_PANE
这些设置控制常见的菜单项,如页面按钮、边框填充物、已解锁的模块槽位和已锁定的模块槽位。
可放置的背包
Placeable: true
DropPlacedBackpacksOnExplosion: false
启用可放置背包后,玩家可以将背包物品放置到世界中。已放置的背包使用渲染的物品显示,并可以像物理对象一样进行交互。
渲染变换可以进行自定义:
PlacedBackpackRender:
Offset:
X: 0.5
Y: 0.4
Z: 0.4
Rotation:
X: 0.0
Y: 0.0
Z: 0.0
Scale:
X: 1.0
Y: 1.0
Z: 1.0
这在需要使用自定义资源包模型且需要在方块上不同放置方式时非常有用。
共享背包
SharedBackpacks:
Enabled: true
MaxSharedUsers: 5
共享背包允许多名玩家共同操作同一个背包数据。可以根据服务器的平衡性和管理需求调整最大共享用户数。
背包类型配置
背包类型在 backpacks.yml 中的 BackpackTypes: 下定义。
示例:
BackpackTypes:
Leather:
Rows: 2
UpgradeSlots: 1
CraftingRecipe:
Type: Crafting
Pattern:
- "SLS"
- "WCW"
- "LLL"
Ingredients:
L: LEATHER
S: STRING
C: CHEST
W: WHITE_WOOL
OutputMaterial: PLAYER_HEAD
DisplayName: "&6Leather Backpack"
Lore:
- "&7Leather Backpack that can carry 2 rows of items."
- "{backpackContents}"
- "{backpackId}"
- "{installedModules}"
CustomModelData: 1001
DefaultColor: 11100488
SkullData: <base64 skull texture>
每种背包类型都可以定义:
Rows - 存储行数
UpgradeSlots - 模块槽位数
CraftingRecipe - 合成或锻造台配方
OutputMaterial - 用于背包的物品材质
DisplayName - 物品显示名称
Lore - 支持占位符的物品描述
CustomModelData - 可选的资源包模型数据
DefaultColor - 支持的视觉效果使用的颜色值
SkullData - 玩家头颅背包的 base64 头颅纹理数据
合成配方
标准合成配方使用 3x3 图案:
CraftingRecipe:
Type: Crafting
Pattern:
- "III"
- "IBI"
- "III"
Ingredients:
I: IRON_INGOT
B: BACKPACK:Leather
OutputMaterial: PLAYER_HEAD
多种配方变体
背包可以有多个替代配方:
CraftingRecipe:
- "1":
Type: Crafting
Pattern:
- "III"
- "IBI"
- "III"
Ingredients:
I: IRON_INGOT
B: BACKPACK:Leather
- "2":
Type: Crafting
Pattern:
- " I "
- "IBI"
- " I "
Ingredients:
I: IRON_INGOT
B: BACKPACK:Copper
玩家可以使用以下命令预览特定变体:
/backpack recipe backpack Iron 2
锻造台配方
背包类型也可以使用锻造台配方:
CraftingRecipe:
Type: Smithing
Template: NETHERITE_UPGRADE_SMITHING_TEMPLATE
Base: BACKPACK:Diamond
Addition: NETHERITE_INGOT
OutputMaterial: PLAYER_HEAD
这对于诸如钻石到下界合金之类的等级升级非常有用。
配方材料标记
配方材料支持原版 Bukkit 材质名称和 ModularPacks 专用标记。
| Token |
Description |
Example |
BACKPACK:<TypeId> |
需要指定类型的 ModularPacks 背包 |
BACKPACK:Leather |
<TYPE>_BACKPACK |
备用的背包标记格式 |
DIAMOND_BACKPACK |
MODULE:<UpgradeId> |
需要 ModularPacks 模块物品 |
MODULE:Magnet |
UPGRADE:<UpgradeId> |
备用的模块标记格式 |
UPGRADE:Crafting |
这些标记允许配方要求使用实际的 ModularPacks 物品,而不仅仅是原版材料。
升级配置
模块在 modules.yml 中的 Upgrades: 下定义。
示例:
Upgrades:
Magnet:
Enabled: true
Toggleable: true
Range: 6.0
MaxItemsPerTick: 32
CraftingRecipe:
Type: Crafting
Pattern:
- "L R"
- "ITI"
- "III"
Ingredients:
L: LAPIS_LAZULI
R: REDSTONE
I: IRON_INGOT
T: MODULE:ModuleTemplate
OutputMaterial: LEVER
Glint: true
DisplayName: "&aMagnet Upgrade"
Lore:
- "&7Automatically picks up items in a radius of the backpack."
- "{toggleState}"
- "{moduleActions}"
- "{magnetRange}"
CustomModelData: 2002
常见的升级设置包括:
Enabled - 模块是否可用
Toggleable - 模块是否可以开启或关闭
SecondaryAction - 模块是否有右键动作
CraftingRecipe - 用于制作模块的配方
OutputMaterial - 用于模块物品的材质
Glint - 物品是否具有附魔光泽
DisplayName - 模块物品名称
Lore - 模块物品描述
CustomModelData - 可选的资源包模型数据
MaxInstalled - 模块类型或其共享组的安装限制
InstallGroup - 跨模块类型的共享安装限制
StackMultiplier - 应用于普通物品堆叠容量的乘数
某些模块还有自己的设置,例如磁力范围、喂食阈值、唱片机播放模式、泵的方向或经验抽取器的行为。
语言文件
语言文件:
plugins/ModularPacks/lang/en_us.yml
语言文件控制 GUI 标题、按钮和描述、设置与颜色、对话框、共享提示、模块界面、排序模式、资源包选择、管理员菜单、模块动作文本以及放置背包的消息。
UI 翻译位于 en_us.yml 下的 gui 中。
对于其他语言,将 en_us.yml 复制到一个与玩家的 Minecraft 语言代码匹配的文件中,然后翻译其值。
支持部分文件:缺失的键将回退到 en_us.yml。
玩家将以自己的客户端语言查看菜单,现有的英文自定义内容仍作为服务器默认值。
空的描述列表 ([]) 会故意隐藏那些描述行。
新的英文键会在启动或重新加载语言时添加,而不会替换现有值。
编辑语言文件后运行 /backpack reload lang,然后关闭并重新打开菜单。
请保留命名标记(如 {name}、{type}、{count}、{group} 和 {color})不变;译者可以在句子内移动它们。
自定义背包名称和配置的类型/资源包名称保持其原始值。
docs/localization.md 中包含可选的翻译启动器和冒烟测试清单。
这添加了 UI 本地化;这些屏幕之外的命令用法文本和诊断消息保留其现有配置和行为。
这使得您可以更改插件的语气而不必编辑源代码。您可以使消息简洁明了、更具风格化,或匹配您服务器的主题。
常见占位符
背包描述占位符:
| Placeholder |
Description |
{backpackContents} |
替换为当前使用的槽位和物品数量,或为空消息 |
{backpackId} |
显示背包 UUID |
{installedModules} |
显示已安装的模块信息 |
模块描述占位符:
| 占位符 |
描述 |
{moduleActions} |
默认模组交互指令 |
{moduleActionsFeeding} |
喂食模组指令 |
{moduleActionsFluidTank} |
流体储罐模组指令 |
{moduleActionsExperienceTank} |
经验储罐指令 |
{moduleActionsJukebox} |
唱片机模组指令 |
{moduleActionsRestock} |
补货模组指令 |
{moduleActionsAutocrafting} |
自动合成模组指令 |
{moduleActionsPump} |
泵模组指令 |
{moduleActionsExpPump} |
经验泵模组指令 |
{toggleState} |
启用或禁用的切换文本 |
{magnetRange} |
磁力范围显示 |
{feedingMode} |
喂食模式显示 |
{containedFluid} |
储罐或存储显示文本 |
{jukeboxMode} |
唱片机播放模式 |
{restockThreshold} |
补货阈值值 |
{pumpMode} |
泵或经验泵模式 |
{expPumpMending} |
经验泵修复状态 |
放置背包消息
放置背包消息也是可配置的:
backpack:
placement:
disabled: "&c可放置的背包已禁用。"
no_permission: "&c你没有权限放置背包。"
open:
no_permission: "&c你没有权限打开背包。"
locked: "&c此背包当前正由 {player} 打开。"
pickup:
no_permission: "&c你没有权限拾取背包。"
数据存储
ModularPacks 使用 SQLite,并将数据存储在:
plugins/ModularPacks/backpacks.db
重要表包括:
| 表名 |
用途 |
backpacks |
存储背包元数据、所有者数据、内容、共享数据、排序锁定状态以及自定义背包名称 |
backpack_modules |
存储已安装的模组、模组快照和模组状态 |
voided_items |
存储被虚空模组移除的可恢复物品数据 |
player_resource_pack_preferences |
存储每位玩家对可选 ModularPacks 资源包层的有序选择 |
使用 SQLite 是为了让服务器管理员无需设置 MySQL 或其他外部数据库。该插件还启用了 SQLite 的设置,如 WAL 模式和忙超时,以使正常服务器使用更顺畅。
背包内容使用带有版本控制的逻辑存储负载,包含数量为 1 的物品原型和单独的数量。旧的 ItemStack[] 负载会自动读取并在下次保存时重写为新格式。模组快照和状态继续使用其现有的独立 ItemStackCodec 格式。
内部游戏机制、被动模组、排序和 GUI 持久性操作基于 BackpackStorage。Bukkit 库存仅作为 vanilla 安全的视觉投影;点击和拖拽直接应用于逻辑存储,渲染的物品不会作为规范状态读回。旧的公开 ItemStack[] 视图保留为已弃用的兼容性适配器,当虚拟数量无法表示时会明确失败。
资源包支持
资源包是可选的,并且按玩家选择。背包设置菜单会打开一个专用的资源包屏幕,玩家可以在其中混合搭配配置的层,暂存更改,并一次性应用完整的选择。
ModularPacks 从 GitHub 发行版中检查配置的资产,在服务器端下载每个 ZIP 以进行验证和 SHA-1 计算,然后向玩家提供该发布资产的公共 browser_download_url。该插件不暴露 HTTP 监听器,也不需要额外的公共端口。包优先级控制堆叠顺序,高优先级的包覆盖低优先级的包。
当发布资产发生更改时,使用其先前 SHA-1 的在线玩家会收到通知。该插件不会强制进行可能破坏性的会话中期重载:玩家可以重新登录或在 GUI 中使用应用所选包。
该插件即使不使用任何包,也可以使用正常的 Minecraft 材质和玩家头颅。对于自定义背包或模组视觉效果,分配 CustomModelData 值,并在一个或多个配置包的资产中提供匹配模型。
用于视觉效果的有用配置字段:
OutputMaterial
CustomModelData
DisplayName
Lore
DefaultColor
SkullData
PlacedBackpackRender
这意味着该插件首先可以作为服务器端存储系统工作,然后在之后进行视觉升级,而无需更改核心背包数据。
开发者 API
API
ModularPacks 包含供其他插件使用的公共 API。
外部插件可以使用该 API 来:
- 检查 ModularPacks 是否已加载
- 访问 ModularPacks 插件实例
- 注册自定义模组
- 注册自定义模组物品定义
- 按 ID 查找模组
- 按屏幕类型查找模组
- 检查玩家的活跃模组会话
- 获取活跃模组会话的背包 UUID
获取 API
ModularPacksAPI api = ModularPacksAPI.getAPI();
if (api == null) {
// ModularPacks 未加载或未就绪。
return;
}
你也可以使用:
ModularPacksAPI api = ModularPacksAPI.getInstance();
getAPI() 会先执行插件管理器检查,这对于软依赖集成通常更安全。
注册模块实现
ModularPacksAPI api = ModularPacksAPI.getAPI();
if (api != null) {
api.registerModule(new MyCustomModule());
}
这仅注册了模块行为。如果你希望该模组可通过合成制作或通过 ModularPacks 的物品创建功能获得,还需使用 UpgradeDef 进行注册。
使用物品定义注册模块
ModularPacksAPI api = ModularPacksAPI.getAPI();
if (api != null) {
MyCustomModule module = new MyCustomModule();
UpgradeDef def = new UpgradeDef(
"MyModule",
"&6My Custom Module",
Material.DIAMOND,
List.of("&7Custom functionality"),
1001,
false,
true,
true,
false,
ScreenType.GENERIC
);
api.registerModule(module, def);
}
模块 ID 与 UpgradeDef ID 必须匹配。ModularPacks 会对此进行验证,以防止模块使用一个 ID 注册而其物品定义使用另一个 ID。
UpgradeDef 提供了针对 maxInstalled、installGroup 和 stackMultiplier 的扩展构造函数。原始构造函数仍受支持,并默认设置为安装一个确切类型的模块,倍率为 1。非空的安装组会使最大数量在该组的所有定义中共同生效。堆叠倍率以乘法方式组合,并应用于每个物品的正常最大堆叠大小,包括原版最大堆叠为 1 的物品。
modularpacks-modules 下的外部插件定义可以配置相同的策略字段:
modularpacks-modules:
MyModule:
Enabled: true
MaxInstalled: 3
InstallGroup: MySharedGroup
StackMultiplier: 2
OutputMaterial: DIAMOND
DisplayName: "&6My Custom Module"
实现 IModule
自定义模块需实现:
public interface IModule {
String getModuleId();
ScreenType getScreenType();
boolean hasSession(Player player);
UUID getSessionBackpackId(Player player);
void open(ModularPacksPlugin plugin, Player player, UUID backpackId, String backpackType, UUID moduleId);
void handleClose(ModularPacksPlugin plugin, Player player, Inventory inventory);
boolean isValidInventoryView(InventoryView view);
String getDisplayName();
}
模块还可以重写:
default void updateResult(Inventory inventory) {}
default boolean isEnabled() { return true; }
这为自定义模块提供了一种一致的方式来打开界面、在关闭时保存状态、验证物品栏视图以及暴露显示名称。
插件依赖设置
如果你的插件需要 ModularPacks,请在你的 plugin.yml 中将其添加为依赖项:
depend: [ModularPacks]
如果你的插件可以在没有 ModularPacks 的情况下运行,请使用软依赖:
softdepend: [ModularPacks]
然后在使用集成之前检查 ModularPacksAPI.getAPI()。
构建、发布和项目状态
从源代码构建
克隆仓库并使用 Maven 进行构建:
git clone https://github.com/TooterTutor/ModularPacks.git
cd ModularPacks
mvn -DskipTests package
编译后的 jar 文件将生成在:
target/modularpacks-<version>.jar
项目状态
ModularPacks 正在积极开发中。随着插件逐渐成熟,配置键、模块行为和 API 细节可能会发生变化。服务器管理员应在重大更新前备份 plugins/ModularPacks/backpacks.db。
致谢
由 TooterTutor 创建。
灵感来源于模组化、可升级背包的概念,但它是作为 Paper 插件构建的,拥有自己的存储模型、管理工具、配置系统和扩展 API。
ModularPacks
Configurable, modular backpacks for Paper servers.
Physical backpack items with persistent storage, portable workstations, passive automation, and shared inventories. Supports vanilla clients, optional resource-pack visuals, and custom modules through a public API.
Table of Contents
Features · Backpacks · Modules · Server setup · Controls · Reference
Features
| Capability |
Support |
| Backpack storage |
Configurable tiers, paginated inventories, sorting, and stack-capacity multipliers. |
| Equipment & placement |
Virtual back slot independent of chest equipment, wearable models, and placeable backpacks. |
| Modules |
Portable workstations, item collection, restocking, feeding, fluid and XP storage, and automatic crafting. |
| Shared inventories |
Backpack hosting and joining with configurable sharing limits. |
| Server configuration |
Custom recipes, module installation limits, insertion restrictions, rendering, and localized menus. |
| Administration & integration |
SQLite persistence, inspection and recovery commands, void recovery logs, and a custom-module API. |
Backpacks
Default survival tiers are defined in backpacks.yml. Storage capacity, module slots, recipes, and appearance are configurable per type.
| Backpack |
Storage rows |
Storage slots |
Module slots |
| Leather |
2 |
18 |
1 |
| Copper |
3 |
27 |
1 |
| Iron |
4 |
36 |
2 |
| Gold |
6 |
54 |
3 |
| Diamond |
8 |
72 |
4 |
| Netherite |
10 |
90 |
5 |
Storage rows exclude the navigation row, which stays available on every backpack. Larger packs use pages of up to 45 storage slots while retaining their full capacity.
Custom tiers and the Creative backpack
These are the defaults in backpacks.yml; server owners can change them or add new types. The command-only Creative backpack provides 30 storage rows (270 slots) and no module slots.
Modules
Module definitions live under Upgrades: in modules.yml. The IDs below are used in commands, recipe ingredients, and configuration. Most upgrade recipes use ModuleTemplate; /backpack recipe module <id> displays the configured recipe.
Utility
| Module ID |
Behavior |
Everlasting |
Makes the backpack indestructible. |
Magnet |
Collects nearby dropped items. |
Feeding |
Automatically feeds the player from backpack contents. |
Restock |
Restocks player inventory from backpack storage. |
Void |
Deletes filtered items, with logs for admin recovery. |
Quiver |
Supplies arrows from backpack storage. |
Jukebox |
Plays music discs with playlist controls. |
Tanks & pumps
| Module ID |
Behavior |
FluidTank |
Stores bucket-based fluids. |
Pump |
Moves fluids between inventory buckets and a Fluid Tank. |
ExperienceTank |
Stores and dispenses experience. |
ExpPump |
Transfers XP or maintains a target level, with optional Mending support. |
Portable workstations
| Module ID |
Workstation |
Crafting |
Crafting table. |
Autocrafting |
Automatic crafting at a configurable interval. |
Smelting · Blasting · Smoking |
Furnace, blast furnace, or smoker. |
Stonecutter |
Stonecutter. |
Anvil |
Anvil. |
Smithing |
Smithing table. |
Stack upgrades
| Module ID |
Stack capacity multiplier |
IronStack |
×2 |
GoldStack |
×4 |
DiamondStack |
×8 |
NetheriteStack |
×16 |
Multipliers combine: Iron + Gold gives ×8 normal stack capacity. They also apply to normally unstackable items.
Installation limits and module configuration
Stack upgrades share a default limit of three combined, subject to available module slots. Defaults also allow two Fluid Tanks, two Experience Tanks, and three each of Smelting, Blasting, Smoking, and Autocrafting.
Module recipes, appearance, limits, and behavior live under Upgrades: in modules.yml. MaxInstalled controls installation limits; InstallGroup shares a limit between module types. The legacy mixed Tank module is disabled by default.
Server setup
Requirements: Paper 1.21.10+ and Java 21; use the Java version required by your chosen Paper release. No client mods are required.
Install the JAR from Modrinth or GitHub Releases into plugins/ and start the server to generate configuration.
Files are generated in plugins/ModularPacks/:
| File |
Customize |
config.yml |
Global behavior, rendering, sharing, update checks, and resource packs. |
backpacks.yml |
Backpack tiers, capacity, recipes, and appearance. |
modules.yml |
Module recipes, limits, and behavior. |
lang/en_us.yml |
Messages, menu text, and module instructions. |
Run /backpack reload all after changes, or /backpack reload lang for translations. Backpack data is stored in backpacks.db.
Resource-pack delivery, default layers, required-pack behavior, and update checks are configured under modularpacks.ResourcePack in config.yml. Players select and apply layers through Backpack Settings → Resource Packs.
Back up the plugin data folder, including backpacks.db, before major updates or migrations. Player permissions for commands, recipe previews, opening, placement, and pickup default to enabled; administration and reload permissions default to operators. See Commands and permissions for the full list.
Controls
| Action |
Control |
| Open a held backpack |
Right-click. |
| Equip or unequip |
Use Equip / Unequip in Backpack Settings. |
| Open an equipped backpack |
Sneak + swap-hands key (Shift+F by default). Works in Survival, Adventure, and Creative. |
| Place a held backpack |
Sneak + right-click a block. |
| Open a placed backpack |
Right-click it. |
| Pick up a placed backpack |
Sneak + right-click with both hands empty. |
| Toggle a toggleable module |
Shift + left-click its installed icon. |
| Remove a module |
Shift + right-click its installed icon. |
Hover over an installed module for its specific actions, including screens and secondary controls.
Additional inventory gestures and interaction rules
In the ordinary Survival/Adventure inventory, double-left-click outside the inventory window within 350 ms to open an equipped backpack. Both clicks require an empty cursor. This does not apply to item slots, containers, or plugin menus.
The virtual back slot takes priority over the chestplate slot. Normal hand swaps are preserved when you are not sneaking or have no backpack equipped. Equipped backpacks do not open on sneak-right-click.
Sneaking with an item in either hand bypasses placed-backpack interaction, allowing vanilla item use or held-backpack placement to proceed.
Reference
Backpack items carry a persistent UUID; contents, module state, and sharing data live in SQLite. Admin tools can inspect stored backpacks, recover backpack items, and restore items logged by the Void module.
Full command syntax, configuration examples, persistence details, and API integration are documented below.
Commands and permissions
Commands
The base command is:
/backpack
Help
/backpack help
/backpack help <command>
Shows available commands based on the sender's permissions.
Give backpacks and modules
/backpack give type <typeId> [player] [amount]
/backpack give module <upgradeId> [player] [amount]
Examples:
/backpack give type Leather Steve 1
/backpack give module Magnet Steve 1
Preview recipes
/backpack recipe backpack <typeId> [variantId]
/backpack recipe module <upgradeId>
Examples:
/backpack recipe backpack Iron
/backpack recipe backpack Iron 2
/backpack recipe module Magnet
Recipe previews are useful for players because ModularPacks recipes can include backpack or module ingredients, not just vanilla materials.
List backpacks
/backpack list [playerName [menu] | unowned]
Examples:
/backpack list
/backpack list Steve
/backpack list Steve menu
/backpack list unowned
This allows admins to inspect stored backpack records, including backpacks owned by offline players if the server has cached their UUID.
If menu is added after a player name, ModularPacks opens a GUI showing that player's stored backpacks instead of printing the list to chat. This is useful when a player owns multiple backpacks and an admin needs to quickly inspect or open one of them.
Open backpacks as an admin
/backpack open <uuid>
/backpack open <player> <Type#N>
Example:
/backpack open Steve Netherite#1
This is useful for moderation, recovery, and support.
Change the backpack type in your hand
/backpack settype <typeId> [--force]
This changes the tier/type of the backpack currently held in your main hand.
Use this carefully. When changing a backpack to a smaller type, ModularPacks normally checks whether any items exist outside the new size and blocks the change if those slots are occupied.
The --force flag bypasses that protection and allows the backpack to be resized anyway. If the new type has fewer storage slots, any items beyond the new size may be truncated and lost. This should only be used by admins who understand the risk, preferably after checking the backpack contents or making a database backup.
Reload configuration
/backpack reload [config|lang|recipes|all]
Examples:
/backpack reload
/backpack reload config
/backpack reload lang
/backpack reload recipes
/backpack reload all
Reloads specific parts of ModularPacks without requiring a full server restart.
config reloads config.yml, backpack types, upgrades, placed backpack renders, and update checker settings.
lang reloads language files.
recipes reloads and re-registers backpack and module recipes.
all reloads everything.
Running /backpack reload with no argument behaves like all.
Recovery tools
/backpack recover backpack <player> <backpackUuid>
/backpack recover void <player|uuid> list [limit] [all]
/backpack recover void <player|uuid> <id|latest> [receiver]
The void recovery commands work with the voided_items database table. When the Void module deletes an item, ModularPacks stores enough item data for admins to recover it later.
Permissions
| Permission |
Default |
Description |
modularpacks.command |
true |
Allows use of the base /backpack command |
modularpacks.recipe |
true |
Allows recipe preview commands |
modularpacks.open |
true |
Allows players to open backpacks |
modularpacks.place |
true |
Allows players to place backpacks in the world |
modularpacks.pickup |
true |
Allows players to pick up placed backpacks |
modularpacks.reload |
op |
Allows reloading config, language, and recipes |
modularpacks.admin |
op |
Allows admin-level backpack tools |
modularpacks.update.notify |
op |
Receives update notifications when enabled |
Server owners should review these defaults before publishing a server. The player-facing permissions are enabled by default, while administrative permissions are restricted to operators.
Configuration and data
Configuration
Main configuration file:
plugins/ModularPacks/config.yml
Configuration is split across three files:
config.yml → modularpacks: for global plugin behavior
backpacks.yml → BackpackTypes: for backpack definitions
modules.yml → Upgrades: for module definitions
Global settings
Important global settings include:
modularpacks:
Enabled: true
ResizeGUI: true
AutoCloseOnTeleport: true
AllowShulkerBoxes: false
AllowBundles: false
BackpackInsertBlacklist: []
ResizeGUI controls whether backpack pages dynamically resize or keep a fixed size.
Every backpack includes a navigation row for settings, sorting, and module slots,
even when UpgradeSlots is zero. Rows counts storage only: Rows: 2 provides
18 storage slots plus the navigation row. Packs with more than five storage rows
use pages of up to 45 storage slots, preserving their full configured capacity.
AutoCloseOnTeleport closes open backpack menus when a player teleports.
AllowShulkerBoxes and AllowBundles control whether nested storage items can be placed inside backpacks.
BackpackInsertBlacklist blocks specific materials from being inserted into backpacks. The Magnet module also respects this list.
Update checker
UpdateChecker:
Enabled: true
ShowChangeLog: true
CheckOnStartup: true
PeriodicCheck: true
CheckIntervalHours: 24
NotifyPermission: modularpacks.update.notify
ReleaseApiUrl: https://api.github.com/repos/tootertutor/ModularPacks/releases/latest
The update checker can notify console and permitted players when a new GitHub release is available. You can disable startup checks, periodic checks, changelog output, or the entire update checker.
Debug click logging
Debug:
ClickLog: false
When enabled, ModularPacks writes backpack and module inventory click or drag events to:
plugins/ModularPacks/click-events.log
This is mainly intended for debugging inventory sorting mods, unexpected GUI behavior, or possible dupe reports. Leave it disabled unless you are actively troubleshooting.
GUI materials
NavPageButtons: ARROW
NavBorderFiller: GRAY_STAINED_GLASS_PANE
ModuleSlotMaterial: WHITE_STAINED_GLASS_PANE
These settings control common menu items such as page buttons, border fillers, unlocked module slots, and locked module slots.
Placeable backpacks
Placeable: true
DropPlacedBackpacksOnExplosion: false
When placeable backpacks are enabled, players can place backpack items into the world. Placed backpacks use a rendered item display and can be interacted with like a physical object.
The render transform can be customized:
PlacedBackpackRender:
Offset:
X: 0.5
Y: 0.4
Z: 0.4
Rotation:
X: 0.0
Y: 0.0
Z: 0.0
Scale:
X: 1.0
Y: 1.0
Z: 1.0
This is useful when using custom resource pack models that need to sit differently on the block.
Shared backpacks
SharedBackpacks:
Enabled: true
MaxSharedUsers: 5
Shared backpacks allow multiple players to work with the same backpack data. The maximum number of shared users can be adjusted to fit your server's balance and moderation needs.
Backpack type configuration
Backpack types are defined under BackpackTypes: in backpacks.yml.
Example:
BackpackTypes:
Leather:
Rows: 2
UpgradeSlots: 1
CraftingRecipe:
Type: Crafting
Pattern:
- "SLS"
- "WCW"
- "LLL"
Ingredients:
L: LEATHER
S: STRING
C: CHEST
W: WHITE_WOOL
OutputMaterial: PLAYER_HEAD
DisplayName: "&6Leather Backpack"
Lore:
- "&7Leather Backpack that can carry 2 rows of items."
- "{backpackContents}"
- "{backpackId}"
- "{installedModules}"
CustomModelData: 1001
DefaultColor: 11100488
SkullData: <base64 skull texture>
Each backpack type can define:
Rows - number of storage rows
UpgradeSlots - number of module slots
CraftingRecipe - crafting or smithing recipe
OutputMaterial - item material used for the backpack
DisplayName - item display name
Lore - item lore with placeholder support
CustomModelData - optional resource pack model data
DefaultColor - color value used by supported visuals
SkullData - base64 skull texture data for player head backpacks
Crafting recipes
A standard crafting recipe uses a 3x3 pattern:
CraftingRecipe:
Type: Crafting
Pattern:
- "III"
- "IBI"
- "III"
Ingredients:
I: IRON_INGOT
B: BACKPACK:Leather
OutputMaterial: PLAYER_HEAD
Multiple recipe variants
Backpacks can have multiple alternative recipes:
CraftingRecipe:
- "1":
Type: Crafting
Pattern:
- "III"
- "IBI"
- "III"
Ingredients:
I: IRON_INGOT
B: BACKPACK:Leather
- "2":
Type: Crafting
Pattern:
- " I "
- "IBI"
- " I "
Ingredients:
I: IRON_INGOT
B: BACKPACK:Copper
Players can preview a specific variant with:
/backpack recipe backpack Iron 2
Smithing recipes
Backpack types can also use smithing recipes:
CraftingRecipe:
Type: Smithing
Template: NETHERITE_UPGRADE_SMITHING_TEMPLATE
Base: BACKPACK:Diamond
Addition: NETHERITE_INGOT
OutputMaterial: PLAYER_HEAD
This is useful for tier upgrades like Diamond to Netherite.
Recipe ingredient tokens
Recipe ingredients support vanilla Bukkit material names and ModularPacks-specific tokens.
| Token |
Description |
Example |
BACKPACK:<TypeId> |
Requires a ModularPacks backpack of the given type |
BACKPACK:Leather |
<TYPE>_BACKPACK |
Alternate backpack token format |
DIAMOND_BACKPACK |
MODULE:<UpgradeId> |
Requires a ModularPacks module item |
MODULE:Magnet |
UPGRADE:<UpgradeId> |
Alternate module token format |
UPGRADE:Crafting |
These tokens are what allow recipes to require actual ModularPacks items instead of only vanilla materials.
Upgrade configuration
Modules are defined under Upgrades: in modules.yml.
Example:
Upgrades:
Magnet:
Enabled: true
Toggleable: true
Range: 6.0
MaxItemsPerTick: 32
CraftingRecipe:
Type: Crafting
Pattern:
- "L R"
- "ITI"
- "III"
Ingredients:
L: LAPIS_LAZULI
R: REDSTONE
I: IRON_INGOT
T: MODULE:ModuleTemplate
OutputMaterial: LEVER
Glint: true
DisplayName: "&aMagnet Upgrade"
Lore:
- "&7Automatically picks up items in a radius of the backpack."
- "{toggleState}"
- "{moduleActions}"
- "{magnetRange}"
CustomModelData: 2002
Common upgrade settings include:
Enabled - whether the module is available
Toggleable - whether the module can be toggled on or off
SecondaryAction - whether the module has a right-click action
CraftingRecipe - recipe used to craft the module
OutputMaterial - material used for the module item
Glint - whether the item should have an enchanted glint
DisplayName - module item name
Lore - module item lore
CustomModelData - optional resource pack model data
MaxInstalled - installation limit for the module type or its shared group
InstallGroup - shared installation limit across module types
StackMultiplier - multiplier applied to normal item stack capacity
Some modules also have their own settings, such as Magnet range, Feeding thresholds, Jukebox playback mode, Pump direction, or Exp Pump behavior.
Language file
Language file:
plugins/ModularPacks/lang/en_us.yml
The language file controls GUI titles, buttons and descriptions, Settings and color, dialogs, sharing prompts, module screens, sorting modes, resource-pack selection, admin menus, module action text, and placed backpack messages.
UI translations live under gui in en_us.yml.
For another language, copy en_us.yml to a file matching the player's Minecraft language code then translate its values.
Partial files are supported: missing keys fall back to en_us.yml.
Players see menus in their own client language, and existing English customizations remain the server default.
An empty lore list ([]) intentionally hides those description lines.
New English keys are added on startup or language reload without replacing existing values.
Run /backpack reload lang after editing language files, then close and reopen the menu.
Keep named tokens such as {name}, {type}, {count}, {group}, and {color} intact; translators can move them within a sentence.
Custom backpack names and configured type/resource-pack names keep their original values.
An optional translation starter and a smoke-test checklist are in docs/localization.md.
This adds UI localization; command usage text and diagnostic messages outside these screens retain their existing configuration and behavior.
This lets you change the plugin's tone without editing the source. You can make the messages clean and minimal, more stylized, or match the theme of your server.
Common placeholders
Backpack lore placeholders:
| Placeholder |
Description |
{backpackContents} |
Replaced with current used slots and item count, or an empty message |
{backpackId} |
Shows the backpack UUID |
{installedModules} |
Shows installed module information |
Module lore placeholders:
| Placeholder |
Description |
{moduleActions} |
Default module interaction instructions |
{moduleActionsFeeding} |
Feeding module instructions |
{moduleActionsFluidTank} |
Fluid Tank module instructions |
{moduleActionsExperienceTank} |
Experience Tank instructions |
{moduleActionsJukebox} |
Jukebox module instructions |
{moduleActionsRestock} |
Restock module instructions |
{moduleActionsAutocrafting} |
Autocrafting module instructions |
{moduleActionsPump} |
Pump module instructions |
{moduleActionsExpPump} |
Exp Pump module instructions |
{toggleState} |
Enabled or disabled toggle text |
{magnetRange} |
Magnet range display |
{feedingMode} |
Feeding mode display |
{containedFluid} |
Tank or storage display text |
{jukeboxMode} |
Jukebox play mode |
{restockThreshold} |
Restock threshold value |
{pumpMode} |
Pump or Exp Pump mode |
{expPumpMending} |
Exp Pump mending state |
Placed backpack messages
Placed backpack messages are also configurable:
backpack:
placement:
disabled: "&cPlaceable backpacks are disabled."
no_permission: "&cYou don't have permission to place backpacks."
open:
no_permission: "&cYou don't have permission to open backpacks."
locked: "&cThis backpack is currently open by {player}."
pickup:
no_permission: "&cYou don't have permission to pick up backpacks."
Data storage
ModularPacks uses SQLite and stores data in:
plugins/ModularPacks/backpacks.db
Important tables include:
| Table |
Purpose |
backpacks |
Stores backpack metadata, owner data, contents, sharing data, sorting lock state, and custom backpack name |
backpack_modules |
Stores installed modules, module snapshots, and module state |
voided_items |
Stores recoverable item data for items removed by the Void module |
player_resource_pack_preferences |
Stores each player's ordered selection of optional ModularPacks resource-pack layers |
SQLite is used so server owners do not need to set up MySQL or another external database. The plugin also enables SQLite settings such as WAL mode and a busy timeout to make normal server usage smoother.
Backpack contents use a versioned logical-storage payload with amount-one item prototypes and separate counts. Legacy ItemStack[] payloads are read automatically and rewritten in the new format on their next save. Module snapshots and state continue to use their existing, separate ItemStackCodec format.
Internal gameplay, passive modules, sorting, and GUI persistence operate on BackpackStorage. The Bukkit inventory is only a vanilla-safe visual projection; clicks and drags are applied directly to logical storage and rendered items are never read back as canonical state. The legacy public ItemStack[] view remains as a deprecated compatibility adapter and fails explicitly when a virtual count cannot be represented.
Resource pack support
Resource packs are optional and selected per player. The Backpack Settings menu opens a dedicated resource-pack screen where players can mix and match configured layers, stage changes, and apply the complete selection once.
ModularPacks checks configured assets from a GitHub release, downloads each ZIP server-side for validation and SHA-1 calculation, then gives players the release asset's public browser_download_url. The plugin does not expose an HTTP listener or require an additional public port. Pack priority controls stacking order, with higher-priority packs layered over lower-priority packs.
When a release asset changes, online players using its previous SHA-1 receive a notification. The plugin does not force a potentially disruptive mid-session reload: players can relog or use Apply Selected Packs in the GUI.
The plugin can still use normal Minecraft materials and player heads without any packs. For custom backpack or module visuals, assign CustomModelData values and provide matching models in one or more configured pack assets.
Useful config fields for visuals:
OutputMaterial
CustomModelData
DisplayName
Lore
DefaultColor
SkullData
PlacedBackpackRender
This means the plugin can work as a server-side storage system first, then be visually upgraded later without changing the core backpack data.
Developer API
API
ModularPacks includes a public API for other plugins.
External plugins can use the API to:
- Check whether ModularPacks is loaded
- Access the ModularPacks plugin instance
- Register custom modules
- Register custom module item definitions
- Look up modules by ID
- Look up modules by screen type
- Check a player's active module session
- Get the backpack UUID for an active module session
Getting the API
ModularPacksAPI api = ModularPacksAPI.getAPI();
if (api == null) {
// ModularPacks is not loaded or not ready.
return;
}
You can also use:
ModularPacksAPI api = ModularPacksAPI.getInstance();
getAPI() performs a plugin manager check first, which is usually safer for soft-depend integrations.
Registering a module implementation
ModularPacksAPI api = ModularPacksAPI.getAPI();
if (api != null) {
api.registerModule(new MyCustomModule());
}
This registers the module behavior only. If you want the module to be craftable or available through ModularPacks item creation, register it with an UpgradeDef as well.
Registering a module with an item definition
ModularPacksAPI api = ModularPacksAPI.getAPI();
if (api != null) {
MyCustomModule module = new MyCustomModule();
UpgradeDef def = new UpgradeDef(
"MyModule",
"&6My Custom Module",
Material.DIAMOND,
List.of("&7Custom functionality"),
1001,
false,
true,
true,
false,
ScreenType.GENERIC
);
api.registerModule(module, def);
}
The module ID and the UpgradeDef ID must match. ModularPacks validates this so modules do not register under one ID while their item definition uses another.
UpgradeDef has extended constructors for maxInstalled, installGroup, and stackMultiplier. The original constructor remains supported and defaults to one installed module of the exact type with a multiplier of one. A non-empty install group makes the maximum apply across all definitions in that group. Stack multipliers compose multiplicatively and apply to each item's normal maximum stack size, including items whose vanilla maximum is one.
External plugin definitions under modularpacks-modules can configure the same policy fields:
modularpacks-modules:
MyModule:
Enabled: true
MaxInstalled: 3
InstallGroup: MySharedGroup
StackMultiplier: 2
OutputMaterial: DIAMOND
DisplayName: "&6My Custom Module"
Implementing IModule
Custom modules implement:
public interface IModule {
String getModuleId();
ScreenType getScreenType();
boolean hasSession(Player player);
UUID getSessionBackpackId(Player player);
void open(ModularPacksPlugin plugin, Player player, UUID backpackId, String backpackType, UUID moduleId);
void handleClose(ModularPacksPlugin plugin, Player player, Inventory inventory);
boolean isValidInventoryView(InventoryView view);
String getDisplayName();
}
Modules can also override:
default void updateResult(Inventory inventory) {}
default boolean isEnabled() { return true; }
This gives custom modules a consistent way to open screens, save state on close, validate inventory views, and expose display names.
Plugin dependency setup
If your plugin requires ModularPacks, add it as a dependency in your plugin.yml:
depend: [ModularPacks]
If your plugin can run without ModularPacks, use a soft dependency:
softdepend: [ModularPacks]
Then check ModularPacksAPI.getAPI() before using the integration.
Building, publishing, and project status
Building from source
Clone the repository and build with Maven:
git clone https://github.com/TooterTutor/ModularPacks.git
cd ModularPacks
mvn -DskipTests package
The compiled jar will be created in:
target/modularpacks-<version>.jar
Project status
ModularPacks is actively being developed. Configuration keys, module behavior, and API details may evolve as the plugin matures. Server owners should back up plugins/ModularPacks/backpacks.db before major updates.
Credits
Created by TooterTutor.
Inspired by the idea of modded, upgradeable backpacks, but built as a Paper plugin with its own storage model, admin tools, configuration system, and extension API.
评论 0
登录后参与评分
还没有评论,来抢沙发吧