getTitle() is not working

Discussion in 'Plugin Development' started by Batista_, Jul 31, 2020.

  1. Offline

    Batista_

    Hi, does anyone know why "getTitle ()" is not working? Java says it is undefined, but I don't understand why!
    Code:
    
    
        @EventHandler
        public void aoClicar(InventoryClickEvent e) { //Evento de clicar no inventario
            if (e.getWhoClicked() instanceof Player) { //se quem clicou no inventario for um player
                if(e.getInventory().getTitle().equals("Clans")) { // Seria pra vereficar se o titulo do inventario eh clans mas nao ta funfando
                    e.setCancelled(true); //cancela o evento
                    Player p = (Player) e.getWhoClicked();
                    if (e.getCurrentItem().getItemMeta().getDisplayName().equals("Criar um clan")) { //Se ele clicar no item em que o displayname for "criar um clan" ele vai fazer determianda acao
                        p.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); //equipa um chestplate
                        p.closeInventory(); //fecha o inventario
                       
                    }
                }
            }
           
        }
    Better picture here
     

    Attached Files:

    Last edited by a moderator: Jul 31, 2020
  2. Offline

    Wick

    Inventory#getTitle was removed on newer versions so it's Inventory#getView#getTitle now
     
  3. Offline

    GoofIt

    Like said above, Inventory#getTitle was removed.

    Here is what you would type instead:
    if (e.getView().getTitle().equalsIgnoreCase(YourGUIsTitle))
     
  4. Offline

    Batista_

    Worked! Thanks!!
     

Share This Page