Solved trying to add commad to give item that i made

Discussion in 'Spigot Plugin Development' started by josh13_, Jul 15, 2018.

  1. im trying to add command to give item. here is code of item:

    Code (Java):
        public void PlayerInteract(PlayerInteractEvent event) {

                Player player = event.getPlayer();
                ItemStack item = event.getItem();

                //Checks if the item is an emerald block and if it has item meta
                if (item.getType() == Material.EMERALD && item.hasItemMeta()) {
                    ItemMeta meta = item.getItemMeta();
                    Action action = event.getAction();
                    List<String> lore = meta.getLore();

                    //Added check for right_click_block and checks the lore and if the item's display name contains green gem
                    if (meta.getDisplayName().contains("Green Gem") && lore != null && lore.get(0).equals(ChatColor.DARK_PURPLE + "This Gem Gives Jump II And Speed II") && (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK)) {
                        player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 700, 1));
                        player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 700, 1));
    can someone help me to add command to this item please?
  3. thanks that one worked. :D