MCPcopy Create free account
hub / github.com/cuberite/cuberite / SendChat

Method SendChat

src/ClientHandle.cpp:1803–1908  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1801
1802
1803void cClientHandle::SendChat(const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData)
1804{
1805 bool ShouldAppendChatPrefixes = true;
1806
1807 if (GetPlayer()->GetWorld() == NULL)
1808 {
1809 cWorld * World = cRoot::Get()->GetWorld(GetPlayer()->GetLoadedWorldName());
1810 if (World == NULL)
1811 {
1812 World = cRoot::Get()->GetDefaultWorld();
1813 }
1814
1815 if (!World->ShouldUseChatPrefixes())
1816 {
1817 ShouldAppendChatPrefixes = false;
1818 }
1819 }
1820 else if (!GetPlayer()->GetWorld()->ShouldUseChatPrefixes())
1821 {
1822 ShouldAppendChatPrefixes = false;
1823 }
1824
1825 AString Message;
1826
1827 switch (a_ChatPrefix)
1828 {
1829 case mtCustom: break;
1830 case mtFailure:
1831 {
1832 if (ShouldAppendChatPrefixes)
1833 Message = Printf("%s[INFO] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str());
1834 else
1835 Message = Printf("%s", cChatColor::Rose.c_str());
1836 break;
1837 }
1838 case mtInformation:
1839 {
1840 if (ShouldAppendChatPrefixes)
1841 Message = Printf("%s[INFO] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str());
1842 else
1843 Message = Printf("%s", cChatColor::Yellow.c_str());
1844 break;
1845 }
1846 case mtSuccess:
1847 {
1848 if (ShouldAppendChatPrefixes)
1849 Message = Printf("%s[INFO] %s", cChatColor::Green.c_str(), cChatColor::White.c_str());
1850 else
1851 Message = Printf("%s", cChatColor::Green.c_str());
1852 break;
1853 }
1854 case mtWarning:
1855 {
1856 if (ShouldAppendChatPrefixes)
1857 Message = Printf("%s[WARN] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str());
1858 else
1859 Message = Printf("%s", cChatColor::Rose.c_str());
1860 break;

Callers 1

BroadcastChatMethod · 0.45

Calls 5

PrintfFunction · 0.85
GetDefaultWorldMethod · 0.80
ShouldUseChatPrefixesMethod · 0.80
c_strMethod · 0.80
GetWorldMethod · 0.45

Tested by

no test coverage detected