Having players respawn with items.

Discussion in 'Plugin Development' started by AstramG, Feb 18, 2013.

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

    AstramG

    I was wondering how I would get players to respawn with items after death. In my plugin, translated to English it basically checks for when you die and when you are, it immediately warps you somewhere and tries to spawn you the items. However, since its the death event it will not spawn the items since it thinks you're dead. I tried to use the PlayerRespawnEvent but it didn't work because the respawn GUI doesn't show when you die (It immediately teleports you). Therefor, I'm in need of a way to give the players the items.
     
  2. It's really not clear what you'retrying to say. Just use the respawn event.
     
  3. Offline

    AstramG

    repsor
    I can't because that is triggered when the player presses the button that says respawn.
    When the player dies he automatically gets teleported, no window comes up.
     
  4. ofcourse it does, unless the playerdeathevent is cancelled :)
     
  5. Offline

    AstramG

    It doesn't I've tried.
     
  6. Try
    Code:java
    1.  
    2. public void onPlayerRespawn(PlayerRespawnEvent event){
    3. Player p = event.getPlayer();
    4. p.sendMessage(ChatColor.BLUE + "You Respawned");
    5. }
     
  7. Offline

    AstramG

    It doesn't happen because the event is never ran :p, when you die it immediately teleports you with no screen coming up
     
  8. WHen you tp them give them stuff that you want to.
     
  9. So let is this what is happening?
    A player dies, the death event is cancelled and he is teleported making it a automatic-respawn? If so, just add the items in the PlayerDeathEvent you were checking for.
     
  10. Offline

    AstramG

    Tried that, didn't work because the death event triggered it
     
  11. Offline

    AstramG

    That doesnt work because it thinks that players are dead
     
  12. Offline

    AstramG

    I found a solution, what I did was checked on movement to see if they're inv was empty and if it was, it'll give the items. :)
     
  13. Please just show your listener class then.
     
  14. AstramG that's good and all but it won't work very effectively, what happens when the player throws all his items to get more? You would have to restrict that and pickingup items
     
  15. Offline

    AstramG

    I've did that already, forgot to mention. I restricted dropping.
     
  16. Okay then good job :p
     
  17. Offline

    AstramG

    I'm just worried about the lag it'd cause if I kept doing this in this sort of situation in the future. And by the way, while I have you. Do you know how to remove drops? (These are drops form the PlayerDeathEvent trying to make the player not drop anything) What I have so far is:
    Code (Text):
    1. for (ItemStack drops : event.getDrops()) {
    2.     drops.setType(Material.AIR);
    3. }
    However, it doesn't work :p
     
  18. Check out my posts please on the dev page, the item menu one and timer one.


    Glad you solved
     
  19. Code:java
    1.  
    2. @EventHandler
    3. public void onPlayerDeath(PlayerDeathEvent event){
    4. event.getDrops().clear();
    5. }
    6.  
     
  20. Offline

    AstramG

    lol, I can't believe I didn't realize that :p. Thanks!
     
Thread Status:
Not open for further replies.

Share This Page