ArrayList does nothing...?

Discussion in 'Plugin Development' started by Blingdaddy1, Jan 23, 2014.

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

    Blingdaddy1

    So, this is my ArrayList:
    Code:java
    1. public static List<String> hasKit = new ArrayList<String>();

    I'm trying to make it so a player has to die before they get their kit again, so heres my death listener:
    Here's a kit from the plugin:
    Code:java
    1. if (args.length == 1) {
    2. if (hasKit.contains(player.getName())) {
    3. player.sendMessage(chosen kit message);
    4. } else {
    5. ItemStack iHelm = new ItemStack(Material.IRON_HELMET, 1);
    6. ItemStack iChest = new ItemStack(Material.IRON_CHESTPLATE, 1);
    7. ItemStack iLegs = new ItemStack(Material.IRON_LEGGINGS, 1);
    8. ItemStack iBoots = new ItemStack(Material.IRON_BOOTS, 1);
    9. ItemStack dSword = new ItemStack(Material.DIAMOND_SWORD, 1);
    10. ItemStack wBow = new ItemStack(Material.BOW, 1);
    11. ItemStack wArrow = new ItemStack(Material.ARROW, 64);
    12. player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, 3));
    13. dSword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
    14. player.getInventory().addItem(iHelm);
    15. player.getInventory().addItem(iChest);
    16. player.getInventory().addItem(iLegs);
    17. player.getInventory().addItem(iBoots);
    18. player.getInventory().addItem(dSword);
    19. player.getInventory().addItem(wBow);
    20. player.getInventory().addItem(wArrow);


    My problem here is, I don't have to die to choose a kit again.
     
  2. Offline

    ccrama

    What are you trying to do here? There is no code that a. shows death at all or b. adds him to the list at all... You have to do hasKit.add(player.getName()); for it to actually work for you :p
     
  3. Offline

    Blingdaddy1

    Would this work:
    Code:java
    1. if (!hasKit.contains(player.getName())) {
    2. hasKit.add(player.getName());
    ?
     
  4. Offline

    ccrama

    Blingdaddy1 Yes, or you can add that to the bottom after your else statement. Both should work!
     
  5. Offline

    Blingdaddy1

    Alright great. Thanks! xD
     
Thread Status:
Not open for further replies.

Share This Page