get free player inventory slots spigot

Solutions on MaxInterview for get free player inventory slots spigot by the best coders in the world

showing results for - "get free player inventory slots spigot"
Gail
04 Feb 2017
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}