Java Code Examples for org.bukkit.inventory.ItemStack#getClass()

The following examples show how to use org.bukkit.inventory.ItemStack#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: CraftItemStack.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean isSimilar(ItemStack stack) {
    if (stack == null) {
        return false;
    }
    if (stack == this) {
        return true;
    }
    if (!(stack instanceof CraftItemStack)) {
        return stack.getClass() == ItemStack.class && stack.isSimilar(this);
    }

    CraftItemStack that = (CraftItemStack) stack;
    if (handle == that.handle) {
        return true;
    }
    if (handle == null || that.handle == null) {
        return false;
    }
    if (!(that.getTypeId() == getTypeId() && getDurability() == that.getDurability())) {
        return false;
    }
    return hasItemMeta() ? that.hasItemMeta() && handle.getTagCompound().equals(that.handle.getTagCompound()) : !that.hasItemMeta();
}
 
Example 2
Source File: CraftItemStack.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean isSimilar(ItemStack stack) {
    if (stack == null) {
        return false;
    }
    if (stack == this) {
        return true;
    }
    if (!(stack instanceof CraftItemStack)) {
        return stack.getClass() == ItemStack.class && stack.isSimilar(this);
    }

    CraftItemStack that = (CraftItemStack) stack;
    if (handle == that.handle) {
        return true;
    }
    if (handle == null || that.handle == null) {
        return false;
    }
    if (!(that.getTypeId() == getTypeId() && getDurability() == that.getDurability())) {
        return false;
    }
    return hasItemMeta() ? that.hasItemMeta() && handle.stackTagCompound.equals(that.handle.stackTagCompound) : !that.hasItemMeta();
}