Why Doesn't my Re-spawn Work ?

Discussion in 'Plugin Development' started by arnie231, Apr 5, 2012.

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

    arnie231

    Hey guys I'm HAving trouble with my OnRepsawn Event i know its somethingsimpel but i dont understand why its not working if you could point out what i should be doing it would help me out loads

    Thanks bukkit Community

    Heres my Code for the listener

    Code:java
    1.  
    2. package com.arnie.doc.listeners;
    3.  
    4. import com.arnie.doc.Main;
    5. import java.util.List;
    6. import org.bukkit.Bukkit;
    7. import org.bukkit.Location;
    8. import org.bukkit.World;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.event.player.PlayerRespawnEvent;
    12.  
    13. public class PlayerRespawn implements Listener
    14. {
    15. public void onPlayerRespawn(PlayerRespawnEvent event)
    16. {
    17.  
    18. World w = Bukkit.getWorld(Main.config.getString("DawnOfCivilization WorldName"));
    19. Main.AztecSpawn = new Location(w, Main.config.getDouble("SpawnPoints.Aztecs.X"), Main.config.getDouble("SpawnPoints.Aztecs.Y"), Main.config.getDouble("SpawnPoints.Aztecs.Z"));
    20. Main.RomanSpawn = new Location(w, Main.config.getDouble("SpawnPoints.Romans.X"), Main.config.getDouble("SpawnPoints.Romans.Y"), Main.config.getDouble("SpawnPoints.Romans.Z"));
    21. Main.MongolSpawn = new Location(w, Main.config.getDouble("SpawnPoints.Mongols.X"), Main.config.getDouble("SpawnPoints.Mongols.Y"), Main.config.getDouble("SpawnPoints.Mongols.Z"));
    22. Main.EgyptainSpawn = new Location(w, Main.config.getDouble("SpawnPoints.Egyptains.X"), Main.config.getDouble("SpawnPoints.Egyptains.Y"), Main.config.getDouble("SpawnPoints.Egyptains.Z"));
    23.  
    24. Player player = event.getPlayer();
    25. String playername = player.getName();
    26.  
    27. List<String> Aztecs = Main.tribes.getStringList("Tribes.Aztecs");
    28. List<String> Romans = Main.tribes.getStringList("Tribes.Romans");
    29. List<String> Mongols = Main.tribes.getStringList("Tribes.Mongols");
    30. List<String> Egyptains = Main.tribes.getStringList("Tribes.Egyptains");
    31.  
    32.  
    33. if (Aztecs.contains(playername))
    34. player.teleport(Main.AztecSpawn);
    35. else if (Romans.contains(playername))
    36. player.teleport(Main.RomanSpawn);
    37. else if (Mongols.contains(playername))
    38. player.teleport(Main.MongolSpawn);
    39. else if (Egyptains.contains(playername))
    40. player.teleport(Main.EgyptainSpawn);
    41. }
    42. }
    43.  
     
  2. Offline

    dsmyth1915

    First off, getPlayer() returns the players name. Not its coordinates. Second, I don't think you can set a players respawn location after they have already died, so maybe consider switching to entityDeath event and check if the instance is q Player. Third, there is a setRespawnLocation and getRespawn location for entityplayer. Other than those your config string gets look good to me. This may also help, http://jd.bukkit.org/doxygen/d5/df4...nEvent.html#a40ccda5fb279bffe919d85b89d0a7201
     
  3. Offline

    arnie231

    Thanks i got it working by doing

    Code:java
    1.  
    2. public class TribeRespawn implements Listener
    3. {
    4. @EventHandler(priority=EventPriority.MONITOR)
    5. public void onAztecRespawn(PlayerRespawnEvent event)
    6. {
    7. Player player = event.getPlayer();
    8.  
    9. if (player.hasPermission("DOC.Aztec.Respawn"))
    10. {
    11. World w = Bukkit.getWorld(Main.config.getString("DawnOfCivilization WorldName"));
    12. Location AztecSpawn = new Location(w, Main.config.getDouble("SpawnPoints.Aztecs.X"), Main.config.getDouble("SpawnPoints.Aztecs.Y"), Main.config.getDouble("SpawnPoints.Aztecs.Z"));
    13. event.setRespawnLocation(AztecSpawn);
    14. }
    15. }
    16. }
    17.  
     
  4. Offline

    dsmyth1915

    You are very welcome!
     
  5. Offline

    Sagacious_Zed Bukkit Docs

    You should not be modifying events with the monitor priority
     
Thread Status:
Not open for further replies.

Share This Page