Hi! I was going to make a GUI for my Plugin. When making the GUI, I ran into the problem that I can't seem to figure out how to change the color of the Wool. I tried some different things that I found on the forums but they didn't seem to work for me (The byte things, DyeColor.. ). I would be really happy if anyone that know how to do this could tell me how! Code (Text): package net.styxnetwork.colornamegui.commands; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import net.md_5.bungee.api.ChatColor; public class color implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (label.equalsIgnoreCase("color")) { if (!(sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "Bara spelare kan använda detta kommando."); return false; } Player p = (Player) sender; Inventory inv = Bukkit.createInventory(null, 18, ChatColor.AQUA + "Färg Byte - STyX Network"); ItemStack lightgraywool = wool(Material.WOOL, (byte)1, ChatColor.GRAY + "Ljus grå färg"); ItemStack graywool = wool(Material.WOOL, (byte)2, ChatColor.DARK_GRAY + "Grå färg"); ItemStack pinkwool = wool(Material.WOOL, (byte)3, ChatColor.RED + "Rosa Ull"); inv.setItem(0, lightgraywool); inv.setItem(1, graywool); inv.setItem(2, pinkwool); p.openInventory(inv); return true; } return false; } private ItemStack wool(ItemStack item, String name) { ItemMeta meta = item.getItemMeta(); meta.setDisplayName(name); item.setItemMeta(meta); return item; } private ItemStack wool(Material item, byte b, String name) { return wool(new ItemStack(item), name); } }
You aren't actually doing anything with that byte value from what I can see, Change Code (Text): private ItemStack wool(Material item, byte b, String name) { return wool(new ItemStack(item), name); } TO Code (Text): private ItemStack wool(Material item, short b, String name) { return wool(new ItemStack(item, 1, b), name); }
ItemStack(Material type, int amount, short damage) https://hub.spigotmc.org/javadocs/s...ml#ItemStack(org.bukkit.Material, int, short)
I think your ItemStack constructor is little messed up. The inputs for the constructor goes as follows: Code (Text): ItemStack(Material type, int amount, short damage) type - Material amount - The quantity damage - The "color" of the wool So if you wanted red wool you would need: Code (Text): ItemStack(Material.WOOL, 1, (short) 14); Here is a link to the color codes for wool: http://minecraft.gamepedia.com/Wool Edit: Semi-Sniped by @NinjaStix
The correct way to do this is as follows: ItemStack(1ST ARG = material, 2ND ARG = QTY, 3RD ARG = Byte Data Value); ItemStack blackWool = new ItemStack(Material.WOOL, 1, (byte)15);
Yes, except that constructor has been deprecated for some time. He should use the constructor ItemStack(Material, int, short)