Java Code Examples for org.bukkit.Material#ordinal()

The following examples show how to use org.bukkit.Material#ordinal() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MaterialRegistry.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a material registry from existing data.
 * @param materials Materials by their number ids.
 */
public MaterialRegistry(Material[] materials) {
	this.materials = materials;
	this.ids = new int[materials.length];
	for (int i = 0; i < materials.length; i++) {
		Material m = materials[i];
		if (m != null)
			ids[m.ordinal()] = i;
	}
}
 
Example 2
Source File: MaterialRegistry.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
public int getId(Material material) {
	try {
		return ids[material.ordinal()];
	} catch (ArrayIndexOutOfBoundsException e) {
		throw new AssertionError("material registry out-of-date");
	}
}