Array with itemstacks

Discussion in 'Spigot Plugin Development' started by Deger, May 25, 2016.

  1. Hello!

    I am searching for a way to store itemstacks in a array(list)! So i can use open up a inventory and when i press on the apple(food tab) ill get steaks and apple etc

    I made simple plugin that opens up a inventory!
    Help me make so one slot gives 1 apple and 2 steaks (can be whatever aslong as one slot gives more than one item)

    Code (Text):
    package com.deger.inv;

    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.Inventory;

    import net.md_5.bungee.api.ChatColor;

    public class Inv extends JavaPlugin{

        public void onEnable() {

        public void onDisable() {

        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            Player p = (Player) sender;
            Inventory inv = Bukkit.createInventory(null, 9, ChatColor.RED + "Cool Inventory");
            if (!(sender instanceof Player)){
                p.sendMessage("You are not allowed");
            return true;
  2. Where is the inventory? And to store an itemstack in an arraylist do:
    Code (Text):
    List<ItemStack> stacks = new ArrayList<>();
  3. MiniDigger


    I refuse to help you if you have help me in your title. Put something informational in your title...
    you need to check if the player clicked on your food tab icon using the inventoryclickevent.
    you can make an arraylist with itemsstack the same way you do with every other object.
    when the player clicks on the item in the inventory iterator over that arraylist and give the player every itemstack that is in that list.
    • Funny Funny x 1