Skocz do zawartości
  • 0

Klikanie w inventory BEACONA


xTea_199
 Udostępnij

Pytanie

zrobiłem takie coś że po kliknięciu w stone w inventory BEACONA canceluje event ale to nie działa.. :( 

@EventHandler
    public static void onInvClick(InventoryClickEvent e){
        Inventory inve = e.getInventory();
        final Player p = (Player) e.getWhoClicked();
        if(inve == null){ return; } if(inve !=null){ if(!inve.getName().equals(inve.getTitle())){ return; } if (e.getCurrentItem() == null){ return; } else{ if(e.getCurrentItem().getItemMeta() == null){ return; } } }
            if(inve.getType().equals(InventoryType.BEACON)){
                ItemStack item = e.getCurrentItem();
                ItemMeta meta = item.getItemMeta();
                if(e.getWhoClicked() instanceof Player){
                    if(e.getCurrentItem().getItemMeta() == null){
                    }
                    if (e.getCurrentItem().getItemMeta().getDisplayName() == null){            
                    return;
                    }
                    if (!(e.getCurrentItem().getItemMeta().getDisplayName() == null)){    
                    }
                    if(e.getCurrentItem().getItemMeta().getDisplayName().equals(Material.STONE)){
                        e.setCancelled(true);
                    }
                }
            }
    }

 

 

Odnośnik do komentarza
Udostępnij na innych stronach

3 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

  • 0

Nie porównuj DisplayName do materiału: 

 if(e.getCurrentItem().getItemMeta().getDisplayName().equals(Material.STONE)){

To są inne typy, IDE powinno ci to oznaczyć jako potencjalny błąd.

Typ itemu pobierasz za pomocą .getType, więc zmień te 

.getItemMeta().getDisplayName().equals(Material.STONE)
na proste
.getType() == Material.STONE

I co ma robić te dziwne sprawdzenie?

 if(!inve.getName().equals(inve.getTitle())){ return; } 

 

Odnośnik do komentarza
Udostępnij na innych stronach

Nieaktywny
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
 Udostępnij

  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...