Solved Already teleport?

Discussion in 'Spigot Plugin Development' started by Frealy1995, May 28, 2016.

  1. Hello, I code works and have a problems.

    Death event to auto respawn works and teleport system work and all teleport

    Example Teleport work and again teleport. again again again..

    Please, only a teleport (1)

    Code (Text):

    public void onDeath(PlayerDeathEvent e){
        Player player = e.getEntity();
        Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.plugin, new Runnable(){
            public void run() {
                double x = 109.473;
                double y = 120;
                double z = 100.525;
                int yaw = (int) 90.0;
                int pitch = (int) 0.0;
                Location spawn = new Location(player.getWorld(), x, y, z, yaw, pitch);
                PacketPlayInClientCommand packet = new PacketPlayInClientCommand(EnumClientCommand.PERFORM_RESPAWN);
        }, 0, 20);
  2. eqx


  3. scheduleSyncRepeatingTask will cause the task to continue running until you stop it manually... which you can do, but if you only want the player to respawn once, I would suggest using a synchronous delayed task instead of a repeating task. (BukkitScheduler)
  4. Player.spigot().respawn() ?

    What are you trying to do here, could you explain a little better?

    Edit: Nevermind, you're running a repeating task, meaning it will continuously run every second. Call BukkitRunnable#runTaskLater(Plugin varPlugin) and it will run once.

    Ps. You can run it 1 tick later, but drop the player's items manually before you respawn them or they will occasionally drop at the spawn location.
  5. No, error, Just problem a again teleport.