📜  获得免费的玩家库存插槽龙头 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:27.401000             🧑  作者: Mango

代码示例1
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;
}