Compare commits

..

1 Commits

Author SHA1 Message Date
07675fff93
Implimented a non-functional but compiling v1.7.2
Unable to get the client connecting, for some strange reason it dies
shortly after it sends a few packets...

The client would complain about a message:
Internal Exception:
    io.netty.handler.codec.DecoderException:
        java.io.IOException: Bad packet id 3

I disabled compression in cProtocol_1_7_2::SendLoginSuccess since it didnt seem to be enabled previously,
this doesnt appear to have resolved it either, throwing another error.
Internal Exception:
    io.netty.handler.codec.DecoderException:
        java.io.IOException: Packet was larget than I expected, found 47
	bytes extra whilst reading packet 0

Unsure the best method to debug this,
wish i could compile the old cuberite rn but Ill hold off on this for
now and work on it slowly as i can.
Will push to this branch to get it working before making a cleaned up
single commit to the main branch.

```
[e85cf48eed82958a|18:50:04] Startup complete, took 2185ms!
[cf19c7c5818bc65|18:50:06] Client "::ffff:127.0.0.1" connected!
[cf19c7c5818bc65|18:50:06] New ClientHandle created at 0x7fec98000c80
Recieved Data!
Next incoming packet is type 0 (0x0), length 13 (0xd) at state 2. Payload:
00000000: 0B 6F 6E 65 65 63 68 61 6E 68 61                   .oneechanha

Outgoing packet: type pktLoginSuccess (translated to 0x02), length 50 (0x0032), state 3. Payload (incl. type):
00000000: 02 24 31 31 63 66 63 39 66 39 2D 30 63 63 32 2D    .$11cfc9f9-0cc2-
00000010: 33 33 63 34 2D 62 65 37 39 2D 37 37 36 64 64 30    33c4-be79-776dd0
00000020: 63 64 30 36 36 31 0B 6F 6E 65 65 63 68 61 6E 68    cd0661.oneechanh
00000030: 61 78                                              ax

[70dec22ea7dbad48|18:50:06] Player "oneechanhax" with save file "players/11/cfc9f9-0cc2-33c4-be79-776dd0cd0661.json" is spawning at {0.50, 61.50, 0.50} in world "world"
[70dec22ea7dbad48|18:50:06] Player oneechanhax has joined the game
Outgoing packet: type pktJoinGame (translated to 0x01), length 17 (0x0011), state 3. Payload (incl. type):
00000000: 01 00 00 00 0B 00 00 02 64 07 64 65 66 61 75 6C    ........d.defaul
00000010: 74                                                 t

Outgoing packet: type pktSpawnPosition (translated to 0x05), length 9 (0x0009), state 3. Payload (incl. type):
00000000: 05 00 00 00 00 F4 00 00 00                         .....�..

Outgoing packet: type pktPlayerAbilities (translated to 0x39), length 10 (0x000a), state 3. Payload (incl. type):
00000000: 39 00 3D 4C CC CD 3D CC CC CD                      9.=L�=��

Outgoing packet: type pktPlayerList (translated to 0x38), length 13 (0x000d), state 3. Payload (incl. type):
00000000: 38 0B 6F 6E 65 65 63 68 61 6E 68 61 78             8.oneechanhax

[cf19c7c5818bc65|18:50:06] Client oneechanhax @ ::ffff:127.0.0.1 disconnected
[cf19c7c5818bc65|18:50:06] Destroy: destroying client 0x7fec98000c80, "oneechanhax" @ ::ffff:127.0.0.1
[3551eca320e4cc0b|18:50:06] Adding player oneechanhax to world "world".
Outgoing packet: type pktPlayerMoveLook (translated to 0x08), length 34 (0x0022), state 3. Payload (incl. type):
00000000: 08 3F E0 00 00 00 00 00 00 40 4F 90 A3 D7 0A 3D    .?�.....@O�=
00000010: 71 3F E0 00 00 00 00 00 00 00 00 00 00 00 00 00    q?�............
00000020: 00 00                                              ..

Outgoing packet: type pktPlayerAbilities (translated to 0x39), length 10 (0x000a), state 3. Payload (incl. type):
00000000: 39 02 00 00 00 00 00 00 00 00                      9.........
```
2024-02-13 18:53:14 -05:00
399 changed files with 56749 additions and 3802 deletions

5
.gitignore vendored
View File

@ -46,8 +46,6 @@ GPUCache
*.cbp
## KDevelop
*.kdev*
## Vim
.cache/
# world inside source
ChunkWorx.ini
@ -128,6 +126,3 @@ run-clang-tidy.py
# ctags output
tags
# mac things
.DS_Store

37
.gitmodules vendored
View File

@ -1,3 +1,12 @@
[submodule "Server/Plugins/Core"]
path = Server/Plugins/Core
url = https://github.com/cuberite/Core.git
[submodule "Server/Plugins/ProtectionAreas"]
path = Server/Plugins/ProtectionAreas
url = https://github.com/cuberite/ProtectionAreas.git
[submodule "Server/Plugins/ChatLog"]
path = Server/Plugins/ChatLog
url = https://github.com/cuberite/ChatLog.git
[submodule "lib/mbedtls"]
path = lib/mbedtls
url = https://github.com/cuberite/polarssl.git
@ -26,10 +35,26 @@
path = lib/expat
url = https://github.com/cuberite/expat.git
ignore = dirty
[submodule "lib/lua"]
path = lib/lua
url = https://github.com/cuberite/lua.git
ignore = dirty
[submodule "lib/luaexpat"]
path = lib/luaexpat
url = https://github.com/cuberite/luaexpat.git
ignore = dirty
[submodule "lib/luaproxy"]
path = lib/luaproxy
url = https://github.com/cuberite/luaproxy.git
ignore = dirty
[submodule "lib/sqlite"]
path = lib/sqlite
url = https://github.com/cuberite/sqlite.git
ignore = dirty
[submodule "lib/tolua++"]
path = lib/tolua++
url = https://github.com/cuberite/toluapp.git
ignore = dirty
[submodule "lib/fmt"]
path = lib/fmt
url = https://github.com/fmtlib/fmt.git
@ -40,14 +65,14 @@
[submodule "lib/libdeflate"]
path = lib/libdeflate
url = https://github.com/cuberite/libdeflate
[submodule "lib/libpdw"]
path = lib/libpdw
url = https://github.com/oneechanhax/libpdw
branch = async
[submodule "lib/libglez"]
path = lib/libglez
url = https://git.oneechan.xyz/oneechanhax/libglez
url = https://github.com/oneechanhax/libglez
branch = rainbow
[submodule "lib/libhydride"]
path = lib/libhydride
url = https://git.oneechan.xyz/oneechanhax/libhydride
[submodule "lib/libpdw"]
path = lib/libpdw
url = https://git.oneechan.xyz/oneechanhax/libpdw
branch = async
url = https://github.com/oneechanhax/libhydride

View File

@ -1,56 +0,0 @@
{
"steps": {
"gcc-build": {
"image": "ubuntu",
"when": {
"branch": [
"main",
"dev"
],
"event": [
"push",
"pull_request",
"manual"
]
},
"commands": [
"echo Install development packages",
"apt update",
"apt install -y build-essential cmake python3",
"echo Make build directory",
"mkdir build-gcc",
"echo CMake build make-files",
"CC=gcc CXX=g++ cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build-gcc/",
"echo Build Project",
"cmake --build build-gcc/",
"cmake --install build-gcc/"
]
},
"clang-build": {
"image": "ubuntu",
"when": {
"branch": [
"main",
"dev"
],
"event": [
"push",
"pull_request",
"manual"
]
},
"commands": [
"echo Install development packages",
"apt update",
"apt install -y build-essential cmake clang python3",
"echo Make build directory",
"mkdir build-clang",
"echo CMake build make-files",
"CC=clang CXX=clang++ cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build-clang/",
"echo Build Project",
"cmake --build build-clang/",
"cmake --install build-clang/"
]
}
}
}

View File

@ -33,6 +33,13 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# The need for speed (in Release):
if(WHOLE_PROGRAM_OPTIMISATION)
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ${IPO_SUPPORTED})
endif()
# Static CRT:
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
@ -92,16 +99,5 @@ if(SELF_TEST)
add_subdirectory(tests)
endif()
# The need for speed (in Release):
if(WHOLE_PROGRAM_OPTIMISATION)
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_CHECK_OUTPUT)
if(IPO_SUPPORTED)
set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(WARNING "IPO is not supported: ${IPO_CHECK_OUTPUT}")
endif()
endif()
emit_fixups()
group_sources()

View File

@ -9,8 +9,6 @@ as provided in the LICENSE file.
9caihezi
AirOne01
Altenius
anguslmm (Angus McLean)
ashquarky
BasedDoge (Donated AlchemistVillage prefabs)
bearbin (Alexander Harkness)
beeduck
@ -19,19 +17,16 @@ birkett (Anthony Birkett)
Bond_009
changyongGuo
Cocosushi6
CoolPuppyKid
DarkoGNU
derouinw
dImrich (Damian Imrich)
Diusrex
Duralex
dyexlzc
Earboxer (Zach DeCook)
FakeTruth (founder)
feyokorenhof
Gareth Nelson
GefaketHD
Griezn (Seppe Degryse)
HaoTNN
havel06 (Michal Havlíček)
hle0
@ -62,7 +57,6 @@ mcfadyeni
MeMuXin
mgueydan
MikeHunsinger
mjagdis (Mike Jagdis)
Morritz (TJ)
morsmordere (Anzhelika Iugai)
mtilden
@ -81,16 +75,11 @@ rs2k
SamJBarney
Schwertspize
Seadragon91 (Lukas Pioch)
sleirsgoevy (Sergey Lisov)
Sofapriester
solvictor
Spekdrum (Pablo Beltran)
SphinxC0re
Spongecade (Updated wiki links)
steve-nzr
structinf (xdot)
sweetgiorni
SuperEwald
Sxw1212
Taugeshtu
TheHyper45

View File

@ -24,7 +24,7 @@ I'd say that the important topics are:
Useful Resources
----------------
- [Minecraft Wiki](https://minecraft.wiki/w/Minecraft_Wiki)
- [Minecraft Wiki](https://minecraft.gamepedia.com/Minecraft_Wiki)
- [Minecraft Protocol Wiki](http://wiki.vg/Main_Page)
- [Lua API Documentation](https://api.cuberite.org/)
- [Visual Studio Community Edition Download](https://www.visualstudio.com/downloads/)
@ -127,7 +127,7 @@ Special Things
[1]: https://book.cuberite.org/
[2]: https://github.com/cuberite/cuberite/blob/master/TESTING.md
[3]: https://minecraft.wiki/w/Minecraft_Wiki
[3]: https://minecraft.gamepedia.com/Minecraft_Wiki
[4]: https://github.com/cuberite/cuberite/blob/master/CONTRIBUTING.md
[5]: https://github.com/cuberite/cuberite/blob/master/COMPILING.md
[6]: https://github.com/cuberite/cuberite/issues?q=is%3Aopen+is%3Aissue+label%3Aeffort%2Feasy

3
Jenkinsfile vendored
View File

@ -1,7 +1,4 @@
pipeline {
options {
timeout(time: 1, unit: 'HOURS')
}
agent {
docker 'cuberite/docker-ci/minimal:latest'
}

View File

@ -26,7 +26,7 @@ Copyright 2023 Rebekah Rowe <rebekahrowe9999@gmail.com>
Cuberite: A lightweight, fast and extensible game server for Minecraft
www: https://cuberite.org
Copyright 2011-2025 Cuberite Contributors
Copyright 2011-2022 Cuberite Contributors
A full list of known copyright holders can be found in the CONTRIBUTORS file
to be distributed with all copies of this software.

View File

@ -0,0 +1,21 @@
Copyright (C) 1994-2008 Lua.org, PUC-Rio.
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.

View File

@ -0,0 +1,120 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>LuaExpat: XML Expat parsing for the Lua programming language</title>
<link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"><a href="http://www.keplerproject.org">
<img alt="LuaExpat logo" src="luaexpat.png"/>
</a></div>
<div id="product_name"><big><strong>LuaExpat</strong></big></div>
<div id="product_description">XML Expat parsing for the Lua programming language</div>
</div> <!-- id="product" -->
<div id="main">
<div id="navigation">
<h1>LuaExpat</h1>
<ul>
<li><a href="index.html">Home</a>
<ul>
<li><a href="index.html#overview">Overview</a></li>
<li><a href="index.html#status">Status</a></li>
<li><a href="index.html#download">Download</a></li>
<li><a href="index.html#history">History</a></li>
<li><a href="index.html#references">References</a></li>
<li><a href="index.html#credits">Credits</a></li>
<li><a href="index.html#contact">Contact</a></li>
</ul>
</li>
<li><a href="manual.html">Manual</a>
<ul>
<li><a href="manual.html#introduction">Introduction</a></li>
<li><a href="manual.html#installation">Installation</a></li>
<li><a href="manual.html#parser">Parser Objects</a></li>
</ul>
</li>
<li><a href="examples.html">Examples</a></li>
<li><a href="lom.html">Lua Object Model</a></li>
<li><a href="http://luaforge.net/projects/luaexpat/">Project</a>
<ul>
<li><a href="http://luaforge.net/tracker/?group_id=13">Bug Tracker</a></li>
<li><a href="http://luaforge.net/scm/?group_id=13">CVS</a></li>
</ul>
</li>
<li><strong>License</strong></li>
</ul>
</div> <!-- id="navigation" -->
<div id="content">
<h2>License</h2>
<p>
LuaExpat is free software: it can be used for both academic and
commercial purposes at absolutely no cost. There are no royalties
or GNU-like "copyleft" restrictions. LuaExpat qualifies as <a href=
"http://www.opensource.org/docs/definition.html">Open Source</a>
software. Its licenses are compatible with <a href=
"http://www.gnu.org/licenses/gpl.html">GPL</a>. LuaExpat is not in
the public domain and the
<a href="http://www.keplerproject.org">Kepler Project</a>
keep its copyright. The legal details are below.
</p>
<p>The spirit of the license is that you are free to use LuaExpat
for any purpose at no cost without having to ask us. The only
requirement is that if you do use LuaExpat, then you should give us
credit by including the appropriate copyright notice somewhere in
your product or its documentation.</p>
<p>The LuaExpat library is designed and implemented by Roberto
Ierusalimschy. The implementation is not derived from licensed
software.</p>
<hr/>
<p>Copyright &copy; 2003-2007 The Kepler Project.
</p>
<p>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:</p>
<p>The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.</p>
<p>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.</p>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
<p><small>
$Id: license.html,v 1.9 2007/06/05 20:03:12 carregal Exp $
</small></p>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -0,0 +1,27 @@
/************************************************************************
* lsqlite3 *
* Copyright (C) 2002-2013 Tiago Dionizio, Doug Currie *
* All rights reserved. *
* Author : Tiago Dionizio <tiago.dionizio@ist.utl.pt> *
* Author : Doug Currie <doug.currie@alum.mit.edu> *
* Library : lsqlite3 - a SQLite 3 database binding for Lua 5 *
* *
* 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. *
************************************************************************/

7
Server/Plugins/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
/*
!/APIDump
!/Debuggers
!/DumpInfo
!/HookNotify
!/NetworkTest
!/TestLuaRocks

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,422 @@
return
{
cArrowEntity =
{
Desc = [[
Represents the arrow when it is shot from the bow. A subclass of the {{cProjectileEntity}}.
]],
Functions =
{
CanPickup =
{
Params =
{
{
Name = "Player",
Type = "cPlayer",
},
},
Returns =
{
{
Type = "boolean",
},
},
Notes = "Returns true if the specified player can pick the arrow when it's on the ground",
},
GetBlockHit =
{
Notes = "Returns the coords of the block into which the arrow is stuck. Undefined if the arrow is still moving.",
Returns =
{
{
Type = "Vector3i",
},
},
},
GetDamageCoeff =
{
Returns =
{
{
Type = "number",
},
},
Notes = "Returns the damage coefficient stored within the arrow. The damage dealt by this arrow is multiplied by this coeff",
},
GetPickupState =
{
Returns =
{
{
Type = "cArrowEntity#ePickupState",
},
},
Notes = "Returns the pickup state (one of the psXXX constants, above)",
},
IsCritical =
{
Returns =
{
{
Type = "boolean",
},
},
Notes = "Returns true if the arrow should deal critical damage. Based on the bow charge when the arrow was shot.",
},
SetDamageCoeff =
{
Params =
{
{
Name = "DamageCoeff",
Type = "number",
},
},
Notes = "Sets the damage coefficient. The damage dealt by this arrow is multiplied by this coeff",
},
SetIsCritical =
{
Params =
{
{
Name = "IsCritical",
Type = "boolean",
},
},
Notes = "Sets the IsCritical flag on the arrow. Critical arrow deal additional damage",
},
SetPickupState =
{
Params =
{
{
Name = "PickupState",
Type = "cArrowEntity#ePickupState",
},
},
Notes = "Sets the pickup state (one of the psXXX constants, above)",
},
},
Constants =
{
psInCreative =
{
Notes = "The arrow can be picked up only by players in creative gamemode",
},
psInSurvivalOrCreative =
{
Notes = "The arrow can be picked up by players in survival or creative gamemode",
},
psNoPickup =
{
Notes = "The arrow cannot be picked up at all",
},
},
ConstantGroups =
{
ePickupState =
{
Include = "ps.*",
TextBefore = [[
The following constants are used to signalize whether the arrow, once it lands, can be picked by
players:
]],
},
},
Inherits = "cProjectileEntity",
},
cExpBottleEntity =
{
Desc = [[
Represents a thrown ExpBottle. A subclass of the {{cProjectileEntity}}.
]],
Functions =
{
},
Inherits = "cProjectileEntity",
},
cFireChargeEntity =
{
Desc = [[
Represents a fire charge that has been shot by a Blaze or a {{cDispenserEntity|Dispenser}}. A subclass
of the {{cProjectileEntity}}.
]],
Functions =
{
},
Inherits = "cProjectileEntity",
},
cFireworkEntity =
{
Desc = [[
Represents a firework rocket.
]],
Functions =
{
GetItem =
{
Returns =
{
{
Type = "cItem",
},
},
Notes = "Returns the item that has been used to create the firework rocket. The item's m_FireworkItem member contains all the firework-related data.",
},
GetTicksToExplosion =
{
Returns =
{
{
Type = "number",
},
},
Notes = "Returns the number of ticks left until the firework explodes.",
},
SetItem =
{
Params =
{
{
Name = "FireworkItem",
Type = "cItem",
},
},
Notes = "Sets a new item to be used for the firework.",
},
SetTicksToExplosion =
{
Params =
{
{
Name = "NumTicks",
Type = "number",
},
},
Notes = "Sets the number of ticks left until the firework explodes.",
},
},
Inherits = "cProjectileEntity",
},
cGhastFireballEntity =
{
Desc = "",
Functions =
{
},
Inherits = "cProjectileEntity",
},
cProjectileEntity =
{
Desc = "Base class for all projectiles, such as arrows and fireballs.",
Functions =
{
GetCreatorName =
{
Returns =
{
{
Type = "string",
},
},
Notes = "Returns the name of the player that created the projectile. Will be empty for non-player creators",
},
GetCreatorUniqueID =
{
Returns =
{
{
Type = "number",
},
},
Notes = "Returns the unique ID of the entity who created this projectile, or {{cEntity#INVALID_ID|cEntity.INVALID_ID}} if the projectile wasn't created by an entity.",
},
GetMCAClassName =
{
Returns =
{
{
Type = "string",
},
},
Notes = "Returns the string that identifies the projectile type (class name) in MCA files",
},
GetProjectileKind =
{
Returns =
{
{
Type = "cProjectileEntity#eKind",
},
},
Notes = "Returns the kind of this projectile (pkXXX constant)",
},
IsInGround =
{
Returns =
{
{
Type = "boolean",
},
},
Notes = "Returns true if this projectile has hit the ground.",
},
},
Constants =
{
pkArrow =
{
Notes = "The projectile is an {{cArrowEntity|arrow}}",
},
pkEgg =
{
Notes = "The projectile is a {{cThrownEggEntity|thrown egg}}",
},
pkEnderPearl =
{
Notes = "The projectile is a {{cThrownEnderPearlEntity|thrown enderpearl}}",
},
pkExpBottle =
{
Notes = "The projectile is a {{cExpBottleEntity|thrown exp bottle}}",
},
pkFireCharge =
{
Notes = "The projectile is a {{cFireChargeEntity|fire charge}}",
},
pkFirework =
{
Notes = "The projectile is a (flying) {{cFireworkEntity|firework}}",
},
pkGhastFireball =
{
Notes = "The projectile is a {{cGhastFireballEntity|ghast fireball}}",
},
pkSnowball =
{
Notes = "The projectile is a {{cThrownSnowballEntity|thrown snowball}}",
},
pkSplashPotion =
{
Notes = "The projectile is a {{cSplashPotionEntity|thrown splash potion}}",
},
pkWitherSkull =
{
Notes = "The projectile is a {{cWitherSkullEntity|wither skull}}",
},
},
ConstantGroups =
{
eKind =
{
Include = "pk.*",
TextBefore = "The following constants are used to distinguish between the different projectile kinds:",
},
},
Inherits = "cEntity",
},
cSplashPotionEntity =
{
Desc = [[
Represents a thrown splash potion.
]],
Functions =
{
GetEntityEffectType =
{
Returns =
{
{
Type = "cEntityEffect#eType",
},
},
Notes = "Returns the effect type of this potion",
},
GetItem =
{
Returns =
{
{
Type = "cItem",
},
},
Notes = "Gets the potion item that was thrown.",
},
GetPotionColor =
{
Returns =
{
{
Type = "number",
},
},
Notes = "Returns the color index of the particles emitted by this potion",
},
SetEntityEffectType =
{
Params =
{
{
Name = "EntityEffectType",
Type = "cEntityEffect#eType",
},
},
Notes = "Sets the effect type of this potion",
},
SetPotionColor =
{
Params =
{
{
Name = "PotionColor",
Type = "number",
},
},
Notes = "Sets the color index of the particles for this potion",
},
},
Inherits = "cProjectileEntity",
},
cThrownEggEntity =
{
Desc = [[
Represents a thrown egg.
]],
Functions =
{
},
Inherits = "cProjectileEntity",
},
cThrownEnderPearlEntity =
{
Desc = "Represents a thrown ender pearl.",
Functions =
{
},
Inherits = "cProjectileEntity",
},
cThrownSnowballEntity =
{
Desc = "Represents a thrown snowball.",
Functions =
{
},
Inherits = "cProjectileEntity",
},
cWitherSkullEntity =
{
Desc = "Represents a wither skull being shot.",
Functions =
{
},
Inherits = "cProjectileEntity",
},
}

View File

@ -0,0 +1,741 @@
-- Describes the cRankManager class API
return
{
cRankManager =
{
Desc = [[
Manages the players' permissions. The players are assigned a single rank, which contains groups of
permissions and restrictions. The functions in this class query or modify these.</p>
<p>
All the functions are static, call them using the <code>cRankManager:Function()</code> convention.</p>
<p>
The players are identified by their UUID, to support player renaming.</p>
<p>
The rank also contains specific "mesage visuals" - bits that are used for formatting messages from the
players. There's a message prefix, which is put in front of every message the player sends, and the
message suffix that is appended to each message. There's also a PlayerNameColorCode, which holds the
color that is used for the player's name in the messages.</p>
<p>
Each rank can contain any number of permission groups. These groups allow for an easier setup of the
permissions - you can share groups among ranks, so the usual approach is to group similar permissions
together and add that group to any rank that should use those permissions.</p>
<p>
Permissions are added to individual groups. Each group can support unlimited permissions. Note that
adding a permission to a group will make the permission available to all the ranks that contain that
permission group.</p>
<p>
One rank is reserved as the Default rank. All players that don't have an explicit rank assigned to them
will behave as if assigned to this rank. The default rank can be changed to any other rank at any time.
Note that the default rank cannot be removed from the RankManager - RemoveRank() will change the default
rank to the replacement rank, if specified, and fail if no replacement rank is specified. Renaming the
default rank using RenameRank() will change the default rank to the new name.
]],
Functions =
{
AddGroup =
{
IsStatic = true,
Params =
{
{
Name = "GroupName",
Type = "string",
},
},
Notes = "Adds the group of the specified name. Logs a warning and does nothing if the group already exists.",
},
AddGroupToRank =
{
IsStatic = true,
Params =
{
{
Name = "GroupName",
Type = "string",
},
{
Name = "RankName",
Type = "string",
},
},
Returns =
{
{
Type = "boolean",
},
},
Notes = "Adds the specified group to the specified rank. Returns true on success, false on failure - if the group name or the rank name is not found.",
},
AddPermissionToGroup =
{
IsStatic = true,
Params =
{
{
Name = "Permission",
Type = "string",
},
{
Name = "GroupName",
Type = "string",
},
},
Returns =
{
{
Type = "boolean",
},
},
Notes = "Adds the specified permission to the specified group. Returns true on success, false on failure - if the group name is not found.",
},
AddRank =
{
IsStatic = true,
Params =
{
{
Name = "RankName",
Type = "string",
},
{
Name = "MsgPrefix",
Type = "string",
},
{
Name = "MsgSuffix",
Type = "string",
},
{
Name = "MsgNameColorCode",
Type = "string",
},
},
Notes = "Adds a new rank of the specified name and with the specified message visuals. Logs an info message and does nothing if the rank already exists.",
},
AddRestrictionToGroup =
{
IsStatic = true,
Params =
{
{
Name = "Permission",
Type = "string",
},
{
Name = "GroupName",
Type = "string",
},
},
Returns =
{
{ Type = "boolean" },
},
Notes = "Adds a new restriction to the specified group. Returns true if successful, false if it fails (no such group). No action if the group already has the restriction.",
},
ClearPlayerRanks =
{
IsStatic = true,
Notes = "Removes all player ranks from the database. Note that this doesn't change the cPlayer instances for the already connected players, you need to update all the instances manually.",
},
GetAllGroups =
{
IsStatic = true,
Returns =
{
{
Type = "table",
},
},
Notes = "Returns an array-table containing the names of all the groups that are known to the manager.",
},
GetAllPermissions =
{
IsStatic = true,
Returns =
{
{
Type = "table",
},
},
Notes = "Returns an array-table containing all the permissions that are known to the manager.",
},
GetAllPermissionsRestrictions =
{
IsStatic = true,
Returns =
{
{
Type = "table",
},
},
Notes = "Returns an array-table containing all the permissions and restrictions (intermixed together) that are known to the manager.",
},
GetAllPlayerUUIDs =
{
IsStatic = true,
Returns =
{
{
Type = "table",
},
},
Notes = "Returns the short uuids of all players stored in the rank DB, sorted by the players' names (case insensitive).",
},
GetAllRanks =
{
IsStatic = true,
Returns =
{
{
Type = "table",
},
},
Notes = "Returns an array-table containing the names of all the ranks that are known to the manager.",
},
GetAllRestrictions =
{
IsStatic = true,
Returns =
{
{
Type = "table",
},
},
Notes = "Returns an array-table containing all the restrictions that are known to the manager.",
},
GetDefaultRank =
{
IsStatic = true,
Returns =
{
{
Type = "string",
},
},
Notes = "Returns the name of the default rank. ",
},
GetGroupPermissions =
{
IsStatic = true,
Params =
{
{
Name = "GroupName",
Type = "string",
},
},
Returns =
{
{
Type = "table",
},
},
Notes = "Returns an array-table containing the permissions that the specified group contains.",
},
GetGroupRestrictions =
{
IsStatic = true,
Params =
{
{
Name = "GroupName",
Type = "string",
},
},
Returns =
{
{
Type = "table",
},
},
Notes = "Returns an array-table containing the restrictions that the specified group contains.",
},
GetPlayerGroups =
{
IsStatic = true,
Params =
{
{
Name = "PlayerUUID",
Type = "cUUID",
},
},
Returns =
{
{
Type = "table",
},
},
Notes = "Returns an array-table of the names of the groups that are assigned to the specified player through their rank. Returns an empty table if the player is not known or has no rank or groups assigned to them.",
},
GetPlayerMsgVisuals =
{
IsStatic = true,
Params =
{
{
Name = "PlayerUUID",
Type = "cUUID",
},
},
Returns =
{
{
Name = "MsgPrefix",
Type = "string",
},
{
Name = "MsgSuffix",
Type = "string",
},
{
Name = "MsgNameColorCode",
Type = "string",
},
},
Notes = "Returns the message visuals assigned to the player. If the player is not explicitly assigned a rank, the default rank's visuals are returned. If there is an error, no value is returned at all.",
},
GetPlayerName =
{
IsStatic = true,
Params =
{
{
Name = "PlayerUUID",
Type = "cUUID",
},
},
Returns =
{
{
Name = "PlayerName",
Type = "string",
},
},
Notes = "Returns the last name that the specified player has, for a player in the ranks database. An empty string is returned if the player isn't in the database.",
},
GetPlayerPermissions =
{
IsStatic = true,
Params =
{
{
Name = "PlayerUUID",
Type = "cUUID",
},
},
Returns =
{
{
Type = "table",
},
},
Notes = "Returns an array-table containing all permissions that the specified player is assigned through their rank. Returns the default rank's permissions if the player has no explicit rank assigned to them. Returns an empty array on error.",
},
GetPlayerRankName =
{
IsStatic = true,
Params =
{
{
Name = "PlayerUUID",
Type = "cUUID",
},
},
Returns =
{
{
Name = "RankName",
Type = "string",
},
},
Notes = "Returns the name of the rank that is assigned to the specified player. An empty string (NOT the default rank) is returned if the player has no rank assigned to them.",
},
GetRankGroups =
{
IsStatic = true,
Params =
{
{
Name = "RankName",
Type = "string",
},
},
Returns =
{
{
Type = "table",
},
},
Notes = "Returns an array-table of the names of all the groups that are assigned to the specified rank. Returns an empty table if there is no such rank.",
},
GetRankPermissions =
{
IsStatic = true,
Params =
{
{
Name = "RankName",
Type = "string",
},
},
Returns =
{
{
Type = "table",
},
},
Notes = "Returns an array-table of all the permissions that are assigned to the specified rank through its groups. Returns an empty table if there is no such rank.",
},
GetRankRestrictions =
{
IsStatic = true,
Params =
{
{
Name = "RankName",
Type = "string",
},
},
Returns =
{
{
Type = "table",
},
},
Notes = "Returns an array-table of all the restrictions that are assigned to the specified rank through its groups. Returns an empty table if there is no such rank.",
},
GetRankVisuals =
{
IsStatic = true,
Params =
{
{
Name = "RankName",
Type = "string",
},
},
Returns =
{
{
Name = "MsgPrefix",
Type = "string",
},
{
Name = "MsgSuffix",
Type = "string",
},
{
Name = "MsgNameColorCode",
Type = "string",
},
},
Notes = "Returns the message visuals for the specified rank. Returns no value if the specified rank does not exist.",
},
GroupExists =
{
IsStatic = true,
Params =
{
{
Name = "GroupName",
Type = "string",
},
},
Returns =
{
{
Type = "boolean",
},
},
Notes = "Returns true iff the specified group exists.",
},
IsGroupInRank =
{
IsStatic = true,
Params =
{
{
Name = "GroupName",
Type = "string",
},
{
Name = "RankName",
Type = "string",
},
},
Returns =
{
{
Type = "boolean",
},
},
Notes = "Returns true iff the specified group is assigned to the specified rank.",
},
IsPermissionInGroup =
{
IsStatic = true,
Params =
{
{
Name = "Permission",
Type = "string",
},
{
Name = "GroupName",
Type = "string",
},
},
Returns =
{
{
Type = "boolean",
},
},
Notes = "Returns true iff the specified permission is assigned to the specified group.",
},
IsPlayerRankSet =
{
IsStatic = true,
Params =
{
{
Name = "PlayerUUID",
Type = "cUUID",
},
},
Returns =
{
{
Type = "boolean",
},
},
Notes = "Returns true iff the specified player has a rank assigned to them.",
},
IsRestrictionInGroup =
{
IsStatic = true,
Params =
{
{
Name = "Restriction",
Type = "string",
},
{
Name = "GroupName",
Type = "string",
},
},
Returns =
{
{
Type = "boolean",
},
},
Notes = "Returns true iff the specified restriction is assigned to the specified group.",
},
RankExists =
{
IsStatic = true,
Params =
{
{
Name = "RankName",
Type = "string",
},
},
Returns =
{
{
Type = "boolean",
},
},
Notes = "Returns true iff the specified rank exists.",
},
RemoveGroup =
{
IsStatic = true,
Params =
{
{
Name = "GroupName",
Type = "string",
},
},
Notes = "Removes the specified group completely. The group will be removed from all the ranks using it and then erased from the manager. Logs an info message and does nothing if the group doesn't exist.",
},
RemoveGroupFromRank =
{
IsStatic = true,
Params =
{
{
Name = "GroupName",
Type = "string",
},
{
Name = "RankName",
Type = "string",
},
},
Notes = "Removes the specified group from the specified rank. The group will still exist, even if it isn't assigned to any rank. Logs an info message and does nothing if the group or rank doesn't exist.",
},
RemovePermissionFromGroup =
{
IsStatic = true,
Params =
{
{
Name = "Permission",
Type = "string",
},
{
Name = "GroupName",
Type = "string",
},
},
Notes = "Removes the specified permission from the specified group. Logs an info message and does nothing if the group doesn't exist.",
},
RemovePlayerRank =
{
IsStatic = true,
Params =
{
{
Name = "PlayerUUID",
Type = "cUUID",
},
},
Notes = "Removes the player's rank; the player's left without a rank. Note that this doesn't change the {{cPlayer}} instances for the already connected players, you need to update all the instances manually. No action if the player has no rank assigned to them already.",
},
RemoveRank =
{
IsStatic = true,
Params =
{
{
Name = "RankName",
Type = "string",
},
{
Name = "ReplacementRankName",
Type = "string",
IsOptional = true,
},
},
Notes = "Removes the specified rank. If ReplacementRankName is given, the players that have RankName will get their rank set to ReplacementRankName. If it isn't given, or is an invalid rank, the players will be removed from the manager, their ranks will be unset completely. Logs an info message and does nothing if the rank is not found.",
},
RemoveRestrictionFromGroup =
{
IsStatic = true,
Params =
{
{
Name = "Restriction",
Type = "string",
},
{
Name = "GroupName",
Type = "string",
},
},
Notes = "Removes the specified restriction from the specified group.",
},
RenameGroup =
{
IsStatic = true,
Params =
{
{
Name = "OldName",
Type = "string",
},
{
Name = "NewName",
Type = "string",
},
},
Notes = "Renames the specified group. Logs an info message and does nothing if the group is not found or the new name is already used.",
},
RenameRank =
{
IsStatic = true,
Params =
{
{
Name = "OldName",
Type = "string",
},
{
Name = "NewName",
Type = "string",
},
},
Notes = "Renames the specified rank. Logs an info message and does nothing if the rank is not found or the new name is already used.",
},
SetDefaultRank =
{
IsStatic = true,
Params =
{
{
Name = "RankName",
Type = "string",
},
},
Returns =
{
{
Type = "boolean",
},
},
Notes = "Sets the specified rank as the default rank. Returns true on success, false on failure (rank doesn't exist).",
},
SetPlayerRank =
{
IsStatic = true,
Params =
{
{
Name = "PlayerUUID",
Type = "cUUID",
},
{
Name = "PlayerName",
Type = "string",
},
{
Name = "RankName",
Type = "string",
},
},
Notes = "Updates the rank for the specified player. The player name is provided for reference, the UUID is used for identification. Logs a warning and does nothing if the rank is not found.",
},
SetRankVisuals =
{
IsStatic = true,
Params =
{
{
Name = "RankName",
Type = "string",
},
{
Name = "MsgPrefix",
Type = "string",
},
{
Name = "MsgSuffix",
Type = "string",
},
{
Name = "MsgNameColorCode",
Type = "string",
},
},
Notes = "Updates the rank's message visuals. Logs an info message and does nothing if rank not found.",
},
},
},
}

View File

@ -0,0 +1,228 @@
return
{
cWebAdmin =
{
Desc = "",
Functions =
{
AddWebTab =
{
IsStatic = true,
Params =
{
{
Name = "Title",
Type = "string",
},
{
Name = "UrlPath",
Type = "string",
},
{
Name = "HandlerFn",
Type = "function",
},
},
Notes = "Adds a new web tab to webadmin. The tab uses \"Title\" as its display string and is identified in the URL using the UrlPath (https://server.domain.com/webadmin/{PluginName}/{UrlPath}). The HandlerFn is the callback function that is called when the admin accesses the page, it has the following signature:<br/><pre class=\"prettyprint lang-lua\">function ({{HTTPRequest|a_Request}}, a_UrlPath)<br/> return Content, ContentType<br/>end</pre> URLPath must not contain a '/', the recommendation is to use only 7-bit-clean ASCII character set.",
},
GetAllWebTabs =
{
IsStatic = true,
Returns =
{
{
Type = "table",
},
},
Notes = "Returns an array-table with each item describing a web tab, for all web tabs registered in the WebAdmin, for all plugins. The returned table has the following format:<br/><pre class=\"prettyprint lang-lua\">{<br/> {<br/> PluginName = \"Plugin's API name\",<br/> UrlPath = \"UrlPath given to AddWebTab\",<br/> Title = \"Title given to AddWebTab\",<br/> },<br/> ...<br/>}",
},
GetBaseURL =
{
IsStatic = true,
Params =
{
{
Name = "URL",
Type = "string",
},
},
Returns =
{
{
Type = "string",
},
},
Notes = "Returns the string that is the path of the base webadmin (\"../../../webadmin\") relative to the given URL.",
},
GetContentTypeFromFileExt =
{
IsStatic = true,
Params =
{
{
Name = "FileExt",
Type = "string",
},
},
Returns =
{
{
Type = "string",
},
},
Notes = "Returns the content-type that should be used for files with the specified extension (without the dot), such as \"text/plain\" for the \"txt\" extension. If the extension is not known, returns an empty string.",
},
GetHTMLEscapedString =
{
IsStatic = true,
Params =
{
{
Name = "Input",
Type = "string",
},
},
Returns =
{
{
Type = "string",
},
},
Notes = "Gets the HTML-escaped representation of a requested string. This is useful for user input and game data that is not guaranteed to be escaped already.",
},
GetPage =
{
IsStatic = true,
Params =
{
{
Name = "Request",
Type = "HTTPRequest",
},
},
Returns =
{
{
Type = "table",
},
},
Notes = "Returns the (inner HTML) page contents for the specified request. Calls the appropriate WebTab handler registered via AddWebTab() and returns the information from that plugin wrapped in a table with the following structure:<br/><pre class=\"prettyprint lang-lua\">{<br/> Content = \"\", -- Content returned by the plugin<br/> ContentType = \"\", -- Content type returned by the plugin, or \"text/html\" if none returned<br/> UrlPath = \"\", -- UrlPath decoded from the request<br/> TabTitle = \"\", -- Title of the tab that handled the request, as given to AddWebTab()<br/> PluginName = \"\", -- API name of the plugin that handled the request<br/> PluginFolder = \"\", -- Folder name (= display name) of the plugin that handled the request<br/>}</pre>This function is mainly used in the webadmin template file.",
},
GetPorts =
{
Returns =
{
{
Type = "string",
},
},
Notes = "Returns a comma-separated list of ports on which the webadmin is configured to listen. Note that this list does include ports that may currently be unavailable (another server was already listening on them prior to launching Cuberite).",
},
GetURLEncodedString =
{
IsStatic = true,
ObsoletedBy = "cUrlParser:UrlEncode",
Params =
{
{
Name = "Input",
Type = "string",
},
},
Returns =
{
{
Type = "string",
},
},
Notes = "<b>OBSOLETE</b> - use {{cUrlParser}}:UrlEncode() instead.<br/>Returns the string given to it escaped by URL encoding, which makes the string suitable for transmission in an URL. Invalid characters are turned into \"%xy\" values.",
},
Reload =
{
Notes = "Reloads the webadmin's config - the allowed logins, the template script and the login page. Note that reloading will not change the \"enabled\" state of the server, and it will not update listening ports. Existing WebTabs will be kept registered even after the reload.",
},
},
},
HTTPFormData =
{
Desc = "This class stores data for one form element for a {{HTTPRequest|HTTP request}}.",
Variables =
{
Name =
{
Type = "string",
Notes = "Name of the form element",
},
Type =
{
Type = "string",
Notes = "Type of the data (usually empty)",
},
Value =
{
Type = "string",
Notes = "Value of the form element. Contains the raw data as sent by the browser.",
},
},
},
HTTPRequest =
{
Desc = [[
This class encapsulates all the data that is sent to the WebAdmin through one HTTP request. Plugins
receive this class as a parameter to the function handling the web requests, as registered in the
{{cPluginLua}}:AddWebPage().
]],
Constants =
{
Params =
{
Notes = "Map-table of parameters given to the request in the URL (?param=value); if a form uses GET method, this is the same as FormData. For each parameter given as \"param=value\", there is an entry in the table with \"param\" as its key and \"value\" as its value.",
},
FormData =
{
Notes = "Array-table of {{HTTPFormData}}, contains the values of individual form elements submitted by the client",
},
PostParams =
{
Notes = "Map-table of data posted through a FORM - either a GET or POST method. Logically the same as FormData, but in a map-table format (for each parameter given as \"param=value\", there is an entry in the table with \"param\" as its key and \"value\" as its value).",
},
},
Variables =
{
Method =
{
Type = "string",
Notes = "The HTTP method used to make the request. Usually GET or POST.",
},
Path =
{
Type = "string",
Notes = "The Path part of the URL (excluding the parameters)",
},
URL =
{
Type = "string",
Notes = "The entire URL used for the request.",
},
Username =
{
Type = "string",
Notes = "Name of the logged-in user.",
},
},
},
HTTPTemplateRequest =
{
Desc = [[
This class is used only in the WebAdmin template script as the parameter to the function that provides the template.
]],
Variables =
{
Request =
{
Type = "HTTPRequest",
Notes = "The request for which the template is being built.",
},
},
},
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,56 @@
return
{
HOOK_BLOCK_SPREAD =
{
CalledWhen = "Called when a block spreads based on world conditions",
DefaultFnName = "OnBlockSpread", -- also used as pagename
Desc = [[
This hook is called when a block spreads.</p>
<p>
The spread carries with it the type of its source - whether it's a block spreads.
It also carries the identification of the actual source. The exact type of the identification
depends on the source kind:
<table>
<tr><th>Source</th><th>Notes</th></tr>
<tr><td>ssFireSpread</td><td>Fire spreading</td></tr>
<tr><td>ssGrassSpread</td><td>Grass spreading</td></tr>
<tr><td>ssMushroomSpread</td><td>Mushroom spreading</td></tr>
<tr><td>ssMycelSpread</td><td>Mycel spreading</td></tr>
<tr><td>ssVineSpread</td><td>Vine spreading</td></tr>
</table></p>
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the block resides" },
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
{ Name = "Source", Type = "eSpreadSource", Notes = "Source of the spread. See the table above." },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called, and finally
Cuberite will process the spread. If the function
returns true, no other callback is called for this event and the spread will not occur.
]],
Examples =
{
{
Title = "Stop fire spreading",
Desc = "Stops fire from spreading, but does not remove any player-placed fire.",
Code = [[
function OnBlockSpread(World, BlockX, Blocky, BlockZ, source)
if (source == ssFireSpread) then
-- Return true to block the fire spreading.
return true
end
-- We don't care about any other events, let them continue.
return false
end
-- Add the callback.
cPluginManager:AddHook(cPluginManager.HOOK_BLOCK_SPREAD, OnBlockSpread);
]],
},
},
}, -- HOOK_BLOCK_SPREAD
}

View File

@ -0,0 +1,62 @@
return
{
HOOK_BLOCK_TO_PICKUPS =
{
CalledWhen = "A block is about to be dug ({{cPlayer|player}}, {{cEntity|entity}} or natural reason), plugins may override what pickups that will produce.",
DefaultFnName = "OnBlockToPickups", -- also used as pagename
Desc = [[
This callback gets called whenever a block is about to be dug. This includes {{cPlayer|players}}
digging blocks, entities causing blocks to disappear ({{cTNTEntity|TNT}}, Endermen) and natural
causes (water washing away a block). Plugins may override the amount and kinds of pickups this
action produces.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the block resides" },
{ Name = "Digger", Type = "{{cEntity}} descendant", Notes = "The entity causing the digging. May be a {{cPlayer}}, {{cTNTEntity}} or even nil (natural causes)" },
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
{ Name = "BlockType", Type = "BLOCKTYPE", Notes = "Block type of the block" },
{ Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "Block meta of the block" },
{ Name = "Pickups", Type = "{{cItems}}", Notes = "Items that will be spawned as pickups" },
},
Returns = [[
If the function returns false or no value, the next callback in the hook chain will be called. If
the function returns true, no other callbacks in the chain will be called.</p>
<p>
Either way, the server will then spawn pickups specified in the Pickups parameter, so to disable
pickups, you need to Clear the object first, then return true.
]],
CodeExamples =
{
{
Title = "Modify pickups",
Desc = "This example callback function makes tall grass drop diamonds when digged by natural causes (washed away by water).",
Code = [[
function OnBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_Pickups)
if (a_Digger ~= nil) then
-- Not a natural cause
return false;
end
if (a_BlockType ~= E_BLOCK_TALL_GRASS) then
-- Not a tall grass being washed away
return false;
end
-- Remove all pickups suggested by Cuberite:
a_Pickups:Clear();
-- Drop a diamond:
a_Pickups:Add(cItem(E_ITEM_DIAMOND));
return true;
end;
]],
},
} , -- CodeExamples
}, -- HOOK_BLOCK_TO_PICKUPS
}

View File

@ -0,0 +1,26 @@
return
{
HOOK_BREWING_COMPLETED =
{
CalledWhen = "A brewing process is completed.",
DefaultFnName = "OnBrewingCompleted", -- also used as pagename
Desc = [[
This hook is called whenever a {{cBrewingstandEntity|brewing stand}} has completed the brewing process.
See also the {{OnBrewingCompleting|HOOK_BREWING_COMPLETING}} hook for a similar hook, is called when a
brewing process is completing.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "World where the brewing stand resides." },
{ Name = "Brewingstand", Type = "{{cBrewingstandEntity}}", Notes = "The brewing stand that completed the brewing process." },
},
Returns = [[
If the function returns false or no value, Cuberite calls other plugins with this event. If the
function returns true, no other plugin is called for this event.</p>
]],
}, -- HOOK_BREWING_COMPLETED
}

View File

@ -0,0 +1,28 @@
return
{
HOOK_BREWING_COMPLETING =
{
CalledWhen = "A brewing process is completing.",
DefaultFnName = "OnBrewingCompleting", -- also used as pagename
Desc = [[
This hook is called whenever a {{cBrewingstandEntity|brewing stand}} is completing the brewing process. Plugins may
refuse the completing of the brewing process.<p>
See also the {{OnBrewingCompleted|HOOK_BREWING_COMPLETED}} hook for a similar hook, is called after the
brewing process has been completed.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "World where the brewing stand resides." },
{ Name = "Brewingstand", Type = "{{cBrewingstandEntity}}", Notes = "The brewing stand that completes the brewing process." },
},
Returns = [[
If the function returns false or no value, Cuberite calls other plugins with this event. If the function returns true,
no other plugin's callback is called and the brewing process is canceled.
<p>
]],
}, -- HOOK_BREWING_COMPLETING
}

View File

@ -0,0 +1,30 @@
return
{
HOOK_CHAT =
{
CalledWhen = "Player sends a chat message",
DefaultFnName = "OnChat", -- also used as pagename
Desc = [[
A plugin may implement an OnChat() function and register it as a Hook to process chat messages from
the players. The function is then called for every in-game message sent from any player. Note that
registered in-game commands are not sent through this hook. Use the
{{OnExecuteCommand|HOOK_EXECUTE_COMMAND}} to intercept registered in-game commands.
]],
Params = {
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who sent the message" },
{ Name = "Message", Type = "string", Notes = "The message" },
},
Returns = [[
The plugin may return 2 values. The first is a boolean specifying whether the hook handling is to be
stopped or not. If it is false, the message is broadcast to all players in the world. If it is true,
no message is broadcast and no further action is taken.</p>
<p>
The second value is specifies the message to broadcast. This way, plugins may modify the message. If
the second value is not provided, the original message is used.
]],
}, -- HOOK_CHAT
}

View File

@ -0,0 +1,27 @@
return
{
HOOK_CHUNK_AVAILABLE =
{
CalledWhen = "A chunk has just been added to world, either generated or loaded. ",
DefaultFnName = "OnChunkAvailable", -- also used as pagename
Desc = [[
This hook is called after a chunk is either generated or loaded from the disk. The chunk is
already available for manipulation using the {{cWorld}} API. This is a notification-only callback,
there is no behavior that plugins could override.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk belongs" },
{ Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" },
{ Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event.
]],
}, -- HOOK_CHUNK_AVAILABLE
}

View File

@ -0,0 +1,67 @@
return
{
HOOK_CHUNK_GENERATED =
{
CalledWhen = "After a chunk was generated. Notification only.",
DefaultFnName = "OnChunkGenerated", -- also used as pagename
Desc = [[
This hook is called when world generator finished its work on a chunk. The chunk data has already
been generated and is about to be stored in the {{cWorld|world}}. A plugin may provide some
last-minute finishing touches to the generated data. Note that the chunk is not yet stored in the
world, so regular {{cWorld}} block API will not work! Instead, use the {{cChunkDesc}} object
received as the parameter.</p>
<p>
See also the {{OnChunkGenerating|HOOK_CHUNK_GENERATING}} hook.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk will be added" },
{ Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" },
{ Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" },
{ Name = "ChunkDesc", Type = "{{cChunkDesc}}", Notes = "Generated chunk data. Plugins may still modify the chunk data contained." },
},
Returns = [[
If the plugin returns false or no value, Cuberite will call other plugins' callbacks for this event.
If a plugin returns true, no other callback is called for this event.</p>
<p>
In either case, Cuberite will then store the data from ChunkDesc as the chunk's contents in the world.
]],
CodeExamples =
{
{
Title = "Generate emerald ore",
Desc = "This example callback function generates one block of emerald ore in each chunk, under the condition that the randomly chosen location is in an ExtremeHills biome.",
Code = [[
function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc)
-- Generate a psaudorandom value that is always the same for the same X/Z pair, but is otherwise random enough:
-- This is actually similar to how Cuberite does its noise functions
local PseudoRandom = (a_ChunkX * 57 + a_ChunkZ) * 57 + 19785486
PseudoRandom = PseudoRandom * 8192 + PseudoRandom;
PseudoRandom = ((PseudoRandom * (PseudoRandom * PseudoRandom * 15731 + 789221) + 1376312589) % 0x7fffffff;
PseudoRandom = PseudoRandom / 7;
-- Based on the PseudoRandom value, choose a location for the ore:
local OreX = PseudoRandom % 16;
local OreY = 2 + ((PseudoRandom / 16) % 20);
local OreZ = (PseudoRandom / 320) % 16;
-- Check if the location is in ExtremeHills:
if (a_ChunkDesc:GetBiome(OreX, OreZ) ~= biExtremeHills) then
return false;
end
-- Only replace allowed blocks with the ore:
local CurrBlock = a_ChunDesc:GetBlockType(OreX, OreY, OreZ);
if (
(CurrBlock == E_BLOCK_STONE) or
(CurrBlock == E_BLOCK_DIRT) or
(CurrBlock == E_BLOCK_GRAVEL)
) then
a_ChunkDesc:SetBlockTypeMeta(OreX, OreY, OreZ, E_BLOCK_EMERALD_ORE, 0);
end
end;
]],
},
} , -- CodeExamples
}, -- HOOK_CHUNK_GENERATED
}

View File

@ -0,0 +1,35 @@
return
{
HOOK_CHUNK_GENERATING =
{
CalledWhen = "A chunk is about to be generated. Plugin can override the built-in generator.",
DefaultFnName = "OnChunkGenerating", -- also used as pagename
Desc = [[
This hook is called before the world generator starts generating a chunk. The plugin may provide
some or all parts of the generation, by-passing the built-in generator. The function is given access
to the {{cChunkDesc|ChunkDesc}} object representing the contents of the chunk. It may override parts
of the built-in generator by using the object's <i>SetUseDefaultXXX(false)</i> functions. After all
the callbacks for a chunk have been processed, the server will generate the chunk based on the
{{cChunkDesc|ChunkDesc}} description - those parts that are set for generating (by default
everything) are generated, the rest are read from the ChunkDesc object.</p>
<p>
See also the {{OnChunkGenerated|HOOK_CHUNK_GENERATED}} hook.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk will be added" },
{ Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" },
{ Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" },
{ Name = "ChunkDesc", Type = "{{cChunkDesc}}", Notes = "Generated chunk data." },
},
Returns = [[
If this function returns true, the server will not call any other plugin with the same chunk. If
this function returns false, the server will call the rest of the plugins with the same chunk,
possibly overwriting the ChunkDesc's contents.
]],
}, -- HOOK_CHUNK_GENERATING
}

View File

@ -0,0 +1,28 @@
return
{
HOOK_CHUNK_UNLOADED =
{
CalledWhen = "A chunk has been unloaded from the memory.",
DefaultFnName = "OnChunkUnloaded", -- also used as pagename
Desc = [[
This hook is called when a chunk is unloaded from the memory. Though technically still in memory,
the plugin should behave as if the chunk was already not present. In particular, {{cWorld}} block
API should not be used in the area of the specified chunk.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world from which the chunk is unloading" },
{ Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" },
{ Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event. There is no behavior that plugins could
override.
]],
}, -- HOOK_CHUNK_UNLOADED
}

View File

@ -0,0 +1,29 @@
return
{
HOOK_CHUNK_UNLOADING =
{
CalledWhen = " A chunk is about to be unloaded from the memory. Plugins may refuse the unload.",
DefaultFnName = "OnChunkUnloading", -- also used as pagename
Desc = [[
Cuberite calls this function when a chunk is about to be unloaded from the memory. A plugin may
force Cuberite to keep the chunk in memory by returning true.</p>
<p>
CAUTION: Preventing the server from unloading chunks can cause the server to use too much RAM, which will adversely affect both performance and stability (i.e. your computer will get slow and crash). Return true sparingly.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world from which the chunk is unloading" },
{ Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" },
{ Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called and finally Cuberite
unloads the chunk. If the function returns true, no other callback is called for this event and the
chunk is left in the memory.
]],
}, -- HOOK_CHUNK_UNLOADING
}

View File

@ -0,0 +1,32 @@
return
{
HOOK_COLLECTING_PICKUP =
{
CalledWhen = "Player is about to collect a pickup. Plugin can refuse / override behavior. ",
DefaultFnName = "OnCollectingPickup", -- also used as pagename
Desc = [[
This hook is called when a player is about to collect a pickup. Plugins may refuse the action.</p>
<p>
Pickup collection happens within the world tick, so if the collecting is refused, it will be tried
again in the next world tick, as long as the player is within reach of the pickup.</p>
<p>
FIXME: There is no OnCollectedPickup() callback.</p>
<p>
FIXME: This callback is called even if the pickup doesn't fit into the player's inventory.</p>
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who's collecting the pickup" },
{ Name = "Pickup", Type = "{{cPickup}}", Notes = "The pickup being collected" },
},
Returns = [[
If the function returns false or no value, Cuberite calls other plugins' callbacks and finally the
pickup is collected. If the function returns true, no other plugins are called for this event and
the pickup is not collected.
]],
}, -- HOOK_COLLECTING_PICKUP
}

View File

@ -0,0 +1,32 @@
return
{
HOOK_CRAFTING_NO_RECIPE =
{
CalledWhen = " No built-in crafting recipe is found. Plugin may provide a recipe.",
DefaultFnName = "OnCraftingNoRecipe", -- also used as pagename
Desc = [[
This callback is called when a player places items in their {{cCraftingGrid|crafting grid}} and
Cuberite cannot find a built-in {{cCraftingRecipe|recipe}} for the combination. Plugins may provide
a recipe for the ingredients given.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose crafting is reported in this hook" },
{ Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "Contents of the player's crafting grid" },
{ Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that will be used (can be filled by plugins)" },
},
Returns = [[
If the function returns false or no value, no recipe will be used. If the function returns true, no
other plugin will have their callback called for this event and Cuberite will use the crafting
recipe in Recipe.</p>
<p>
FIXME: To allow plugins give suggestions and overwrite other plugins' suggestions, we should change
the behavior with returning false, so that the recipe will still be used, but fill the recipe with
empty values by default.
]],
}, -- HOOK_CRAFTING_NO_RECIPE
}

View File

@ -0,0 +1,38 @@
return
{
HOOK_DISCONNECT =
{
CalledWhen = [[
A client has disconnected, either by explicitly sending the disconnect packet (in older protocols) or
their connection was terminated
]],
DefaultFnName = "OnDisconnect", -- also used as pagename
Desc = [[
This hook is called when a client has disconnected from the server, for whatever reason. It is also
called when the client sends the Disconnect packet (only in pre-1.7 protocols). This hook is not called
for server ping connections.</p>
<p>
Note that the hook is called even for connections to players who failed to auth. In such a case there's
no {{cPlayer}} object associated with the client.</p>
<p>
See also the {{OnHandshake|HOOK_HANDSHAKE}} hook which is called when the client connects (and presents
a handshake message, so that they are not just status-pinging). If you need to store a per-player
object, use the {{OnPlayerJoined|HOOK_PLAYER_JOINED}} and {{OnPlayerDestroyed|HOOK_PLAYER_DESTROYED}}
hooks instead, those are guaranteed to have the {{cPlayer}} object associated.
]],
Params =
{
{ Name = "Client", Type = "{{cClientHandle}}", Notes = "The client who has disconnected" },
{ Name = "Reason", Type = "string", Notes = "The reason that the client has sent in the disconnect packet" },
},
Returns = [[
If the function returns false or no value, Cuberite calls other plugins' callbacks for this event.
If the function returns true, no other plugins are called for this event. In either case,
the client is disconnected.
]],
}, -- HOOK_DISCONNECT
}

View File

@ -0,0 +1,26 @@
return
{
HOOK_DROPSPENSE =
{
CalledWhen = "A dispenser or dropper is about to dispense/drop an item.",
DefaultFnName = "OnDropSpense", -- also used as pagename
Desc = [[
This callback is called whenever a {{cDropSpenserEntity|dropspenser}} dropspenses an {{cItem|item}}. A plugin may decide to disallow
the move by returning true.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "World where the dropspenser resides" },
{ Name = "DropSpenser", Type = "{{cDropSpenserEntity}}", Notes = "The dropspenser that is pulling the item" },
{ Name = "SlotNum", Type = "number", Notes = "The slot of the dropspensed item in the dropspenser's {{cItemGrid|internal storage}}" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event and the dropspenser will not dropspense the item.
]],
}, -- HOOK_DROPSPENSE
}

View File

@ -0,0 +1,33 @@
return
{
HOOK_ENTITY_ADD_EFFECT =
{
CalledWhen = "An entity effect is about to get added to an entity.",
DefaultFnName = "OnEntityAddEffect", -- also used as pagename
Desc = [[
This hook is called whenever an entity effect is about to be added to an entity. The plugin may
disallow the addition by returning true.</p>
<p>Note that this hook only fires for adding the effect, but not for the actual effect application. See
also the {{OnEntityRemoveEffect|HOOK_ENTITY_REMOVE_EFFECT}} for notification about effects expiring /
removing, and {{OnEntityApplyEffect|HOOK_ENTITY_APPLY_EFFECT}} for the actual effect application to the
entity.
]],
Params =
{
{ Name = "Entity", Type = "{{cEntity}}", Notes = "The entity to which the effect is about to be added" },
{ Name = "EffectType", Type = "number", Notes = "The type of the effect to be added. One of the effXXX constants." },
{ Name = "EffectDuration", Type = "number", Notes = "The duration of the effect to be added, in ticks." },
{ Name = "EffectIntensity", Type = "number", Notes = "The intensity (level) of the effect to be added. " },
{ Name = "DistanceModifier", Type = "number", Notes = "The modifier for the effect intensity, based on distance. Used mainly for splash potions." },
},
Returns = [[
If the plugin returns true, the effect will not be added and none of the remaining hook handlers will
be called. If the plugin returns false, Cuberite calls all the remaining hook handlers and finally
the effect is added to the entity.
]],
}, -- HOOK_EXECUTE_COMMAND
}

View File

@ -0,0 +1,28 @@
return
{
HOOK_ENTITY_CHANGED_WORLD =
{
CalledWhen = "After a entity has changed the world.",
DefaultFnName = "OnEntityChangedWorld", -- also used as pagename
Desc = [[
This hook is called after the server has moved the {{cEntity|entity}} to the given world. This is an information-only
callback, the entity is already in the new world.<p>
See also the {{OnEntityChangingWorld|HOOK_ENTITY_CHANGING_WORLD}} hook for a similar hook called before the
entity is moved to the new world.
]],
Params =
{
{ Name = "Entity", Type = "{{cEntity}}", Notes = "The entity that has changed the world" },
{ Name = "World", Type = "{{cWorld}}", Notes = "The world from which the entity has come" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event.
]],
}, -- HOOK_ENTITY_CHANGED_WORLD
}

View File

@ -0,0 +1,29 @@
return
{
HOOK_ENTITY_CHANGING_WORLD =
{
CalledWhen = "Before a entity is changing the world.",
DefaultFnName = "OnEntityChangingWorld", -- also used as pagename
Desc = [[
This hook is called before the server moves the {{cEntity|entity}} to the given world. Plugins may
refuse the changing of the entity to the new world.<p>
See also the {{OnEntityChangedWorld|HOOK_ENTITY_CHANGED_WORLD}} hook for a similar hook is called after the
entity has been moved to the world.
]],
Params =
{
{ Name = "Entity", Type = "{{cEntity}}", Notes = "The entity that wants to change the world" },
{ Name = "World", Type = "{{cWorld}}", Notes = "The world to which the entity wants to change" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event and the change of the entity to the world is
cancelled.
]],
}, -- HOOK_ENTITY_CHANGING_WORLD
}

View File

@ -0,0 +1,29 @@
return
{
HOOK_ENTITY_TELEPORT =
{
CalledWhen = "Any entity teleports. Plugin may refuse teleport.",
DefaultFnName = "OnEntityTeleport", -- also used as pagename
Desc = [[
This function is called in each server tick for each {{cEntity|Entity}} that has
teleported. Plugins may refuse the teleport.
]],
Params =
{
{ Name = "Entity", Type = "{{cEntity}}", Notes = "The entity who has teleported. New position is set in the object after successfull teleport" },
{ Name = "OldPosition", Type = "{{Vector3d}}", Notes = "The old position." },
{ Name = "NewPosition", Type = "{{Vector3d}}", Notes = "The new position." },
},
Returns = [[
If the function returns true, teleport is prohibited.</p>
<p>
If the function returns false or no value, other plugins' callbacks are called and finally the new
position is permanently stored in the cEntity object.</p>
]],
}, -- HOOK_ENTITY_TELEPORT
}

View File

@ -0,0 +1,41 @@
return
{
HOOK_EXECUTE_COMMAND =
{
CalledWhen = [[
A player executes an in-game command, or the admin issues a console command. Note that built-in
console commands are exempt to this hook - they are always performed and the hook is not called.
]],
DefaultFnName = "OnExecuteCommand", -- also used as pagename
Desc = [[
A plugin may implement a callback for this hook to intercept both in-game commands executed by the
players and console commands executed by the server admin. The function is called for every in-game
command sent from any player and for those server console commands that are not built in in the
server.</p>
<p>
If the command is in-game, the first parameter to the hook function is the {{cPlayer|player}} who's
executing the command. If the command comes from the server console, the first parameter is nil.</p>
<p>
The server calls this hook even for unregistered (unknown) console commands. It also calls the hook
for unknown in-game commands, as long as they begin with a slash ('/'). If a plugin needs to intercept
in-game chat messages not beginning with a slash, it should use the {{OnChat|HOOK_CHAT}} hook.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "For in-game commands, the player who has sent the message. For console commands, nil" },
{ Name = "CommandSplit", Type = "array-table of strings", Notes = "The command and its parameters, broken into a table by spaces" },
{ Name = "EntireCommand", Type = "string", Notes = "The entire command as a single string" },
},
Returns = [[
If the plugin returns false, Cuberite calls all the remaining hook handlers and finally the command
will be executed. If the plugin returns true, the none of the remaining hook handlers will be called.
In this case the plugin can return a second value, specifying whether what the command result should
be set to, one of the {{cPluginManager#CommandResult|CommandResult}} constants. If not
provided, the value defaults to crBlocked.
]],
}, -- HOOK_EXECUTE_COMMAND
}

View File

@ -0,0 +1,36 @@
return
{
HOOK_EXPLODED =
{
CalledWhen = "An explosion has happened",
DefaultFnName = "OnExploded", -- also used as pagename
Desc = [[
This hook is called after an explosion has been processed in a world.</p>
<p>
See also {{OnExploding|HOOK_EXPLODING}} for a similar hook called before the explosion.</p>
<p>
The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT,
etc. It also carries the identification of the actual source. The exact type of the identification
depends on the source kind, see the {{Globals#ExplosionSource|esXXX}} constants' descriptions for details.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world where the explosion happened" },
{ Name = "ExplosionSize", Type = "number", Notes = "The relative explosion size" },
{ Name = "CanCauseFire", Type = "bool", Notes = "True if the explosion has turned random air blocks to fire (such as a ghast fireball)" },
{ Name = "X", Type = "number", Notes = "X-coord of the explosion center" },
{ Name = "Y", Type = "number", Notes = "Y-coord of the explosion center" },
{ Name = "Z", Type = "number", Notes = "Z-coord of the explosion center" },
{ Name = "Source", Type = "eExplosionSource", Notes = "Source of the explosion. See the table above." },
{ Name = "SourceData", Type = "varies", Notes = "Additional data for the source. The exact type varies by the source. See the {{Globals#ExplosionSource|esXXX}} constants' descriptions." },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event. There is no overridable behaviour.
]],
}, -- HOOK_EXPLODED
}

View File

@ -0,0 +1,41 @@
return
{
HOOK_EXPLODING =
{
CalledWhen = "An explosion is about to be processed",
DefaultFnName = "OnExploding", -- also used as pagename
Desc = [[
This hook is called before an explosion has been processed in a world.</p>
<p>
See also {{OnExploded|HOOK_EXPLODED}} for a similar hook called after the explosion.</p>
<p>
The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT,
etc. It also carries the identification of the actual source. The exact type of the identification
depends on the source kind, see the {{Globals#ExplosionSource|esXXX}} constants' descriptions for details
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world where the explosion happens" },
{ Name = "ExplosionSize", Type = "number", Notes = "The relative explosion size" },
{ Name = "CanCauseFire", Type = "bool", Notes = "True if the explosion will turn random air blocks to fire (such as a ghast fireball)" },
{ Name = "X", Type = "number", Notes = "X-coord of the explosion center" },
{ Name = "Y", Type = "number", Notes = "Y-coord of the explosion center" },
{ Name = "Z", Type = "number", Notes = "Z-coord of the explosion center" },
{ Name = "Source", Type = "eExplosionSource", Notes = "Source of the explosion. See the table above." },
{ Name = "SourceData", Type = "varies", Notes = "Additional data for the source. The exact type varies by the source. See the {{Globals#ExplosionSource|esXXX}} constants' description." },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called, and finally
Cuberite will process the explosion - destroy blocks and push + hurt entities. If the function
returns true, no other callback is called for this event and the explosion will not occur.</p>
<p>
The hook handler may return up to two more values after the initial bool. The second returned value
overrides the CanCauseFire parameter for subsequent hook calls and the final explosion, the third
returned value overrides the ExplosionSize parameter for subsequent hook calls and the final explosion.
]],
}, -- HOOK_EXPLODING
}

View File

@ -0,0 +1,29 @@
return
{
HOOK_HANDSHAKE =
{
CalledWhen = "A client is connecting.",
DefaultFnName = "OnHandshake", -- also used as pagename
Desc = [[
This hook is called when a client sends the Handshake packet. At this stage, only the client IP and
(unverified) username are known. Plugins may refuse access to the server based on this
information.</p>
<p>
Note that the username is not authenticated - the authentication takes place only after this hook is
processed.
]],
Params =
{
{ Name = "Client", Type = "{{cClientHandle}}", Notes = "The client handle representing the connection. Note that there's no {{cPlayer}} object for this client yet." },
{ Name = "UserName", Type = "string", Notes = "The username presented in the packet. Note that this username is unverified." },
},
Returns = [[
If the function returns false, the user is let in to the server. If the function returns true, no
other plugin's callback is called, the user is kicked and the connection is closed.
]],
}, -- HOOK_HANDSHAKE
}

View File

@ -0,0 +1,30 @@
return
{
HOOK_HOPPER_PULLING_ITEM =
{
CalledWhen = "A hopper is pulling an item from another block entity.",
DefaultFnName = "OnHopperPullingItem", -- also used as pagename
Desc = [[
This callback is called whenever a {{cHopperEntity|hopper}} transfers an {{cItem|item}} from another
block entity into its own internal storage. A plugin may decide to disallow the move by returning
true. Note that in such a case, the hook may be called again for the same hopper, with different
slot numbers.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "World where the hopper resides" },
{ Name = "Hopper", Type = "{{cHopperEntity}}", Notes = "The hopper that is pulling the item" },
{ Name = "DstSlot", Type = "number", Notes = "The destination slot in the hopper's {{cItemGrid|internal storage}}" },
{ Name = "SrcBlockEntity", Type = "{{cBlockEntityWithItems}}", Notes = "The block entity that is losing the item" },
{ Name = "SrcSlot", Type = "number", Notes = "Slot in SrcBlockEntity from which the item will be pulled" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event and the hopper will not pull the item.
]],
}, -- HOOK_HOPPER_PULLING_ITEM
}

View File

@ -0,0 +1,30 @@
return
{
HOOK_HOPPER_PUSHING_ITEM =
{
CalledWhen = "A hopper is pushing an item into another block entity. ",
DefaultFnName = "OnHopperPushingItem", -- also used as pagename
Desc = [[
This hook is called whenever a {{cHopperEntity|hopper}} transfers an {{cItem|item}} from its own
internal storage into another block entity. A plugin may decide to disallow the move by returning
true. Note that in such a case, the hook may be called again for the same hopper and block, with
different slot numbers.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "World where the hopper resides" },
{ Name = "Hopper", Type = "{{cHopperEntity}}", Notes = "The hopper that is pushing the item" },
{ Name = "SrcSlot", Type = "number", Notes = "Slot in the hopper that will lose the item" },
{ Name = "DstBlockEntity", Type = "{{cBlockEntityWithItems}}", Notes = " The block entity that will receive the item" },
{ Name = "DstSlot", Type = "number", Notes = " Slot in DstBlockEntity's internal storage where the item will be stored" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event and the hopper will not push the item.
]],
}, -- HOOK_HOPPER_PUSHING_ITEM
}

View File

@ -0,0 +1,22 @@
return
{
HOOK_KILLED =
{
CalledWhen = "A player or a mob died.",
DefaultFnName = "OnKilled",
Desc = [[
This hook is called whenever player or a mob dies. It can be used to change the death message.
]],
Params =
{
{ Name = "Victim", Type = "{{cEntity}}", Notes = "The player or mob that died" },
{ Name = "TDI", Type = "{{TakeDamageInfo}}", Notes = "Informations about the death" },
{ Name = "DeathMessage", Type = "string", Notes = "The default death message. An empty string if the victim is not a player" },
},
Returns = [[
The function may return two values. The first value is a boolean specifying whether other plugins should be called. If it is true, the other plugins won't get notified of the death. If it is false, the other plugins will get notified.</p>
<p>The second value is a string containing the death message. If the victim is a player, this death message is broadcasted instead of the default death message. If it is empty, no death message is broadcasted. If it is nil, the message is left unchanged. If the victim is not a player, the death message is never broadcasted.</p>
<p>In either case, the victim is dead.
]],
}, -- HOOK_KILLED
}

View File

@ -0,0 +1,30 @@
return
{
HOOK_KILLING =
{
CalledWhen = "A player or a mob is dying.",
DefaultFnName = "OnKilling", -- also used as pagename
Desc = [[
This hook is called whenever a {{cPawn|pawn}}'s (a player's or a mob's) health reaches zero. This
means that the pawn is about to be killed, unless a plugin "revives" them by setting their health
back to a positive value.
]],
Params =
{
{ Name = "Victim", Type = "{{cPawn}}", Notes = "The player or mob that is about to be killed" },
{ Name = "Killer", Type = "{{cEntity}}", Notes = "The entity that has caused the victim to lose the last point of health. May be nil for environment damage" },
{ Name = "TDI", Type = "{{TakeDamageInfo}}", Notes = "The damage type, cause and effects." },
},
Returns = [[
If the function returns false or no value, Cuberite calls other plugins with this event. If the
function returns true, no other plugin is called for this event.</p>
<p>
In either case, the victim's health is then re-checked and if it is greater than zero, the victim is
"revived" with that health amount. If the health is less or equal to zero, the victim is killed.
]],
}, -- HOOK_KILLING
}

View File

@ -0,0 +1,31 @@
return
{
HOOK_LOGIN =
{
CalledWhen = "Right before player authentication. If auth is disabled, right after the player sends their name.",
DefaultFnName = "OnLogin", -- also used as pagename
Desc = [[
This hook is called whenever a client logs in. It is called right before the client's name is sent
to be authenticated. Plugins may refuse the client from accessing the server. Note that when this
callback is called, the {{cPlayer}} object for this client doesn't exist yet - the client has no
representation in any world. To process new players when their world is known, use a later callback,
such as {{OnPlayerJoined|HOOK_PLAYER_JOINED}} or {{OnPlayerSpawned|HOOK_PLAYER_SPAWNED}}.
]],
Params =
{
{ Name = "Client", Type = "{{cClientHandle}}", Notes = "The client handle representing the connection" },
{ Name = "ProtocolVersion", Type = "number", Notes = "Versio of the protocol that the client is talking" },
{ Name = "UserName", Type = "string", Notes = "The name that the client has presented for authentication. This name will be given to the {{cPlayer}} object when it is created for this client." },
},
Returns = [[
If the function returns true, no other plugins are called for this event and the client is kicked.
If the function returns false or no value, Cuberite calls other plugins' callbacks and finally
sends an authentication request for the client's username to the auth server. If the auth server
is disabled in the server settings, the player object is immediately created.
]],
}, -- HOOK_LOGIN
}

View File

@ -0,0 +1,28 @@
return
{
HOOK_PLAYER_ANIMATION =
{
CalledWhen = "A client has sent an Animation packet",
DefaultFnName = "OnPlayerAnimation", -- also used as pagename
Desc = [[
This hook is called when the server receives an Animation packet from the client.</p>
<p>
For the list of animations that are sent by the client, see the
<a href="http://wiki.vg/Protocol#Animation_.28clientbound.29">Protocol wiki</a>.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player from whom the packet was received" },
{ Name = "Animation", Type = "number", Notes = "The kind of animation" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. Afterwards, the
server broadcasts the animation packet to all nearby clients. If the function returns true, no other
callback is called for this event and the packet is not broadcasted.
]],
}, -- HOOK_PLAYER_ANIMATION
}

View File

@ -0,0 +1,36 @@
return
{
HOOK_PLAYER_BREAKING_BLOCK =
{
CalledWhen = "Just before a player breaks a block. Plugin may override / refuse. ",
DefaultFnName = "OnPlayerBreakingBlock", -- also used as pagename
Desc = [[
This hook is called when a {{cPlayer|player}} breaks a block, before the block is actually broken in
the {{cWorld|World}}. Plugins may refuse the breaking.</p>
<p>
See also the {{OnPlayerBrokenBlock|HOOK_PLAYER_BROKEN_BLOCK}} hook for a similar hook called after
the block is broken.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is digging the block" },
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
{ Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player is acting. One of the BLOCK_FACE_ constants" },
{ Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block being broken" },
{ Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block being broken " },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called, and then the block
is broken. If the function returns true, no other plugin's callback is called and the block breaking
is cancelled. The server re-sends the block back to the player to replace it (the player's client
already thinks the block was broken).
]],
}, -- HOOK_PLAYER_BREAKING_BLOCK
}

View File

@ -0,0 +1,36 @@
return
{
HOOK_PLAYER_BROKEN_BLOCK =
{
CalledWhen = "After a player has broken a block. Notification only.",
DefaultFnName = "OnPlayerBrokenBlock", -- also used as pagename
Desc = [[
This function is called after a {{cPlayer|player}} breaks a block. The block is already removed
from the {{cWorld|world}} and {{cPickup|pickups}} have been spawned. To get the world in which the
block has been dug, use the {{cPlayer}}:GetWorld() function.</p>
<p>
See also the {{OnPlayerBreakingBlock|HOOK_PLAYER_BREAKING_BLOCK}} hook for a similar hook called
before the block is broken. To intercept the creation of pickups, see the
{{OnBlockToPickups|HOOK_BLOCK_TO_PICKUPS}} hook.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who broke the block" },
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
{ Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" },
{ Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" },
{ Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event.
]],
}, -- HOOK_PLAYER_BROKEN_BLOCK
}

View File

@ -0,0 +1,18 @@
return
{
HOOK_PLAYER_CROUCHED =
{
CalledWhen = "Player crouched in the tick being currently processed.",
DefaultFnName = "OnPlayerCrouched", -- also used as pagename
Desc = [[
This function is called in each server tick for each {{cPlayer|player}} that has crouched.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has crouched." },
},
Returns = [[
If the function returns false or no value, other plugins callbacks are called.</p>
]],
}, -- HOOK_PLAYER_CROUCHED
}

View File

@ -0,0 +1,27 @@
return
{
HOOK_PLAYER_DESTROYED =
{
CalledWhen = "A player object is about to be destroyed.",
DefaultFnName = "OnPlayerDestroyed", -- also used as pagename
Desc = [[
This function is called before a {{cPlayer|player}} is about to be destroyed.
The player has disconnected for whatever reason and is no longer in the server.
If a plugin returns true, a leave message is not broadcast, and vice versa.
However, whatever the return value, the player object is removed from memory.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The destroyed player" },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called and a leave message is broadcast.
If the function returns true, no other callbacks are called for this event and no leave message appears. Either way the player is removed internally.
]],
}, -- HOOK_PLAYER_DESTROYED
}

View File

@ -0,0 +1,27 @@
return
{
HOOK_PLAYER_EATING =
{
CalledWhen = "When the player starts eating",
DefaultFnName = "OnPlayerEating", -- also used as pagename
Desc = [[
This hook gets called when the {{cPlayer|player}} starts eating, after the server checks that the
player can indeed eat (is not satiated and is holding food). Plugins may still refuse the eating by
returning true.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who started eating" },
},
Returns = [[
If the function returns false or no value, the server calls the next plugin handler, and finally
lets the player eat. If the function returns true, the server doesn't call any more callbacks for
this event and aborts the eating. A "disallow" packet is sent to the client.
]],
}, -- HOOK_PLAYER_EATING
}

View File

@ -0,0 +1,20 @@
return
{
HOOK_PLAYER_FISHED =
{
CalledWhen = "A player gets a reward from fishing.",
DefaultFnName = "OnPlayerFished", -- also used as pagename
Desc = [[
This hook gets called after a player reels in the fishing rod. This is a notification-only hook, the reward has already been decided. If a plugin needs to modify the reward, use the {{OnPlayerFishing|HOOK_PLAYER_FISHING}} hook.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who pulled the fish in." },
{ Name = "Reward", Type = "{{cItems}}", Notes = "The reward the player gets. It can be a fish, treasure and junk." },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function returns true, no other
callback is called for this event.
]],
}, -- HOOK_PLAYER_FISHED
};

View File

@ -0,0 +1,21 @@
return
{
HOOK_PLAYER_FISHING =
{
CalledWhen = "A player is about to get a reward from fishing.",
DefaultFnName = "OnPlayerFishing", -- also used as pagename
Desc = [[
This hook gets called when a player right clicks with a fishing rod while the floater is under water. The reward is already descided, but the plugin may change it.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who pulled the fish in." },
{ Name = "Reward", Type = "{{cItems}}", Notes = "The reward the player gets. It can be a fish, treasure and junk." },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. Afterwards, the
server gives the player his reward. If the function returns true, no other
callback is called for this event and the player doesn't get his reward.
]],
}, -- HOOK_PLAYER_FISHING
};

View File

@ -0,0 +1,27 @@
return
{
HOOK_PLAYER_FOOD_LEVEL_CHANGE =
{
CalledWhen = "Called before the player food level changed. Plugin may override",
DefaultFnName = "OnPlayerFoodLevelChange", -- also used as pagename
Desc = [[
This hook is called before the food level changes.
The food level is not changed yet, plugins may choose
to refuse the change.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who changes the food level." },
{ Name = "NewFoodLevel", Type = "number", Notes = "The new food level." },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. Afterwards, the
server changes the food level of the player. If the function returns true, no
other callback is called for this event and the player's food level doesn't change.
]],
}, -- HOOK_PLAYER_FOOD_LEVEL_CHANGE
};

View File

@ -0,0 +1,29 @@
return
{
HOOK_PLAYER_JOINED =
{
CalledWhen = "After Login and before Spawned, before being added to world. ",
DefaultFnName = "OnPlayerJoined", -- also used as pagename
Desc = [[
This hook is called whenever a {{cPlayer|player}} has completely logged in. If authentication is
enabled, this function is called after their name has been authenticated. It is called after
{{OnLogin|HOOK_LOGIN}} and before {{OnPlayerSpawned|HOOK_PLAYER_SPAWNED}}, right after the player's
entity is created, but not added to the world yet. The player is not yet visible to other players.
Returning true will block a join message from being broadcast, but otherwise, the player is still allowed to join.
Plugins wishing to refuse player's entry should kick the player using the {{cPlayer}}:Kick() function.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has joined the game" },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called and a join message is broadcast. If the function
returns true, no other callbacks are called for this event and a join message is not sent. Either way the player is let in.
]],
}, -- HOOK_PLAYER_JOINED
}

View File

@ -0,0 +1,47 @@
return
{
HOOK_PLAYER_LEFT_CLICK =
{
CalledWhen = "A left-click packet is received from the client. Plugin may override / refuse.",
DefaultFnName = "OnPlayerLeftClick", -- also used as pagename
Desc = [[
This hook is called when Cuberite receives a left-click packet from the {{cClientHandle|client}}. It
is called before any processing whatsoever is performed on the packet, meaning that hacked /
malicious clients may be trigerring this event very often and with unchecked parameters. Therefore
plugin authors are advised to use extreme caution with this callback.</p>
<p>
Plugins may refuse the default processing for the packet, causing Cuberite to behave as if the
packet has never arrived. This may, however, create inconsistencies in the client - the client may
think that they broke a block, while the server didn't process the breaking, etc. For this reason,
if a plugin refuses the processing, Cuberite sends the block specified in the packet back to the
client (as if placed anew), if the status code specified a block-break action. For other actions,
plugins must rectify the situation on their own.</p>
<p>
The client sends the left-click packet for several other occasions, such as dropping the held item
(Q keypress) or shooting an arrow. This is reflected in the Status code. Consult the
<a href="http://wiki.vg/Protocol#Player_Digging">protocol documentation</a> for details on the actions.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose client sent the packet" },
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
{ Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" },
{ Name = "Action", Type = "number", Notes = "Action to be performed on the block (\"status\" in the protocol docs)" },
},
Returns = [[
If the function returns false or no value, Cuberite calls other plugins' callbacks and finally sends
the packet for further processing.</p>
<p>
If the function returns true, no other plugins are called, processing is halted. If the action was a
block dig, Cuberite sends the block specified in the coords back to the client. The packet is
dropped.
]],
}, -- HOOK_PLAYER_LEFT_CLICK
}

View File

@ -0,0 +1,30 @@
return
{
HOOK_PLAYER_MOVING =
{
CalledWhen = "Player tried to move in the tick being currently processed. Plugin may refuse movement.",
DefaultFnName = "OnPlayerMoving", -- also used as pagename
Desc = [[
This function is called in each server tick for each {{cPlayer|player}} that has sent any of the
player-move packets. Plugins may refuse the movement.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has moved. The object already has the new position stored in it." },
{ Name = "OldPosition", Type = "{{Vector3d}}", Notes = "The old position." },
{ Name = "NewPosition", Type = "{{Vector3d}}", Notes = "The new position." },
{ Name = "PreviousIsOnGround", Type = "{{boolean}}", Notes = "Specifies if the player was standing on a solid block." },
},
Returns = [[
If the function returns true, movement is prohibited.</p>
<p>
If the function returns false or no value, other plugins' callbacks are called and finally the new
position is permanently stored in the cPlayer object.</p>
]],
}, -- HOOK_PLAYER_MOVING
}

View File

@ -0,0 +1,20 @@
return
{
HOOK_PLAYER_OPENING_WINDOW =
{
CalledWhen = "Called when a player is about to open a window",
DefaultFnName = "OnPlayerOpeningWindow", -- also used as pagename
Desc = [[
This hook is called when a player is about to open a window, e.g. when they click on a chest or a furnace.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is opening the window" },
{ Name = "Window", Type = "{{cWindow}}", Notes = "The window that is being opened" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called, and finally
Cuberite will process the opening window. If the function returns true, no other callback is called for this event.
]],
}, -- HOOK_PLAYER_OPENING_WINDOW
}

View File

@ -0,0 +1,40 @@
return
{
HOOK_PLAYER_PLACED_BLOCK =
{
CalledWhen = "After a player has placed a block. Notification only.",
DefaultFnName = "OnPlayerPlacedBlock", -- also used as pagename
Desc = [[
This hook is called after a {{cPlayer|player}} has placed a block in the {{cWorld|world}}. The block
is already added to the world and the corresponding item removed from player's
{{cInventory|inventory}}.</p>
<p>
Use the {{cPlayer}}:GetWorld() function to get the world to which the block belongs.</p>
<p>
See also the {{OnPlayerPlacingBlock|HOOK_PLAYER_PLACING_BLOCK}} hook for a similar hook called
before the placement.</p>
<p>
If the client action results in multiple blocks being placed (such as a bed or a door), each separate
block is reported through this hook. All the blocks are already present in the world before the first
instance of this hook is called.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who placed the block" },
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
{ Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" },
{ Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" },
},
Returns = [[
If this function returns false or no value, Cuberite calls other plugins with the same event. If
this function returns true, no other plugin is called for this event.
]],
}, -- HOOK_PLAYER_PLACED_BLOCK
}

View File

@ -0,0 +1,45 @@
return
{
HOOK_PLAYER_PLACING_BLOCK =
{
CalledWhen = "Just before a player places a block. Plugin may override / refuse.",
DefaultFnName = "OnPlayerPlacingBlock", -- also used as pagename
Desc = [[
This hook is called just before a {{cPlayer|player}} places a block in the {{cWorld|world}}. The
block is not yet placed, plugins may choose to override the default behavior or refuse the placement
at all.</p>
<p>
Note that the client already expects that the block has been placed. For that reason, if a plugin
refuses the placement, Cuberite sends the old block at the provided coords to the client.</p>
<p>
Use the {{cPlayer}}:GetWorld() function to get the world to which the block belongs.</p>
<p>
See also the {{OnPlayerPlacedBlock|HOOK_PLAYER_PLACED_BLOCK}} hook for a similar hook called after
the placement.</p>
<p>
If the client action results in multiple blocks being placed (such as a bed or a door), each separate
block is reported through this hook and only if all of them succeed, all the blocks are placed. If
any one of the calls are refused by the plugin, all the blocks are refused and reverted on the client.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is placing the block" },
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
{ Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" },
{ Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" },
},
Returns = [[
If this function returns false or no value, Cuberite calls other plugins with the same event and
finally places the block and removes the corresponding item from player's inventory. If this
function returns true, no other plugin is called for this event, Cuberite sends the old block at
the specified coords to the client and drops the packet.
]],
}, -- HOOK_PLAYER_PLACING_BLOCK
}

View File

@ -0,0 +1,40 @@
return
{
HOOK_PLAYER_RIGHT_CLICK =
{
CalledWhen = "A right-click packet is received from the client. Plugin may override / refuse.",
DefaultFnName = "OnPlayerRightClick", -- also used as pagename
Desc = [[
This hook is called when Cuberite receives a right-click packet from the {{cClientHandle|client}}. It
is called before any processing whatsoever is performed on the packet, meaning that hacked /
malicious clients may be trigerring this event very often and with unchecked parameters. Therefore
plugin authors are advised to use extreme caution with this callback.</p>
<p>
Plugins may refuse the default processing for the packet, causing Cuberite to behave as if the
packet has never arrived. This may, however, create inconsistencies in the client - the client may
think that they placed a block, while the server didn't process the placing, etc.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose client sent the packet" },
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
{ Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" },
{ Name = "CursorX", Type = "number", Notes = "X-coord of the mouse crosshair on the block" },
{ Name = "CursorY", Type = "number", Notes = "Y-coord of the mouse crosshair on the block" },
{ Name = "CursorZ", Type = "number", Notes = "Z-coord of the mouse crosshair on the block" },
},
Returns = [[
If the function returns false or no value, Cuberite calls other plugins' callbacks and finally sends
the packet for further processing.</p>
<p>
If the function returns true, no other plugins are called, processing is halted.
]],
}, -- HOOK_PLAYER_RIGHT_CLICK
}

View File

@ -0,0 +1,27 @@
return
{
HOOK_PLAYER_RIGHT_CLICKING_ENTITY =
{
CalledWhen = "A player has right-clicked an entity. Plugins may override / refuse.",
DefaultFnName = "OnPlayerRightClickingEntity", -- also used as pagename
Desc = [[
This hook is called when the {{cPlayer|player}} right-clicks an {{cEntity|entity}}. Plugins may
override the default behavior or even cancel the default processing.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has right-clicked the entity" },
{ Name = "Entity", Type = "{{cEntity}} descendant", Notes = "The entity that has been right-clicked" },
},
Returns = [[
If the functino returns false or no value, Cuberite calls other plugins' callbacks and finally does
the default processing for the right-click. If the function returns true, no other callbacks are
called and the default processing is skipped.
]],
}, -- HOOK_PLAYER_RIGHT_CLICKING_ENTITY
}

View File

@ -0,0 +1,32 @@
return
{
HOOK_PLAYER_SHOOTING =
{
CalledWhen = "When the player releases the bow, shooting an arrow (other projectiles: unknown)",
DefaultFnName = "OnPlayerShooting", -- also used as pagename
Desc = [[
This hook is called when the {{cPlayer|player}} shoots their bow. It is called for the actual
release of the {{cArrowEntity|arrow}}. FIXME: It is currently unknown whether other
{{cProjectileEntity|projectiles}} (snowballs, eggs) trigger this hook.</p>
<p>
To get the player's position and direction, use the {{cPlayer}}:GetEyePosition() and
cPlayer:GetLookVector() functions. Note that for shooting a bow, the position for the arrow creation
is not at the eye pos, some adjustments are required. FIXME: Export the {{cPlayer}} function for
this adjustment.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player shooting" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called, and finally
Cuberite creates the projectile. If the functino returns true, no other callback is called and no
projectile is created.
]],
}, -- HOOK_PLAYER_SHOOTING
}

View File

@ -0,0 +1,32 @@
return
{
HOOK_PLAYER_SPAWNED =
{
CalledWhen = "After a player (re)spawns in the world to which they belong to.",
DefaultFnName = "OnPlayerSpawned", -- also used as pagename
Desc = [[
This hook is called after a {{cPlayer|player}} has spawned in the world. It is called after
{{OnLogin|HOOK_LOGIN}} and {{OnPlayerJoined|HOOK_PLAYER_JOINED}}, after the player name has been
authenticated, the initial worldtime, inventory and health have been sent to the player and the
player spawn packet has been broadcast to all players near enough to the player spawn place. This is
a notification-only event, plugins wishing to refuse player's entry should kick the player using the
{{cPlayer}}:Kick() function.</p>
<p>
This hook is also called when the player respawns after death (and a respawn packet is received from
the client, meaning the player has already clicked the Respawn button).
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has (re)spawned" },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called. If the function
returns true, no other callbacks are called for this event. There is no overridable behavior.
]],
}, -- HOOK_PLAYER_SPAWNED
}

View File

@ -0,0 +1,31 @@
return
{
HOOK_PLAYER_TOSSING_ITEM =
{
CalledWhen = "A player is tossing an item. Plugin may override / refuse.",
DefaultFnName = "OnPlayerTossingItem", -- also used as pagename
Desc = [[
This hook is called when a {{cPlayer|player}} has tossed an item. The
{{cPickup|pickup}} has not been spawned yet. Plugins may disallow the tossing, but in that case they
need to clean up - the player's client already thinks the item has been tossed so the
{{cInventory|inventory}} needs to be re-sent to the player.</p>
<p>
To get the item that is about to be tossed, call the {{cPlayer}}:GetEquippedItem() function.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player tossing an item" },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called and finally Cuberite
creates the pickup for the item and tosses it, using {{cPlayer}}:TossHeldItem, {{cPlayer}}:TossEquippedItem,
or {{cPlayer}}:TossPickup. If the function returns true, no other callbacks are called for this event
and Cuberite doesn't toss the item.
]],
}, -- HOOK_PLAYER_TOSSING_ITEM
}

View File

@ -0,0 +1,46 @@
return
{
HOOK_PLAYER_USED_BLOCK =
{
CalledWhen = "A player has just used a block (chest, furnace...). Notification only.",
DefaultFnName = "OnPlayerUsedBlock", -- also used as pagename
Desc = [[
This hook is called after a {{cPlayer|player}} has right-clicked a block that can be used, such as a
{{cChestEntity|chest}} or a lever. It is called after Cuberite processes the usage (sends the UI
handling packets / toggles redstone). Note that for UI-related blocks, the player is most likely
still using the UI. This is a notification-only event.</p>
<p>
Note that the block coords given in this callback are for the (solid) block that is being clicked,
not the air block between it and the player.</p>
<p>
To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function.</p>
<p>
See also the {{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} for a similar hook called before the
use, the {{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} and {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}}
for similar hooks called when a player interacts with any block with a usable item in hand, such as
a bucket.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who used the block" },
{ Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" },
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" },
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" },
{ Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" },
{ Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" },
{ Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" },
{ Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" },
{ Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" },
{ Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called. If the function
returns true, no other callbacks are called for this event.
]],
}, -- HOOK_PLAYER_USED_BLOCK
}

View File

@ -0,0 +1,44 @@
return
{
HOOK_PLAYER_USED_ITEM =
{
CalledWhen = "A player has used an item in hand (bucket...)",
DefaultFnName = "OnPlayerUsedItem", -- also used as pagename
Desc = [[
This hook is called after a {{cPlayer|player}} has right-clicked a block with an {{cItem|item}} that
can be used (is not placeable, is not food and clicked block is not use-able), such as a bucket or a
hoe. It is called after Cuberite processes the usage (places fluid / turns dirt to farmland).
This is an information-only hook, there is no way to cancel the event anymore.</p>
<p>
Note that the block coords given in this callback are for the (solid) block that is being clicked,
not the air block between it and the player.</p>
<p>
To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function. To get
the item that the player is using, use the {{cPlayer}}:GetEquippedItem() function.</p>
<p>
See also the {{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} for a similar hook called before the use,
the {{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} and {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}}
for similar hooks called when a player interacts with a block, such as a chest.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who used the item" },
{ Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" },
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" },
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" },
{ Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" },
{ Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" },
{ Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" },
{ Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called. If the function
returns true, no other callbacks are called for this event.
]],
}, -- HOOK_PLAYER_USED_ITEM
}

View File

@ -0,0 +1,47 @@
return
{
HOOK_PLAYER_USING_BLOCK =
{
CalledWhen = "Just before a player uses a block (chest, furnace...). Plugin may override / refuse.",
DefaultFnName = "OnPlayerUsingBlock", -- also used as pagename
Desc = [[
This hook is called when a {{cPlayer|player}} has right-clicked a block that can be used, such as a
{{cChestEntity|chest}} or a lever. It is called before Cuberite processes the usage (sends the UI
handling packets / toggles redstone). Plugins may refuse the interaction by returning true.</p>
<p>
Note that the block coords given in this callback are for the (solid) block that is being clicked,
not the air block between it and the player.</p>
<p>
To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function.</p>
<p>
See also the {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}} for a similar hook called after the use, the
{{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} and {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}} for
similar hooks called when a player interacts with any block with a usable item in hand, such as a
bucket.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is using the block" },
{ Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" },
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" },
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" },
{ Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" },
{ Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" },
{ Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" },
{ Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" },
{ Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" },
{ Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called and then Cuberite
processes the interaction. If the function returns true, no other callbacks are called for this
event and the block is treated like any other block (i.e. if it's possible to place a torch on,
it will be placed, and so on.)
]],
}, -- HOOK_PLAYER_USING_BLOCK
}

View File

@ -0,0 +1,45 @@
return
{
HOOK_PLAYER_USING_ITEM =
{
CalledWhen = "Just before a player uses an item in hand (bucket...). Plugin may override / refuse.",
DefaultFnName = "OnPlayerUsingItem", -- also used as pagename
Desc = [[
This hook is called when a {{cPlayer|player}} has right-clicked a block with an {{cItem|item}} that
can be used (is not placeable, is not food and clicked block is not use-able), such as a bucket or a
hoe. It is called before Cuberite processes the usage (places fluid / turns dirt to farmland).
Plugins may refuse the interaction by returning true.</p>
<p>
Note that the block coords given in this callback are for the (solid) block that is being clicked,
not the air block between it and the player.</p>
<p>
To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function. To get
the item that the player is using, use the {{cPlayer}}:GetEquippedItem() function.</p>
<p>
See also the {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}} for a similar hook called after the use, the
{{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} and {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}} for
similar hooks called when a player interacts with a block, such as a chest.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is using the item" },
{ Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" },
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" },
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" },
{ Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" },
{ Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" },
{ Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" },
{ Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called and then Cuberite
processes the interaction. If the function returns true, no other callbacks are called for this
event and the interaction is silently dropped.
]],
}, -- HOOK_PLAYER_USING_ITEM
}

View File

@ -0,0 +1,25 @@
return
{
HOOK_PLUGIN_MESSAGE =
{
CalledWhen = "The server receives a plugin message from a client",
DefaultFnName = "OnPluginMessage", -- also used as pagename
Desc = [[
A plugin may implement an OnPluginMessage() function and register it as a Hook to process plugin messages
from the players. The function is then called for every plugin message sent from any player.
]],
Params = {
{ Name = "Client", Type = "{{cClientHandle}}", Notes = "The client who sent the plugin message" },
{ Name = "Channel", Type = "string", Notes = "The channel on which the message was sent" },
{ Name = "Message", Type = "string", Notes = "The message's payload" },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called. If the function
returns true, no other callbacks are called for this event.
]],
}, -- HOOK_CHAT
}

View File

@ -0,0 +1,84 @@
return
{
HOOK_PLUGINS_LOADED =
{
CalledWhen = "All the enabled plugins have been loaded",
DefaultFnName = "OnPluginsLoaded", -- also used as pagename
Desc = [[
This callback gets called when the server finishes loading and initializing plugins. This is the
perfect occasion for a plugin to query other plugins through {{cPluginManager}}:GetPlugin() and
possibly start communicating with them using the {{cPlugin}}:Call() function.
]],
Params = {},
Returns = [[
The return value is ignored, all registered callbacks are called.
]],
CodeExamples =
{
{
Title = "CoreMessaging",
Desc = [[
This example shows how to implement the CoreMessaging functionality - messages to players will be
sent through the Core plugin, formatted by that plugin. As a fallback for when the Core plugin is
not present, the messages are sent directly by this code, unformatted.
]],
Code = [[
-- These are the fallback functions used when the Core is not present:
local function SendMessageFallback(a_Player, a_Message)
a_Player:SendMessage(a_Message);
end
local function SendMessageSuccessFallback(a_Player, a_Message)
a_Player:SendMessage(a_Message);
end
local function SendMessageFailureFallback(a_Player, a_Message)
a_Player:SendMessage(a_Message);
end
-- These three "variables" will hold the actual functions to call.
-- By default they are initialized to the Fallback variants,
-- but will be redirected to Core when all plugins load
SendMessage = SendMessageFallback;
SendMessageSuccess = SendMessageSuccessFallback;
SendMessageFailure = SendMessageFailureFallback;
-- The callback tries to connect to the Core
-- If successful, overwrites the three functions with Core ones
local function OnPluginsLoaded()
local CorePlugin = cPluginManager:Get():GetPlugin("Core");
if (CorePlugin == nil) then
-- The Core is not loaded, keep the Fallback functions
return;
end
-- Overwrite the three functions with Core functionality:
SendMessage = function(a_Player, a_Message)
CorePlugin:Call("SendMessage", a_Player, a_Message);
end
SendMessageSuccess = function(a_Player, a_Message)
CorePlugin:Call("SendMessageSuccess", a_Player, a_Message);
end
SendMessageFailure = function(a_Player, a_Message)
CorePlugin:Call("SendMessageFailure", a_Player, a_Message);
end
end
-- Global scope, register the callback:
cPluginManager.AddHook(cPluginManager.HOOK_PLUGINS_LOADED, CoreMessagingPluginsLoaded);
-- Usage, anywhere else in the plugin:
SendMessageFailure(
a_Player,
"Cannot teleport to player, the destination player " .. PlayerName .. " was not found"
);
]],
},
} , -- CodeExamples
}, -- HOOK_PLUGINS_LOADED
}

View File

@ -0,0 +1,36 @@
return
{
HOOK_POST_CRAFTING =
{
CalledWhen = "After the built-in recipes are checked and a recipe was found.",
DefaultFnName = "OnPostCrafting", -- also used as pagename
Desc = [[
This hook is called when a {{cPlayer|player}} changes contents of their
{{cCraftingGrid|crafting grid}}, after the recipe has been established by Cuberite. Plugins may use
this to modify the resulting recipe or provide an alternate recipe.</p>
<p>
If a plugin implements custom recipes, it should do so using the {{OnPreCrafting|HOOK_PRE_CRAFTING}}
hook, because that will save the server from going through the built-in recipes. The
HOOK_POST_CRAFTING hook is intended as a notification, with a chance to tweak the result.</p>
<p>
Note that this hook is not called if a built-in recipe is not found;
{{OnCraftingNoRecipe|HOOK_CRAFTING_NO_RECIPE}} is called instead in such a case.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has changed their crafting grid contents" },
{ Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "The new crafting grid contents" },
{ Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that Cuberite has decided to use (can be tweaked by plugins)" },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called. If the function
returns true, no other callbacks are called for this event. In either case, Cuberite uses the value
of Recipe as the recipe to be presented to the player.
]],
}, -- HOOK_POST_CRAFTING
}

View File

@ -0,0 +1,37 @@
return
{
HOOK_PRE_CRAFTING =
{
CalledWhen = "Before the built-in recipes are checked.",
DefaultFnName = "OnPreCrafting", -- also used as pagename
Desc = [[
This hook is called when a {{cPlayer|player}} changes contents of their
{{cCraftingGrid|crafting grid}}, before the built-in recipes are searched for a match by Cuberite.
Plugins may use this hook to provide a custom recipe.</p>
<p>
If you intend to tweak built-in recipes, use the {{OnPostCrafting|HOOK_POST_CRAFTING}} hook, because
that will be called once the built-in recipe is matched.</p>
<p>
Also note a third hook, {{OnCraftingNoRecipe|HOOK_CRAFTING_NO_RECIPE}}, that is called when Cuberite
cannot find any built-in recipe for the given ingredients.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has changed their crafting grid contents" },
{ Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "The new crafting grid contents" },
{ Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that Cuberite will use. Modify this object to change the recipe" },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called and then Cuberite
searches the built-in recipes. The Recipe output parameter is ignored in this case.</p>
<p>
If the function returns true, no other callbacks are called for this event and Cuberite uses the
recipe stored in the Recipe output parameter.
]],
}, -- HOOK_PRE_CRAFTING
}

View File

@ -0,0 +1,29 @@
return
{
HOOK_PROJECTILE_HIT_BLOCK =
{
CalledWhen = "A projectile hits a solid block.",
DefaultFnName = "OnProjectileHitBlock", -- also used as pagename
Desc = [[
This hook is called when a {{cProjectileEntity|projectile}} hits a solid block..
]],
Params =
{
{ Name = "ProjectileEntity", Type = "{{cProjectileEntity}}", Notes = "The projectile that hit an entity." },
{ Name = "BlockX", Type = "number", Notes = "The X-coord where the projectile hit." },
{ Name = "BlockY", Type = "number", Notes = "The Y-coord where the projectile hit." },
{ Name = "BlockZ", Type = "number", Notes = "The Z-coord where the projectile hit." },
{ Name = "BlockFace", Type = "number", Notes = "The side of the block where the projectile hit." },
{ Name = "BlockHitPos", Type = "Vector3d", Notes = "The exact position where the projectile hit." },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event and the projectile flies through block..
]],
}, -- HOOK_PROJECTILE_HIT_BLOCK
}

View File

@ -0,0 +1,25 @@
return
{
HOOK_PROJECTILE_HIT_ENTITY =
{
CalledWhen = "A projectile hits another entity.",
DefaultFnName = "OnProjectileHitEntity", -- also used as pagename
Desc = [[
This hook is called when a {{cProjectileEntity|projectile}} hits another entity.
]],
Params =
{
{ Name = "ProjectileEntity", Type = "{{cProjectileEntity}}", Notes = "The projectile that hit an entity." },
{ Name = "Entity", Type = "{{cEntity}}", Notes = "The entity wich was hit." },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event and the projectile flies through the entity.
]],
}, -- HOOK_PROJECTILE_HIT_ENTITY
}

View File

@ -0,0 +1,53 @@
return
{
HOOK_SERVER_PING =
{
CalledWhen = "Client pings the server from the server list.",
DefaultFnName = "OnServerPing", -- also used as pagename
Desc = [[
A plugin may implement an OnServerPing() function and register it as a Hook to process pings from
clients in the server server list. It can change the logged in players and player capacity, as well
as the server description and the favicon, that are displayed to the client in the server list.</p>
<p>
The client handle already has its protocol version assigned to it, so the plugin can check that; however,
there's no username associated with the client yet, and no player object.
]],
Params = {
{ Name = "ClientHandle", Type = "{{cClientHandle}}", Notes = "The client handle that pinged the server" },
{ Name = "ServerDescription", Type = "string", Notes = "The server description" },
{ Name = "OnlinePlayersCount", Type = "number", Notes = "The number of players currently on the server" },
{ Name = "MaxPlayersCount", Type = "number", Notes = "The current player cap for the server" },
{ Name = "Favicon", Type = "string", Notes = "The base64 encoded favicon to be displayed in the server list for compatible clients" },
},
Returns = [[
The plugin can return whether to continue processing of the hook with other plugins, the server description to
be displayed to the client, the currently online players, the player cap and the base64/png favicon data, in that order.
]],
CodeExamples = {
{
Title = "Change information returned to the player",
Desc = "Tells the client that the server description is 'test', there are one more players online than there actually are, and that the player cap is zero. It also changes the favicon data.",
Code = [[
function OnServerPing(ClientHandle, ServerDescription, OnlinePlayers, MaxPlayers, Favicon)
-- Change Server Description
ServerDescription = "Test"
-- Change online / max players
OnlinePlayers = OnlinePlayers + 1
MaxPlayers = 0
-- Change favicon
if cFile:IsFile("my-favicon.png") then
local FaviconData = cFile:ReadWholeFile("my-favicon.png")
if (FaviconData ~= "") and (FaviconData ~= nil) then
Favicon = Base64Encode(FaviconData)
end
end
return false, ServerDescription, OnlinePlayers, MaxPlayers, Favicon
end
]],
},
},
}, -- HOOK_SERVER_PING
}

View File

@ -0,0 +1,31 @@
return
{
HOOK_SPAWNED_ENTITY =
{
CalledWhen = "After an entity is spawned in the world.",
DefaultFnName = "OnSpawnedEntity", -- also used as pagename
Desc = [[
This hook is called after the server spawns an {{cEntity|entity}}. This is an information-only
callback, the entity is already spawned by the time it is called. If the entity spawned is a
{{cMonster|monster}}, the {{OnSpawnedMonster|HOOK_SPAWNED_MONSTER}} hook is called before this
hook.</p>
<p>
See also the {{OnSpawningEntity|HOOK_SPAWNING_ENTITY}} hook for a similar hook called before the
entity is spawned.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity has spawned" },
{ Name = "Entity", Type = "{{cEntity}} descentant", Notes = "The entity that has spawned" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event.
]],
}, -- HOOK_SPAWNED_ENTITY
}

View File

@ -0,0 +1,30 @@
return
{
HOOK_SPAWNED_MONSTER =
{
CalledWhen = "After a monster is spawned in the world",
DefaultFnName = "OnSpawnedMonster", -- also used as pagename
Desc = [[
This hook is called after the server spawns a {{cMonster|monster}}. This is an information-only
callback, the monster is already spawned by the time it is called. After this hook is called, the
{{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} is called for the monster entity.</p>
<p>
See also the {{OnSpawningMonster|HOOK_SPAWNING_MONSTER}} hook for a similar hook called before the
monster is spawned.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the monster has spawned" },
{ Name = "Monster", Type = "{{cMonster}} descendant", Notes = "The monster that has spawned" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event.
]],
}, -- HOOK_SPAWNED_MONSTER
}

View File

@ -0,0 +1,33 @@
return
{
HOOK_SPAWNING_ENTITY =
{
CalledWhen = "Before an entity is spawned in the world.",
DefaultFnName = "OnSpawningEntity", -- also used as pagename
Desc = [[
This hook is called before the server spawns an {{cEntity|entity}}. The plugin can either modify the
entity before it is spawned, or disable the spawning altogether. You can't disable the spawning if the
entity is a player. If the entity spawning is a monster, the {{OnSpawningMonster|HOOK_SPAWNING_MONSTER}}
hook is called before this hook.</p>
<p>
See also the {{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} hook for a similar hook called after the
entity is spawned.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity will spawn" },
{ Name = "Entity", Type = "{{cEntity}} descentant", Notes = "The entity that will spawn" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. Finally, the server
spawns the entity with whatever parameters have been set on the {{cEntity}} object by the callbacks.
If the function returns true, no other callback is called for this event and the entity is not
spawned.
]],
}, -- HOOK_SPAWNING_ENTITY
}

View File

@ -0,0 +1,33 @@
return
{
HOOK_SPAWNING_MONSTER =
{
CalledWhen = "Before a monster is spawned in the world.",
DefaultFnName = "OnSpawningMonster", -- also used as pagename
Desc = [[
This hook is called before the server spawns a {{cMonster|monster}}. The plugins may modify the
monster's parameters in the {{cMonster}} class, or disallow the spawning altogether. This hook is
called before the {{OnSpawningEntity|HOOK_SPAWNING_ENTITY}} is called for the monster entity.</p>
<p>
See also the {{OnSpawnedMonster|HOOK_SPAWNED_MONSTER}} hook for a similar hook called after the
monster is spawned.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity will spawn" },
{ Name = "Monster", Type = "{{cMonster}} descentant", Notes = "The monster that will spawn" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. Finally, the server
spawns the monster with whatever parameters the plugins set in the cMonster parameter.</p>
<p>
If the function returns true, no other callback is called for this event and the monster won't
spawn.
]],
}, -- HOOK_SPAWNING_MONSTER
}

View File

@ -0,0 +1,31 @@
return
{
HOOK_TAKE_DAMAGE =
{
CalledWhen = "An {{cEntity|entity}} is taking any kind of damage",
DefaultFnName = "OnTakeDamage", -- also used as pagename
Desc = [[
This hook is called when any {{cEntity}} descendant, such as a {{cPlayer|player}} or a
{{cMonster|mob}}, takes any kind of damage. The plugins may modify the amount of damage or effects
with this hook by editting the {{TakeDamageInfo}} object passed.</p>
<p>
This hook is called after the final damage is calculated, including all the possible weapon
{{cEnchantments|enchantments}}, armor protection and potion effects.
]],
Params =
{
{ Name = "Receiver", Type = "{{cEntity}} descendant", Notes = "The entity taking damage" },
{ Name = "TDI", Type = "{{TakeDamageInfo}}", Notes = "The damage type, cause and effects. Plugins may modify this object to alter the final damage applied." },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called and then the server
applies the final values from the TDI object to Receiver. If the function returns true, no other
callbacks are called, and no damage nor effects are applied.
]],
}, -- HOOK_TAKE_DAMAGE
}

View File

@ -0,0 +1,29 @@
return
{
HOOK_TICK =
{
CalledWhen = "Every server tick (approximately 20 times per second)",
DefaultFnName = "OnTick", -- also used as pagename
Desc = [[
This hook is called every game tick (50 msec, or 20 times a second). If the server is overloaded,
the interval is larger, which is indicated by the TimeDelta parameter.</p>
<p>
This hook is called in the context of the server-tick thread, that is, the thread that takes care of
{{cClientHandle|client connections}} before they're assigned to {{cPlayer|player entities}}, and
processing console commands.
]],
Params =
{
{ Name = "TimeDelta", Type = "number", Notes = "The number of milliseconds elapsed since the last server tick. Will not be less than 50 msec." },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called. If the function
returns true, no other callbacks are called. There is no overridable behavior.
]],
}, -- HOOK_TICK
}

View File

@ -0,0 +1,38 @@
return
{
HOOK_UPDATED_SIGN =
{
CalledWhen = "After the sign text is updated. Notification only.",
DefaultFnName = "OnUpdatedSign", -- also used as pagename
Desc = [[
This hook is called after a sign has had its text updated. The text is already updated at this
point.</p>
<p>The update may have been caused either by a {{cPlayer|player}} directly updating the sign, or by
a plugin changing the sign text using the API.</p>
<p>
See also the {{OnUpdatingSign|HOOK_UPDATING_SIGN}} hook for a similar hook called before the update,
with a chance to modify the text.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the sign resides" },
{ Name = "BlockX", Type = "number", Notes = "X-coord of the sign" },
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the sign" },
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the sign" },
{ Name = "Line1", Type = "string", Notes = "1st line of the new text" },
{ Name = "Line2", Type = "string", Notes = "2nd line of the new text" },
{ Name = "Line3", Type = "string", Notes = "3rd line of the new text" },
{ Name = "Line4", Type = "string", Notes = "4th line of the new text" },
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is changing the text. May be nil for non-player updates." }
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called. If the function
returns true, no other callbacks are called. There is no overridable behavior.
]],
}, -- HOOK_UPDATED_SIGN
}

View File

@ -0,0 +1,58 @@
return
{
HOOK_UPDATING_SIGN =
{
CalledWhen = "Before the sign text is updated. Plugin may modify the text / refuse.",
DefaultFnName = "OnUpdatingSign", -- also used as pagename
Desc = [[
This hook is called when a sign text is about to be updated, either as a result of player's
manipulation or any other event, such as a plugin setting the sign text. Plugins may modify the text
or refuse the update altogether.</p>
<p>
See also the {{OnUpdatedSign|HOOK_UPDATED_SIGN}} hook for a similar hook called after the update.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the sign resides" },
{ Name = "BlockX", Type = "number", Notes = "X-coord of the sign" },
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the sign" },
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the sign" },
{ Name = "Line1", Type = "string", Notes = "1st line of the new text" },
{ Name = "Line2", Type = "string", Notes = "2nd line of the new text" },
{ Name = "Line3", Type = "string", Notes = "3rd line of the new text" },
{ Name = "Line4", Type = "string", Notes = "4th line of the new text" },
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is changing the text. May be nil for non-player updates." }
},
Returns = [[
The function may return up to five values. If the function returns true as the first value, no other
callbacks are called for this event and the sign is not updated. If the function returns no value or
false as its first value, other plugins' callbacks are called.</p>
<p>
The other up to four values returned are used to update the sign text, line by line, respectively.
Note that other plugins may again update the texts (if the first value returned is false).
]],
CodeExamples =
{
{
Title = "Add player signature",
Desc = "The following example appends a player signature to the last line, if the sign is updated by a player:",
Code = [[
function OnUpdatingSign(World, BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4, Player)
if (Player == nil) then
-- Not changed by a player
return false;
end
-- Sign with playername, allow other plugins to interfere:
return false, Line1, Line2, Line3, Line4 .. Player:GetName();
end
]],
}
} ,
}, -- HOOK_UPDATING_SIGN
}

View File

@ -0,0 +1,28 @@
return
{
HOOK_WEATHER_CHANGED =
{
CalledWhen = "The weather has changed",
DefaultFnName = "OnWeatherChanged", -- also used as pagename
Desc = [[
This hook is called after the weather has changed in a {{cWorld|world}}. The new weather has already
been sent to the clients.</p>
<p>
See also the {{OnWeatherChanging|HOOK_WEATHER_CHANGING}} hook for a similar hook called before the
change.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "World for which the weather has changed" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event. There is no overridable behavior.
]],
}, -- HOOK_WEATHER_CHANGED
}

View File

@ -0,0 +1,35 @@
return
{
HOOK_WEATHER_CHANGING =
{
CalledWhen = "The weather is about to change",
DefaultFnName = "OnWeatherChanging", -- also used as pagename
Desc = [[
This hook is called when the current weather has expired and a new weather is selected. Plugins may
override the new weather being set.</p>
<p>
The new weather setting is sent to the clients only after this hook has been processed.</p>
<p>
See also the {{OnWeatherChanged|HOOK_WEATHER_CHANGED}} hook for a similar hook called after the
change.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "World for which the weather is changing" },
{ Name = "Weather", Type = "number", Notes = "The newly selected weather. One of wSunny, wRain, wStorm" },
},
Returns = [[
The hook handler can return up to two values. If the first value is false or not present, the server
calls other plugins' callbacks and finally sets the weather. If it is true, the server doesn't call any
more callbacks for this hook. The second value returned is used as the new weather. If no value is
given, the weather from the parameters is used as the weather. Returning false as the first value and a
specific weather constant as the second value makes the server call the rest of the hook handlers with
the new weather value.
]],
}, -- HOOK_WEATHER_CHANGING
}

View File

@ -0,0 +1,24 @@
return
{
HOOK_WORLD_STARTED =
{
CalledWhen = "A {{cWorld|world}} is initialized",
DefaultFnName = "OnWorldStarted", -- also used as pagename
Desc = [[
This hook is called whenever a {{cWorld|world}} is initialized.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "World that is started" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event. There is no overridable behavior.
]],
}, -- HOOK_WORLD_STARTED
}

View File

@ -0,0 +1,29 @@
return
{
HOOK_WORLD_TICK =
{
CalledWhen = "Every world tick (about 20 times per second), separately for each world",
DefaultFnName = "OnWorldTick", -- also used as pagename
Desc = [[
This hook is called for each {{cWorld|world}} every tick (50 msec, or 20 times a second). If the
world is overloaded, the interval is larger, which is indicated by the TimeDelta parameter.</p>
<p>
This hook is called in the world's tick thread context and thus has access to all world data
guaranteed without blocking.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "World that is ticking" },
{ Name = "TimeDelta", Type = "number", Notes = "The number of milliseconds since the previous game tick. Will not be less than 50 msec" },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. If the function
returns true, no other callback is called for this event. There is no overridable behavior.
]],
}, -- HOOK_WORLD_TICK
}

View File

@ -0,0 +1,273 @@
<!DOCTYPE html>
<html>
<head>
<title>Cuberite - Info.lua file</title>
<link rel="canonical" href="https://api.cuberite.org/InfoFile.html">
<link rel="stylesheet" type="text/css" href="main.css" />
<link rel="stylesheet" type="text/css" href="prettify.css" />
<script src="prettify.js"></script>
<script src="lang-lua.js"></script>
<meta charset="UTF-8">
</head>
<body>
<div id="content">
<h1>Info.lua file</h1>
<h2>Contents</h2>
<ul>
<li><a href="#Introduction">Introduction</a></li>
<li><a href="#Overall">The overall structure</a></li>
<li><a href="#AdditionalInfo">AdditionalInfo table</a></li>
<li><a href="#Commands">Commands table</a></li>
<li><a href="#ConsoleCommands">ConsoleCommands table</a></li>
<li><a href="#Permissions">Permissions table</a></li>
<li><a href="#Categories">Categories table</a></li>
<li><a href="#Using">Using the file in code</a></li>
<li><a href="#Examples">Examples</a></li>
</ul>
<hr />
<a name="Introduction"><h2>Introduction</h2></a>
<p>For a long time Cuberite plugins were plagued by poor documentation. The plugins worked, people who wrote them knew how to use them, but for anyone new to the plugin it was a terrible ordeal learning how to use it. Most of the times, the plugin authors only wrote what commands the plugin supported, sometimes not even that. Then, there was a call to action to put an end to this, to make documenting the plugins easy and at the same time centralized. Thus, the Info.lua file was born.</p>
<p>Most plugins have some parts that are the same across all the plugins. These are commands, console commands and their permissions. If a plugin implemented a command, it would practically copy &amp; paste the same code over and over again. So it makes sense to extract only unique information, centralize it and automate all the parts around it. This was another reason for the Info.lua file - it is a central hub of commands, console commands and their permissions.</p>
<p>Last, but not least, we want to make a plugin repository on the web in the future, a repository that would store plugins, their descriptions, comments. It makes sense that the centralized information can be parsed by the repository automatically, so that advanced things, such as searching for a plugin based on a command, or determining whether two plugins collide command-wise, are possible.</p>
<p>A tool has been written that allows for an easy generation of the documentation for the plugin in various formats. It outputs the documentation in a format that is perfect for pasting into the forum. It generates documentation in a Markup format to use in README.md on GitHub and similar sites. The clever thing is that you don't need to keep all those formats in sync manually - you edit the Info.lua file and this tool will re-generate the documentation for you.
<br>
To generate documentation for the plugin, activate the DumpInfo plugin on a cuberite server with your plugin installed, and use the webadmin interface to "Dump" the plugin information. This will create a README.md suitable for uploading to your git repo, and a forum_info.txt, which can be copy-pasted into a forum post.
</p>
<p>So to sum up, the Info.lua file contains the plugins' commands, console commands, their permissions and possibly the overall plugin documentation, in a structured manner that can be parsed by a program, yet is human readable and editable.</p>
<hr />
<a name="Overall"><h2>The overall structure</h2></a>
<p>The file consist of a declaration of a single Lua table, g_PluginInfo. This table contains all the information, structured, as its members. Each member can be a structure by itself. The entire file is a valid Lua source file, so any tool that syntax-checks Lua source can syntax-check this file. The file is somewhat forward- and backward- compatible, in the sense that it can be extended in any way without breaking.</p>
<p>Here's a skeleton of the file:</p>
<pre class="prettyprint lang-lua">
g_PluginInfo =
{
Name = "Example Plugin",
Date = "2014-06-12",
Description = "This is an example plugin that shows how to use the Info.lua file",
-- The following members will be documented in greater detail later:
AdditionalInfo = {},
Commands = {},
ConsoleCommands = {},
Permissions = {},
Categories = {},
}
</pre>
<p>As you can see, the structure is pretty straightforward. Note that the order of the elements inside the table is not important (Lua property).</p>
<p>The first few elements are for book-keeping. They declare the plugin's name, the date in ISO-format, representing the version of the plugin, and the description. The idea is that the description sums up what the plugin is all about, within some two or three sentences.</p>
<hr />
<a name="AdditionalInfo"><h2>AdditionalInfo table</h2></a>
<p>This table is used for more detailed description of the plugin. If there is any non-trivial setup process, dependencies, describe them here. This is where the description should get detailed. Don't worry about using several paragraphs of text here, if it makes the plugin easier to understand.</p>
<p>The table should have the following layout:</p>
<pre class="prettyprint lang-lua">
AdditionalInfo =
{
{
Title = "Chapter 1",
Contents = "Describe one big aspect of the plugin here",
},
{
Title = "Chapter 2",
Contents = "Describe another big topic",
},
}
</pre>
<p>The idea here is that the tool that is used to generate the documentation from the Info.lua file will create a linkified table of contents and then each of the information elements' contents. This information should be all that is needed to successfully configure, run and manage the plugin.</p>
<hr />
<a name="Commands"><h2>Commands table</h2></a>
<p>The commands table lists all the commands that the plugin implements, together with their handler functions, required permissions, help strings and further information. The table supports recursion, which allows plugins to create multi-word commands easily (such as "//schematic load" and "//schematic save"), each having its own separate handler.</p>
<p>The table uses structure similar to the following:</p>
<pre class="prettyprint lang-lua">
Commands =
{
["/cmd1"] =
{
HelpString = "Performs the first action",
Permission = "firstplugin.cmds.1",
Alias = "/c1",
Handler = HandleCmd1,
ParameterCombinations =
{
{
Params = "x y z",
Help = "Performs the first action at the specified coordinates",
},
{
Params = "-p",
Help = "Performs the first action at the player's coordinates",
}
},
},
["/cmd2"] =
{
Alias = {"/c2", "//c2" },
Category = "Something",
Subcommands =
{
sub1 = -- This declares a "/cmd2 sub1" command
{
HelpString = "Performs the second action's first subcommand",
Permission = "firstplugin.cmds.2.1",
Alias = "1",
Handler = HandleCmd2Sub1,
ParameterCombinations =
{
{
Params = "x y z",
Help = "Performs the second action's first subcommand at the specified coordinates",
},
{
Params = "-p",
Help = "Performs the second action's first subcommand at the player's coordinates",
}
},
},
sub2 = -- Declares a "/cmd2 sub2" command
{
HelpString = "Performs the second action's second subcommand",
Permission = "firstplugin.cmds.2.2",
Handler = HandleCmd2Sub2,
},
},
},
}
</pre>
<p>Although it may seem overwhelming at first, there is a "method to this madness". Each element of the Commands table defines one command. Most commands start with a slash, so the special Lua syntax for table elements with non-standard names needs to be applied (<code>["/cmd1"] =</code>). The command can either specify subcommands, or a handler function (specifying both is UndefinedBehavior). Subcommands uses the same structure as the entire Commands table, recursively.</p>
<p>The permission element specifies that the command is only available with the specified permission. Note that the permission for subcommand's parent isn't checked when the subcommand is called. This means that specifying the permission for a command that has subcommands has no effect whatsoever, but is discouraged because we may add processing for that in the future.</p>
<p>The optional Categories table provides descriptions for command categories in the generated documentation. The documentation generator will group the commands by their specified Category ("General" by default) and each category will have the specified description written to it.</p>
<p>The ParameterCombinations table is used only for generating the documentation, it lists the various combinations of parameters that the command supports. It's worth specifying even if the command supports only one combination, because that combination will get documented this way.</p>
<p>The Alias member specifies any possible aliases for the command. Each alias is registered separately and if there is a subcommand table, it is applied to all aliases, just as one would expect. You can specify either a single string as the value (if there's only one alias), or a table of strings for multiple aliases. Commands with no aliases do not need to specify this member at all.</p>
<hr />
<a name="ConsoleCommands"><h2>ConsoleCommands table</h2>
<p>This table serves a purpose similar to that of the Commands table, only these commands are provided for the server console. Therefore, there are no permissions specified for these commands. Since most console commands don't use a leading slash, the command names don't need the special syntax. Also, the handler function doesn't receive the Player parameter.</p>
<p>Here's an example of a ConsoleCommands table:</p>
<pre class="prettyprint lang-lua">
ConsoleCommands =
{
concmd =
{
HelpString = "Performs the console action",
Subcommands =
{
sub1 =
{
HelpString = "Performs the console action's first subcommand",
Handler = HandleConCmdSub1,
ParameterCombinations =
{
{
Params = "x y z",
Help = "Performs the console action's first subcommand at the specified coordinates",
},
},
},
sub2 =
{
HelpString = "Performs the console action's second subcommand",
Handler = HandleConCmdSub2,
},
},
},
}
</pre>
<hr />
<a name="Permissions"><h2>Permissions table</h2></a>
<p>The purpose of this table is to document permissions that the plugin uses. The documentation generator automatically collects the permissions specified in the Command table; the Permissions table adds a description for these permissions and may declare other permissions that aren't specifically included in the Command table.</p>
<pre class="prettyprint lang-lua">
Permissions =
{
["firstplugin.cmd.1.1"] =
{
Description = "Allows the players to build high towers using the first action.",
RecommendedGroups = "players",
},
["firstplugin.cmd.2.1"] =
{
Description = "Allows the players to kill entities using the second action. Note that this may be misused to kill other players, too.",
RecommendedGroups = "admins, mods",
},
}
</pre>
<p>The RecommendedGroup element lists, in plain English, the intended groups for which the permission should be enabled on a typical server. Plugin authors are advised to create reasonable defaults, prefering security to openness, so that admins using these settings blindly don't expose their servers to malicious users.</p>
<hr />
<a name="Categories"><h2>Categories</h2></a>
<p>The optional Categories table provides descriptions for categories in the generated documentation. Commands can have categories with or without category descriptions in this table. The documentation generator will output a table of listed categories along with their description.</p>
<pre class="prettyprint lang-lua">
Categories =
{
General =
{
Description = "A general, yet somehow vague description of the default category."
},
Something =
{
Description = "Some descriptive words which form sentences pertaining to this set of commands use and goals."
},
},
</pre>
<hr />
<a name="Using"><h2>Using the file in code</h2></a>
<p>Just writing the Info.lua file and saving it to the plugin folder is not enough for it to actually be used. Your plugin needs to include the following boilerplate code, preferably in its Initialize() function:</p>
<pre class="prettyprint lang-lua">
-- Use the InfoReg shared library to process the Info.lua file:
dofile(cPluginManager:GetPluginsPath() .. "/InfoReg.lua")
RegisterPluginInfoCommands()
RegisterPluginInfoConsoleCommands()
</pre>
<p>Of course, if your plugin doesn't have any console commands, it doesn't need to call the RegisterPluginInfoConsoleCommands() function, and similarly if it doesn't have any in-game commands, it doesn't need to call the RegisterPluginInfoCommands() function.</p>
<hr />
<a name="Examples"><h2>Examples</h2></a>
<p>There are several plugins that already implement this approach. You can visit them for inspiration and to see what the generated documentation looks like:</p>
<ul>
<li>Gallery plugin: <a href="https://github.com/cuberite/gallery/blob/master/Info.lua">Info.lua</a>, <a href="https://forum.cuberite.org/thread-1306.html">Forum</a> documentation</li>
<li>WorldEdit plugin: <a href="https://github.com/cuberite/WorldEdit/blob/master/Info.lua">Info.lua</a>, <a href="https://forum.cuberite.org/thread-870.html">Forum</a> and <a href="https://github.com/cuberite/WorldEdit">MarkDown</a> documentation</li>
</ul>
<script>
prettyPrint();
</script>
</div>
</body>
</html>

View File

@ -0,0 +1,191 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
Copyright 2011 Mike Samuel et al
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html>
<head>
<title>Cuberite - Setting up Decoda</title>
<link rel="canonical" href="https://api.cuberite.org/SettingUpDecoda.html">
<link rel="stylesheet" type="text/css" href="main.css" />
<link rel="stylesheet" type="text/css" href="prettify.css" />
<script src="prettify.js"></script>
<script src="lang-lua.js"></script>
<meta charset="UTF-8">
</head>
<body>
<div id="content">
<h1>Setting up the Decoda IDE</h1>
<p>
This article will explain how to set up Decoda, an IDE for writing Lua code, so that you can develop Cuberite plugins with the comfort of an IDE.</p>
<h2><img src="Static/decoda_logo.png" /> About Decoda</h2>
<p>To quickly introduce Decoda, it is an IDE for writing Lua code. It has the basic features expected of an IDE - you can group files into project, you can edit multiple files in a tabbed editor, the code is syntax-highlighted. Code completion, symbol browsing, and more. It also features a Lua debugger that allows you to debug your Lua code within any application that embeds the Lua runtime or uses Lua as a dynamic-link library (DLL). Although it is written using the multiplatform WxWidgets toolkit, it hasn't yet been ported to any platform other than 32-bit Windows. This unfortunately means that Linux users will not be able to use it. It can be used on 64-bit Windows, but the debugger only works for 32-bit programs.</p>
<p>Here's a screenshot of a default Decoda window with the debugger stepping through the code (scaled down):<br />
<img src="Static/decoda_workspace.png" /></p>
<p>As you can see, you can set breakpoints in the code, inspect variables' values, view both the Lua and native (C++) call-stacks. Decoda also breaks program execution when a faulty Lua script is executed, providing a detailed error message and pointing you directly to the faulting code. It is even possible to attach a C++ debugger to a process that is being debugged by Decoda, this way you can trap both C++ and Lua errors.</p>
<p>Decoda is open-source, the sources are on GitHub: <a href="https://github.com/unknownworlds/decoda">https://github.com/unknownworlds/decoda</a>. You can download a compiled binary from the creators' site, <a href="https://unknownworlds.com/decoda/">https://unknownworlds.com/decoda/</a>.
<h2><img src="Static/decoda_logo.png" /> Project management</h2>
<p>To begin using Decoda, you need to create a project, or load an existing one. Decoda projects have a .deproj extension, and are simply a list of Lua files that are to be opened. You can create a project through menu Project -> New Project. Save your project first, so that Decoda knows what relative paths to use for the files. Then either add existing Lua files or create new one, through menu Project -> Add Add New File / Add Existing File.</p>
<p>Next you need to set up the executable that Decoda will run when debugging your files. Select menu Project -> Settings. A new dialog will open:<br />
<img src="Static/decoda_debug_settings.png" /></p>
<p>In the debugging section, fill in the full path to Cuberite.exe, or click the triple-dot button to browse for the file. Note that the Working directory will be automatically filled in for you with the folder where the executable is (until the last backslash). This is how it's supposed to work, don't change it; if it for some reason doesn't update, copy and paste the folder name from the Command edit box. All done, you can close this dialog now.</p>
<h2><img src="Static/decoda_logo.png" /> Debugging</h2>
<p>You are now ready to debug your code. Before doing that, though, don't forget to save your project file. If you haven't done so already, enable your plugin in the settings.ini file. If you want the program to break at a certain line, it is best to set the breakpoint before starting the program. Set the cursor on the line and hit F9 (or use menu Debug -> Toggle Breakpoint) to toggle a breakpoint on that line. Finally, hit F5, or select menu Debug -> Start to launch Cuberite under the debugger. The Cuberite window comes up and loads your plugin. If Decoda displays the Project Settings dialog instead, you haven't set up the executable to run, see the Project management section for instructions.</p>
<p>At this point you will see that Decoda starts adding new items to your project. All the files for all plugins are added temporarily. Don't worry, they are only temporary, they will be removed again once the debugging session finishes. You can tell the temporary files from the regular files by their icon, it's faded out. Decoda handles all the files that Cuberite loads, so you can actually debug any of those faded files, too.</p>
<p>If there's an error in the code, the Decoda window will flash and a dialog box will come up, describing the error and taking you to the line where it occured. Note that the execution is paused in the thread executing the plugin, so until you select Debug -> Continue from the menu (F5), Cuberite won't be fully running. You can fix the error and issue a "reload" command in Cuberite console to reload the plugin code anew (Cuberite doesn't detect changes in plugin code automatically).</p>
<p>If the execution hits a breakpoint, the Decoda window will flash and a yellow arrow is displayed next to the line. You can step through the code using F10 and F11, just like in MSVS. You can also use the Watch window to inspect variable values, or simply hover your mouse over a variable to display its value in the tooltip.</p>
<h2><img src="Static/decoda_logo.png" /> Limitations</h2>
<p>So far everything seems wonderful. Unfortunately, it doesn't always go as easy. There are several limits to what Decoda can do:</p>
<ul>
<li>When the program encounters a logical bug (using a nil value, calling a non-existent function etc.), Decoda will break, but usually the Watch window and the tooltips are showing nonsense values. You shouldn't trust them in such a case, if you kep running into such a problem regularly, put console logging functions (LOG) in the code to print out any info you need prior to the failure.</li>
<li>Sometimes breakpoints just don't work. This is especially true if there are multiple plugins that have files of the same name. Breakpoints will never work after changing the code and reloading the plugin in Cuberite; you need to stop the server and start again to reenable breakpoints.</li>
<li>Most weirdly, sometimes Decoda reports an error, but instead of opening the current version of the file, opens up another window with old contents of the file. Watch for this, because you could overwrite your new code if you saved this file over your newer file. Fortunately enough, Decoda will always ask you for a filename before saving such a file.</li>
<li>Decoda stores the project in two files. The .deproj file has the file list, and should be put into version control systems. The .deuser file has the settings (debugged application etc.) and is per-user specific. This file shouldn't go to version control systems, because each user may have different paths for the debuggee.</li>
<li>Unfortunately for us Windows users, the Decoda project file uses Unix-lineends (CR only). This makes it problematic when checking the file into a version control system, since those usually expect windows (CRLF) lineends; I personally convert the lineends each time I edit the project file using <a href="http://jsimlo.sk/notepad/">TED Notepad</a>.</li>
</ul>
</div>
</body>
</html>

View File

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html>
<head>
<title>Cuberite - Setting up ZeroBrane Studio</title>
<link rel="canonical" href="https://api.cuberite.org/SettingUpZeroBrane.html">
<link rel="stylesheet" type="text/css" href="main.css" />
<link rel="stylesheet" type="text/css" href="prettify.css" />
<script src="prettify.js"></script>
<script src="lang-lua.js"></script>
<meta charset="UTF-8">
</head>
<body>
<div id="content">
<h1>Setting up the ZeroBrane Studio IDE</h1>
<p>
This article will explain how to set up ZeroBrane Studio, an IDE for writing Lua code, so that you can develop Cuberite plugins with the comfort of an IDE.</p>
<h2><img src="Static/zbs_logo.png" /> About ZeroBrane Studio</h2>
<p>To quickly introduce ZeroBrane Studio, it is an IDE for writing Lua code. It has the basic features expected of an IDE - it allows you to manage groups of files as a project, you can edit multiple files in a tabbed editor, the code is syntax-highlighted. Code completion, symbol browsing, and more. It also features a Lua debugger that allows you to debug your Lua code within any application that uses Lua and can load Lua packages. It is written using the multiplatform WxWidgets toolkit, and runs on multiple platforms, including Windows, Linux and MacOS.</p>
<p>Here's a screenshot of a default ZBS window with the debugger stepping through the code (scaled down):<br />
<img src="Static/zbs_workspace.png" /></p>
<p>As you can see, you can set breakpoints in the code, inspect variables' values, view the Lua call-stacks.</p>
<p>ZBS is open-source, the sources are on GitHub: <a href="https://github.com/pkulchenko/ZeroBraneStudio">https://github.com/pkulchenko/ZeroBraneStudio</a>. The project's homepage is at <a href="https://studio.zerobrane.com/">https://studio.zerobrane.com/</a>.
<h2><img src="Static/zbs_logo.png" /> First-time setup</h2>
<p>Since ZBS is a universal Lua IDE, you need to first set it up so that it is ready for Cuberite plugin development. For that, you need to download one file, <a href="https://raw.githubusercontent.com/pkulchenko/ZeroBranePackage/master/cuberite.lua">cuberite.lua</a> from the <a href="https://github.com/pkulchenko/ZeroBranePackage">ZBS's plugin repository</a>. Place that file in the "packages" folder inside your ZBS's folder. Note that there are other useful plugins in the repository and you may want to have a look there later on to further customize your ZBS. To install them, simply save them into the same folder.</p>
<p>Next you should install the code-completion support specific for Cuberite. You should repeat this step from time to time, because the API evolves in time so new functions and classes are added to it quite often. You should have an APIDump plugin in your Cuberite installation. Enable the APIDump plugin in the server settings, it's very cheap to keep it enabled and it doesn't cost any performance during normal gameplay. To generate the code-completion support file, enter the <code style="background: #ddd; border: 1px solid #aaa">api</code> command into the server console. This will create a new file, "cuberite_api.lua", next to the Cuberite executable. Move that file into the "api/lua" subfolder inside your ZBS's folder. (Note that if you had the "mcserver_api.lua" file from previous versions, you should remove it)</p>
<p>After you download the cuberite.lua file and install the completion support, you need to restart ZBS in order for the plugin to load. If there are no errors, you should see two new items in the Project -> Lua Interpreter submenu: "Cuberite - debug mode" and "Cuberite - release mode". The only difference between the two is which filename they use to launch Cuberite - cuberite_debug(.exe) for the debug option and "cuberite(.exe)" for the release option. If you built your own Cuberite executable and you built it in debug mode, you should select the debug mode option. In all other cases, including if you downloaded the already-compiled Cuberite executable from the internet, you should select the release mode option.</p>
<p>For a first time user, it might be a bit overwhelming that there are no GUI settings in the ZBS, yet the IDE is very configurable. There are two files that you edit in order to change settings, either system-wide (all users of the computer share those settings) or user-wide (the settings are only for a specific user of the computer). Those files are regular Lua sources and you can quickly locate them and edit them from within the IDE itself, select Edit -> Preferences -> Settings: XYZ from the menu, with XYZ being either System or User.</p>
<p>There is a documentation on most of the settings on ZBS's webpage, have a look at <a href="https://studio.zerobrane.com/documentation.html">https://studio.zerobrane.com/documentation.html</a>, especially the Preferences section. Personally I recommend setting editor.usetabs to true and possibly adjusting the editor.tabwidth, turn off the editor.smartindent feature and for debugging the option debugger.alloweditting should be set to true unless you feel like punishing yourself.</p>
<h2><img src="Static/zbs_logo.png" /> Project management</h2>
<p>ZBS works with projects, it considers all files and subfolder in a specific folder to be a project. There's no need for a special project file nor for adding individual files to the workspace, all files are added automatically. To open a Cuberite plugin as the project, click the triple-dot button in the Project pane, or select Project -> Project directory -> Choose... from the menu. Browse and select the Cuberite plugin's folder. ZBS will load all the files in the plugin's folder and you can start editting code.</p>
<p>Note that although ZBS allows you to work with subfolders in your plugins (and you should, especially with larger plugins), the current Cuberite ZBS plugin will not be able to start debugging unless you have a file open in the editor that is at the root level of the Cuberite plugin's folder.</p>
<h2><img src="Static/zbs_logo.png" /> Debugging</h2>
<p>You are now ready to debug your code. Before doing that, though, don't forget to save your project files. If you haven't done so already, enable your plugin in the settings.ini file. If you want the program to break at a certain line, it is best to set the breakpoint before starting the program. Set the cursor on the line and hit F9 (or use menu Project -> Toggle Breakpoint) to toggle a breakpoint on that line. Finally, hit F5, or select menu Project -> Start Debugging to launch Cuberite under the debugger. The Cuberite window comes up and loads your plugin. If the window doesn't come up, inspect the Output pane in ZBS, there are usually two reasons for failure:<ul>
<li>Your code in the currently open file has a hard syntax error. These are reported as "Compilation error" in the Output pane, double-click the line to go to the error</li>
<li>ZBS cannot find the Cuberite executable. Make sure you are editting a file two or three levels down the folder hierarchy from the Cuberite executable and that the Cuberite executable is named properly (cuberite[.exe] or cuberite_debug[.exe]). Also make sure you have selected the right Interpreter (menu Project -> Lua Interpreter).</li>
</ul></p>
<p>Once running, if the execution hits a breakpoint, the ZBS window will come up and a green arrow is displayed next to the breakpoint line. You can step through the code using F10 (Step Into) and Shift+F10 (Step Over). You can also use the Watch window to inspect variable values, or simply hover your mouse over a variable to display its value in the tooltip. Use the Remote console pane to execute commands directly *inside* the Cuberite's plugin context.</p>
<p>You can also use the Project -> Break menu item to break into the debugger as soon as possible. You can also set breakpoints while the Cuberite plugin is running. Note that due to the way in which the debugger is implemented, Cuberite may execute some more Lua code before the break / breakpoint comes into effect. If Cuberite is not executing any Lua code in your plugin, it will not break until the plugin code kicks in again. This may result in missed breakpoints and delays before the Break command becomes effective. Therefore it's best to set breakpoints before running the program, or while the program is waiting in another breakpoint.</p>
</div>
</body>
</html>

View File

@ -0,0 +1 @@

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Some files were not shown because too many files have changed in this diff Show More