I'm trying to set the color of a Leather hat via a command, but I have one issue. I'm trying to use the Args (Would look something like this meta.setColor(Color.fromRGB(args[1], args[2] ,args[3])); ), but from what i know you cant add args[1] to a Color.fromRGB. What can I do to make it so I can use the Args to set the color of the Leather hat? CODE (Move your mouse to reveal the content) CODE (open) CODE (close) Code: package me.SkyLine.core; import org.bukkit.Bukkit; import org.bukkit.Color; 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.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; public class magichat implements CommandExecutor { public boolean onCommand(CommandSender sender, Command cmd, String lable, String[] args){ if ((sender instanceof Player)) { Player player = (Player)sender; if (player.hasPermission("skyline.admin")) { if (args.length == 3) { ItemStack helm = new ItemStack(Material.LEATHER_HELMET); LeatherArmorMeta meta = (LeatherArmorMeta) helm.getItemMeta(); meta.setColor(Color.fromRGB(10,40,10)); helm.setItemMeta(meta); for (Player p : Bukkit.getOnlinePlayers()) { if (p.getWorld().equals(player.getWorld())) { p.getInventory().setHelmet(helm); } } } } } return true; } }
Of course you should surround a parseInt() with a try catch. As soon as anybody does not usd numbers as arguments you will get a NumberFormatException.