summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-22 21:08:34 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-22 21:08:34 +0200
commit943dcaea14c7530eecca57af015f1007b3b9630f (patch)
tree5f6f3c95c67d22810dc349b7831d10a64d89b480 /source
parentAdded the End height and composition generators. (diff)
downloadcuberite-943dcaea14c7530eecca57af015f1007b3b9630f.tar
cuberite-943dcaea14c7530eecca57af015f1007b3b9630f.tar.gz
cuberite-943dcaea14c7530eecca57af015f1007b3b9630f.tar.bz2
cuberite-943dcaea14c7530eecca57af015f1007b3b9630f.tar.lz
cuberite-943dcaea14c7530eecca57af015f1007b3b9630f.tar.xz
cuberite-943dcaea14c7530eecca57af015f1007b3b9630f.tar.zst
cuberite-943dcaea14c7530eecca57af015f1007b3b9630f.zip
Diffstat (limited to '')
-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
9 files changed, 18 insertions, 13 deletions
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