Taking away items from an item stack in enderchest?

Discussion in 'Plugin Development' started by lcpvp, Mar 28, 2013.

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

    lcpvp

    I am trying to take away 5 cookies from a players enderchest if they have 5 cookies in it on command.
    This is what I have so far, but how do I get the cookies out of the players enderchest?
    Code:java
    1.  
    2. if(commandLabel.equalsIgnoreCase("Sharp"))
    3. {
    4. Map<Enchantment, Integer> Enchants = player.getInventory().getItemInHand().getEnchantments();
    5. Integer level = Enchants.get(Enchantment.DAMAGE_ALL);
    6. if(player.hasPermission("gg.sharp")){
    7. if(player.getItemInHand().getType() == Material.DIAMOND_SWORD){
    8. if(player.getEnderChest().contains(Material.COOKIE, 5));
    9. if(player.getItemInHand().containsEnchantment(Enchantment.DAMAGE_ALL)){
    10. if(level == 1){
    11. player.getItemInHand().addEnchantment(Enchantment.DAMAGE_ALL, 2);
    12. }else if(level == 2){
    13. player.getItemInHand().addEnchantment(Enchantment.DAMAGE_ALL, 3);
    14. }else if (level == 0){
    15. player.getItemInHand().addEnchantment(Enchantment.DAMAGE_ALL, 1);
    16. }else{
    17. player.sendMessage(ChatColor.GOLD + "This Sword Has Maximized Its Enchantments!");
    18. }
    19. }
    20. }else{
    21. player.sendMessage(ChatColor.GOLD + "Please Hold A Diamond Sword");
    22. }else{
    23. player.sendMessage(ChatColor.GOLD + "You don't have enough cookies to buy this.);
    24.  
    25. }else{
    26. player.sendMessage(ChatColor.GOLD + "You need permission /sharp to enchant your sword!");
    27. }
    28. }
    29.  
     
  2. Offline

    RingOfStorms

    player.getEnderChest()
     
  3. Offline

    lcpvp

    ...I know that how do I take away 5 cookies from it if he has 5 or more cookies
     
  4. Offline

    RingOfStorms

    Just like you would from any inventory, look it up there are about a million threads on this.
     
  5. Offline

    lcpvp

    Woa, I think they just changed the reply and liking system on this website. I know how to take away from inv with setsmmount then getammount - 1 but I cant find how to do it with enderchest

    Can someone else help?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
Thread Status:
Not open for further replies.

Share This Page