Internal Server Error?

Discussion in 'Plugin Help' started by KingRainbow44, Sep 28, 2019.

  1. KingRainbow44

    KingRainbow44 Spider

    Messages:
    7
    GitHub:
    kingrainbow44
    Im trying to make a plugin that increases an item's desired damage value.

    Here's my code:

    public function onHitSent(EntityDamageByEntityEvent $event){
    $entity = $event->getEntity();
    $damager = $event->getDamager();
    $item = $damager->getInventory()->getItemInHand();
    if($this->getConfig()->get("use-damage") === true){
    if($item->getID() == $this->getConfig()->get("item")) {
    $entity->setHealth($entity->getHealth() - $this->getConfig()->get("damage") );
    }
    }
    }

    And every time I hit an entity it either does not give the damage I want or:
    [08:06:41] [Server thread/CRITICAL]: RuntimeException: "Recursive event call detected (reached max depth of 50 calls)" (EXCEPTION) in "src/pocketmine/event/Event" at line 87
     
  2. Fadhel

    Fadhel Spider Jockey

    Messages:
    47
    GitHub:
    youngfad
    PHP:
    public function onDamage(EntityDamageEvent $event){
    $entity $event->getEntity();
    if(
    $event instanceof EntityDamageByEntityEvent) {
    $damager $event->getDamager();
    $item $damager->getInventory()->getItemInHand();
    if(
    $this->getConfig()->get("use-damage") === true && $item->getId() === $this->getConfig()->get("item")){
    $entity->setHealth($entity->getHealth() - $this->getConfig()->get("damage"));
     
    Last edited: Oct 1, 2019
  3. wolfdale

    wolfdale Zombie

    Messages:
    369
    If you want to change amount of damage dealt to player
    PHP:
    $event->setBaseDamage($this->getConfig()->get("damage"));
    If you want to change amount of damage to durability of item
    PHP:
    $item->applyDamage($this->getConfig()->get("damage"));
     
  4. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    677
    Start deleting plugins? I guess...
     
  5. jasonwynn10

    jasonwynn10 Wither Skeleton Poggit Reviewer

    Messages:
    1,396
    GitHub:
    jasonwynn10
    show the rest of the backtrace
     
    EdwardHamHam and HimbeersaftLP like this.

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.