I can't squish this bug

Discussion in 'Plugin Development' started by Jellydude, Jul 17, 2013.

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

    Jellydude

    I've made it so when a player does /angel they get all the stuff listed below in the code. (The command boolean and stuff is in a different class) but when a player /angel they receive the items but not the enchantment. However if they do /angel again (once they die as I've got a one kit per life system in play) all the enchnatments are there.
    Code:java
    1. package me.jelly.mkits.kit;
    2.  
    3.  
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Material;
    6. import org.bukkit.enchantments.Enchantment;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.inventory.ItemStack;
    9.  
    10.  
    11.  
    12. public class AngelKit extends Kit {
    13. public AngelKit(){
    14. super("Angel");
    15. }
    16.  
    17. @Override
    18. public void applyKit(Player player) {
    19.  
    20. if(player.hasPermission("mkits.angel")) {
    21.  
    22. wipe(player);
    23.  
    24. player.getInventory().addItem(ghoe);
    25. player.getInventory().addItem(new ItemStack(Material.GOLDEN_APPLE, 3));
    26. player.getInventory().setHelmet(ghelm);
    27. player.getInventory().setChestplate(gchest);
    28. player.getInventory().setLeggings(glegs);
    29. player.getInventory().setBoots(gboots);
    30. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    31. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    32. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    33. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    34. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    35. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    36. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    37. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    38. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    39. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    40. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    41. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    42. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    43. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    44. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    45. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP));
    46. ghoe.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 5);
    47. ghoe.addUnsafeEnchantment(Enchantment.DURABILITY, 3);
    48. ghelm.addEnchantment(Enchantment.DURABILITY, 3);
    49. gchest.addEnchantment(Enchantment.DURABILITY, 3);
    50. glegs.addEnchantment(Enchantment.DURABILITY, 3);
    51. gboots.addEnchantment(Enchantment.DURABILITY, 3);
    52. ghelm.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
    53. gchest.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
    54. glegs.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
    55. gboots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
    56.  
    57.  
    58. }else{
    59. player.sendMessage(ChatColor.DARK_RED + "mKits> Sorry, you do not have permission to use this kit.");
    60.  
    61. }
    62.  
    63. }
    64. }
    65.  
    66.  
    67.  
     
  2. Offline

    Henzz

  3. Offline

    Jellydude

    Henzz
    It says the method is deprecated and doesn't work even when I suppress the warning
     
  4. Offline

    Henzz

    Jellydude
    Have you tried it though? Doesn't hurt to try.
     
  5. Offline

    Jellydude

    Henzz
    Yeah I just did.
     
  6. Offline

    skore87

    Try setting the enchantment to the item before adding it to inventory.
     
  7. Offline

    Jellydude

  8. the method is deprecated , but it works.
     
  9. Offline

    Jellydude

  10. make a delayed task and update 1 or 2 ticks later
     
Thread Status:
Not open for further replies.

Share This Page