This plugin I am making has 1 arg. I am not sure how to do this though. I want the first cmd to be whatever I choose. ATM it is stick. And the second command to be them item of the persons choosing here is what I have come up with so far. Please Help! Code: package da.head.change; import java.util.logging.Logger; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; public class DifferentArmor extends JavaPlugin{ public Logger logger = Logger.getLogger("Minecraft"); public static DifferentArmor plugin; @Override public void onDisable() { PluginDescriptionFile pdfFile = this.getDescription(); this.logger.info(pdfFile.getName() + " Has Been Disabled!"); } @Override public void onEnable(){ PluginDescriptionFile pdfFile = this.getDescription(); this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " Has Been Enabled!"); } public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){ Player player = (Player) sender; if(commandLabel.equalsIgnoreCase("stick")){ if(args.length == 0){ player.sendMessage(ChatColor.DARK_RED + "TOO LITTLE ARGUMENTS!"); }else if(args[1].equalsIgnoreCase("bedrock")) { ItemStack stick = new ItemStack(Material.STICK, 1); ItemStack bedrock = new ItemStack(Material.BEDROCK, 1); PlayerInventory pi = player.getInventory(); pi.addItem(stick); pi.setHelmet(bedrock); } } return false; } } Anyone? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Code:java public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){Player player = (Player)sender;if(commandLabel.equalsIgnoreCase("stick")){if(args.length < 1) return false;if(args.length > 2) return false;if(args[0].equalsIgnoreCase("bedrock")){player.getInventory().addItem(new ItemStack(Material.STICK, 1));player.getInventory().addItem(new ItemStack(Material.BEDROCK, 1));}}return true;}
Another way to do it would be: Code:java if(commandLabel.equalsIgnoreCase("stick")){if(args.length == 1){if(args[0].equalsIgnoreCase("bedrock")){ }}else{return false;}}