1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Keep Inventory is not working

Discussion in 'Development' started by adam1609, Jan 23, 2018.

  1. adam1609

    adam1609 Spider

    Messages:
    11
    GitHub:
    Adam1609
    Code:
    public function onDeath (PlayerDeathEvent $ev){
          $ev->setKeepInventory(true);
    }
    It just that I commerce this code
    But player still lose their inventory and I don't know why????
    I use PocketMine-MP
     
    xXNiceAssassinlo YT likes this.
  2. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    You need use tick (I think so don’t ban me @SOFe he got the ban hammer)
     
  3. Oniii-Chan

    Oniii-Chan Witch

    Messages:
    66
    GitHub:
    Vincent583
    Code:
    public function PlayerDeath(PlayerDeathEvent $event){
        $event->setKeepInventory(true);
    }
    and must check in "public function onEnable" have " $this->getServer()->getPluginManager()->registerEvents($this, $this);"
     
    xXNiceAssassinlo YT likes this.
  4. adam1609

    adam1609 Spider

    Messages:
    11
    GitHub:
    Adam1609
    Well, I have add the public function with registerEvent, but still it drop when death.....
    I have checked all of my plugin 3 time in a row and nothing conflict the KeepInventory, I don't know why
    I use spoon, the keepinventory code is working, but when I use PMMP, it doesn't
     
  5. DaPigGuy

    DaPigGuy Slime

    Messages:
    86
    GitHub:
    DaPigGuy
    :facepalm: One change of an argument name and the function name won't make a difference. Also make sure you are implementing Listener in whatever class this is in (main class or a seperate class) & don't blindly copy in $this->getServer()->getPluginManager()->registerEvents($this, $this);. The first argument should be your listener. Only use the given code if you're using your main class as a listener. Otherwise, create an instance of your Listener as your first argument.

    P.S Please don't mention sp**ns in this forums
     
  6. adam1609

    adam1609 Spider

    Messages:
    11
    GitHub:
    Adam1609
    Okay thanks, and I'm sorry for mentioning the word. I will test this
     
  7. adam1609

    adam1609 Spider

    Messages:
    11
    GitHub:
    Adam1609
    Ok it seemed that I have tested this
    Please don't facepalm me, I know what I am doing here
    It is not working, player still lose inventory when death
    I tested with all my plugin out and I don't know why????
     
  8. Oniii-Chan

    Oniii-Chan Witch

    Messages:
    66
    GitHub:
    Vincent583
    Did you have this "class KeepInventory extends PluginBase implements Listener" ?
     
  9. adam1609

    adam1609 Spider

    Messages:
    11
    GitHub:
    Adam1609
    Yes, I always have this line, this is the first time I have seen this unwork :(
     
  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.