summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/Protocol')
-rw-r--r--src/Protocol/Protocol_1_9.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp
index 712658329..8e43fd2cc 100644
--- a/src/Protocol/Protocol_1_9.cpp
+++ b/src/Protocol/Protocol_1_9.cpp
@@ -2966,20 +2966,24 @@ void cProtocol_1_9_0::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, con
BookItem = cItem(E_ITEM_BOOK_AND_QUILL);
cBookContent::ParseFromNBT(0, BookItem.m_BookContent, NBT);
}
+ BookItem.m_BookContent.SetIsSigned(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
+ // Plugin denied the player to edit the book
+ cInventory & inv = Player.GetInventory();
+ inv.SetHotbarSlot(inv.GetEquippedSlotNum(), BookItem);
+ Player.GetInventory().SendEquippedSlot();
return;
}
- // Book has been edited, inform plugins
- cRoot::Get()->GetPluginManager()->CallHookPlayerEditedBook(Player, BookItem.m_BookContent, IsSigned);
-
cInventory & inv = Player.GetInventory();
inv.SetHotbarSlot(inv.GetEquippedSlotNum(), BookItem);
Player.GetInventory().SendEquippedSlot();
+
+ // Book has been edited by player, inform plugins
+ cRoot::Get()->GetPluginManager()->CallHookPlayerEditedBook(Player, BookItem.m_BookContent, IsSigned);
return;
}
LOG("Unhandled vanilla plugin channel: \"%s\".", a_Channel.c_str());
@@ -3418,9 +3422,9 @@ void cProtocol_1_9_0::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item)
return;
}
- if ((ItemType == E_ITEM_BOOK_AND_QUILL) && (a_Item.m_BookContent.GetPages().size() == 0))
+ if ((ItemType == E_ITEM_BOOK_AND_QUILL) && a_Item.m_BookContent.GetPages().empty())
{
- // Don't send any nbt tag if the book is writeable and has no pages
+ // Don't send any nbt tag if the book is not signed and has no pages
// If a tag with a empty pages list is send, the player can't enter anything
a_Pkt.WriteBEInt8(0);
return;
@@ -3539,24 +3543,24 @@ void cProtocol_1_9_0::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item)
{
if (a_Item.m_ItemType == E_ITEM_WRITTEN_BOOK)
{
- // Only send author and title for a signed book
+ // Only send author and title if the book is signed
Writer.AddString("author", a_Item.m_BookContent.GetAuthor());
Writer.AddString("title", a_Item.m_BookContent.GetTitle());
}
- if (a_Item.m_BookContent.GetPages().size() > 0)
+ if (a_Item.m_BookContent.GetPages().empty())
{
+ // A signed book, has a empty page
Writer.BeginList("pages", TAG_String);
- for (auto & Page : a_Item.m_BookContent.GetPages())
- {
- Writer.AddString("", Page);
- }
+ Writer.AddString("", "");
Writer.EndList();
}
else
{
- // A signed book, has a empty page
Writer.BeginList("pages", TAG_String);
- Writer.AddString("", "");
+ for (const auto & Page : a_Item.m_BookContent.GetPages())
+ {
+ Writer.AddString("", Page);
+ }
Writer.EndList();
}
}