Respawn Event

Discussion in 'Spigot Plugin Development' started by bludsprae, Jun 12, 2017.

  1. Hello, I am having trouble with a respawn event I am trying to make it so where when a player dies the kit gui automatically pops up so I tried making a respawn event and then doing p.performCommand but when I try to create the string Player p = e.getPlayer it doesn't allow that when I type in e.get all that pops up is e.getClass. How can I get the player?
     
  2. You'll need to respawn the player first!

    Code (Text):
    @EventHandler
    public void onPlayerDeath(PlayerDeathEvent event) {
        event.getPlayer().spigot().respawn();
    }

    @EventHandler
    public void onPlayerRespawn(PlayerRespawnEvent event) {
        event.getPlayer().openInventory(inventory);
    }
     
  3. @Triozer Its not letting me create a string for player...
     
  4. "player" isn't defined in a string and when I try to do so it doesnt let me do e.get Player
     
  5. Ah, my bad! The object Player store the string name ;)

    Code (Text):
    String name = player.getName();
    I think is that you want..
     
  6. @Triozer You cannot do player.getName because player isnt defined
     
  7. Have you learn Java? Can I see your actual code?
     
  8. I fixed it I added it to my PlayerDeathEvent instead of creating a respawn event
     
  9. If you actually knew Java or the API you would know that player is a on Object of type Player and thus the method e.getPlayer() can only be used when it is being assigned to a Player object.

    You are attempting to assign a Player to a string when they are of different types, so yes its a valid question to ask if you know Java.

    You can assign a Player's name to a String name = e.getPlayer().getName()
     
    • Agree Agree x 1
  10. What is your kit command exactly?
    /kit <kit>
    /kit <player> <kit>
    /kit <player>

    Just what is it....