Answers for "get free player inventory slots spigot"

0

get free player inventory slots spigot

public int getFreeSlots(Player player) {
    int freeslots = 0;
    for (ItemStack it : player.getInventory().getContents()) {
        if (it == null || it.getType() == Material.AIR) {
            freeslots++;
        }
    }
    freeslots = freeslots - 5; // subtract shield and armor

    return freeslots;
}
Posted by: Guest on July-04-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language