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.setDisplayName("§7§l[§6§lGOD§7§l]");
           
            ItemMeta itemMetaA = BARRIER.getItemMeta();
           
            itemMetaA.setDisplayName("§c§lClear");
             DIAMOND_SWORD.setItemMeta(itemMeta);
             BARRIER.setItemMeta(itemMetaA);
             
             ItemMeta itemMetaB = PANE.getItemMeta();
                itemMetaB.setDisplayName("§2§lSoon!");
                 DIAMOND_SWORD.setItemMeta(itemMeta);
                 PANE.setItemMeta(itemMetaB);
                 
                 ItemMeta itemMetaC = HEY.getItemMeta();
                    itemMetaC.setDisplayName("§7§l[§2§lNOTCH!§7§l]");
                     HEY.setItemMeta(itemMetaC);
                     
                     ItemMeta itemMetaD = PANE1.getItemMeta();
                        itemMetaD.setDisplayName("§2§lSoon!");
                         PANE1.setItemMeta(itemMetaD);
                         
                         ItemMeta itemMetaE = PANE2.getItemMeta();
                            itemMetaE.setDisplayName("§2§lSoon!");
                             PANE2.setItemMeta(itemMetaE);
                             
                             ItemMeta itemMetaF = PANE3.getItemMeta();
                                itemMetaF.setDisplayName("§2§lSoon!");
                                 PANE3.setItemMeta(itemMetaF);
                                 
                                 ItemMeta itemMetaG = PANE4.getItemMeta();
                                    itemMetaG.setDisplayName("§2§lSoon!");
                                     PANE4.setItemMeta(itemMetaG);
                                     
                                     ItemMeta itemMetaH = PANE5.getItemMeta();
                                        itemMetaH.setDisplayName("§2§lSoon!");
                                         PANE5.setItemMeta(itemMetaH);
                                         
                                         ItemMeta itemMetaI = PANE6.getItemMeta();
                                            itemMetaI.setDisplayName("§2§lSoon!");
                                             PANE.setItemMeta(itemMetaI);
               
           
           
            inv.addItem(DIAMOND_SWORD,HEY,PANE,PANE2,PANE3,PANE4,PANE5,PANE6, BARRIER);

            player.openInventory(inv);
           
    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