diff options
author | Mike Hunsinger <mike.hunsinger@gmail.com> | 2014-01-23 08:27:39 +0100 |
---|---|---|
committer | Mike Hunsinger <mike.hunsinger@gmail.com> | 2014-01-23 08:27:39 +0100 |
commit | 41b05416c75b9cbe31406f04b58b5da9892872f8 (patch) | |
tree | 0c592551b36871ae695f3bc5396fc92e5701f6b8 /src/UI | |
parent | Fix a crash but somewhere... (diff) | |
download | cuberite-41b05416c75b9cbe31406f04b58b5da9892872f8.tar cuberite-41b05416c75b9cbe31406f04b58b5da9892872f8.tar.gz cuberite-41b05416c75b9cbe31406f04b58b5da9892872f8.tar.bz2 cuberite-41b05416c75b9cbe31406f04b58b5da9892872f8.tar.lz cuberite-41b05416c75b9cbe31406f04b58b5da9892872f8.tar.xz cuberite-41b05416c75b9cbe31406f04b58b5da9892872f8.tar.zst cuberite-41b05416c75b9cbe31406f04b58b5da9892872f8.zip |
Diffstat (limited to 'src/UI')
-rw-r--r-- | src/UI/Window.cpp | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 3ffeff7a0..3dd6d2264 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -13,7 +13,8 @@ #include "../BlockEntities/DropSpenserEntity.h" #include "../BlockEntities/EnderChestEntity.h" #include "../BlockEntities/HopperEntity.h" - +#include "../Root.h" +#include "../Bindings/PluginManager.h" @@ -169,6 +170,8 @@ void cWindow::Clicked( const cItem & a_ClickedItem ) { + cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); + if (a_WindowID != m_WindowID) { LOGWARNING("%s: Wrong window ID (exp %d, got %d) received from \"%s\"; ignoring click.", __FUNCTION__, m_WindowID, a_WindowID, a_Player.GetName().c_str()); @@ -179,14 +182,36 @@ void cWindow::Clicked( { case caRightClickOutside: { + if (PlgMgr->CallHookPlayerTossingItem(a_Player)) + { + // A plugin doesn't agree with the tossing. The plugin itself is responsible for handling the consequences (possible inventory mismatch) + return; + } + + if (a_Player.IsGameModeCreative()) + { + a_Player.TossPickup(a_ClickedItem); + } + // Toss one of the dragged items: - a_Player.TossItem(true); + a_Player.TossHeldItem(); return; } case caLeftClickOutside: { + if (PlgMgr->CallHookPlayerTossingItem(a_Player)) + { + // A plugin doesn't agree with the tossing. The plugin itself is responsible for handling the consequences (possible inventory mismatch) + return; + } + + if (a_Player.IsGameModeCreative()) + { + a_Player.TossPickup(a_ClickedItem); + } + // Toss all dragged items: - a_Player.TossItem(true, a_Player.GetDraggingItem().m_ItemCount); + a_Player.TossHeldItem(a_Player.GetDraggingItem().m_ItemCount); return; } case caLeftClickOutsideHoldNothing: @@ -259,11 +284,13 @@ void cWindow::OpenedByPlayer(cPlayer & a_Player) bool cWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) { + cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); + // Checks whether the player is still holding an item if (a_Player.IsDraggingItem()) { - LOGD("Player holds item! Dropping it..."); - a_Player.TossItem(true, a_Player.GetDraggingItem().m_ItemCount); + LOGD("Player holds item! Dropping it..."); + a_Player.TossHeldItem(a_Player.GetDraggingItem().m_ItemCount); } cClientHandle * ClientHandle = a_Player.GetClientHandle(); |