summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-02-03 23:46:56 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-02-03 23:46:56 +0100
commit3583a58cf7bbeb867e568f4210f270cd5058e9f3 (patch)
treee9f569df63724298f6ebee0bf5bf623bf06efb1a /src
parentPartial fix for #130 (diff)
downloadcuberite-3583a58cf7bbeb867e568f4210f270cd5058e9f3.tar
cuberite-3583a58cf7bbeb867e568f4210f270cd5058e9f3.tar.gz
cuberite-3583a58cf7bbeb867e568f4210f270cd5058e9f3.tar.bz2
cuberite-3583a58cf7bbeb867e568f4210f270cd5058e9f3.tar.lz
cuberite-3583a58cf7bbeb867e568f4210f270cd5058e9f3.tar.xz
cuberite-3583a58cf7bbeb867e568f4210f270cd5058e9f3.tar.zst
cuberite-3583a58cf7bbeb867e568f4210f270cd5058e9f3.zip
Diffstat (limited to 'src')
-rw-r--r--src/Defines.h70
-rw-r--r--src/Entities/Player.h3
2 files changed, 72 insertions, 1 deletions
diff --git a/src/Defines.h b/src/Defines.h
index 5b868b2e5..17885394e 100644
--- a/src/Defines.h
+++ b/src/Defines.h
@@ -1,6 +1,8 @@
#pragma once
+#include "ChatColor.h"
+
@@ -441,7 +443,73 @@ inline float GetSpecialSignf( float a_Val )
-// tolua_begin
+enum ChatPrefixCodes
+{
+ // http://forum.mc-server.org/showthread.php?tid=1212
+ // MessageType...
+
+ mtCustom, // Plugin prints what it wants
+ mtFailure, // Something could not be done (i.e. command not executed due to insufficient privilege)
+ mtInformation, // Informational message (i.e. command usage)
+ mtSuccess, // Something executed successfully
+ mtWarning, // Something concerning (i.e. reload) is about to happen
+ mtFatal, // Something catastrophic occured (i.e. plugin crash)
+ mtDeath, // Denotes death of player
+ mtPrivateMessage // Player to player messaging identifier
+};
+
+
+
+
+inline AString AppendChatEpithet(const AString & a_ChatMessage, ChatPrefixCodes a_ChatPrefix)
+{
+ switch (a_ChatPrefix)
+ {
+ case mtCustom: return a_ChatMessage;
+ case mtFailure:
+ {
+ AString Message(Printf("%s[INFO] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str()));
+ Message.append(a_ChatMessage);
+ return Message;
+ }
+ case mtInformation:
+ {
+ AString Message(Printf("%s[INFO] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str()));
+ Message.append(a_ChatMessage);
+ return Message;
+ }
+ case mtSuccess:
+ {
+ AString Message(Printf("%s[INFO] %s", cChatColor::Green.c_str(), cChatColor::White.c_str()));
+ Message.append(a_ChatMessage);
+ return Message;
+ }
+ case mtWarning:
+ {
+ AString Message(Printf("%s[WARN] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str()));
+ Message.append(a_ChatMessage);
+ return Message;
+ }
+ case mtFatal:
+ {
+ AString Message(Printf("%s[FATAL] %s", cChatColor::Red.c_str(), cChatColor::White.c_str()));
+ Message.append(a_ChatMessage);
+ return Message;
+ }
+ case mtDeath:
+ {
+ AString Message(Printf("%s[DEATH] %s", cChatColor::Gray.c_str(), cChatColor::White.c_str()));
+ Message.append(a_ChatMessage);
+ return Message;
+ }
+ case mtPrivateMessage:
+ {
+ AString Message(Printf("%s[MSG] %s%s", cChatColor::LightBlue.c_str(), cChatColor::White.c_str(), cChatColor::Italic.c_str()));
+ Message.append(a_ChatMessage);
+ return Message;
+ }
+ }
+}// tolua_begin
/// Normalizes an angle in degrees to the [-180, +180) range:
inline double NormalizeAngleDegrees(const double a_Degrees)
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 50f7560d6..764b47ae0 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -196,6 +196,9 @@ public:
cClientHandle * GetClientHandle(void) const { return m_ClientHandle; }
void SendMessage(const AString & a_Message);
+ void SendMessageInfo(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtInformation)); }
+ void SendMessageFailure(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtFailure)); }
+ void SendMessageSuccess(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtSuccess)); }
const AString & GetName(void) const { return m_PlayerName; }
void SetName(const AString & a_Name) { m_PlayerName = a_Name; }