Potions and mushroom soup not showing up when added to player inv

Discussion in 'Plugin Development' started by SeibelFTW, Sep 30, 2013.

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

    SeibelFTW

    this is my code: (i already tried to put the potion code after the sword code, no luck.)

    public boolean onCommand(CommandSender sender, Command cmd, String lbl, String[] args)
    {
    Player p = (Player)sender;
    p.getInventory().clear();
    PlayerInventory inv = p.getInventory();
    if ((sender instanceof Player)) {
    if (args.length == 0) {
    sender.sendMessage(ChatColor.RED + "Here's Your Kit!");
    p.setFoodLevel(20);
    inv.addItem(new ItemStack[] { mageUtils.getSword() });
    inv.setArmorContents(new ItemStack[] {
    mageUtils.getBoots(),
    mageUtils.getLeggings(),
    mageUtils.getChestplate(),
    mageUtils.getHelmet() });
    ItemStack item = new ItemStack(Material.POTION, 10);
    Potion pot = new Potion(1);
    pot.setType(PotionType.INSTANT_DAMAGE);
    pot.setHasExtendedDuration(false);
    pot.setSplash(true);
    pot.apply(item);
    p.getInventory().addItem(item);
    ItemStack item1 = new ItemStack(Material.POTION, 3);
    Potion pot1 = new Potion(1);
    pot1.setType(PotionType.POISON);
    pot1.setHasExtendedDuration(false);
    pot1.setSplash(true);
    pot1.apply(item1);
    p.getInventory().addItem(item1);
    ItemStack item2 = new ItemStack(Material.POTION, 2);
    Potion pot2 = new Potion(1);
    pot2.setType(PotionType.WEAKNESS);
    pot2.setHasExtendedDuration(false);
    pot2.setSplash(true);
    pot2.apply(item2);
    p.getInventory().addItem(item2);
    }

    for (int i = 0; i < 32; i++)
    inv.addItem(new ItemStack[] { Utils.getSoup() });
    }
    else {
    sender.sendMessage(ChatColor.RED + "You Cannot Perform this command.");
    }
    returnfalse;
    }
    }
     
  2. Offline

    etaxi341

    SeibelFTW Add this at the end:
    Code:java
    1. p.updateInventory()
     
  3. Offline

    Garris0n

    Use code tags, and your command doesn't even make sense...
    -Why are you checking if the args == 0? You haven't even checked what the actual command is yet.
    -Did you even register the command in the plugin.yml, seeing as it doesn't appear to exist?
    -Why do you give them soup after checking if the args == 0?
    -returnfalse?
    -You should really clean up the item creation code and use some methods elsewhere to get them...
    -Also: "You Cannot Perform this command"? Why on earth did you capitalize half the words in the sentence..
     
  4. Offline

    SeibelFTW

    i already fixed it, and i did define the command in the plugin.yml
     
Thread Status:
Not open for further replies.

Share This Page