Ok, I'll thank everyone who answers to me. What my plugin is doing right here is creating an Inventory upon executing a command. Then I've made so it should replace 'empty' slots get replaced with glass panel. The thing is that I'm not understanding how can this code throw a null pointer exception when I use the Inventory#getItem().getType(); method. The code seems to give a NullPointerException. Is the issue trying to get an item slot of an inventory that isn't opened? I think not? Here's the code: https://paste.gg/p/anonymous/559c09afa7444a7bab7df2fef5d57dcb And here's the javadoc of Material getType() from ItemStack.