diff options
author | madmaxoft <github@xoft.cz> | 2014-01-25 15:37:00 +0100 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-01-25 15:37:00 +0100 |
commit | a2dfb2853718cc8bf73b954e5b678c12d93c815c (patch) | |
tree | b793ef13c8793cf4943659d75fcbe10cb4074daf /src/UI/Window.cpp | |
parent | Removed unnecessary define (diff) | |
parent | Comm logging is available in both Debug and Release modes. (diff) | |
download | cuberite-a2dfb2853718cc8bf73b954e5b678c12d93c815c.tar cuberite-a2dfb2853718cc8bf73b954e5b678c12d93c815c.tar.gz cuberite-a2dfb2853718cc8bf73b954e5b678c12d93c815c.tar.bz2 cuberite-a2dfb2853718cc8bf73b954e5b678c12d93c815c.tar.lz cuberite-a2dfb2853718cc8bf73b954e5b678c12d93c815c.tar.xz cuberite-a2dfb2853718cc8bf73b954e5b678c12d93c815c.tar.zst cuberite-a2dfb2853718cc8bf73b954e5b678c12d93c815c.zip |
Diffstat (limited to 'src/UI/Window.cpp')
-rw-r--r-- | src/UI/Window.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 3ffeff7a0..1a8456f70 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,7 @@ 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 +181,35 @@ 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: @@ -263,7 +286,7 @@ bool cWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) if (a_Player.IsDraggingItem()) { LOGD("Player holds item! Dropping it..."); - a_Player.TossItem(true, a_Player.GetDraggingItem().m_ItemCount); + a_Player.TossHeldItem(a_Player.GetDraggingItem().m_ItemCount); } cClientHandle * ClientHandle = a_Player.GetClientHandle(); |