summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Entities/Player.cpp4
-rw-r--r--src/Protocol/Protocol17x.cpp14
-rw-r--r--src/Protocol/Protocol17x.h2
-rw-r--r--src/UI/SlotArea.cpp24
-rw-r--r--src/UI/Window.cpp2
5 files changed, 29 insertions, 17 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index c1f2456eb..abdd792e0 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -120,6 +120,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
cPlayer::~cPlayer(void)
{
+ cRoot::Get()->GetPluginManager()->CallHookPlayerDestroying(*this);
+
LOGD("Deleting cPlayer \"%s\" at %p, ID %d", m_PlayerName.c_str(), this, GetUniqueID());
// Notify the server that the player is being destroyed
@@ -134,6 +136,8 @@ cPlayer::~cPlayer(void)
delete m_InventoryWindow;
LOGD("Player %p deleted", this);
+
+ cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*this);
}
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index d120d8d91..f302da2ad 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -1143,7 +1143,7 @@ bool cProtocol172::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
case 0x0e: HandlePacketWindowClick (a_ByteBuffer); return true;
case 0x0f: // Confirm transaction - not used in MCS
case 0x10: HandlePacketCreativeInventoryAction(a_ByteBuffer); return true;
- case 0x11: HandlePacketEnchanting (a_ByteBuffer); return true;
+ case 0x11: HandlePacketEnchanting (a_ByteBuffer); return true;
case 0x12: HandlePacketUpdateSign (a_ByteBuffer); return true;
case 0x13: HandlePacketPlayerAbilities (a_ByteBuffer); return true;
case 0x14: HandlePacketTabComplete (a_ByteBuffer); return true;
@@ -1551,11 +1551,19 @@ void cProtocol172::HandlePacketEnchanting(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, WindowID);
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Enchantment);
- //TODO: EnchantItem (getWindow, getItem, Enchant)
+ LOGWARN("Enchantment Packet received!");
+ //Get Item from Window Slot
+ cItem EnchantItem = *m_Client->GetPlayer()->GetWindow()->GetSlot(*m_Client->GetPlayer(), 0);
+ //Enchant item with Sharpness 5
+ EnchantItem.m_Enchantments.SetLevel(cEnchantments::enchSharpness, 5);
- LOG("Enchantment Paket empfangen!");
+ //Set Enchanted Item to Window Slot
+ m_Client->GetPlayer()->GetWindow()->SetSlot(*m_Client->GetPlayer(), 0, EnchantItem);
+
+ LOGWARN("Item enchanted!");
+
}
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index 04d65910c..7877e783a 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -258,7 +258,7 @@ protected:
void HandlePacketTabComplete (cByteBuffer & a_ByteBuffer);
void HandlePacketUpdateSign (cByteBuffer & a_ByteBuffer);
void HandlePacketUseEntity (cByteBuffer & a_ByteBuffer);
- void HandlePacketEnchanting (cByteBuffer & a_ByteBuffer);
+ void HandlePacketEnchanting (cByteBuffer & a_ByteBuffer);
void HandlePacketWindowClick (cByteBuffer & a_ByteBuffer);
void HandlePacketWindowClose (cByteBuffer & a_ByteBuffer);
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index ae6bfccb5..a226d027b 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -576,7 +576,7 @@ cSlotAreaTemporary(a_NumSlots, a_ParentWindow)
void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
{
- LOG("Clicked");
+ LOGWARN("Clicked");
// Check if Slot is in the Enchantment Table
if (a_SlotNum == 0)
{
@@ -610,28 +610,28 @@ void cSlotAreaEnchanting::OnPlayerRemoved(cPlayer & a_Player)
void cSlotAreaEnchanting::ClickedResult(cPlayer & a_Player)
{
- LOG("Click!");
+ LOGWARN("Click!");
if (a_Player.GetDraggingItem().IsEmpty())
{
- LOG("EMPTY");
- this->m_ParentWindow.SetProperty(0, NULL);
- this->m_ParentWindow.SetProperty(1, NULL);
- this->m_ParentWindow.SetProperty(2, NULL);
+ LOGWARN("EMPTY");
+ this->m_ParentWindow.SetProperty(0, 0);
+ this->m_ParentWindow.SetProperty(1, 0);
+ this->m_ParentWindow.SetProperty(2, 0);
}
else if (a_Player.GetDraggingItem().IsEnchantable)
{
- LOG("Enchantable");
+ LOGWARN("Enchantable");
this->m_ParentWindow.SetProperty(0, 30);
this->m_ParentWindow.SetProperty(1, 20);
this->m_ParentWindow.SetProperty(2, 10);
}
else
{
- LOG("Not Enchantable");
- this->m_ParentWindow.SetProperty(0, NULL);
- this->m_ParentWindow.SetProperty(1, NULL);
- this->m_ParentWindow.SetProperty(2, NULL);
+ LOGWARN("Not Enchantable");
+ this->m_ParentWindow.SetProperty(0, 0);
+ this->m_ParentWindow.SetProperty(1, 0);
+ this->m_ParentWindow.SetProperty(2, 0);
}
}
@@ -641,7 +641,7 @@ void cSlotAreaEnchanting::ClickedResult(cPlayer & a_Player)
void cSlotAreaEnchanting::ShiftClickedResult(cPlayer & a_Player)
{
- LOG("Shift Click!");
+ LOGWARN("Shift Click!");
}
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index fcfe6faf3..9188b47a7 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -785,7 +785,7 @@ cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
// cEnchantingWindow:
cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
-cWindow(wtEnchantment, "Enchantment Table")
+cWindow(wtEnchantment, "Enchant")
{
m_SlotAreas.push_back(new cSlotAreaEnchanting(1, *this));
m_SlotAreas.push_back(new cSlotAreaInventory(*this));