Having players respawn with items.

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

  1. Offline

    AstramG

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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. Offline

    repsor

    My BukkitDev Profile
    My Plugins (2)
    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    It's really not clear what you'retrying to say. Just use the respawn event.
     
  3. Offline

    AstramG

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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. Offline

    repsor

    My BukkitDev Profile
    My Plugins (2)
    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    ofcourse it does, unless the playerdeathevent is cancelled :)
     
  5. Offline

    AstramG

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    It doesn't I've tried.
     
  6. Offline

    lcpvp

    My BukkitDev Profile
    My Plugins (4)
    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    It doesn't happen because the event is never ran :p, when you die it immediately teleports you with no screen coming up
     
  8. Offline

    lcpvp

    My BukkitDev Profile
    My Plugins (4)
    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    WHen you tp them give them stuff that you want to.
     
  9. Offline

    CubixCoders

    My BukkitDev Profile
    My Plugins (3)
    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Tried that, didn't work because the death event triggered it
     
  11. Offline

    AstramG

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    That doesnt work because it thinks that players are dead
     
  12. Offline

    AstramG

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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. Offline

    CubixCoders

    My BukkitDev Profile
    My Plugins (3)
    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Please just show your listener class then.
     
  14. Offline

    CubixCoders

    My BukkitDev Profile
    My Plugins (3)
    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I've did that already, forgot to mention. I restricted dropping.
     
  16. Offline

    CubixCoders

    My BukkitDev Profile
    My Plugins (3)
    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Okay then good job :p
     
  17. Offline

    AstramG

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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. Offline

    lcpvp

    My BukkitDev Profile
    My Plugins (4)
    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Check out my posts please on the dev page, the item menu one and timer one.


    Glad you solved
     
  19. Offline

    lcpvp

    My BukkitDev Profile
    My Plugins (4)
    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Code:java
    1.  
    2. @EventHandler
    3. public void onPlayerDeath(PlayerDeathEvent event){
    4. event.getDrops().clear();
    5. }
    6.  
     
  20. Offline

    AstramG

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    lol, I can't believe I didn't realize that :p. Thanks!
     

Share This Page