Preventing a player from moving an item out of their own inventory

Discussion in 'Plugin Development' started by ferrago, Jun 10, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    ferrago

    So I have drove myself crazy trying to figure this out how to block every single move event to prevent an item from being removed from an inventory. I want to allow the player to move the item as much as they want around their own inventory, while preventing them from putting the item in any other inventory like a chest, furnace, craftingtable, enchantingtable, anvil, or anything. Anyone have any ideas? I figured I could use drag/click event but I am unsure how to tell when the item moves inventories, I have tried using InventoryAction.MOVE_TO_OTHER_INVENTORY, but it doesn't seem to prevent hovering over a slot and pressing a key to move them item, nor dragging the item.
     
  2. Offline

    Epicballzy

    Get the item you don't want them to move and cancel the event? I think you would use InventoryClickEvent
     
  3. Offline

    ferrago

    Tried this already, player's won't be able to move the item about their inventory, and hovering over the other inventory's slot and pressing numeric key representing item will transfer the item into the other inventory.

    Figured this out using InventoryView. If the view isn't InventoryView.PLAYER cancel all drag/move/click events if it is my item I don't want moved.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
Thread Status:
Not open for further replies.

Share This Page