Example plugin for Cuberite - WIP
This repository isn't official. Please, visit https://api.cuberite.org/ to get full information about API etc.
Also, you can get more info on Cuberite Discord and on Cuberite forum.
Currently, this repository has only brief information and some scripts for Linux to help you use and install all necessary stuff to develop Cuberite plugins.
Install ZeroBrane Studio (optional) and Cuberite manually or using Linux scripts below.
Open a Linux terminal (Ctrl+Alt+T) and then use the commands below.
Installation of dependencies on Debian and Ubuntu:
sudo apt-get install git curl -y
# Install ZBS (ZeroBrane Studio) v1.90
# https://studio.zerobrane.com/doc-installation#linux
# NOTE: uninstall is `zbstudio-uninstall`
curl https://download.zerobrane.com/ZeroBraneStudioEduPack-1.90-linux.sh -o zerobrane.sh &&\
chmod +x zerobrane.sh &&\
./zerobrane.sh &&\
rm zerobrane.sh
# Download cuberite.lua into ZBS
curl -L https://raw.githubusercontent.com/pkulchenko/ZeroBranePackage/master/cuberite.lua > /opt/zbstudio/packages/cuberite.lua
# Install Cuberite
mkdir -p Cuberite &&\
cd Cuberite &&\
curl -sSfL https://download.cuberite.org | sh &&\
./Cuberite <<- EOF
load APIDump
api
apicheck
restart
stop
EOF
# Download important plugins for developing
cd Plugins
git clone https://github.com/Rorkh/HotReload || cd HotReload && git pull && cd ..
git clone https://github.com/madmaxoft/PluginMemory || cd PluginMemory && git pull && cd ..
git clone https://github.com/cuberite/APIFuzzing || cd APIFuzzing && git pull && cd ..
git clone https://github.com/cuberite/PerfPages || cd PerfPages && git pull && cd ..
git clone https://github.com/mathiascode/CommandSpy || cd CommandSpy && git pull && cd ..
cd ..
# Copy the API into ZBS
cp -f cuberite_api.lua /opt/zbstudio/api/lua/cuberite_api.lua
# Launch ZBS
zbstudio
After ZBS opened, select Project
-> Lua Interpreter submenu
: Cuberite - release mode
If you don't see Cuberite - release mode
, Restart ZBS.
You're ready to use ZeroBrane Studio for Cuberite.
Let's load plugins, but first we need to set username, password in webadmin.ini
.
Uncomment 5th and 6th lines in webadmin.ini
. Remember, default password is's not safe etc.
[User:admin]
Password=admin
Open your browser and type this localhost:8080 as url to open WebAadmin. As the site loaded, press Log in
, enter the username and password, then click Sign in
.
After you signed in, press Plugins
and find HotReload
, PluginMemory
, PerfPages
, APIFuzzing
, CommandSpy
and press Enable
button for the plugins. (Btw, APIFuzzing will prevent loading if there are some mistakes in active plugins)
Now press Reload now
button and you're ready to use plugins and the server.
Don't forget to change your rank to admin on the server.
- Plugin name and folder name should be identical, otherwise it may cause some problems with other plugins.
- Please, keep plugins on GitHub, because it gives you a possibility to show them on https://plugins.cuberite.org/.
Cuberite plugins uses lua 5.1, if you want to use external lua tools or other IDEs then read it, otherwise skip to section Notes.
If don't have experience with lua with then read this or this or watch a some video on youtube. For instance: "Lua for Beginners".
I recommend to install luaver for managing versions of Lua and luarocks.
Installation of dependencies on Debian and Ubuntu:
sudo apt-get install linux-headers-generic libreadline-dev build-essential git dkms -y
Installation of luaver in a folder:
git clone https://github.com/DhavalKapil/luaver
cd luaver
. ./install.sh
. ~/.bashrc
Manage versions in a Linux terminal:
luaver install 5.1
luaver use 5.1
luaver set-default 5.1
luaver install-luarocks 3.7.0
luaver use-luarocks 3.7.0
luaver set-default-luarocks 3.7.0
You can now use it with other IDEs and download and use tools like: luacheck, LuaFormatter etc.
- If you're not familiar with git, then read this or watch a some video on youtube. For instance: "Learn Git In 15 Minutes". Though you might use other programs/extenstions instead of cli for git.
- .scripts folder isn't necessary, but those scripts might be useful for you.
- .vscode folder uses for Visual Studio Code, and it's not necessary for any other editor
- .editorconfig file isn't necessary for Zero Brain Studio, because it doesn't support it. Nonetheless, it may be useful for other editors. More information on https://editorconfig.org/
- lint.yml uses as a GitHub action for linting. Example: https://github.com/ZwerOxotnik/CuberiteExamplePlugin/runs/4114814565
- Optimization tips: https://stigmax.gitbook.io/lua-guide/auxiliary/optimizations & http://lua-users.org/wiki/OptimisationTips & https://springrts.com/wiki/Lua_Performance & https://www.lua.org/gems/sample.pdf & tips (please, notice that Cuberite plugins uses lua 5.1, so some tips might be irrelevant!) & Performance Comparison & https://gitspartv.github.io/LuaJIT-Benchmarks/
Perhaps, EmmyLua might be useful.- I should add more examples and info
I'm interested in distributing code as freely as possible.
Copyright (c) 2021 ZwerOxotnik [email protected]
Licensed under the MIT licence.
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.