Someone knows why on line 33 i get null error in console? Code: package pl.tradeApi; import java.util.ArrayList; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; public class TradeApi extends JavaPlugin implements Listener{ public void onEnable() { Bukkit.getServer().getPluginManager().registerEvents(this, this); } @EventHandler public void onChat(PlayerChatEvent e) { Trade.offer(e.getPlayer(), "Handel", Utils.createIm(Material.COOKIE, "&e&oCiasteczko!", 2, 5, "Niesamowicie pyszne ciasteczko!"), 5); } @EventHandler public void onInventoryClick(InventoryClickEvent event) { Player p = (Player) event.getWhoClicked(); if(event.getInventory().getTitle().equalsIgnoreCase("Handel")) { if(event.getCursor().getItemMeta().getLore().contains(Utils.fixColors("&eCena: "))) { event.setCancelled(true); Trade.newTrade(p, "Sprzedaz", 5, event.getCurrentItem()); } } } } Item what i click contains in lore Cena:
DevManABCD I believe getCursor() returns the current item on the cursor when you click, not after you click. Use getCurrentItem() instead, which returns the item in the clicked slot.
Why don't you post the error? By the way, breaking that line up into multiple lines will make it easier for you to figure out what is actually null. Also, read the documentation please. If there is any doubt as to what a method does you should read the docs. The difference between getCursor() and getCurrentItem() are made crystal clear in the docs.
I beg your pardon? Regardless, it seems as though you are first working with .getCursor() and then later with getCurrentItem(). Is this what you want? The context you have provided is frankly a bit vague.