Solved Different stained glass in chest GUI

Discussion in 'Plugin Development' started by Boobah, Feb 21, 2017.

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


    Hey, I'm trying to make a /prefs plugin, but I'm not sure how to make different stained glass in the inventory. I have this:
    Player player = (Player) sender;
                Inventory pInv = Bukkit.createInventory(null, 45, "My Preferences");
                ItemStack border = new ItemStack (Material.STAINED_GLASS_PANE);
                border.setData(MaterialData((byte) 3));
                ItemMeta borderMeta = border.getItemMeta();
                for(int i = 0; i < 9; i++){
                    pInv.setItem(i, border);
                    pInv.setItem(i + 36, border);
                if(!Ranks.hasAccess(player, Ranks.TRAINEE)){
    When I open the GUI, the stained glass is just white.
    Been searching on the internet, that's how I found the "border.setData(MaterialData((byte) 3));".
    Probably not close to how you are supposed to do it, but I tried.
  2. Offline


    Use ItemStack#setData(Byte) to change the color of the glass. You can use DyeColor if do not know the values by hand.
  3. Offline


    That really doesn't make sense.
  4. Offline


    This is what I use for my GUI's and I currently have it as a block, but you can change it to stained glass pane, I'm sure you can figure it out.

    ItemStack Glass = new ItemStack(Material.STAINED_GLASS, 1, (byte) 14);
            ItemMeta GlassMeta = Glass.getItemMeta();
            GlassMeta.setDisplayName(ChatColor.RED + "Custom Name");
    All of this code should be real simple, but at the end of the first line, there's '(byte) 14'
    The number 14 is the color for red. You can look up on all the color's of wool's or stained clay and where it says the ID:#, take that number, at separating the ID from the colon to the right, and that's the color.
  5. Offline


    @Boobah from what I can tell, you haven't set the item meta on your item stack with ItemStack#setItemMeta(ItemMeta), this shouldn't have anything to do with the color issue but it should be affecting the name of the pane. Just thought I would mention this.
  6. Offline


    Thanks. <3 This works.
Thread Status:
Not open for further replies.

Share This Page