summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MCServer/Plugins/Debuggers/Debuggers.lua9
-rw-r--r--source/ClientHandle.cpp5
-rw-r--r--source/Plugin.cpp2
-rw-r--r--source/Plugin.h2
-rw-r--r--source/PluginManager.cpp2
-rw-r--r--source/PluginManager.h2
-rw-r--r--source/Plugin_NewLua.cpp12
-rw-r--r--source/Plugin_NewLua.h2
-rw-r--r--source/Server.cpp2
-rw-r--r--source/Server.h2
10 files changed, 27 insertions, 13 deletions
diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua
index 55a954f47..fa49456bb 100644
--- a/MCServer/Plugins/Debuggers/Debuggers.lua
+++ b/MCServer/Plugins/Debuggers/Debuggers.lua
@@ -20,6 +20,7 @@ function Initialize(Plugin)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USING_ITEM);
PluginManager:AddHook(Plugin, cPluginManager.HOOK_TAKE_DAMAGE);
PluginManager:AddHook(Plugin, cPluginManager.HOOK_TICK);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT);
PluginManager:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "Shows a list of all the loaded entities");
PluginManager:BindCommand("/ke", "debuggers", HandleKillEntitiesCmd, "Kills all the loaded entities");
@@ -631,3 +632,11 @@ end
+
+function OnChat(a_Player, a_Message)
+ return false, "blabla " .. a_Message;
+end
+
+
+
+
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index 23a34d7bc..e1ade39e7 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -898,14 +898,15 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c
void cClientHandle::HandleChat(const AString & a_Message)
{
- if (!cRoot::Get()->GetServer()->Command(*this, a_Message))
+ AString Message(a_Message);
+ if (!cRoot::Get()->GetServer()->Command(*this, Message))
{
AString Msg;
Printf(Msg, "<%s%s%s> %s",
m_Player->GetColor().c_str(),
m_Player->GetName().c_str(),
cChatColor::White.c_str(),
- a_Message.c_str()
+ Message.c_str()
);
m_Player->GetWorld()->BroadcastChat(Msg);
}
diff --git a/source/Plugin.cpp b/source/Plugin.cpp
index 879a1a3d6..389ef15e4 100644
--- a/source/Plugin.cpp
+++ b/source/Plugin.cpp
@@ -57,7 +57,7 @@ bool cPlugin::OnBlockToPickups(cWorld * a_World, cEntity * a_Digger, int a_Block
-bool cPlugin::OnChat(cPlayer * a_Player, const AString & a_Message)
+bool cPlugin::OnChat(cPlayer * a_Player, AString & a_Message)
{
UNUSED(a_Player);
UNUSED(a_Message);
diff --git a/source/Plugin.h b/source/Plugin.h
index 74447d888..9107cce6f 100644
--- a/source/Plugin.h
+++ b/source/Plugin.h
@@ -49,7 +49,7 @@ public:
* You can also return false, so default behavior is used.
**/
virtual bool OnBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups);
- virtual bool OnChat (cPlayer * a_Player, const AString & a_Message);
+ virtual bool OnChat (cPlayer * a_Player, AString & a_Message);
virtual bool OnChunkAvailable (cWorld * a_World, int a_ChunkX, int a_ChunkZ);
virtual bool OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc);
virtual bool OnChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc);
diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp
index d26a0a680..a180f5618 100644
--- a/source/PluginManager.cpp
+++ b/source/PluginManager.cpp
@@ -198,7 +198,7 @@ bool cPluginManager::CallHookBlockToPickups(
-bool cPluginManager::CallHookChat(cPlayer * a_Player, const AString & a_Message)
+bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
{
if (ExecuteCommand(a_Player, a_Message))
{
diff --git a/source/PluginManager.h b/source/PluginManager.h
index 4a035f088..655081568 100644
--- a/source/PluginManager.h
+++ b/source/PluginManager.h
@@ -112,7 +112,7 @@ public: // tolua_export
unsigned int GetNumPlugins() const; // tolua_export
bool CallHookBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups);
- bool CallHookChat (cPlayer * a_Player, const AString & a_Message);
+ bool CallHookChat (cPlayer * a_Player, AString & a_Message);
bool CallHookChunkAvailable (cWorld * a_World, int a_ChunkX, int a_ChunkZ);
bool CallHookChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc);
bool CallHookChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc);
diff --git a/source/Plugin_NewLua.cpp b/source/Plugin_NewLua.cpp
index 885184c12..335ac000a 100644
--- a/source/Plugin_NewLua.cpp
+++ b/source/Plugin_NewLua.cpp
@@ -228,7 +228,7 @@ bool cPlugin_NewLua::OnBlockToPickups(cWorld * a_World, cEntity * a_Digger, int
-bool cPlugin_NewLua::OnChat(cPlayer * a_Player, const AString & a_Message)
+bool cPlugin_NewLua::OnChat(cPlayer * a_Player, AString & a_Message)
{
cCSLock Lock(m_CriticalSection);
const char * FnName = GetHookFnName(cPluginManager::HOOK_CHAT);
@@ -241,13 +241,17 @@ bool cPlugin_NewLua::OnChat(cPlayer * a_Player, const AString & a_Message)
tolua_pushusertype(m_LuaState, a_Player, "cPlayer");
tolua_pushstring (m_LuaState, a_Message.c_str());
- if (!CallFunction(2, 1, FnName))
+ if (!CallFunction(2, 2, FnName))
{
return false;
}
- bool bRetVal = (tolua_toboolean(m_LuaState, -1, 0) > 0);
- lua_pop(m_LuaState, 1);
+ bool bRetVal = (tolua_toboolean(m_LuaState, -2, 0) > 0);
+ if (lua_isstring(m_LuaState, -1))
+ {
+ a_Message = tolua_tostring(m_LuaState, -1, "");
+ }
+ lua_pop(m_LuaState, 2);
return bRetVal;
}
diff --git a/source/Plugin_NewLua.h b/source/Plugin_NewLua.h
index de6077a55..086568f76 100644
--- a/source/Plugin_NewLua.h
+++ b/source/Plugin_NewLua.h
@@ -38,7 +38,7 @@ public:
virtual void Tick(float a_Dt) override;
virtual bool OnBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) override;
- virtual bool OnChat (cPlayer * a_Player, const AString & a_Message) override;
+ virtual bool OnChat (cPlayer * a_Player, AString & a_Message) override;
virtual bool OnChunkAvailable (cWorld * a_World, int a_ChunkX, int a_ChunkZ) override;
virtual bool OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) override;
virtual bool OnChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) override;
diff --git a/source/Server.cpp b/source/Server.cpp
index 03fd3c4d8..21fbb97db 100644
--- a/source/Server.cpp
+++ b/source/Server.cpp
@@ -413,7 +413,7 @@ bool cServer::Start(void)
-bool cServer::Command(cClientHandle & a_Client, const AString & a_Cmd)
+bool cServer::Command(cClientHandle & a_Client, AString & a_Cmd)
{
return cRoot::Get()->GetPluginManager()->CallHookChat(a_Client.GetPlayer(), a_Cmd);
}
diff --git a/source/Server.h b/source/Server.h
index abcd7eaa1..dfda56c62 100644
--- a/source/Server.h
+++ b/source/Server.h
@@ -44,7 +44,7 @@ public: // tolua_export
bool Start(void);
- bool Command(cClientHandle & a_Client, const AString & a_Cmd);
+ bool Command(cClientHandle & a_Client, AString & a_Cmd);
void ExecuteConsoleCommand(const AString & a_Cmd);
/// Binds the built-in console commands with the plugin manager