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

Respawn Bug

Discussion in 'Plugin Help' started by EerieAlchemist, May 28, 2020.

  1. EerieAlchemist

    EerieAlchemist Spider Jockey

    Messages:
    36
    In this skywars plugin, I have encountered an issue that exists only for Windows 10 players. Whenever a player falls into the void, they are greeting with an infinite “generating world” message, which I believe is a Pocketmine bug. Is there anything I could do to this code In regards to PlayerDeathEvent and PlayerRespawnEvent to fix it? Thanks for the help.
    PHP:
        /**
         * @param PlayerDeathEvent $event
         */
        
    public function onDeath(PlayerDeathEvent $event) {
            
    $player $event->getPlayer();

            if(!
    $this->inGame($player)) return;

            foreach (
    $event->getDrops() as $item) {
                
    $player->getLevel()->dropItem($player$item);
            }
            
    $this->toRespawn[$player->getName()] = $player;
            
    $this->disconnectPlayer($player""true);
            
    $this->broadcastMessage("§a> {$this->plugin->getServer()->getLanguage()->translate($event->getDeathMessage())} §7[".count($this->players)."/{$this->data["slots"]}]");
            
    $event->setDeathMessage("");
            
    $event->setDrops([]);
        }

        
    /**
         * @param PlayerRespawnEvent $event
         */
        
    public function onRespawn(PlayerRespawnEvent $event) {
            
    $player $event->getPlayer();
            if(isset(
    $this->toRespawn[$player->getName()])) {
                
    $event->setRespawnPosition($this->plugin->getServer()->getDefaultLevel()->getSpawnLocation());
                unset(
    $this->toRespawn[$player->getName()]);
            }
        }
     
  2. Joao Nunes

    Joao Nunes Spider Jockey

    Messages:
    30
    GitHub:
    joaonunes12
    Try change the event for EntityDamageEvent and don't let the player die.
     
  3. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Player in Mobile also gets this bug. Try chatting when a player kill you
     
  4. Draglor56

    Draglor56 Silverfish

    Messages:
    24
    Use the EntityDamageByEntityEvent and do this:

    PHP:
    $hearts $player->getHealth();    

    $damage $event->getFinalDamage();
    if (
    $hearts $damage <= 0) {
                      
      
    $event->setCancelled(true);      

      
    $player->setHealth(20);

    }
     
  5. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Bad code
     
  6. EerieAlchemist

    EerieAlchemist Spider Jockey

    Messages:
    36
    I tried using this and it didn’t work.
     
  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.