Disable specific item to be put in chest

Discussion in 'Development' started by WhoAreMe, May 6, 2020.

  1. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    I want to write a plugin on how to disable putting specific item on chest. I ask back then how to disable specific item drop on chest but now this one. But i dont know where to start. Is there someone who can help me. Is there an event that check if player is gonna put item on chest.
     
  2. KinokiYT

    KinokiYT Spider Jockey

    Messages:
    25
    GitHub:
    kinokiyt
    Correct me if I'm wrong, but I'm sure you can use pocketmine\tile\Chest as $chest to get the chest inventory. $inventory = $chest->getInventory();
     
    Last edited: May 6, 2020
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,549
    GitHub:
    muqsit
    InventoryTransactionEvent is fired when player puts an item in chest. It actually fires everytime a player makes a change in an inventory so you need to validate whether they're putting an item and not taking out.
     
  4. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    I still dont know where to start. I found getTransaction but it is deprecated
     
  5. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
  6. Muqsit

    Muqsit Chicken

    Messages:
    1,549
    GitHub:
    muqsit
  7. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
  8. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    Still cant make it work can someone give me a code using transaction event to cancel chest transaction. The api change and i cant seem to make it work.
     
  9. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    Now i only need to check if player is selecting specific item in inventory
     
  10. Muqsit

    Muqsit Chicken

    Messages:
    1,549
    GitHub:
    muqsit
    Check if SlotChangeAction's $newItem is not air
     
    HimbeersaftLP likes this.
  11. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    What do u mean by that. I want to check if player is clicking or selecting an item then use $event set cancelled true
     
  12. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    Oh you're the maker of InvMenu. I have found your callback that detect the "ItemClicked" in inventory. Can u create a seperate api to that that check if player is holding/selecting/clicking item in inventory.
     
    Last edited: May 11, 2020

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.