summaryrefslogtreecommitdiffstats
path: root/source/cPluginManager.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-18 12:38:15 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-18 12:38:15 +0200
commit1b5eaa92b562c09ed7cea4de7186ff6541e65e5f (patch)
tree7e196c6021c1777d25ad4d79bb6530fd933a65d4 /source/cPluginManager.cpp
parentPacket refactoring, phase two, partial. Rewritten a few packet handling functions not to use cPacket-descendant objects. (diff)
downloadcuberite-1b5eaa92b562c09ed7cea4de7186ff6541e65e5f.tar
cuberite-1b5eaa92b562c09ed7cea4de7186ff6541e65e5f.tar.gz
cuberite-1b5eaa92b562c09ed7cea4de7186ff6541e65e5f.tar.bz2
cuberite-1b5eaa92b562c09ed7cea4de7186ff6541e65e5f.tar.lz
cuberite-1b5eaa92b562c09ed7cea4de7186ff6541e65e5f.tar.xz
cuberite-1b5eaa92b562c09ed7cea4de7186ff6541e65e5f.tar.zst
cuberite-1b5eaa92b562c09ed7cea4de7186ff6541e65e5f.zip
Diffstat (limited to 'source/cPluginManager.cpp')
-rw-r--r--source/cPluginManager.cpp92
1 files changed, 43 insertions, 49 deletions
diff --git a/source/cPluginManager.cpp b/source/cPluginManager.cpp
index c64b466c2..dd1051762 100644
--- a/source/cPluginManager.cpp
+++ b/source/cPluginManager.cpp
@@ -191,55 +191,6 @@ bool cPluginManager::CallHook(PluginHook a_Hook, unsigned int a_NumArgs, ...)
{
HookMap::iterator Plugins = m_Hooks.find( a_Hook );
- // Special case for chat hook, since you can also bind commands (bound commands don't use chat hook)
- if (a_Hook == HOOK_CHAT)
- {
- if (a_NumArgs != 2)
- {
- return false;
- }
- va_list argptr;
- va_start( argptr, a_NumArgs);
- const char * Message = va_arg(argptr, const char* );
- cPlayer * Player = va_arg(argptr, cPlayer * );
- va_end (argptr);
-
-#ifdef USE_SQUIRREL
- if (m_SquirrelCommandBinder->HandleCommand( std::string( Message ), Player))
- {
- return true;
- }
-#endif
-
- if (m_LuaCommandBinder->HandleCommand( std::string( Message ), Player))
- {
- return true;
- }
-
- //Check if it was a standard command (starts with a slash)
- if(Message[0] == '/')
- {
- Player->SendMessage("Unknown Command");
- LOGINFO("Player \"%s\" issued command: %s", Player->GetName().c_str(), Message);
- return true; //Cancel sending
- }
-
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
-
- for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
- {
- if ((*itr)->OnChat(Message, Player))
- {
- return true;
- }
- }
-
- return false;
- }
-
if (Plugins == m_Hooks.end())
{
return false;
@@ -452,6 +403,49 @@ bool cPluginManager::CallHookBlockPlace(cPlayer * a_Player, int a_BlockX, int a_
+bool cPluginManager::CallHookChat(cPlayer * a_Player, const AString & a_Message)
+{
+ #ifdef USE_SQUIRREL
+ if (m_SquirrelCommandBinder->HandleCommand(a_Message, a_Player))
+ {
+ return true;
+ }
+ #endif // USE_SQUIRREL
+
+ if (m_LuaCommandBinder->HandleCommand(a_Message, a_Player))
+ {
+ return true;
+ }
+
+ //Check if it was a standard command (starts with a slash)
+ if (a_Message[0] == '/')
+ {
+ a_Player->SendMessage("Unknown Command");
+ LOGINFO("Player \"%s\" issued an unknown command: \"%s\"", a_Player->GetName().c_str(), a_Message.c_str());
+ return true; // Cancel sending
+ }
+
+ HookMap::iterator Plugins = m_Hooks.find(HOOK_CHAT);
+ if (Plugins == m_Hooks.end())
+ {
+ return false;
+ }
+
+ for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
+ {
+ if ((*itr)->OnChat(a_Player, a_Message))
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+
+
+
bool cPluginManager::CallHookChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_LuaChunk)
{
HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_GENERATING);