
LuaInMineBukkit
This plugin provides a Lua runtime environment capable of writing most Bukkit plugins. And provide easy-to-use API and detailed documentation. Lua is lightweight and fast, so let's run Lua script in your minecraft server!
- Загрузки
- 182
- Подписчики
- 3
- Обновлён
- 8 ноября 2025 г.
- Лицензия
- MIT
Опубликован 29 августа 2025 г.
LuaInMinecraftBukkit II
English | 中文
Introduction
LuaInMinecraftBukkit II is a Minecraft Bukkit server plugin that aims to use Lua scripts to interact with Bukkit servers.
Lua is a small scripting language with very simple syntax and decent execution speed. Just imagine how wonderful it would be to write a Bukkit plugin with a lightweight script that doesn't need to be compiled to run. If you need to modify something, you can just change it and reload the script—it's like a dream.
Differences from the Previous Generation
Compared to the previous generation, this version focuses more on the native Lua virtual machine. Similarly, this version is also based on the luajava project. However, this version uses a cloned luajava repository. Compared to the original repository, the cloned luajava repository has fundamentally rewritten parts of the reflection functionality, further simplifying the process of Lua calling Java methods, and provides very friendly exception messages on the C language side.
What Can It Do?
Major functions:
- Command Registration: Register any command you want, and it will automatically generate help information and command hierarchy.
- Event Listening: Listen for any Bukkit event you want, even if it's a custom event from another plugin.
- Lua Pooling: By pooling Lua, you can submit Lua closures to run on other state machines to achieve true multi-threaded parallel execution: Example.
Other features include:
- Fast Reflection: The reflection component for Lua now uses MethodHandle-based fast reflection, which is significantly faster than standard reflection.
- Auto-Reload: The plugin can monitor changes to Lua script files and automatically reload them.
However, relying on Java's reflection and dynamic proxy mechanisms, it is currently possible to inherit Java interfaces and call any public method or public attribute of a Java type in a Lua script. This means this plugin can dynamically load scripts and enjoy a subset of Java's functionality. Of course, reflection isn't a silver bullet, and there will still be many situations that cannot be handled on the Lua side. In such cases, Java needs to bridge the gap for Lua. But in the development process, I will try to simplify the interaction between Lua and Java.
In addition to what has been mentioned, similar to the first generation, it can also load dynamic link libraries written in C/C++. Of course, these are features that the Lua language itself supports.
Lua Pooling
Thanks to the tireless efforts of luajava, it is now possible to execute different Lua code on multiple threads.
In this plugin, each Lua environment configuration has a main Lua virtual machine.
Without a pooled Lua virtual machine, when the main Lua virtual machine is running, if another thread B needs to acquire the execution rights of the main Lua virtual machine (e.g., when a Bukkit event is triggered or for a Bukkit asynchronous task) to run Lua code (such as a Lua closure function), thread B must block and wait for the main Lua virtual machine. Only after the main Lua virtual machine completes its current task can thread B acquire the execution rights to run the Lua code. After the Lua code finishes, it must release the execution rights of the main Lua virtual machine. If the code executed by thread B takes a very long time, the main Lua virtual machine will remain occupied by thread B, blocking the execution of other Lua code until thread B releases the execution rights.
With a Lua pool, in the same scenario, after thread B acquires the execution rights of the main Lua virtual machine, it will immediately transfer the Lua code to be executed and all related data to another Lua virtual machine. Once the transfer is complete, it will immediately release the execution rights of the main Lua virtual machine and acquire the execution rights of the other Lua virtual machine to run the transferred code. This allows thread B to release the execution rights of the main Lua virtual machine in a very short amount of time, without waiting for the Lua code to finish, ensuring that the main Lua virtual machine can respond quickly to other calls.
Here is a more specific example. The following code calls two Bukkit asynchronous tasks, and both tasks are infinite loops.
local import = require "import"
local Thread = import "java.lang.Thread"
for i = 1, 2 do
luaBukkit.helper:asyncCall(luaBukkit.env:pooledCallable(
function ()
while true do
luaBukkit.log:info(Thread:currentThread():getName() .. " async call " .. i .. "!")
Thread:sleep(1000)
end
end
))
end
When Lua pooling is enabled and the capacity is 2, the code above outputs the following content.
You can see output from multiple threads, and the server can be shut down with a stop command:
[13:14:41 INFO]: [LuaInMinecraftBukkitII] Craft Scheduler Thread - 3 - LuaInMinecraftBukkitII async call 1!
[13:14:41 INFO]: [LuaInMinecraftBukkitII] Craft Scheduler Thread - 1 - LuaInMinecraftBukkitII async call 2!
[13:14:42 INFO]: [LuaInMinecraftBukkitII] Craft Scheduler Thread - 1 - LuaInMinecraftBukkitII async call 2!
[13:14:42 INFO]: [LuaInMinecraftBukkitII] Craft Scheduler Thread - 3 - LuaInMinecraftBukkitII async call 1!
When Lua pooling is disabled, the code above outputs the following.
You can see output from only one thread, and while the stop command is acknowledged,
the server cannot be shut down because it cannot acquire the execution rights to
release the Lua VM resources from the infinite loop:
[13:17:49 INFO]: [LuaInMinecraftBukkitII] Craft Scheduler Thread - 2 - LuaInMinecraftBukkitII async call 2!
[13:17:52 INFO]: [LuaInMinecraftBukkitII] Craft Scheduler Thread - 2 - LuaInMinecraftBukkitII async call 2!
stop
[13:17:53 INFO]: [LuaInMinecraftBukkitII] Craft Scheduler Thread - 2 - LuaInMinecraftBukkitII async call 2!
[13:17:53 INFO]: Stopping the server
[13:17:53 INFO]: Stopping server
[13:17:53 INFO]: [LuaInMinecraftBukkitII] Disabling LuaInMinecraftBukkitII vmaster-59748d7+luajava-master-a3ddaf6+java-21
[13:17:53 INFO]: [LuaInMinecraftBukkitII] [LuaEnv default] Shutdown auto-reload.
[13:17:54 INFO]: [LuaInMinecraftBukkitII] Craft Scheduler Thread - 2 - LuaInMinecraftBukkitII async call 2!
[13:17:55 INFO]: [LuaInMinecraftBukkitII] Craft Scheduler Thread - 2 - LuaInMinecraftBukkitII async call 2!
[13:17:56 INFO]: [LuaInMinecraftBukkitII] Craft Scheduler Thread - 2 - LuaInMinecraftBukkitII async call 2!
JNIBridge
Thanks to the support of cffi, JNIBridge was born! Now it's possible to interact with dynamic link libraries. JNIBridge is still being improved, but currently supports:
- Java method invocation
- Basic type conversion
Features planned for the next stage include:
- Field access and assignment
- Array access and assignment
The image below shows a simple player join event, but the event handling logic is managed on the Cpp side.

Ченджлог
1.1.0Релиз1.21.8, 1.21.9, 1.21.10 · 8 ноября 2025 г.
Full Changelog: https://github.com/SmileYik/LuaInMinecraftBukkitII/compare/1.0.9...1.1.0
主要改变:
- 修复 Windows 下 luajit native 库索引错误问题
- 修复快速反射在生成字节码失败时报错, 并在生成失败时回退到标准的反射
- 添加更新检查器, 异步检查插件更新, 若网络请求未在一分钟内完成则将跳过更新检测
- 更新时自动重新下载依赖库文件, 防止依赖库过时导致的崩溃
- 添加 Lua API
registerRawCommand用于快速注册单个指令 - Lua虚拟机在Panic时将会给予更多的错误信息
- 添加新的 bStats 表格, 用于统计所使用的 Lua 版本
- 将 ILuaStateManager 作为 Service 注册进 Bukkit
- 添加了 Luacage 包管理器, 以及配套指令
/luacage - 若干其他更改
- Lua 代码自动补全支持
Major Changes:
- Fixed indexing errors in the LuaJIT native library on Windows
- Fixed fast reflection errors when bytecode generation fails, falling back to standard reflection during generation failures
- Added an update checker that asynchronously checks for plugin updates; skips checks if network requests take longer than one minute
- Automatically redownloads dependency files during updates to prevent crashes caused by outdated dependencies
- Added Lua API
registerRawCommandfor quick registration of individual commands - Lua VM now provides more detailed error messages during panic states
- Added new bStats table to track usage statistics of Lua versions
- Registered ILuaStateManager as a Service within Bukkit
- Added Luacage package manager with corresponding command
/luacage - Several other changes
- Lua code auto-completion support
1.1.0+foliaРелиз1.21.8, 1.21.9, 1.21.10 · 8 ноября 2025 г.
Full Changelog: https://github.com/SmileYik/LuaInMinecraftBukkitII/compare/1.0.9...1.1.0
主要改变:
- 修复 Windows 下 luajit native 库索引错误问题
- 修复快速反射在生成字节码失败时报错, 并在生成失败时回退到标准的反射
- 添加更新检查器, 异步检查插件更新, 若网络请求未在一分钟内完成则将跳过更新检测
- 更新时自动重新下载依赖库文件, 防止依赖库过时导致的崩溃
- 添加 Lua API
registerRawCommand用于快速注册单个指令 - Lua虚拟机在Panic时将会给予更多的错误信息
- 添加新的 bStats 表格, 用于统计所使用的 Lua 版本
- 将 ILuaStateManager 作为 Service 注册进 Bukkit
- 添加了 Luacage 包管理器, 以及配套指令
/luacage - 若干其他更改
- Lua 代码自动补全支持
Major Changes:
- Fixed indexing errors in the LuaJIT native library on Windows
- Fixed fast reflection errors when bytecode generation fails, falling back to standard reflection during generation failures
- Added an update checker that asynchronously checks for plugin updates; skips checks if network requests take longer than one minute
- Automatically redownloads dependency files during updates to prevent crashes caused by outdated dependencies
- Added Lua API
registerRawCommandfor quick registration of individual commands - Lua VM now provides more detailed error messages during panic states
- Added new bStats table to track usage statistics of Lua versions
- Registered ILuaStateManager as a Service within Bukkit
- Added Luacage package manager with corresponding command
/luacage - Several other changes
- Lua code auto-completion support
1.0.9Релиз1.21.6, 1.21.7, 1.21.8 · 19 сентября 2025 г.
Changes
- Folia Server Support: feat: Folia support, add build params -PFoliaSupport to support Fol…, fix: folia scheduler cancel schedule method.
- Automatic Lua script reload after modification: feat: auto reload scripts when it was modified
- Lua scripts can now call default methods defined in Java interfaces and support configuring the behavior when the Lua environment finds multiple matching methods: update luajava
- Added new API to freely switch the Lua environment's behavior when multiple matching methods are found: feat: add new lua api to switch luajava behavior on searched multi ja…
- A sample Lua script file is now generated on the first plugin initialization: feat: add default test.lua file when first initialize plugin config
- Added fast reflection support: feat: fast reflection util for invoke method, get/set field, fix: return null if return type is void & lambda instance class canno…, feat: first part fo FastReflection for LuaJavaApi, feat: bump luajava, fix: update luajava-java8.patch, fix: detect lambda instance and generate method accessor of superclas…, feat: remove lua debug hook for lua state in LuaPool.
- Removed Lua environment global variable separation: remove lua _G table split
- Fixed incorrect recognition of emoji proxies: fix: bump luajava fix emoji
- Fixed stack imbalance and random crashes caused by the Lua pool implementation: fix: LuaPool source lua state stack imbalance & LuaPool destination l…, fix: PooledLuaCallable implement IInnerLuaObject, perf: remove thread pool in LuaPool
- Fixed issues where asynchronous threads and Bukkit events could not be properly shut down when disabling the plugin: feat: scheduler interface add new method to cancel all tasks, fix: unregister event and cancel all tasks when disable plugin
- Fixed errors in the reflection cache under multithreaded conditions: fix: use Collections.synchronizedMap wrap cache
1.0.9+foliaРелиз1.21.6, 1.21.7, 1.21.8 · 19 сентября 2025 г.
Changes
- Folia Server Support: feat: Folia support, add build params -PFoliaSupport to support Fol…, fix: folia scheduler cancel schedule method.
- Automatic Lua script reload after modification: feat: auto reload scripts when it was modified
- Lua scripts can now call default methods defined in Java interfaces and support configuring the behavior when the Lua environment finds multiple matching methods: update luajava
- Added new API to freely switch the Lua environment's behavior when multiple matching methods are found: feat: add new lua api to switch luajava behavior on searched multi ja…
- A sample Lua script file is now generated on the first plugin initialization: feat: add default test.lua file when first initialize plugin config
- Added fast reflection support: feat: fast reflection util for invoke method, get/set field, fix: return null if return type is void & lambda instance class canno…, feat: first part fo FastReflection for LuaJavaApi, feat: bump luajava, fix: update luajava-java8.patch, fix: detect lambda instance and generate method accessor of superclas…, feat: remove lua debug hook for lua state in LuaPool.
- Removed Lua environment global variable separation: remove lua _G table split
- Fixed incorrect recognition of emoji proxies: fix: bump luajava fix emoji
- Fixed stack imbalance and random crashes caused by the Lua pool implementation: fix: LuaPool source lua state stack imbalance & LuaPool destination l…, fix: PooledLuaCallable implement IInnerLuaObject, perf: remove thread pool in LuaPool
- Fixed issues where asynchronous threads and Bukkit events could not be properly shut down when disabling the plugin: feat: scheduler interface add new method to cancel all tasks, fix: unregister event and cancel all tasks when disable plugin
- Fixed errors in the reflection cache under multithreaded conditions: fix: use Collections.synchronizedMap wrap cache
1.0.8Релиз1.21.6, 1.21.7, 1.21.8 · 29 августа 2025 г.
Full Changelog: https://github.com/SmileYik/LuaInMinecraftBukkitII/compare/1.0.7...1.0.8
Changes
- Try downloads resources from project url in config.json at frist
- Implementation of Lua pool, allow running Lua closure on other lua state, and allow transfer return values to main lua state(Running Lua scripts in multiple threads): feat: upgrade luajava, feat: Simple implementation of Lua pool, feat: complete SimpleLuaPool.
主要改变:
- 优先使用 config.json 中设置的 projectUrl 下载依赖
- Lua 池实现, 允许传输 Lua 闭包到其他 Lua 状态机中运行, 并允许将运行的返回值传输给主 Lua 状态机(多线程运行Lua脚本): feat: upgrade luajava, feat: Simple implementation of Lua pool, feat: complete SimpleLuaPool.
Комментарии
Загружаем…