
PermPacks
English |
中文
一个 Paper 插件,根据权限向玩家分发分层资源包堆栈。它支持远程 URL 和本地文件,内置自托管和 Amazon S3 上传后端,并可选择阻止外部资源包以确保一致性。
亮点
- 基于权限的资源包堆栈:根据玩家权限从
packs.yml 中筛选资源包,按优先级升序加载;后面的资源包会覆盖前面的资源包。
- 多源统一分发:将
url 和 file 项统一为单个客户端请求。
- 可插拔上传服务:内置
self_host(嵌入式 HTTP 服务器)和 amazon_s3;自动计算并复用 SHA-1 以避免重复上传。
- 外部资源包拦截:安装 ProtocolLib 后,可拦截任何未被本插件标记的资源包。
- 热重载与诊断:重载配置并重新分发在线玩家;检查资源包详情和玩家堆栈状态。
要求
- Paper 1.21+,Java 21
- 可选:ProtocolLib(推荐用于外部资源包拦截)
安装
- 将
PermPacks-<version>-all.jar 放入 plugins/ 目录
- 启动服务器以生成
config.yml 和 packs.yml
- 根据需要编辑配置文件,然后运行
/permpacks reload packs 应用更改
注意:插件会创建缓存/仓库目录(例如 .filerepo/)。删除它们是安全的;它们会自动重新创建。
配置 (config.yml)
block_other_packs: false
file_upload:
enabled: false
cleanup: false
service: self_host # amazon_s3, self_host
self_host:
host: 127.0.0.1
port: 7077
amazon_s3:
endpoint: s3.amazonaws.com
region: cn-north-1
bucket: your-bucket-name
directory: uploads
access_key_id: ""
secret_access_key: ""
path_style_access: false
chunked_encoding: true
block_other_packs: 如果启用,则阻止任何未被本插件标记的资源包(需要 ProtocolLib)。
file_upload.enabled: 启用 packs.yml 中 file 项的使用;禁用时,file 项将被忽略。
file_upload.service: 选择 self_host(嵌入式 HTTP)或 amazon_s3。
file_upload.cleanup: 在启动时,移除仓库/桶中未引用的对象;仅保留当前配置中引用的对象。
self_host.*: 嵌入式 HTTP 服务器的监听地址和端口。
amazon_s3.*: S3 客户端和桶设置;支持路径样式寻址和分块编码。
资源包 (packs.yml)
优先级规则:默认为 0;允许负数。资源包按优先级升序加载;优先级相同的项按文件顺序加载,后面的项覆盖前面的项。
example:
permission: permpacks.pack.example
priority: 10
items:
- url: https://example.com/high.zip
hash: d41d8cd98f00b204e9800998ecf8427e
- file: plugins/OtherPlugin/assets.zip
hash: 900150983cd24fb0d6963f7d28e17f72
permission: 拥有此权限的玩家将获得该资源包(及其中的各项)。
priority: 数值越小加载越早;后面的资源包覆盖前面的资源包。
items.url: 直接下载 URL;建议提供官方 SHA-1 哈希值。
items.file: 本地文件路径;需要上传服务。插件会验证、计算 SHA-1,并上传到自托管服务器或 S3 以生成可访问的 URL。
使用以下命令应用更改:/permpacks reload packs。
命令与权限
/permpacks reload configs (permpacks.admin): 重载 config.yml 和 packs.yml。
/permpacks reload packs (permpacks.admin): 根据当前配置重新缓存并重新分发。
/permpacks info <PACK_ID> (permpacks.admin): 显示资源包的权限和各项详情(URL/文件和哈希值)。
/permpacks check <PLAYER> (permpacks.admin): 比较玩家权限与实际分发的资源包;显示 ✔/✘。
别名:/ppacks, /pp
工作原理(内部机制)
- 启动:
PermPacks 初始化 Options、BinaryCache 和上传服务(SelfHostService/S3Service),然后读取并缓存资源包。
- 分发:
Packer.distribute(player) 根据权限过滤 Packs,构建单个请求,并发送所有项;每项都在 PackPacketTracker 中标记。
- 拦截:当启用
block_other_packs 时,PackBlocker(通过 ProtocolLib)会拦截任何之前未被标记的传出资源包。
- 清理:启用
file_upload.cleanup 后,在启动期间会清理自托管/S3 上未引用的文件/对象。
从源代码构建
./gradlew build
- 产物:
build/libs/PermPacks-<version>-all.jar
- 开发服务器:
./gradlew runServer (Paper 1.21)
许可证
GPL-3.0。欢迎通过 Issue/PR 贡献。

PermPacks
English |
中文
A Paper plugin that distributes a layered resource-pack stack to players based on permissions. It supports both remote URLs and local files, ships with self-host and Amazon S3 upload backends, and can optionally block external packs for consistency.
Highlights
- Permission-driven pack stack: filter packs from
packs.yml by player permissions, load in ascending priority; later packs override earlier ones.
- Unified delivery for multiple sources:
url and file items are unified into a single client request.
- Pluggable upload services: built-in
self_host (embedded HTTP server) and amazon_s3; SHA-1 is auto-computed and reused to avoid duplicate uploads.
- External pack blocking: with ProtocolLib installed, block any resource pack not marked by this plugin.
- Hot reload and diagnostics: reload configs and redistribute online players; inspect pack details and player stack state.
Requirements
- Paper 1.21+, Java 21
- Optional: ProtocolLib (recommended for external-pack blocking)
Installation
- Drop
PermPacks-<version>-all.jar into plugins/
- Start the server to generate
config.yml and packs.yml
- Edit configs as needed, then run
/permpacks reload packs to apply
Note: the plugin creates cache/repository directories (e.g., .filerepo/). They are safe to delete; they will be re-created automatically.
Configuration (config.yml)
block_other_packs: false
file_upload:
enabled: false
cleanup: false
service: self_host # amazon_s3, self_host
self_host:
host: 127.0.0.1
port: 7077
amazon_s3:
endpoint: s3.amazonaws.com
region: cn-north-1
bucket: your-bucket-name
directory: uploads
access_key_id: ""
secret_access_key: ""
path_style_access: false
chunked_encoding: true
block_other_packs: if enabled, block any resource pack not marked by this plugin (requires ProtocolLib).
file_upload.enabled: enable usage of file items in packs.yml; when disabled, file items are ignored.
file_upload.service: choose self_host (embedded HTTP) or amazon_s3.
file_upload.cleanup: on startup, remove unreferenced objects from the repository/bucket; keep only those referenced by current config.
self_host.*: listen address and port for the embedded HTTP server.
amazon_s3.*: S3 client and bucket settings; supports path-style addressing and chunked encoding.
Packs (packs.yml)
Priority rules: default is 0; negatives allowed. Packs are loaded in ascending priority; items with equal priority are loaded in file order, with later items overriding earlier ones.
example:
permission: permpacks.pack.example
priority: 10
items:
- url: https://example.com/high.zip
hash: d41d8cd98f00b204e9800998ecf8427e
- file: plugins/OtherPlugin/assets.zip
hash: 900150983cd24fb0d6963f7d28e17f72
permission: players owning this permission receive the pack (and its items).
priority: lower loads earlier; later packs override earlier ones.
items.url: direct download URL; providing official SHA-1 is recommended.
items.file: local file path; requires upload service. The plugin validates, computes SHA-1, and uploads to self-host or S3 to generate an accessible URL.
Apply changes with: /permpacks reload packs.
Commands & Permissions
/permpacks reload configs (permpacks.admin): reload config.yml and packs.yml.
/permpacks reload packs (permpacks.admin): re-cache and redistribute based on current config.
/permpacks info <PACK_ID> (permpacks.admin): show permission and item details (URL/File and hashes) for a pack.
/permpacks check <PLAYER> (permpacks.admin): compare player permissions with actually distributed packs; shows ✔/✘.
Aliases: /ppacks, /pp
How It Works (Internals)
- Startup:
PermPacks initializes Options, BinaryCache, and upload services (SelfHostService/S3Service), then reads and caches packs.
- Distribution:
Packer.distribute(player) filters Packs by permissions, builds a single request, and sends all items; each item is marked in PackPacketTracker.
- Blocking: when
block_other_packs is enabled, PackBlocker (via ProtocolLib) blocks any outgoing resource pack not previously marked.
- Cleanup: with
file_upload.cleanup enabled, unreferenced files/objects are cleaned up on self-host/S3 during startup.
Build From Source
./gradlew build
- Artifact:
build/libs/PermPacks-<version>-all.jar
- Dev server:
./gradlew runServer (Paper 1.21)
License
GPL-3.0. Contributions via Issues/PRs are welcome.
评论 0
登录后参与评分
还没有评论,来抢沙发吧