Remove player from a ArrayList is he is died

Discussion in 'Plugin Development' started by bramhaag, Mar 15, 2014.

Thread Status:
Not open for further replies.
  1. Hi all,

    I have a problem. My code is not working. You probally already read the title, so you know where I'm talking about

    And yes, i registered my events.
    My current code:
    Code:java
    1. public void onPlayerDie(PlayerDeathEvent e)
    2. {
    3.  
    4. if (plugin.getConfig().getBoolean("remove-break-on-death") == true)
    5. {
    6. if (e.getEntityType() == EntityType.PLAYER) {
    7.  
    8. Player p = e.getEntity();
    9. if (plugin.wood.contains(p.getName()) ||
    10. plugin.stone.contains(p.getName()) ||
    11. plugin.glass.contains(p.getName()) ||
    12. plugin.clay.contains(p.getName()) ||
    13. plugin.other.contains(p.getName()))
    14. {
    15. if (plugin.wood.contains(p.getName()))
    16. {
    17. plugin.wood.remove(p.getName());
    18. }
    19. else if (plugin.stone.contains(p.getName()))
    20. {
    21. plugin.stone.remove(p.getName());
    22. }
    23. else if (plugin.glass.contains(p.getName()))
    24. {
    25. plugin.glass.remove(p.getName());
    26. }
    27. else if (plugin.clay.contains(p.getName()))
    28. {
    29. plugin.clay.remove(p.getName());
    30. }
    31. else if (plugin.other.contains(p.getName()))
    32. {
    33. plugin.other.remove(p.getName());
    34. }
    35. else
    36. {
    37. Bukkit.getLogger().log(Level.SEVERE, plugin.pr + "DAFUQ? This plugin is glitching out! Please check if you are using the newest version of UHC. If the problem keeps happening, please contact: Bramhaag, on BukkitDev!");
    38. }
    39. }
    40. else
    41. {
    42. return;
    43. }
    44. }
    45. else
    46. {
    47. return;
    48. }
    49. }
    50. }


    Thanks,

    bramhaag

    Btw. for some reason my signature is not working correctly, can someone give me some advise for that?
     
  2. Offline

    CoderMusgrove

    You could try using System.out.println(arg0); or Bukkit.broadcastMessage(String arg0); at different location of your code to see where it stops, but I can tell that you don't need the if statement at line 6, because the entity is already a player. Check that and see how it works.
    As well, when you said you registered all of your events, does that also include the @EventHandler annotation over that method? If not, you might want to add it.
     
  3. Offline

    RawCode

    if your code dont work start by adding debug output.

    can you tell me right now result of condition on line 31?
    can you tell me result of condition on line 9?
     
  4. Offline

    alex123099

    bramhaag
    do you have a "@EventHandler" above the method?
     
  5. alex123099

    OMG! I just totally forgot! Thanks!
     
Thread Status:
Not open for further replies.

Share This Page