xTea_199 4 Opublikowano 1 lipca 2017 Udostępnij Opublikowano 1 lipca 2017 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 Więcej opcji udostępniania...
0 GotoFinal 195 Opublikowano 1 lipca 2017 Udostępnij Opublikowano 1 lipca 2017 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; } xTea_199 1 Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
0 xTea_199 4 Opublikowano 1 lipca 2017 Autor Udostępnij Opublikowano 1 lipca 2017 zrobiłem sobie sam, ale dzięki Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
0 PoweredDragon 1 014 Opublikowano 1 lipca 2017 Udostępnij Opublikowano 1 lipca 2017 Ten temat został zamknięty. Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
Pytanie
xTea_199 4
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