Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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;
}
Comment

PREVIOUS NEXT
Code Example
Java :: integer parse int exceptions 
Java :: how to convert character into operator 
Java :: Java Creating a Java LinkedList 
Java :: array list vs vector 
Java :: default java keystore 
Java :: android java change text value 
Java :: string to char 
Java :: Exception in thread "main" java.lang.NoClassDefFoundError sdkmanager 
Java :: implements java 
Java :: java xml element get attribute value 
Java :: set gamemode of player spigot 
Java :: selenium drag slider 
Java :: iterative inorder traversal 
Java :: maths.abs function in java 
Java :: types of methods in java 
Java :: JFrame change border 
Java :: what is a cache-less reload 
Java :: check if input is empty java 
Java :: jsoup remove element 
Java :: generic method lambda java 
Java :: return random boolean 
Java :: java list of lists 
Java :: string compareto vs equals java 
Java :: java animated gif example 
Java :: java questions 
Java :: kotlin spinner default value 
Java :: Alerter for java 
Java :: java finally block 
Java :: get node inside node in of xml using java 
Java :: how to check size of arrayin java 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =