Перейти к содержимому
Mineforgian

Plugin ASM

Plugin ASM is a lightweight, Mixin-style bytecode injection framework for Paper/Bukkit servers, enabling declarative method modifications via ASM with no manual bytecode writing.

154 загрузок1 подписчиковLGPL-2.1-or-laterjava-agent

Обновлён 18 февраля 2026 г. · опубликован 13 февраля 2026 г.

  • Скриншот: Plugin ASM

中文

Plugin ASM

PASM 是一个轻量级、Mixin 风格的字节码注入框架,专为 Paper / Folia 服务端设计。 它允许你通过简单的注解,在运行时修改任意类的字节码——无需反射,无需继承,无性能损耗。

🎯 目标:让 Bukkit/Paper 插件开发者能像写普通 Java 一样实现热修补、API 增强、事件拦截等操作,而不触碰复杂的 ASM 细节。


✨ 核心特性

特性 说明
🚀 Mixin 式注入 @Pasm + @Inject 定义目标类与方法,框架自动合并字节码
🩸全注入类型 BEFORE / AFTER / REPLACE / HEAD / TAIL(AROUND 降级为 REPLACE)
🏗️ 构造函数注入 支持 ,自动插入 super() 之后
🔥异常处理兼容 try-catch-finally 完整复制,标签映射正确
📏宽类型自动偏移 long / double 参数自动处理双槽位,无需手动计算 this 偏移
⚔️ REPLACE 独占 同一方法若存在 REPLACE,自动忽略其他注入(符合 Mixin 规范)
🧩 ASM 处理器钩子 在 pasm.json 中声明 asms 数组,实现 PasmAsmProcessor 接口,可在 premain 前后执行自定义字节码操作
📦插件式扫描 将 pasm.json 放入插件 Jar 根目录,PASM 自动扫描所有注入点

📋 环境要求

  • Java 8 - 21

  • Minecraft 1.0+

  • MavenGradle(仅编译插件时需要)


📥 使用方法

  1. 去Github或Modrinth下载最新的Plugin ASM

  2. 添加到服务器根目录,添加后,结构应该如下:

server
| -> paper-1.xx.x-xx.jar
| -> pasm-x.x.x.jar
| -> plugins
    | -> 一些插件.jar
  1. 修改你的启动命令,修改后,应该如下:
java -javaagent:pasm-x.x.x.jar -jar paper-1.xx.x-xx.jar

使用Plugin ASM来字节码注入

参考Wiki


🧪 测试与兼容性

PASM 已在以下场景通过完整测试:

  • ✅ BEFORE、AFTER、REPLACE、HEAD、TAIL全类型覆盖

  • ✅ 构造函数 <init> 注入

  • ✅ 包含 try-catch-finally 的复杂方法

  • ✅ 参数含 long / double 的宽类型方法(静态→非静态、静态→静态)

  • ✅ 同一方法的多个 REPLACE 冲突检测(仅执行优先级最高者)

  • ✅ 无 pasms 仅有 asms 的配置

  • ✅ Paper 1.21.11 / Java 21

已知限制(将在后续版本改进):

  • AROUND 注入暂未实现,使用时会降级为 REPLACE 并输出警告。

  • 热加载功能尚不稳定,不建议生产环境使用。

  • 不支持修改 native 方法或抽象方法。


📦 如何构建 PASM 本体(仅框架维护者)

git clone https://github.com/laolizhennui/Plugin-ASM.git
cd Plugin-ASM
mvn clean package

生成产物:target/pasm-x.x.x.jar(这就是 Java Agent)


🤝 参与贡献

PASM 还是一个年轻的项目,欢迎任何形式的贡献! 你可以:

  • 提交 Issue:报告 Bug 或提议新功能

  • Pull Request:修复代码、完善文档

  • 分享你的使用案例

期待你的 Star ⭐ 和 Fork 🍴!


📄 许可证

LGPL License

Copyright © 2026 laolizhennui


最后——PASM 并不是要取代 Mixin,而是为 Paper 开发者提供一个更简单、更符合直觉的字节码注入选择。 如果你喜欢它,请告诉你的朋友;如果你遇到问题,请告诉我们。 Happy Coding! 🎮🔧


English

Plugin ASM

PASM is a lightweight, Mixin‑style bytecode injection framework designed specifically for Paper / Folia server environments. It allows you to modify the bytecode of arbitrary classes at runtime using simple annotations—no reflection, no inheritance, zero performance penalty.

🎯 Goal: Let Bukkit/Paper plugin developers implement hot‑patches, API enhancements, event interceptors, and more—* just by writing plain Java, without touching complex ASM internals*.


✨ Core Features

Feature Description
🚀 Mixin‑style injection @Pasm + @Inject define target class & method; the framework merges bytecode automatically.
🩸 Full injection types BEFORE / AFTER / REPLACE / HEAD / TAIL (AROUND falls back to REPLACE with a warning).
🏗️ Constructor injection Supports ; automatically inserted after super() call.
🔥 Exception‑handler compatibility Full replication of try‑catch‑finally blocks; correct label mapping.
📏 Automatic wide‑type offset long / double parameters are handled as double‑slots; no manual calculation of this offset.
⚔️ Exclusive REPLACE If a method has multiple REPLACE injections, only the one with highest priority is applied.
🧩 ASM processor hooks Declare asms array in pasm.json; implement PasmAsmProcessor interface to run custom bytecode operations before/after premain.
📦 Plugin‑style scanning Place pasm.json in your plugin JAR root; PASM automatically discovers all injection points.

📋 Environment Requirements

  • Java 8–21

  • Minecraft 1.0+

  • Maven or Gradle(only needed when compiling your plugin)


📥 Installation & Setup

  1. Download the latest Plugin ASM from GitHub or Modrinth

  2. Place it in your server root directory. The structure should look like this:

server
| -> paper-1.xx.x-xx.jar
| -> pasm-x.x.x.jar
| -> plugins
    | -> some-plugin.jar
  1. Modify your startup command accordingly:
java -javaagent:pasm-x.x.x.jar -jar paper-1.xx.x-xx.jar

🛠️ Using Plugin ASM for Bytecode Injection

Refer to the Wiki for detailed usage and examples.

🧪 Testing & Compatibility

PASM has been fully tested in the following scenarios:

  • ✅ BEFORE, AFTER, REPLACE, HEAD, TAIL–all types covered

  • ✅ Constructor(<init>) injection

  • ✅ Methods containing try‑catch‑finally blocks

  • ✅ Methods with long / double parameters(static → non‑static, static → static)

  • ✅ Conflict detection for multiple REPLACE injectors on the same method(only the highest priority runs)

  • ✅ Configuration with asms only(no pasms)

  • ✅ Paper 1.21.11 / Java 21

Known limitations(to be improved in future versions):

  • AROUND injection is not yet implemented; using it will fall back to REPLACE and emit a warning.

  • Hot‑reload is experimental and not recommended for production.

  • Native methods and abstract methods cannot be modified.


📦 How to Build PASM Itself(Framework Maintainers Only)

git clone https://github.com/laolizhennui/Plugin-ASM.git
cd Plugin-ASM
mvn clean package

Output artifact: target/pasm-x.x.x.jar–this is the Java Agent.


🤝 Contributing

PASM is still a young project, and contributions of any form are welcome! You can:

  • Submit an issue: report bugs or suggest new features

  • Pull Request: fix code, improve documentation

  • Share your use cases

We look forward to your Star ⭐ and Fork 🍴!


📄 License

LGPL License

Copyright © 2026 laolizhennui


Finally–PASM is not meant to replace Mixin, but to offer Paper developers a simpler, more intuitive choice for bytecode injection. If you like it, tell your friends; if you encounter problems, tell us. Happy Coding! 🎮🔧

Версии

ВерсияКаналИграЗагрузчикиДатаСкачать
0.1.0-alpha3Альфа1.21.8, 1.21.9, 1.21.10, 1.21.11java-agent18 февраля 2026 г..jar (3.4 МБ)
0.1.0-alpha2Альфа1.21.8, 1.21.9, 1.21.10, 1.21.11java-agent15 февраля 2026 г..jar (594 КБ)
0.1.0-alpha1Альфа1.21.8, 1.21.9, 1.21.10, 1.21.11java-agent13 февраля 2026 г..jar (596 КБ)

Ченджлог

0.1.0-alpha3Альфа1.21.9, 1.21.10, 1.21.11 · 18 февраля 2026 г.
  1. 现在彻底支持Java8
  2. 优化代码结构
  3. 简化类加载器和注入处理器逻辑
  4. 修复共同超类计算和局部变量处理问题
  5. 优化字节码合并和指令复制性能
  6. 更新API文档和注释说明
  7. 降级Gradle版本并更新依赖
  8. 清理无用代码和优化配置加载
0.1.0-alpha2Альфа1.21.9, 1.21.10, 1.21.11 · 15 февраля 2026 г.

这个版本做的修改:

  1. 把RedefineAgent重命名成劳动PasmAgent
  2. 把热重载从实验特性转成正式特性
  3. 移除了冗余代码
  4. 优化了ASMHOOK的启动性能(尽管可以忽略不计)
0.1.0-alpha1Альфа1.21.9, 1.21.10, 1.21.11 · 13 февраля 2026 г.

🚀 PASM v0.1.0-alpha1

PASM(Plugin ASM) 是一个轻量级、Mixin 风格的字节码注入框架,专为 Paper/Bukkit 服务端设计。这是 PASM 的首个公开预览版本,核心功能已稳定,欢迎社区试用反馈。


✨ 核心特性

  • 声明式注入 –仅需 @Pasm + @Inject 注解,零字节码基础即可修改目标方法。

  • 完整注入类型BEFORE / AFTER / REPLACE / HEAD / TAIL 全部可用,覆盖绝大多数增强场景。

  • 构造函数支持 –可对 <init> 方法进行 HEAD 注入,自动在 super() 后插入。

  • 异常处理兼容 –完美保留 try-catch-finally 结构,注入后异常表不丢失。

  • 宽类型自动偏移long / double 参数在静态→非静态注入时自动计算双槽位偏移,无需手动配置。

  • REPLACE 独占语义 –同一方法的多个注入点若包含 REPLACE,仅执行优先级最高的 REPLACE,其余自动跳过,避免冲突。

  • ASM 处理器扩展 –通过 pasm.jsonasms 字段注册自定义处理器,在 beforeInject / afterInject 生命周期执行任意字节码增强,支持优先级排序。

  • 热加载支持(实验性) –提供 reloadPlugins() 接口,可运行时重新扫描插件并重新注入,适合开发调试。


📦 系统兼容性

  • Java 8~25 –框架自身完全兼容,已在 Java 8、11、17、21完成测试。

  • Paper 1.16.5~1.21+ –实际运行版本取决于服务端要求,最低支持 Java 8(配合 Paper 1.16.5)。

  • ASM 9.x + Gson 2.10 –内置依赖,无外部冲突风险。


⚠️ 已知限制

  • AROUND 注入暂未实现,使用时会降级为 REPLACE 并输出警告。

  • 热加载功能尚不稳定,频繁重载可能导致类冲突,不建议在生产环境高频使用。

  • ASM 处理器钩子(asms)为预览特性,API 可能在未来调整。


📥 快速开始

  1. 下载 pasm-0.1.0-alpha1.jar 放置于服务端根目录。

  2. 启动参数添加 -javaagent:pasm-0.1.0-alpha1.jar[=debug]

  3. 在插件 JAR 的 src/main/resources/pasm.json 中声明注入类。

  4. 编写带 @Pasm@Inject 注解的静态方法,打包后放入 plugins/ 目录。

  5. 启动服务端,框架将自动扫描并完成注入。

详细使用示例请参阅 README


🙏 致谢

感谢所有在开发过程中提供反馈与测试的朋友,特别感谢 PaperMC 社区对字节码操作技术的无私分享。


PASM 仍处于早期阶段,欢迎提交 Issue 或 Pull Request。 GitHub 仓库 | 问题反馈

Полная история изменений — на Modrinth.

Комментарии

Загружаем…