Java Code Examples for org.bukkit.material.MaterialData#getClass()

The following examples show how to use org.bukkit.material.MaterialData#getClass() . 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: ItemStack.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the MaterialData for this stack of items
 *
 * @param data New MaterialData for this item
 */
public void setData(MaterialData data) {
    Material mat = getType();

    if (data == null || mat == null || mat.getData() == null) {
        this.data = data;
    } else {
        if ((data.getClass() == mat.getData()) || (data.getClass() == MaterialData.class)) {
            this.data = data;
        } else {
            throw new IllegalArgumentException("Provided data is not of type " + mat.getData().getName() + ", found " + data.getClass().getName());
        }
    }
}
 
Example 2
Source File: CraftBlockState.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public void setData(final MaterialData data) {
    Material mat = getType();

    if ((mat == null) || (mat.getData() == null)) {
        this.data = data;
    } else {
        if ((data.getClass() == mat.getData()) || (data.getClass() == MaterialData.class)) {
            this.data = data;
        } else {
            throw new IllegalArgumentException("Provided data is not of type "
                    + mat.getData().getName() + ", found " + data.getClass().getName());
        }
    }
}
 
Example 3
Source File: ItemStackImpl.java    From Civs with GNU General Public License v3.0 5 votes vote down vote up
public void setData(MaterialData data) {
    Material mat = Bukkit.getUnsafe().toLegacy(this.getType());
    if (data != null && mat != null && mat.getData() != null) {
        if (data.getClass() != mat.getData() && data.getClass() != MaterialData.class) {
            throw new IllegalArgumentException("Provided data is not of type " + mat.getData().getName() + ", found " + data.getClass().getName());
        }

        this.data = data;
    } else {
        this.data = data;
    }

}
 
Example 4
Source File: CraftBlockState.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public void setData(final MaterialData data) {
    Material mat = getType();

    if ((mat == null) || (mat.getData() == null)) {
        this.data = data;
    } else {
        if ((data.getClass() == mat.getData()) || (data.getClass() == MaterialData.class)) {
            this.data = data;
        } else {
            throw new IllegalArgumentException("Provided data is not of type "
                    + mat.getData().getName() + ", found " + data.getClass().getName());
        }
    }
}