Like the title says how would I check if a players inventory is full. EDIT: I think i got it by checking if inv.firstEmpty() < 0
I would do something like this (Not checked if it works): Code: public boolean isPlayerInventoryFull(Player player) { ItemStack[] contents = player.getInventory().getContents(); for (ItemStack itemStack : contents) { if (itemStack == null) { return false; } } return true; }
Code:java public boolean isPlayerInventoryFull(PlayerInventory inv) { (inv.firstEmpty() < 0) ? return true : return false;} I'm going to try that, also I seem to have another problem when I give the diamond to a player it is nommable(I can eat it ). I thought maybe it was because I never sent ply.updateInventory() but it looks like that is depreciated. What I am trying to do is this Code:java public void onSpoutCraftEnable(SpoutCraftEnableEvent event) { Player ply = event.getPlayer(); ItemStack stack = new ItemStack(264); PlayerInventory inv = ply.getInventory(); if(hasSpout(ply.getName())){ /* do nothing*/ } else if(inv.firstEmpty() < 0){ ply.sendMessage(ChatColor.RED + "Your inventory is full please make some space and rejoin!"); } else{ inv.addItem(stack); countPlayer(ply.getName()); ply.sendMessage(ChatColor.AQUA + "Here is that Diamond!"); }} So how do I give the diamond properly? EDIT: Ahh I got it, args1 of the ItemStack needed to be quantity.