Помогите Что возвращает null?

Статус
Закрыто для дальнейших ответов.

TheZefirrkka

Активный участник
Пользователь
Баллы
76
Неа
 
Последнее редактирование:
Java:
public void onBla-bla (PlayerInteractEvent e) {
Player p = e.getPlayer
if(e != null && p.getItemInHand().getType() != null && p.getItemInHand().getItemMeta().getDisplayName() != null && e.getClickedBlock() != null && p.getItemInHand().getItemMeta() != null && e.getClickedBlock().getType() != null && p.getItemInHand() != null && e.getItem() != null){
        if (p.getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.BLUE + "Прокладка") && e.getClickedBlock().getType() == Material.GOLD_BLOCK){
            p.sendMessage("Месяки убраны!");
            mesyachnie.remove(p.getName());
}
}
}
Ругается на строчку 4
Научи так же, плиииз "
  1. if(e != null && p.getItemInHand().getType() != null && p.getItemInHand().getItemMeta().getDisplayName() != null && e.getClickedBlock() != null && p.getItemInHand().getItemMeta() != null && e.getClickedBlock().getType() != null && p.getItemInHand() != null && e.getItem() != null){"

А так ты ItemMetу на null не проверяешь :DDD
Хотя нет проверяешь
Кидай лог!
 
В одном из старых плагинов делал так:
Код:
        if(e.getPlayer().getInventory().getItemInMainHand()==null) return;
        if(!e.getPlayer().getInventory().getItemInMainHand().hasItemMeta()) return;
        if(e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName()==null) return;
В принципе должно работать:3
 
хаххаа
 
Последнее редактирование:
Java:
    public void onBla(PlayerInteractEvent e) {
        if(e.getAction() == Action.RIGHT_CLICK_BLOCK && e.getItem()!=null) {
            if(e.getItem().getItemMeta()!=null) {
              //что то делаем.
            }
        }
    }
 
  1. Мде, ор
 
Последнее редактирование:
Статус
Закрыто для дальнейших ответов.
Назад
Верх