MCLuaBukkit
Ever wanted to make a Bukkit plugin, but didn't know how? Want to edit code in-game and test it right away? MCLuaBukkit allows use of the Bukkit API with Lua, a simple, yet powerful, scripting language.
Quick Start
Example Code
Overview
MCLuaBukkit provides a Lua VM with mappings to the Bukkit API, and a few ways to load code into the VM. It allows developers to create Bukkit plugins in Lua. This means plugins with less mistakes, more security, and smaller size. Here's an example of an MCLuaBukkit plugin:
events.onPlayerInteract:add(function(p) x,y,z = p:getTargetBlock(100) p:getLocation():lightning(x,y,z) end)
This simple plugin strikes lightning where players click. It could easily be made to work only for certain players. MCLuaBukkit provides 3 ways for server operators to load Lua plugins:
- By Files Files ending in ".lua" inside MCLuaBukkit's data folder will be loaded as Lua plugins.
- By Chat The /lua command will run Lua code in-game.
- By Book And Quill The /luaload command will run Lua code contained inside a book and quill.
Lua APIs Added
- Server API
- Event API
- Player API
- World API
- Config API
- Inventory API
Commands
- /lua <code> Runs specified code.
- /luaload Runs code from a book and quill in the player's hand.
Permissions
- mcluabukkit.lua Allows execution of Lua code in-game.

-
View User Profile
-
Send Message
Posted Jun 5, 2015Sadly my server is the only server using the plugin. maybe I am the only one qualified enough to write plugins in lua? well lucky for you I am using this plugin on two networks soon :)
-
View User Profile
-
Send Message
Posted Nov 6, 2014@nedurland
These plugins don't go in the Lukkit folder, and there isn't a command to run the plugins. They currently run on startup.
-
View User Profile
-
Send Message
Posted Nov 5, 2014This is an awesome plugin, I will be using this on my server, but do you have an ETA on when there will be commands? And, I think you should be able to write your own API's like you can in ComputerCraft, could be useful.
-
View User Profile
-
Send Message
Posted Mar 28, 2014could you make an example lua plugin, if i copy the code above and put in .lua and then in the lukkit folder and i use the command it doesnt work. it says this in the console: http://f63.net/i/update_available_on_snapr.pw-b211ac100e92098.png
-
View User Profile
-
Send Message
Posted Sep 17, 2013I'm a huge fan of your plugin and have a question (actually two): Is there a way to use the API's of other plugins? (luajava keeps giving me class not found errors) Is there a way to hook into any event desired?
Keep up the good work!
-
View User Profile
-
Send Message
Posted Sep 14, 2013Hi, nice plugin
I dont know if you are still updating this (i hope you are) but can you make a list with all functions?
I know I can find all functions in the mcluabukkit folder but can you make a list with a description of what it does? Thank you :)
-
View User Profile
-
Send Message
Posted Aug 26, 2013Is there a way of getting / setting scoreboard values, such as player:setScoreboardValue(objective, value) and player:getScoreboardValue(objective)?
-
View User Profile
-
Send Message
Posted Aug 7, 2013@ExxGen
To send chat as a player, use something like this:
To send chat to a player:
As for using Bukkit events directly, you might be able to pull it off with LuaJava, but I haven't done it myself. The next release will have a more advanced event system that should be able to do this.
-
View User Profile
-
Send Message
Posted Aug 7, 2013@monowii
This script should run from /lua, as long as you run the lines with separate commands, like this:
/lua Bukkit = luajava.bindClass("org.bukkit.Bukkit")
/lua Bukkit:broadcastMessage("Hi from LuaJava!")
Also, you only have to put lib-luaj into the jar file if you are recompiling MCLuaBukkit. Sorry about not making that clear.
-
View User Profile
-
Send Message
Posted Jul 26, 2013I get this error when I try to run a script:
[MCLuaBukkit] Lua script loaded by lua command produced error: org.luaj.vm2.LuaError: [string "lua command"]:1: syntax error
And the script is just:
Bukkit = luajava.bindClass("org.bukkit.Bukkit")
Bukkit:broadcastMessage("Hi from LuaJava!")
I also put the content of lib-luaj in MCLuaBukkit.jar
I use CB 1.6.2-R0.1 (Build #02820) and MCLuaBukkit 0.63
Edit: This work only with books
-
View User Profile
-
Send Message
Posted Jul 20, 2013@ExxGen
To answer your first question, you can use chat() to send a message to a player, like this:
-
View User Profile
-
Send Message
Posted Jul 18, 2013I want to send chat as a player, how can i do that?
And, is there a way to use events like org.bukkit.event.player.PlayerChatEvent directly?
-
View User Profile
-
Send Message
Posted Jul 3, 2013@carocrazy132
Caro, I've personally used onPlayerInteract as a block breaking event. Granted, it may not be as good as an onBlockBreak event, but it can certainly be used as such for the most part.
-
View User Profile
-
Send Message
Posted Jun 28, 2013@carocrazy132
events.onPlayerInteract can be used to tell when block breaking is started. If you need more advanced tracking, please let me know.
-
View User Profile
-
Send Message
Posted Jun 26, 2013This has to be a record for how much effort was put into something useless. How about an events.onBlockBreak so that all the other functions are actually useful? Jesus in a game about breaking blocks you sure missed the target by a few miles, didn't you?
-
View User Profile
-
Send Message
Posted Jun 10, 2013@lieudusty
Sorry about that. I should have checked if the script worked before posting it. Here's the fixed version:
As for setting velocity, here's a script for that:
-
View User Profile
-
Send Message
Posted Jun 9, 2013@ndinventor
Interesting... I tried that code and it errored:
EDIT: Also is there a way to set the player's velocity?
-
View User Profile
-
Send Message
Posted Jun 9, 2013@justync7
You would have to use LuaJava, as MCLuaBukkit doesn't have API mappings to the effect system yet. The code would look something like:
-
View User Profile
-
Send Message
Posted Jun 9, 2013Is there anyway to make a particle effect that follows a players footsteps but only when they are moving?
-
View User Profile
-
Send Message
Posted May 26, 2013@Nixola97
".txt" files only work in 0.6. Come 0.63, they will no longer work. This is because the old script loader thought that "config.yml" was a Lua script, which meant that I couldn't add a config to MCLuaBukkit without changing that.