cRoot


Index:
Articles
Classes
Hooks

Quick navigation:
cArrowEntity
cBeaconEntity
cBlockArea
cBlockEntity
cBlockEntityWithItems
cBlockInfo
cBoundingBox
cBrewingstandEntity
cChatColor
cChestEntity
cChunkDesc
cClientHandle
cCommandBlockEntity
cCompositeChat
cCraftingGrid
cCraftingRecipe
cCryptoHash
cCuboid
cDispenserEntity
cDropperEntity
cDropSpenserEntity
cEnchantments
cEntity
cEntityEffect
cExpBottleEntity
cFile
cFireChargeEntity
cFireworkEntity
cFloater
cFlowerPotEntity
cFurnaceEntity
cGhastFireballEntity
cHangingEntity
cHopperEntity
cIniFile
cInventory
cItem
cItemFrame
cItemGrid
cItems
cJson
cJukeboxEntity
cLineBlockTracer
cLuaWindow
cMap
cMapManager
cMobHeadEntity
cMobSpawnerEntity
cMojangAPI
cMonster
cNetwork
cNoteEntity
cObjective
cPainting
cPawn
cPickup
cPlayer
cPlugin
cPluginLua
cPluginManager
cProjectileEntity
cRankManager
cRoot
cScoreboard
cServer
cServerHandle
cSignEntity
cSplashPotionEntity
cStatManager
cStringCompression
cTCPLink
cTeam
cThrownEggEntity
cThrownEnderPearlEntity
cThrownSnowballEntity
cTNTEntity
cTracer
cUDPEndpoint
cUrlClient
cUrlParser
cWebAdmin
cWindow
cWitherSkullEntity
cWorld
HTTPFormData
HTTPRequest
HTTPTemplateRequest
ItemCategory
lxp
sqlite3
TakeDamageInfo
tolua
Vector3d
Vector3f
Vector3i
Globals

Contents


cRoot class

This class represents the root of Cuberite's object hierarchy. There is always only one cRoot object. It manages and allows querying all the other objects, such as cServer, cPluginManager, individual worlds etc.

To get the singleton instance of this object, you call the cRoot:Get() function. Then you can call the individual functions on this object. Note that some of the functions are static and don't need the instance, they are to be called directly on the cRoot class, such as cRoot:GetPhysicalRAMUsage()


Functions

NameParametersReturn valueNotes
BroadcastChat MessageText, MessageType Broadcasts a message to all players, with its message type set to MessageType (default: mtCustom).
BroadcastChat CompositeChat Broadcasts a composite chat message to all players.
BroadcastChatDeath MessageText Broadcasts the specified message to all players, with its message type set to mtDeath. Use for when a player has died.
BroadcastChatFailure MessageText Broadcasts the specified message to all players, with its message type set to mtFailure. Use for a command that failed to run because of insufficient permissions, etc.
BroadcastChatFatal MessageText Broadcasts the specified message to all players, with its message type set to mtFatal. Use for a plugin that crashed, or similar.
BroadcastChatInfo MessageText Broadcasts the specified message to all players, with its message type set to mtInfo. Use for informational messages, such as command usage.
BroadcastChatJoin MessageText Broadcasts the specified message to all players, with its message type set to mtJoin. Use for players joining the server.
BroadcastChatLeave MessageText Broadcasts the specified message to all players, with its message type set to mtLeave. Use for players leaving the server.
BroadcastChatSuccess MessageText Broadcasts the specified message to all players, with its message type set to mtSuccess. Use for success messages.
BroadcastChatWarning MessageText Broadcasts the specified message to all players, with its message type set to mtWarning. Use for concerning events, such as plugin reload etc.
DoWithPlayerByUUID PlayerUUID, CallbackFunction bool If there is the player with the uuid, calls the CallbackFunction with the cPlayer parameter representing the player. The CallbackFunction has the following signature:
function Callback(Player)
The function returns false if the player was not found, or whatever bool value the callback returned if the player was found.
FindAndDoWithPlayer PlayerName, CallbackFunction bool Calls the given callback function for the player with the name best matching the name string provided.
This function is case-insensitive and will match partial names.
Returns false if player not found or there is ambiguity, true otherwise. The CallbackFunction has the following signature:
function Callback(Player)
ForEachPlayer CallbackFunction Calls the given callback function for each player. The callback function has the following signature:
function Callback(cPlayer)
ForEachWorld CallbackFunction Calls the given callback function for each world. The callback function has the following signature:
function Callback(cWorld)
Get Root object (STATIC) This function returns the cRoot object.
GetBrewingRecipe cItem, cItem cItem (STATIC) Returns the result item, if a recipe has been found. If no recipe is found, returns no value.
GetBuildCommitID string (STATIC) For official builds (Travis CI / Jenkins) it returns the exact commit hash used for the build. For unofficial local builds, returns the approximate commit hash (since the true one cannot be determined), formatted as "approx: <CommitHash>".
GetBuildDateTime string (STATIC) For official builds (Travic CI / Jenkins) it returns the date and time of the build. For unofficial local builds, returns the approximate datetime of the commit (since the true one cannot be determined), formatted as "approx: <DateTime-iso8601>".
GetBuildID string (STATIC) For official builds (Travis CI / Jenkins) it returns the unique ID of the build, as recognized by the build system. For unofficial local builds, returns the string "Unknown".
GetBuildSeriesName string (STATIC) For official builds (Travis CI / Jenkins) it returns the series name of the build (for example "Cuberite Windows x64 Master"). For unofficial local builds, returns the string "local build".
GetCraftingRecipes cCraftingRecipe Returns the CraftingRecipes object
GetDefaultWorld cWorld Returns the world object from the default world.
GetFurnaceFuelBurnTime Fuel number (STATIC) Returns the number of ticks for how long the item would fuel a furnace. Returns zero if not a fuel.
GetFurnaceRecipe InItem OutItem, NumTicks, InItem (STATIC) Returns the furnace recipe for smelting the specified input. If a recipe is found, returns the smelted result, the number of ticks required for the smelting operation, and the input consumed (note that Cuberite supports smelting M items into N items and different smelting rates). If no recipe is found, returns no value.
GetPhysicalRAMUsage number Returns the amount of physical RAM that the entire Cuberite process is using, in KiB. Negative if the OS doesn't support this query.
GetPluginManager cPluginManager Returns the cPluginManager object.
GetProtocolVersionTextFromInt Protocol Version string Returns the Minecraft version from the given Protocol. If there is no version found, it returns 'Unknown protocol(Parameter)'
GetServer cServer Returns the cServer object.
GetServerUpTime number Returns the uptime of the server in seconds.
GetTotalChunkCount number Returns the amount of loaded chunks.
GetVirtualRAMUsage number Returns the amount of virtual RAM that the entire Cuberite process is using, in KiB. Negative if the OS doesn't support this query.
GetWebAdmin cWebAdmin Returns the cWebAdmin object.
GetWorld WorldName cWorld Returns the cWorld object of the given world. It returns nil if there is no world with the given name.
QueueExecuteConsoleCommand Message Queues a console command for execution through the cServer class. The command will be executed in the tick thread. The command's output will be sent to console.
SaveAllChunks Saves all the chunks in all the worlds. Note that the saving is queued on each world's tick thread and this functions returns before the chunks are actually saved.

Querying a furnace recipe

To find the furnace recipe for an item, use the following code (adapted from the Debuggers plugin's /fr command):
local HeldItem = a_Player:GetEquippedItem();
local Out, NumTicks, In = cRoot:GetFurnaceRecipe(HeldItem);  -- Note STATIC call - no need for a Get()
if (Out ~= nil) then
	-- There is a recipe, list it:
	a_Player:SendMessage(
		"Furnace turns " .. ItemToFullString(In) ..
		" to " .. ItemToFullString(Out) ..
		" in " .. NumTicks .. " ticks (" ..
		tostring(NumTicks / 20) .. " seconds)."
	);
else
	-- No recipe found
	a_Player:SendMessage("There is no furnace recipe that would smelt " .. ItemToString(HeldItem));
end
Generated on 2016-08-22 23:53:06, Build ID Unknown, Commit approx: 2ed4af74edd14ae17e1c6c64d44caa7b7fc30d5a