1public int getFreeSlots(Player player) {
2 int freeslots = 0;
3 for (ItemStack it : player.getInventory().getContents()) {
4 if (it == null || it.getType() == Material.AIR) {
5 freeslots++;
6 }
7 }
8 freeslots = freeslots - 5; // subtract shield and armor
9
10 return freeslots;
11}