cCompositeChat
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 | ContentscCompositeChat classEncapsulates a chat message that can contain various formatting, URLs, commands executed on click and commands suggested on click. The chat message can be sent by the regular chat-sending functions, cPlayer:SendMessage(), cWorld:BroadcastChat() and cRoot:BroadcastChat(). Note that most of the functions in this class are so-called chaining modifiers - they modify the object and then return the object itself, so that they can be chained one after another. See the Chaining example below for details. Each part of the composite chat message takes a "Style" parameter, this is a string that describes the formatting. It uses the following strings, concatenated together:
Functions
Chaining exampleSending a chat message that is composed of multiple different parts has been made easy thanks to chaining. Consider the following example that shows how a message containing all kinds of parts is sent (adapted from the Debuggers plugin):function OnPlayerJoined(a_Player) -- Send an example composite chat message to the player: a_Player:SendMessage(cCompositeChat() :AddTextPart("Hello, ") :AddUrlPart(a_Player:GetName(), "http://cuberite.org", "u@2") -- Colored underlined link :AddSuggestCommandPart(", and welcome.", "/help", "u") -- Underlined suggest-command :AddRunCommandPart(" SetDay", "/time set 0") -- Regular text that will execute command when clicked :SetMessageType(mtJoin) -- It is a join-message ) end |