diff options
author | Lukas Pioch <lukas@zgow.de> | 2017-08-04 12:07:10 +0200 |
---|---|---|
committer | Lukas Pioch <lukas@zgow.de> | 2017-08-27 14:54:44 +0200 |
commit | 099e82db67b093eb009c6c5d80278c2e5ee128ee (patch) | |
tree | 9ca877b573bbf507a152f024b91ef44d1608c788 | |
parent | Removed unnecessary brackets (diff) | |
download | cuberite-099e82db67b093eb009c6c5d80278c2e5ee128ee.tar cuberite-099e82db67b093eb009c6c5d80278c2e5ee128ee.tar.gz cuberite-099e82db67b093eb009c6c5d80278c2e5ee128ee.tar.bz2 cuberite-099e82db67b093eb009c6c5d80278c2e5ee128ee.tar.lz cuberite-099e82db67b093eb009c6c5d80278c2e5ee128ee.tar.xz cuberite-099e82db67b093eb009c6c5d80278c2e5ee128ee.tar.zst cuberite-099e82db67b093eb009c6c5d80278c2e5ee128ee.zip |
-rw-r--r-- | Server/Plugins/APIDump/Hooks/OnPlayerEditedBook.lua | 2 | ||||
-rw-r--r-- | Server/Plugins/APIDump/Hooks/OnPlayerEditingBook.lua | 3 | ||||
-rw-r--r-- | src/Bindings/LuaState.cpp | 11 | ||||
-rw-r--r-- | src/Bindings/LuaState.h | 1 | ||||
-rw-r--r-- | src/Bindings/Plugin.h | 4 | ||||
-rw-r--r-- | src/Bindings/PluginLua.cpp | 8 | ||||
-rw-r--r-- | src/Bindings/PluginLua.h | 4 | ||||
-rw-r--r-- | src/Bindings/PluginManager.cpp | 8 | ||||
-rw-r--r-- | src/Bindings/PluginManager.h | 4 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_9.cpp | 3 |
10 files changed, 31 insertions, 17 deletions
diff --git a/Server/Plugins/APIDump/Hooks/OnPlayerEditedBook.lua b/Server/Plugins/APIDump/Hooks/OnPlayerEditedBook.lua index 9a6c0bc8c..a34f93a08 100644 --- a/Server/Plugins/APIDump/Hooks/OnPlayerEditedBook.lua +++ b/Server/Plugins/APIDump/Hooks/OnPlayerEditedBook.lua @@ -12,7 +12,7 @@ return Params = { { Name = "Player", Type = "cPlayer", Notes = "The player that edited the book" }, - { Name = "BookContent", Type = "cBookContent", Notes = "The class that contains the current info of the book" }, + { Name = "NewContent", Type = "cBookContent", Notes = "Contains the new content of the book" }, { Name = "IsSigned", Type = "boolean", Notes = "Player has signed the book" }, }, Returns = [[ diff --git a/Server/Plugins/APIDump/Hooks/OnPlayerEditingBook.lua b/Server/Plugins/APIDump/Hooks/OnPlayerEditingBook.lua index 455bf4f69..082c6a4a2 100644 --- a/Server/Plugins/APIDump/Hooks/OnPlayerEditingBook.lua +++ b/Server/Plugins/APIDump/Hooks/OnPlayerEditingBook.lua @@ -12,7 +12,8 @@ return Params = { { Name = "Player", Type = "cPlayer", Notes = "The player that is editing the book" }, - { Name = "BookContent", Type = "cBookContent", Notes = "The class that contains the current info of the book" }, + { Name = "OriginalContent", Type = "cBookContent", Notes = "Contains the original content of the book" }, + { Name = "NewContent", Type = "cBookContent", Notes = "Contains the new content of the book" }, { Name = "IsSigned", Type = "boolean", Notes = "Player is signing the book" }, }, Returns = [[ diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 7bd4becb6..ee4d0c7c2 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -865,6 +865,17 @@ void cLuaState::Push(const AStringVector & a_Vector) +void cLuaState::Push(const cBookContent & a_Content) +{ + ASSERT(IsValid()); + auto c = new cBookContent(a_Content); + tolua_pushusertype_and_takeownership(m_LuaState, c, "cBookContent"); +} + + + + + void cLuaState::Push(const char * a_Value) { ASSERT(IsValid()); diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index 98f1cbc28..abe09985a 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -613,6 +613,7 @@ public: void Push(const AString & a_String); void Push(const AStringMap & a_Dictionary); void Push(const AStringVector & a_Vector); + void Push(const cBookContent & a_Content); void Push(const char * a_Value); void Push(const cItem & a_Item); void Push(const cNil & a_Nil); diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 62863fea5..a9444a4e2 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -74,8 +74,8 @@ public: virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; virtual bool OnPlayerDestroyed (cPlayer & a_Player) = 0; virtual bool OnPlayerEating (cPlayer & a_Player) = 0; - virtual bool OnPlayerEditedBook (cPlayer & a_Player, cBookContent & a_BookContent, bool a_IsSigned) = 0; - virtual bool OnPlayerEditingBook (cPlayer & a_Player, cBookContent & a_BookContent, bool a_IsSigned) = 0; + virtual bool OnPlayerEditedBook (cPlayer & a_Player, const cBookContent & a_NewContent, bool a_IsSigned) = 0; + virtual bool OnPlayerEditingBook (cPlayer & a_Player, const cBookContent & a_OriginalContent, cBookContent & a_NewContent, bool a_IsSigned) = 0; virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) = 0; virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) = 0; virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index a4097ccf1..90be9bd07 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -595,18 +595,18 @@ bool cPluginLua::OnPlayerEating(cPlayer & a_Player) -bool cPluginLua::OnPlayerEditedBook(cPlayer & a_Player, cBookContent & a_BookContent, bool a_IsSigned) +bool cPluginLua::OnPlayerEditedBook(cPlayer & a_Player, const cBookContent & a_NewContent, bool a_IsSigned) { - return CallSimpleHooks(cPluginManager::HOOK_PLAYER_EDITED_BOOK, &a_Player, &a_BookContent, a_IsSigned); + return CallSimpleHooks(cPluginManager::HOOK_PLAYER_EDITED_BOOK, &a_Player, a_NewContent, a_IsSigned); } -bool cPluginLua::OnPlayerEditingBook(cPlayer & a_Player, cBookContent & a_BookContent, bool a_IsSigned) +bool cPluginLua::OnPlayerEditingBook(cPlayer & a_Player, const cBookContent & a_OriginalContent, cBookContent & a_NewContent, bool a_IsSigned) { - return CallSimpleHooks(cPluginManager::HOOK_PLAYER_EDITING_BOOK, &a_Player, &a_BookContent, a_IsSigned); + return CallSimpleHooks(cPluginManager::HOOK_PLAYER_EDITING_BOOK, &a_Player, a_OriginalContent, &a_NewContent, a_IsSigned); } diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index 59266a35a..6a815db74 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -95,8 +95,8 @@ public: virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; virtual bool OnPlayerDestroyed (cPlayer & a_Player) override; virtual bool OnPlayerEating (cPlayer & a_Player) override; - virtual bool OnPlayerEditedBook (cPlayer & a_Player, cBookContent & a_BookContent, bool a_IsSigned) override; - virtual bool OnPlayerEditingBook (cPlayer & a_Player, cBookContent & a_BookContent, bool a_IsSigned) override; + virtual bool OnPlayerEditedBook (cPlayer & a_Player, const cBookContent & a_NewContent, bool a_IsSigned) override; + virtual bool OnPlayerEditingBook (cPlayer & a_Player, const cBookContent & a_OriginalContent, cBookContent & a_NewContent, bool a_IsSigned) override; virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) override; virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) override; virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 19b337523..e36554e25 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -885,14 +885,14 @@ bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player) -bool cPluginManager::CallHookPlayerEditedBook(cPlayer & a_Player, cBookContent & a_BookContent, bool a_IsSigned) +bool cPluginManager::CallHookPlayerEditedBook(cPlayer & a_Player, const cBookContent & a_NewContent, bool a_IsSigned) { FIND_HOOK(HOOK_PLAYER_EDITED_BOOK); VERIFY_HOOK; for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnPlayerEditedBook(a_Player, a_BookContent, a_IsSigned)) + if ((*itr)->OnPlayerEditedBook(a_Player, a_NewContent, a_IsSigned)) { return true; } @@ -904,14 +904,14 @@ bool cPluginManager::CallHookPlayerEditedBook(cPlayer & a_Player, cBookContent & -bool cPluginManager::CallHookPlayerEditingBook(cPlayer & a_Player, cBookContent & a_BookContent, bool a_IsSigned) +bool cPluginManager::CallHookPlayerEditingBook(cPlayer & a_Player, const cBookContent & a_OriginalContent, cBookContent & a_NewContent, bool a_IsSigned) { FIND_HOOK(HOOK_PLAYER_EDITING_BOOK); VERIFY_HOOK; for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnPlayerEditingBook(a_Player, a_BookContent, a_IsSigned)) + if ((*itr)->OnPlayerEditingBook(a_Player, a_OriginalContent, a_NewContent, a_IsSigned)) { return true; } diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 5f765fd03..d7bbf62c2 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -256,8 +256,8 @@ public: bool CallHookPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); bool CallHookPlayerDestroyed (cPlayer & a_Player); bool CallHookPlayerEating (cPlayer & a_Player); - bool CallHookPlayerEditedBook (cPlayer & a_Player, cBookContent & a_BookContent, bool a_IsSigned); - bool CallHookPlayerEditingBook (cPlayer & a_Player, cBookContent & a_BookContent, bool a_IsSigned); + bool CallHookPlayerEditedBook (cPlayer & a_Player, const cBookContent & a_NewContent, bool a_IsSigned); + bool CallHookPlayerEditingBook (cPlayer & a_Player, const cBookContent & a_OrigialContent, cBookContent & a_NewContent, bool a_IsSigned); bool CallHookPlayerFished (cPlayer & a_Player, const cItems & a_Reward); bool CallHookPlayerFishing (cPlayer & a_Player, cItems a_Reward); bool CallHookPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel); diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp index 1ee0f450e..712658329 100644 --- a/src/Protocol/Protocol_1_9.cpp +++ b/src/Protocol/Protocol_1_9.cpp @@ -2967,7 +2967,8 @@ void cProtocol_1_9_0::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, con cBookContent::ParseFromNBT(0, BookItem.m_BookContent, NBT); } - if (cRoot::Get()->GetPluginManager()->CallHookPlayerEditingBook(Player, BookItem.m_BookContent, IsSigned)) + // The equipped item contains the old book content + if (cRoot::Get()->GetPluginManager()->CallHookPlayerEditingBook(Player, Player.GetEquippedItem().m_BookContent, BookItem.m_BookContent, IsSigned)) { // Plugin denied the editing of the book return; |