Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Task problem

Comments in 'Plugin Development' started by JackboyPlay, May 21, 2016.

  1. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Hi I have a problem when the player joins he will teleported too to the position but the player shall only teleported after 3 seconds on death
    PS: the player will be correctly inputted in the array with $this->soup[] = $player->getName()
    and the player will only inputted on command but he will be teleported on Join too!
    Here is the deathEvent
    PHP:
    public function onTod(EntityDeathEvent $event){
    $opfer $event->getEntity();
    $killer $event->getEntity()->getLastDamageCause()->getDamager();
    if(
    in_array($opfer->getName(), $this->soup)){
    $this->getServer()->getScheduler()->scheduleDelayedTask(new Respawn($this$opfer), 60);
    }
    }
    Here is the task
    PHP:
    class Respawn extends PluginTask {
    public function 
    __construct(Plugin $ownerPlayer $opfer) { 
    parent::__construct($owner);
    $this->player $opfer;
    public function 
    onRun($currentTick) {
    if(
    in_array($this->player->getName(), $this->getOwner()->soup)){
    $this->player->teleport(new Position(1258128));
    }
    }
    }
    }
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Use PlayerRespawnEvent.
  3. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    I used it before and the bug still exists too

Share This Page

Advertisement