Right click for command

Discussion in 'Plugin Development' started by Raul_gamer, Feb 11, 2019.

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

    Raul_gamer

    Code:
    public class ItemsAlEntrar implements Listener {
        private BasicPlugin plugin;
      
        public ItemsAlEntrar(BasicPlugin plugin){
            this.plugin = plugin;
        }
    
    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        FileConfiguration config = plugin.getConfig();
        String slot = "Items-Al-Entrar.slot";
        String material = plugin.getConfig().getString("Items-Al-Entrar.material");
        String nombre = "Items-Al-Entrar.nombre";
        Player player = event.getPlayer();
    
    ItemStack item = new ItemStack(Material.getMaterial(material), 1);
    ItemMeta meta = item.getItemMeta();
    
    meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(nombre)));
    ArrayList<String> lore = new ArrayList<String>();
    List<String> desc = config.getStringList("Items-Al-Entrar.lore");
    for(int i=0;i<desc.size();i++){
    String desc1 = desc.get(i);
    lore.add(ChatColor.translateAlternateColorCodes('&', desc1));
    meta.setLore(lore);
    item.setItemMeta(meta);
    
    player.getInventory().setItem(config.getInt(slot), item);
      }
    }
    }
    I have done this code that consists in that when the player enters an item, what I want to do is that when I right click the item, execute a command
     
    Last edited by a moderator: Feb 11, 2019
  2. Online

    timtower Administrator Administrator Moderator

    @Raul_gamer And what kind of help do you need then?
    What have you tried?
     
Thread Status:
Not open for further replies.

Share This Page