How to separate Glass Panes in a INV?

Discussion in 'Spigot Plugin Development' started by ShishKaBobz, Apr 27, 2017.

  1. So PRETEND!! This is your code
    Code (Text):
            ItemStack DIAMOND_SWORD = new ItemStack(Material.DIAMOND_SWORD);
            ItemStack BARRIER = new ItemStack(Material.BARRIER);
            ItemStack HEY = new ItemStack(Material.WHEAT);
            ItemStack PANE = new ItemStack(Material.STAINED_GLASS_PANE);
            ItemStack PANE1 = new ItemStack(Material.STAINED_GLASS_PANE);
            ItemStack PANE2 = new ItemStack(Material.STAINED_GLASS_PANE);
            ItemStack PANE3 = new ItemStack(Material.STAINED_GLASS_PANE);
            ItemStack PANE4 = new ItemStack(Material.STAINED_GLASS_PANE);
            ItemStack PANE5 = new ItemStack(Material.STAINED_GLASS_PANE);
            ItemStack PANE6 = new ItemStack(Material.STAINED_GLASS_PANE);
            ItemMeta itemMeta = DIAMOND_SWORD.getItemMeta();
            ItemMeta itemMetaA = BARRIER.getItemMeta();
             ItemMeta itemMetaB = PANE.getItemMeta();
                 ItemMeta itemMetaC = HEY.getItemMeta();
                     ItemMeta itemMetaD = PANE1.getItemMeta();
                         ItemMeta itemMetaE = PANE2.getItemMeta();
                             ItemMeta itemMetaF = PANE3.getItemMeta();
                                 ItemMeta itemMetaG = PANE4.getItemMeta();
                                     ItemMeta itemMetaH = PANE5.getItemMeta();
                                         ItemMeta itemMetaI = PANE6.getItemMeta();

    How do i separate the glass panes?
  2. what do u mean by separate?
  3. So they dont stack
  4. call setMaxStackSize on all of the item stacks. If this option is not available, add random (but different) colorcodes to your items lores :)
  5. Hey Thanks!
  6. Why did you make 6 different variables for the stained glass material? Just make 1 and add it 6 times. Or you can make the itemstack 6 glass panes, by adding an integer argument to the itemstack.

    This also means you can eliminate the copied and pasted itemmetas too, and just have it once! :).

    This also makes your code more expandable, so you can add as many as you want just by switching the number, without making a variable. Like, let's say you wanted 1000 panes, you just switch the argument to 1000 instead of making 1000 itemstacks and setting the itemmeta 1000 times.
  7. they are all the same so no need to use Pane 2, etc...
    use inv.setItem(); you can use the item multiple times...
    or use the inv.addItem(PANE, PANE, PANE); like that... but I don't know if it works :)
    and, ItemStack(Material, Amount, Damage);
  8. I legit just said this, just with more detail.
  9. aw... well sorry, i havent read the previous replies