LuaInMinecraftBukkit II icon

LuaInMinecraftBukkit II -----

this plugin provides a Lua runtime environment capable of writing most Bukkit plugins.



LuaInMinecraftBukkit.png
LuaInMinecraftBukkit II
Run Lua Script In Your Server!

[​IMG] [​IMG] [​IMG] [​IMG] [​IMG]
GitHub | Lua Side API (Global Variabes)

Compared with the previous generation, this generation will focus on native LuaVM and try to make it easier to use, more friendly . It supports Lua5.1(LuaJIT), Lua5.2, Lua5.3, Lua5.4.

Welcome to GitHub open issue!
Discord: https://discord.gg/6eP93Z2Msb
What is this plugin?
=====

This plugin offers the possibility to “use Lua to interact with Bukkit”. Lua is a small scripting language with a very simple syntax and a good speed. Imagine how nice it would be to write a Bukkit plugin with a lightweight script that doesn't need to be compiled to run. If you want to change something, just change it and reload the script, it's like a dream.

Of course, the Lua script interpreter used by this plugin is not the Luaj project, but the native Lua virtual machine. Thanks to Kepler's luajava project, this plugin is possible. However, compared to the first LuaInMinecraftBukkit plugin, the luajava project used has been more thoroughly refurbished by me, and compared to Kepler's original repository, I've improved the reflection support for it, as well as providing very friendly exception hints on the C side.


What can it do now?
=====

There are basically 3 main functions supported.
  • Register commands: Register any command you want, and automatically generate help and command hierarchies.
  • Listening to events: Listen to any Bukkit event you want, even if it's a custom event from another plugin.
  • Multithreaded parallel execution of Lua scripts: You can submit closure to lua pool, and the closure will running on another lua state machine, you can find examples in here.
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.
Lua Pooling
=====

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.

Example:
Here is a more specific example. The following code calls two Bukkit asynchronous tasks, and both tasks are infinite loops.
Code (Text):
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:
Code (Text):

[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:
Code (Text):

[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!
 


Installation
=====

Just put jar file to the plugins folder, and launch your server. Now, the plugin will detect your system and arch, auto download the pre-compiled native library for you!

QuickStart
=====

follow the quick start document, maka a lua terminal in your chat box!
QuickStart.1_compressed.png

Commands
=====

After launched server, you just dispatch command: "/
LuaInMinecraftBukkitII help" or "/lua help", all command request op permission.



Global Variable
=====

"luaBukkit" is a global table variable.
You can browser global variables at GrobalVariable Docs (Blog)

[​IMG]
Resource Information
Author:
----------
Total Downloads: 344
First Release: Jun 26, 2025
Last Update: Sep 19, 2025
Category: ---------------
All-Time Rating:
2 ratings
Find more info at github.com...
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings