package fr.aumgn.bukkitutils.util;

import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

public class MaterialAndData {

    private Material material;
    private byte data;

    public MaterialAndData(Material material, byte data) {
        this.material = material;
        this.data = data;
    }

    public Material getMaterial() {
        return material;
    }

    public byte getData() {
        return data;
    }

    public ItemStack toItemStack(int amount, short damage) {
        return new ItemStack(material, amount, damage, data);
    }
}

@@ -57,16 +57,47 @@
 terial;%0A
+import org.bukkit.block.Block;%0A
 import o
@@ -172,16 +172,22 @@
 private 
+final 
 Material
@@ -209,16 +209,22 @@
 private 
+final 
 byte dat
@@ -275,335 +275,2319 @@
 rial
-, byte data) %7B%0A        this.material = material;%0A        this.data = data;%0A    %7D%0A%0A    public Material getMaterial() %7B%0A        return material;%0A    %7D%0A%0A    public byte getData() %7B%0A        return data;%0A    %7D%0A%0A    public ItemStack toItemStack(int amount, short damage) %7B%0A        return new ItemStack(material, amount, damage, data)
+) %7B%0A        this(material, 0);%0A    %7D%0A%0A    public MaterialAndData(Material material, int data) %7B%0A        this(material, (byte) data);%0A    %7D%0A%0A    public MaterialAndData(Material material, byte data) %7B%0A        if (material == null) %7B%0A            throw new IllegalArgumentException(%22Material can't be null.%22);%0A        %7D%0A%0A        this.material = material;%0A        this.data = data;%0A    %7D%0A%0A    public MaterialAndData(ItemStack stack) %7B%0A        this(stack.getType(), stack.getData().getData());%0A    %7D%0A%0A    public MaterialAndData(Block block) %7B%0A        this(block.getType(), block.getData());%0A    %7D%0A%0A    public Material getMaterial() %7B%0A        return material;%0A    %7D%0A%0A    public MaterialAndData setMaterial(Material material) %7B%0A        return new MaterialAndData(material, data);%0A    %7D%0A%0A    public byte getData() %7B%0A        return data;%0A    %7D%0A%0A    public MaterialAndData setData(byte data) %7B%0A        return new MaterialAndData(material, data);%0A    %7D%0A%0A    public int getMaxStackSize() %7B%0A        return material.getMaxStackSize();%0A    %7D%0A%0A    public int getMaxDurability() %7B%0A        return material.getMaxDurability();%0A    %7D%0A%0A    public ItemStack toItemStack() %7B%0A        return toItemStack(1);%0A    %7D%0A%0A    public ItemStack toMaxItemStack() %7B%0A        return toItemStack(getMaxStackSize());%0A    %7D%0A%0A    public ItemStack toItemStack(int amount) %7B%0A        return toItemStack(amount, 0);%0A    %7D%0A%0A    public ItemStack toItemStack(int amount, int damage) %7B%0A        return toItemStack(amount, (short) damage);%0A    %7D%0A%0A    public ItemStack toItemStack(int amount, short damage) %7B%0A        return new ItemStack(material, amount, damage, data);%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        final int prime = 31;%0A        int result = 1;%0A        result = prime * result + data;%0A        result = prime * result + material.hashCode();%0A        return result;%0A    %7D%0A%0A    @Override%0A    public boolean equals(Object obj) %7B%0A        if (this == obj) %7B%0A            return true;%0A        %7D%0A%0A        if (!(obj instanceof MaterialAndData)) %7B%0A            return false;%0A        %7D%0A%0A        MaterialAndData other = (MaterialAndData) obj;%0A        if (data != other.data %7C%7C material != other.material) %7B%0A            return false;%0A        %7D%0A%0A        return true;%0A    %7D%0A%0A    public String toString() %7B%0A        return %22(%22 + material + %22:%22 + data + %22)%22
 ;%0A  

Add methods to MaterialAndData