i need help with my plugin plz

Discussion in 'Spigot Plugin Help' started by xTreMeDanii, Feb 2, 2020.

  1. 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
  2. Please post the whole class and insert it as code or use Pastebin, it would be much easier to help you that way.
  3. 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)) {

    • Like Like x 1
  4. 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.

    Code (Text):
    event.getView().getTitle() will help you
    • Like Like x 1

  5. Oh Thanks!
    It has served me! (I have not tried yours MrPixxima) since it served me the kingOf0
    Thank you very much to both :)