/** * 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()); } } }
/** * Gets the MaterialData for this stack of items * * @return MaterialData for this item */ public MaterialData getData() { Material mat = getType(); if (data == null && mat != null && mat.getData() != null) { data = mat.getNewData((byte) this.getDurability()); } return data; }
@Override public void onBlockChanged(GlowBlock block, Material oldType, byte oldData, Material newType, byte newData) { if (newType != Material.AIR) { return; } if (oldType.getData() == Door.class) { Door door = new Door(oldType); door.setData(oldData); if (door.isTopHalf()) { Block b = block.getRelative(BlockFace.DOWN); if (b.getState().getData() instanceof Door) { b.setType(Material.AIR); } } else { Block b = block.getRelative(BlockFace.UP); if (b.getState().getData() instanceof Door) { b.setType(Material.AIR); } } } }
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()); } } }
/** * 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()); } } }
/** * Gets the MaterialData for this stack of items * * @return MaterialData for this item */ public MaterialData getData() { Material mat = getType(); if (data == null && mat != null && mat.getData() != null) { data = mat.getNewData((byte) this.getDurability()); } return data; }