Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Get player in InventoryTransactionEvent

Comments in 'Plugin Development' started by MyNameIsTriXz, Dec 29, 2015.

  1. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Because the code, I got from the people from the first thread was called on null, so I am reopening this thread. So how I do that?
  2. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    PHP:
    public function TapItemsInChest(InventoryTransactionEvent $event){
            foreach(
    $event->getTransaction()->getTransactions() as $t){
                
    $inv $t->getInventory();
                if(
    $inv instanceof PlayerInventory){
                    
    $player $inv->getHolder();
                }elseif(
    $inv instanceof ChestInventory){
                    
    $chest $inv->getHolder();
                }
            }
        }
    MyNameIsTriXz likes this.
  3. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Does it really work on your plugin? Because as I did it, it said Player on null... Thats why I reopened this thread, see, or is it that I am to stupid to script? :/ https://forums.pocketmine.net/threads/how-to-get-the-player-on-inventorytransactionevent.14003/
  4. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    It worked, thanks :)

Share This Page

Advertisement