summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
authorarchshift <admin@archshift.com>2014-04-26 18:21:49 +0200
committerarchshift <admin@archshift.com>2014-04-26 18:25:30 +0200
commitaef2c8ec628aa2522364da1333bc5158e55ac6a2 (patch)
treeda83f950fb33b4910d006499930b98fb231e2fd7 /src/ClientHandle.cpp
parentFixed mobs that don't naturally spawn. (diff)
downloadcuberite-aef2c8ec628aa2522364da1333bc5158e55ac6a2.tar
cuberite-aef2c8ec628aa2522364da1333bc5158e55ac6a2.tar.gz
cuberite-aef2c8ec628aa2522364da1333bc5158e55ac6a2.tar.bz2
cuberite-aef2c8ec628aa2522364da1333bc5158e55ac6a2.tar.lz
cuberite-aef2c8ec628aa2522364da1333bc5158e55ac6a2.tar.xz
cuberite-aef2c8ec628aa2522364da1333bc5158e55ac6a2.tar.zst
cuberite-aef2c8ec628aa2522364da1333bc5158e55ac6a2.zip
Diffstat (limited to 'src/ClientHandle.cpp')
-rw-r--r--src/ClientHandle.cpp78
1 files changed, 21 insertions, 57 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 7bfae9ca7..78402d4d3 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -186,53 +186,31 @@ void cClientHandle::GenerateOfflineUUID(void)
+AString cClientHandle::FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2)
+{
+ if (ShouldAppendChatPrefixes)
+ return Printf("%s%s %s", m_Color1.c_str(), a_ChatPrefixS.c_str(), m_Color2.c_str());
+ else
+ return Printf("%s", m_Color1.c_str());
+}
+
+
+
+
+
AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString &a_AdditionalData)
{
switch (a_ChatPrefix)
{
- case mtCustom: return AString();
- case mtFailure:
- {
- if (ShouldAppendChatPrefixes)
- return Printf("%s[INFO] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str());
- else
- return Printf("%s", cChatColor::Rose.c_str());
- }
- case mtInformation:
- {
- if (ShouldAppendChatPrefixes)
- return Printf("%s[INFO] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str());
- else
- return Printf("%s", cChatColor::Yellow.c_str());
- }
- case mtSuccess:
- {
- if (ShouldAppendChatPrefixes)
- return Printf("%s[INFO] %s", cChatColor::Green.c_str(), cChatColor::White.c_str());
- else
- return Printf("%s", cChatColor::Green.c_str());
- }
- case mtWarning:
- {
- if (ShouldAppendChatPrefixes)
- return Printf("%s[WARN] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str());
- else
- return Printf("%s", cChatColor::Rose.c_str());
- }
- case mtFatal:
- {
- if (ShouldAppendChatPrefixes)
- return Printf("%s[FATAL] %s", cChatColor::Red.c_str(), cChatColor::White.c_str());
- else
- return Printf("%s", cChatColor::Red.c_str());
- }
- case mtDeath:
- {
- if (ShouldAppendChatPrefixes)
- return Printf("%s[DEATH] %s", cChatColor::Gray.c_str(), cChatColor::White.c_str());
- else
- return Printf("%s", cChatColor::Gray.c_str());
- }
+ case mtCustom: return AString();
+ case mtFailure: return FormatChatPrefix(ShouldAppendChatPrefixes, "[INFO]", cChatColor::Rose, cChatColor::White);
+ case mtInformation: return FormatChatPrefix(ShouldAppendChatPrefixes, "[INFO]", cChatColor::Yellow, cChatColor::White);
+ case mtSuccess: return FormatChatPrefix(ShouldAppendChatPrefixes, "[INFO]", cChatColor::Green, cChatColor::White);
+ case mtWarning: return FormatChatPrefix(ShouldAppendChatPrefixes, "[WARN]", cChatColor::Rose, cChatColor::White);
+ case mtFatal: return FormatChatPrefix(ShouldAppendChatPrefixes, "[FATAL]", cChatColor::Red, cChatColor::White);
+ case mtDeath: return FormatChatPrefix(ShouldAppendChatPrefixes, "[DEATH]", cChatColor::Gray, cChatColor::White);
+ case mtJoin: return FormatChatPrefix(ShouldAppendChatPrefixes, "[JOIN]", cChatColor::Yellow, cChatColor::White);
+ case mtLeave: return FormatChatPrefix(ShouldAppendChatPrefixes, "[LEAVE]", cChatColor::Yellow, cChatColor::White);
case mtPrivateMessage:
{
if (ShouldAppendChatPrefixes)
@@ -240,20 +218,6 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage
else
return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue.c_str());
}
- case mtJoin:
- {
- if (ShouldAppendChatPrefixes)
- return Printf("%s[JOIN] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str());
- else
- return Printf("%s", cChatColor::Yellow.c_str());
- }
- case mtLeave:
- {
- if (ShouldAppendChatPrefixes)
- return Printf("%s[LEAVE] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str());
- else
- return Printf("%s", cChatColor::Yellow.c_str());
- }
}
ASSERT(!"Unhandled chat prefix type!");
}