diff options
Diffstat (limited to '')
-rw-r--r-- | src/Defines.h | 56 | ||||
-rw-r--r-- | src/Entities/Player.h | 1 | ||||
-rw-r--r-- | src/Root.h | 4 | ||||
-rw-r--r-- | src/World.h | 12 |
4 files changed, 46 insertions, 27 deletions
diff --git a/src/Defines.h b/src/Defines.h index f766d4d04..7fe93399d 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -448,14 +448,15 @@ 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 + mtPrivateMessage, // Player to player messaging identifier + mtJoin, // A player has joined the server + mtLeave, // A player has left the server }; @@ -463,53 +464,60 @@ enum ChatPrefixCodes inline AString AppendChatEpithet(const AString & a_ChatMessage, ChatPrefixCodes a_ChatPrefix) { + AString Message; + 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; + Message = Printf("%s[INFO] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str()); + break; } case mtInformation: { - AString Message(Printf("%s[INFO] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str())); - Message.append(a_ChatMessage); - return Message; + Message = Printf("%s[INFO] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str()); + break; } case mtSuccess: { - AString Message(Printf("%s[INFO] %s", cChatColor::Green.c_str(), cChatColor::White.c_str())); - Message.append(a_ChatMessage); - return Message; + Message = Printf("%s[INFO] %s", cChatColor::Green.c_str(), cChatColor::White.c_str()); + break; } case mtWarning: { - AString Message(Printf("%s[WARN] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str())); - Message.append(a_ChatMessage); - return Message; + Message = Printf("%s[WARN] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str()); + break; } case mtFatal: { - AString Message(Printf("%s[FATAL] %s", cChatColor::Red.c_str(), cChatColor::White.c_str())); - Message.append(a_ChatMessage); - return Message; + Message = Printf("%s[FATAL] %s", cChatColor::Red.c_str(), cChatColor::White.c_str()); + break; } case mtDeath: { - AString Message(Printf("%s[DEATH] %s", cChatColor::Gray.c_str(), cChatColor::White.c_str())); - Message.append(a_ChatMessage); - return Message; + Message = Printf("%s[DEATH] %s", cChatColor::Gray.c_str(), cChatColor::White.c_str()); + break; } 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; + Message = Printf("%s[MSG] %s%s", cChatColor::LightBlue.c_str(), cChatColor::White.c_str(), cChatColor::Italic.c_str()); + break; + } + case mtJoin: + { + Message = Printf("%s[JOIN] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str()); + break; + } + case mtLeave: + { + Message = Printf("%s[LEAVE] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str()); + break; } default: ASSERT(!"Unhandled chat prefix type!"); return ""; } + + Message.append(a_ChatMessage); + return Message; } // tolua_begin diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 925011c9c..f2830a0c7 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -201,7 +201,6 @@ public: void SendMessageSuccess(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtSuccess)); } void SendMessageWarning(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtWarning)); } void SendMessageFatal(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtFailure)); } - void SendMessageDeath(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtDeath)); } void SendMessagePrivateMsg(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtPrivateMessage)); } const AString & GetName(void) const { return m_PlayerName; } diff --git a/src/Root.h b/src/Root.h index fa52c21a1..ba106b54e 100644 --- a/src/Root.h +++ b/src/Root.h @@ -104,6 +104,9 @@ public: /// Finds a player from a partial or complete player name and calls the callback - case-insensitive bool FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << + + void BroadcastChatJoin(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtJoin)); } + void BroadcastChatLeave(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtLeave)); } // tolua_begin @@ -115,7 +118,6 @@ public: void BroadcastChatWarning(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtWarning)); } void BroadcastChatFatal(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtFailure)); } void BroadcastChatDeath(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtDeath)); } - void BroadcastChatPrivateMsg(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtPrivateMessage)); } /// Returns the textual description of the protocol version: 49 -> "1.4.4". Provided specifically for Lua API static AString GetProtocolVersionTextFromInt(int a_ProtocolVersionNum); diff --git a/src/World.h b/src/World.h index bf6a4ba28..01481c049 100644 --- a/src/World.h +++ b/src/World.h @@ -157,7 +157,17 @@ public: void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = NULL); // tolua_export void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = NULL); void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); ///< If there is a block entity at the specified coods, sends it to all clients except a_Exclude - void BroadcastChat (const AString & a_Message, const cClientHandle * a_Exclude = NULL); // tolua_export + + // tolua_start + void BroadcastChat(const AString & a_Message, const cClientHandle * a_Exclude = NULL); + void BroadcastChatInfo(const AString & a_Message, const cClientHandle * a_Exclude = NULL) { BroadcastChat(AppendChatEpithet(a_Message, mtInformation)); } + void BroadcastChatFailure(const AString & a_Message, const cClientHandle * a_Exclude = NULL) { BroadcastChat(AppendChatEpithet(a_Message, mtFailure)); } + void BroadcastChatSuccess(const AString & a_Message, const cClientHandle * a_Exclude = NULL) { BroadcastChat(AppendChatEpithet(a_Message, mtSuccess)); } + void BroadcastChatWarning(const AString & a_Message, const cClientHandle * a_Exclude = NULL) { BroadcastChat(AppendChatEpithet(a_Message, mtWarning)); } + void BroadcastChatFatal(const AString & a_Message, const cClientHandle * a_Exclude = NULL) { BroadcastChat(AppendChatEpithet(a_Message, mtFailure)); } + void BroadcastChatDeath(const AString & a_Message, const cClientHandle * a_Exclude = NULL) { BroadcastChat(AppendChatEpithet(a_Message, mtDeath)); } + // tolua_end + void BroadcastChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL); void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL); void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); |