Help with a command

Discussion in 'Plugin Development' started by 360_, Jun 1, 2018.

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


    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 (open)

    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();
                            for (Player p : Bukkit.getOnlinePlayers()) {
                                if (p.getWorld().equals(player.getWorld())) {
            return true;
  2. Offline


    Hi there!

    The class Integer has a method called parseInt(String), so you can use for it
  3. Offline


    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.
Thread Status:
Not open for further replies.

Share This Page