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

damage are not changing why ?

Discussion in 'Help' started by Spotted, May 25, 2022.

  1. Spotted

    Spotted Spider

    Messages:
    6
    <?php

    namespace ItemModifier\UnknownCod;

    use pocketmine\event\entity\EntityDamageByEntityEvent;
    use pocketmine\event\Listener;
    use pocketmine\player\Player;
    use pocketmine\plugin\PluginBase;

    class ItemModifier extends PluginBase implements Listener
    {
    public function onHit(EntityDamageByEntityEvent $event)
    {
    $damager = $event->getDamager();
    $target = $event->getEntity();
    if($damager instanceof Player && $target instanceof Player){
    $item = $damager->getInventory()->getItemInHand();
    if($item->getId() == $this->getConfig()->get("Item1") && $item->getMeta() == $this->getConfig()->get("Meta1")){
    $event->setBaseDamage(($this->getConfig()->get("damage1")));
    }
    elseif($item->getId() == $this->getConfig()->get("Item2") && $item->getMeta() == $this->getConfig()->get("Meta2")){
    $event->setBaseDamage($this->getConfig()->get("damage2"));
    }
    elseif($item->getId() == $this->getConfig()->get("Item3") && $item->getMeta() == $this->getConfig()->get("Meta3")){
    $event->setBaseDamage($this->getConfig()->get("damage3"));
    }
    elseif($item->getId() == $this->getConfig()->get("Item4") && $item->getMeta() == $this->getConfig()->get("Meta4")){
    $event->setBaseDamage($this->getConfig()->get("damage4"));
    }
    elseif($item->getId() == $this->getConfig()->get("Item5") && $item->getMeta() == $this->getConfig()->get("Meta5")){
    $event->setBaseDamage($this->getConfig()->get("damage5"));
    }
    }
    }
    }
     
  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.