Fixing my timer

Discussion in 'Plugin Development' started by diamondcodes, Aug 2, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    diamondcodes

    Alright so i have this plugin im making and im adding a timer before it teleports the alive player out of the arena, I have tried this
    Code:java
    1. public void endDuel(final Player player) {
    2. final FileManager fm = this.plugin.getFileManager();
    3. ItemManager im = this.plugin.getItemManager();
    4. String playerName = player.getName();
    5. final DuelArena arena = getPlayersArena(playerName);
    6.  
    7.  
    8.  
    9. if (arena.getPlayers().size() == 1);
    10. Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new BukkitRunnable() {
    11.  
    12. public void run() {
    13. arena.getPlayers().clear();
    14. player.teleport(fm.getLobbySpawnLocation());
    15. arena.setDuelState(DuelState.WAITING);
    16. }
    17.  
    18. }, 500L);
    19.  
    20. if (this.plugin.isUsingSeperatedInventories()) {
    21. restoreInventory(player);
    22. }
    23. im.rewardPlayer(arena);
    24. }

    But with this it teleports the dead player after 25 seconds not the alive player, It also does not remove the dead player from the duel its self so when he types a command it says type /duel leave but he has already died so he is already out of the duel :/
    Can anybody help?
    (I want it to teleport the alive player after 25 seconds, and remove the dead player from the duel right when he dies)
     
  2. Offline

    IkBenHarm

    diamondcodes
    so the problem is that he gets teleported while dead?

    Maybe revive him berfore teleporting
     
  3. Offline

    diamondcodes

    No, So after the player dies he gets teleported to the spawn But then after 25 seconds he gets teleported to the spawn again because of the timer but i dont want the player that dies to get teleported the second time, I just need the killer to get teleported after 25 seconds because CombatLog prevents teleportation unless you die
     
  4. Offline

    IkBenHarm

    diamondcodes
    I still dont think that i understand correctly...
    but if i do:

    if(!player.isDead()){
    teleport
    }else{
    do nothing
    }
     
  5. Offline

    BaranCODE

    If you mean the wrong player is getting teleported, give "endDuel(Player player)" the other player, in the arguments, when you're running it.
     
  6. Offline

    diamondcodes

    What exactly do you mean? Can you show me?

    Bumb

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  7. Offline

    BaranCODE

    Well, you have the function endDuel, right? Somewhere, you're probably running it with code similar to this:

    endDuel(deadPlayer);

    Well, you need to change that to:

    endDuel(killerPlayer);

    Your variables are probably not called deadPlayer and killerPlayer, but whatever they are, this switch is what you need to do.
     
Thread Status:
Not open for further replies.

Share This Page