Hi,
I would like to use a command like this: / set mangouson efficiency 50.
It's for set efficienct enchant lvl 50 on an item.
But I want to check the value of args[0] and args[2] before check the enchant name of the args[1].
I want to check it to don't create exception and error in the console.
Do you have a solution please ?
I would like to use a command like this: / set mangouson efficiency 50.
It's for set efficienct enchant lvl 50 on an item.
But I want to check the value of args[0] and args[2] before check the enchant name of the args[1].
I want to check it to don't create exception and error in the console.
Code:
if(cmd.getName().equalsIgnoreCase("set") && args.length == 3){
//check args[0] and args[2]
Player p = Bukkit.getPlayer(args[0]);
int x = Integer.valueOf(args[2]);
ItemStack item = p.getInventory().getItem(0);
ItemMeta itemM = item.getItemMeta();
if(args[1].equalsIgnoreCase("efficiency")) {
itemM.addEnchant(Enchantment.DIG_SPEED, x, true);
}
Do you have a solution please ?
