I am creating a plugin in which in eclipse, and in a sheet which I am doing an event for when they click, do certain things, but the problem is in the first if public void clickInventory(InventoryClickEvent event) { String name = ChatColor.translateAlternateColorCodes('&', "&2MiPlugin Inventario"); String nameM = ChatColor.stripColor(name); if(ChatColor.stripColor(event.getInventory().getName()).equals(nameM)) { if(event.getCurrentItem() == null || event.getSlotType() == null || event.getCurrentItem().getType() == Material.AIR || event.isShiftClick() ) { In that part of the code, in the eclipse I get an error in the getName () indicating the following: The method getName() is undefined for the type Inventory And as a solution it offers me: Add cast to method receiver Which doesn't work for me because it doesn't work for me I would appreciate an answer please, thank you
Please post the whole class and insert it as code or use Pastebin, it would be much easier to help you that way.
You are getting an error on getName() because that doesn't exist. You can use something like this to see if the player clicked inside of an specific inventory. Code (Java): if (player.getOpenInventory().getTitle().equalsIgnoreCase(invName)) { }
which version are you using? try InventoryView class, it has getTitle() method that returns title aka name. InventoryEvent class has getView() method event.getView() will return InventoryView class. so, Code (Text): event.getView().getTitle() will help you
Oh Thanks! It has served me! (I have not tried yours MrPixxima) since it served me the kingOf0 Thank you very much to both