jasonw4331 / EasyCommandAutofill

A PocketMine plugin which adds commands to the client's autofill system by parsing usage messages
GNU Lesser General Public License v3.0
13 stars 5 forks source link

EntityLevelChangeEvent entity #1

Closed Invy55 closed 4 years ago

Invy55 commented 4 years ago

I sincerally don't know if this is really an issue but when my script dump the event (EntityLevelChangeEvent) and the plugin is installed I can see that

object(pocketmine\event\entity\EntityLevelChangeEvent)#98350 (5) {
  ["originLevel":"pocketmine\event\entity\EntityLevelChangeEvent":private]=>
  object(pocketmine\level\Level)#11509 (0) {
  }
  ["targetLevel":"pocketmine\event\entity\EntityLevelChangeEvent":private]=>
  object(pocketmine\level\Level)#97152 (0) {
  }
  ["entity":protected]=>
  object(pocketmine\Player)#13484 (0) {
  }
  ["eventName":protected]=>
  NULL
  ["isCancelled":"pocketmine\event\Event":private]=>
  bool(false)
}

entity is changed from the correct:

 object(pocketmine\event\entity\EntityLevelChangeEvent)#98350 (5) {
   ["originLevel":"pocketmine\event\entity\EntityLevelChangeEvent":private]=>
   object(pocketmine\level\Level)#11509 (0) {
   }
   ["targetLevel":"pocketmine\event\entity\EntityLevelChangeEvent":private]=>
   object(pocketmine\level\Level)#97152 (0) {
   }
   ["entity":protected]=>
   object(pocketmine\Player)#13484 (0) {
   }
   ["eventName":protected]=>
   NULL
   ["isCancelled":"pocketmine\event\Event":private]=>
   bool(false)
 }

so obviusly my plugin don't work.

PS: Can you please make me an example of how your plugin work?

jasonw4331 commented 4 years ago

I don't see what you mean or what you are asking here.

Invy55 commented 4 years ago

Ok, so:

 public function anormaleventlistenerfunction(EntityLevelChangeEvent $event){
        var_dump($event);
    }

I've this very simple function that checks for the EntityLevelChangeEvent and dumps its contents in the console. Then in that function I need to get the entity that is triggering the event, with: $entity = $event->getEntity(); and then $entity->setHunger(20); // to set entity hunger (obviusly after checking for the entity to be a player) Which trow an error saying:

Error: "Call to undefined method jasonwynn10\EasyCommandAutofill\AutofillPlayer::setHunger()" (EXCEPTION) in "plugins/NoStarving/src/Invy55/NoStarving/Main" at line 32

jasonw4331 commented 4 years ago

Oh I see. It's not actually my plugin which is causing the issue. There is no setHunger() function in the base Player class.