cRoot


Index:
Articles
Classes
Hooks

Quick navigation:
BannerPattern
BossBarColor
BossBarDivisionType
cArrowEntity
cBeaconEntity
cBedEntity
cBlockArea
cBlockEntity
cBlockEntityWithItems
cBlockInfo
cBoat
cBoundingBox
cBrewingstandEntity
cChatColor
cChestEntity
cChunkDesc
cClientHandle
cColor
cCommandBlockEntity
cCompositeChat
cCraftingGrid
cCraftingRecipe
cCryptoHash
cCuboid
cDispenserEntity
cDropperEntity
cDropSpenserEntity
cEnchantments
cEnderCrystal
cEntity
cEntityEffect
cExpBottleEntity
cExpOrb
cFallingBlock
cFile
cFireChargeEntity
cFireworkEntity
cFloater
cFlowerPotEntity
cFurnaceEntity
cGhastFireballEntity
cHangingEntity
cHopperEntity
cIniFile
cInventory
cItem
cItemFrame
cItemGrid
cItems
cJson
cJukeboxEntity
cLeashKnot
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
cStringCompression
cTCPLink
cTeam
cThrownEggEntity
cThrownEnderPearlEntity
cThrownSnowballEntity
cTNTEntity
cUDPEndpoint
cUrlClient
cUrlParser
CustomStatistic
cUUID
cWebAdmin
cWindow
cWitherSkullEntity
cWorld
EffectID
HTTPFormData
HTTPRequest
HTTPTemplateRequest
ItemCategory
lxp
SmokeDirection
sqlite3
StatisticsManager
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
MessageTextstring
MessageTypeeMessageType
Broadcasts a message to all players, with its message type set to MessageType (default: mtCustom).
BroadcastChat
CompositeChatcCompositeChat
Broadcasts a composite chat message to all players.
BroadcastChatDeath
MessageTextstring
Broadcasts the specified message to all players, with its message type set to mtDeath. Use for when a player has died.
BroadcastChatFailure
MessageTextstring
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
MessageTextstring
Broadcasts the specified message to all players, with its message type set to mtFatal. Use for a plugin that crashed, or similar.
BroadcastChatInfo
MessageTextstring
Broadcasts the specified message to all players, with its message type set to mtInfo. Use for informational messages, such as command usage.
BroadcastChatJoin
MessageTextstring
Broadcasts the specified message to all players, with its message type set to mtJoin. Use for players joining the server.
BroadcastChatLeave
MessageTextstring
Broadcasts the specified message to all players, with its message type set to mtLeave. Use for players leaving the server.
BroadcastChatSuccess
MessageTextstring
Broadcasts the specified message to all players, with its message type set to mtSuccess. Use for success messages.
BroadcastChatWarning
MessageTextstring
Broadcasts the specified message to all players, with its message type set to mtWarning. Use for concerning events, such as plugin reload etc.
BroadcastPlayerListsHeaderFooter
HeadercCompositeChat
FootercCompositeChat
(undocumented)
DoWithPlayerByUUID
PlayerUUIDcUUID
CallbackFunctionfunction
boolean
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
PlayerNamestring
CallbackFunctionfunction
boolean
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
CallbackFunctionfunction
boolean
Calls the given callback function for each player. The callback function has the following signature:
function Callback(cPlayer)
ForEachWorld
CallbackFunctionfunction
boolean
Calls the given callback function for each world. The callback function has the following signature:
function Callback(cWorld)
. Returns false if a callback aborts, otherwise true.
Get
cRoot
(STATIC) Returns the one and only cRoot object.
GetBrewingRecipe
BottlecItem
IngredientcItem
cItem
(STATIC) Returns the result item, if a recipe has been found to brew the Ingredient into Bottle. 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
FuelcItem
number
(STATIC) Returns the number of ticks for how long the item would fuel a furnace. Returns zero if not a fuel.
GetFurnaceRecipe
InItemcItem
OutItemcItem
NumTicksnumber
InItemcItem
(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
(STATIC) 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
ProtocolVersionNumbernumber
string
(STATIC) Returns the Minecraft client version from the given Protocol version number. If there is no version found, it returns 'Unknown protocol (Number)'
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
(STATIC) 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
WorldNamestring
cWorld
Returns the cWorld object of the given world. It returns nil if there is no world with the given name.
QueueExecuteConsoleCommand
Messagestring
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.
SetSavingEnabled
SavingEnabledboolean
Sets whether saving chunk data is enabled for all worlds. If disabled, dirty chunks will stay in memory forever, which can cause performance and stability issues.

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 by APIDump on 2024-11-21 00:44:11, Build ID 74, Commit c0f6c97dcea08feb7d5cd1deefc0f6f76eb2cdbd