Could not pass Player OnDeathEvent to my plugin

Discussion in 'Plugin Development' started by theodorehip, Sep 26, 2014.

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

    theodorehip

    Hi guys,
    Im trying to teleport players to a certain spot when they die.
    I keep getting a stacktrace in which bukkit cant pass on the death event to my plugin.

    The error: http://gyazo.com/0f7db57147c3f5c5ac683a7db2d2a976


    Heres the code:

    Code:java
    1. @EventHandler
    2. public void onPlayerDeath(PlayerDeathEvent e) { // checks for death of players
    3.  
    4. final Player p = e.getEntity();
    5. boolean joincheck = false;
    6. for (int i = 1; i <= total; i++) {
    7. Player spot = savedPlayers[I];[/I]
    8. [I] if (spot.equals(p)) {[/I]
    9. [I] joincheck = true;[/I]
    10.  
    11. [I] }[/I]
    12.  
    13. [I] }[/I]
    14. [I] if (joincheck == true && gameRunning == true) {[/I]
    15. [I] int tpx = getConfig().getInt("SpawnX");[/I]
    16. [I] int tpy = getConfig().getInt("SpawnY");[/I]
    17. [I] int tpz = getConfig().getInt("SpawnZ");[/I]
    18. [I] World world = p.getWorld();[/I]
    19. [I] Location tpa = new Location(world, tpx, tpy, tpz);[/I]
    20. [I] p.teleport(tpa);[/I]
    21. [I] p.getInventory().clear();[/I]
    22. [I] p.getInventory().setHelmet(new ItemStack(Material.LEATHER_HELMET, 1));[/I]
    23. [I] p.getInventory().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE, 1));[/I]
    24. [I] p.getInventory().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS, 1));[/I]
    25. [I] p.getInventory().setBoots(new ItemStack(Material.LEATHER_BOOTS, 1));[/I]
    26. [I] p.getInventory().addItem(new ItemStack(Material.IRON_SWORD, 1));[/I]
    27.  
    28. [I] }[/I]
    29.  
    30. [I] }[/I]
    31. [I][/I]



    It isnt a listening issue or event log issue because i have other events like PlayerMoveEvents, registered just fine.


    Thanks Everyone!
     
  2. Offline

    theodorehip

    It's over 800 lines or so, you sure you want to look through all of it?
     
  3. Offline

    CraftCreeper6

  4. Offline

    theodorehip

    Actually I fixed it guys, thanks, i switched out the OnDeath Event with a RespawnEvent, i dont know what i was thinking. Ill delete this thread in a few minutes.
    Thanks guys.
     
  5. Offline

    CraftCreeper6

  6. Offline

    theodorehip

    I suppose so, i just jumped the gun because the thread really wasnt used for what it should have been. But i can leave it up.
     
  7. Offline

    ChipDev

    I want to see freaking 800 lines of code.
    plz I liek coed
     
  8. Offline

    fireblast709

    theodorehip instead of a Player[], you might want to use a Set<UUID>. It's much faster than looping over an array, plus there is no real need to store the whole Player object.
     
Thread Status:
Not open for further replies.

Share This Page