Solved How to fill empty slots when running a command

Discussion in 'Spigot Plugin Development' started by greenalex16, Aug 7, 2018.

Thread Status:
Not open for further replies.
  1. Hey guys!

    So I'm really new to coding plugins, and I'm working on this test kitpvp plugin and I want to fill all empty slots in the player's inventory with mushroom stew. Someone told me to use a for loop and I don't know what it is lol

    This is the code I have so far, there red spot will be where I would put the code to fill empty spots, I just need to know the code I would have to put there :p
    if(cmd.getName().equalsIgnoreCase("starter")) {
    p.sendTitle(ChatColor.translateAlternateColorCodes('&', "&6Succesfully given"), ChatColor.translateAlternateColorCodes('&', "&ekit Starter"));
    p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6&lKits &8» &eSuccesfully given kit Starter"));
    p.getInventory().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
    p.getInventory().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    p.getInventory().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    p.getInventory().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
    return true;
  2. You should consider to learn the basics of Java first (and don't ask where… there are already thousands of threads about this, we don't need another).
    So why don't you try to find out?

    I'll guide you into the right direction. If you want more, then you're asking for spoon feeding (then i'm out).
    2. org.bukkit.inventory.PlayerInventory#setItem
    3. org.bukkit.inventory.Inventory#getItem
    Now show us your motivation to think by yourself and trying to learn something.
    (We got enough spoon feed requests today)
    • Agree Agree x 2
  3. I usually watch tutorials, but I noticed looking for specific things won't help me, I started just being curious and finding things out on my own but when I have no clue I just ask someone else, but today I decided to come here, never thought to look at wikis, though thanks for showing me the website and the nicest attitude!
Thread Status:
Not open for further replies.