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

Help me fix plugins

Discussion in 'Plugin Help' started by Viyen, Mar 20, 2020.

  1. Viyen

    Viyen Spider

    Messages:
    7
    GitHub:
    Viyen
    Fatal error: Declaration of BattleRoyale\EntityManager::attack(pocketmine\event\entity\EntityDamageEvent $source) must be compatible with pocketmine\entity\Living::attack(pocketmine\event\entity\EntityDamageEvent $source): void in /storage/emulated/0/PocketMine-MP/plugins/BattleRoyale-master/src/BattleRoyale/EntityManager.php on line 60

    on the console such error message

    Below is the code of the EntityManager.php file

    PHP:
    <?php

    namespace BattleRoyale;

    use 
    pocketmine\Player;
    use 
    pocketmine\entity\Living;
    use 
    pocketmine\network\mcpe\protocol\AddEntityPacket;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    use 
    pocketmine\nbt\tag\CompoundTag;
    use 
    pocketmine\nbt\tag\ListTag;
    use 
    pocketmine\nbt\tag\DoubleTag;
    use 
    pocketmine\nbt\tag\FloatTag;

    abstract class 
    EntityManager extends Living {

        public 
    $width 1;

        public function 
    attack(EntityDamageEvent $source){
            if(
    $source->getCause() !== EntityDamageEvent::CAUSE_VOID){
                
    $source->setCancelled();
            }else{
                if(
    $this->isAlive()){
                    
    $this->close();
                }
            }
        }

        public function 
    spawnTo(Player $player){
            
    $packet = new AddEntityPacket();
            
    $packet->type = static::NETWORK_ID;
            
    $packet->motion $this->getMotion();
            
    $packet->position $this->asVector3();
            
    $packet->entityRuntimeId $this->getId();
            
    $packet->pitch $this->pitch;
            
    $packet->yaw $this->yaw;
            
    $packet->metadata $this->getDataPropertyManager()->getAll();
            
    $player->dataPacket($packet);
            
    parent::spawnTo($player);
        }

        public static function 
    getCompoundMotion(Player $player): CompoundTag{
            
    $data = new CompoundTag("", [
                new 
    ListTag("Pos", array(
                    new 
    DoubleTag(""$player->getX()),
                    new 
    DoubleTag(""$player->getY() + $player->getEyeHeight()),
                    new 
    DoubleTag(""$player->getZ())
                )),
                new 
    ListTag("Motion", array(
                    new 
    DoubleTag("", -sin($player->yaw 180 M_PI) * cos($player->pitch 180 M_PI)),
                    new 
    DoubleTag("", -sin($player->pitch 180 M_PI)),
                    new 
    DoubleTag(""cos($player->yaw 180 M_PI) * cos($player->pitch 180 M_PI))
                )),
                new 
    ListTag("Rotation", array(
                    new 
    FloatTag(""$player->yaw),
                    new 
    FloatTag(""$player->pitch)
                ))
            ]);
            return 
    $data;
        }
    }
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Add a : void return type declaration to the attack function.
     
  3. Viyen

    Viyen Spider

    Messages:
    7
    GitHub:
    Viyen
    I added as you said but still got errors maybe I put it wrong or can you write down any additional details (I use Google Translate to communicate so there is a wrong word for the word)
     
  4. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Replace this:
    PHP:
    public function attack(EntityDamageEvent $source){
    with this
    PHP:
    public function attack(EntityDamageEvent $source) : void{
    and

    this
    PHP:
    public function spawnTo(Player $player){
    with this
    PHP:
    public function spawnTo(Player $player) : void{
     
    wolfdale likes this.
  5. Viyen

    Viyen Spider

    Messages:
    7
    GitHub:
    Viyen
    this is the plugins I downloaded the old api plugins is the api: 3.0.0-ALPHA12 I have upgraded to api 3.0.0 and there are too many errors here are the plugins I have fixed as you said but still have errors in the plugins below are the plugins I have correct but still have errors

    can also fix plugins to work properly or outdated plugins
    Here are the plugins I mentioned
     

    Attached Files:

  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.