Solved Using a command to put on armor

Discussion in 'Plugin Development' started by 17nhammond, Jan 18, 2014.

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

    17nhammond

    How would I make it so that when you type a command it would give you full leather armor. Like if you did /leatherarmor. I need to know how to do this so that I can make specific armor patterns for a plugin i am making. Thank you!
     
  2. Offline

    sgavster

    17nhammond You could do this:

    Code:java
    1. ItemStack[] leather = { new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.LEATHER_CHESTPLATE), new ItemStack(Material.LEATHER_LEGGINGS), new ItemStack(Material.LEATHER_BOOTS) };
    2. player.getInventory().setArmorContents(leather);

    Untested
     
  3. Offline

    SuperOmegaCow

    17nhammond cast the sender to player, get their inventory and set their armour.
     
  4. Offline

    17nhammond

    sgavster
    I think that would work, but how about the command included?
     
  5. Offline

    SuperOmegaCow

    17nhammond we don't spoon feed, search it up.
     
  6. Offline

    Captain Dory

    I've typed this on my phone so there may be spelling mistakes:

    ItemStack[] leather = { new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.LEATHER_CHESTPLATE), new ItemStack(Material.LEATHER_LEGGINGS), new ItemStack(Material.LEATHER_BOOTS) };

    public boolean onCommand (CommandSender sender, Command cmd, String label, String [] args) {
    if (cmd.getName().equalsIgnoreCase("leather")) {
    player.getInventory().setArmorContents(leather);
    }
    That should work ;)
     
  7. Offline

    sgavster

    17nhammond You have 6 plugins and don't know how to create a command? ..
     
  8. Offline

    SuperOmegaCow

    sgavster after looking through his plugins I believe he is the kind of dev that posts what they get from a tutorial.
     
    sgavster likes this.
  9. Offline

    Niknea

    Create a command, a Itemstack for each piece of armour, then put it on the player with
    Code:java
    1. player.getInventory().setHelmet(helmet);
     
  10. Offline

    17nhammond

    sgavster
    I know how to make a command it just wasn't working...
     
  11. Offline

    xTigerRebornx

    17nhammond Could've asked for help if it wasn't working :p
     
    17nhammond likes this.
  12. Offline

    17nhammond

    sgavster SuperOmegaCow
    Thank u for cooperating, I got the problem solved and I haven't coded in about 4 months so thank you for being patient with me. I got the command to work I just forgot what to do and I had an error in my code. Thanks again!
    NateD101

    xTigerRebornx
    Thanks tiger, thank you for being willing to help me and others like me on the forums :) You have helped a lot of people, keep up the good work.

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

Share This Page