2011-06-13 00:59:10 +02:00
|
|
|
package com.Acrobot.ChestShop.Items;
|
|
|
|
|
|
|
|
import org.bukkit.CoalType;
|
|
|
|
import org.bukkit.DyeColor;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.TreeSpecies;
|
|
|
|
import org.bukkit.material.*;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Acrobot
|
|
|
|
*/
|
|
|
|
public class DataValue {
|
2011-07-02 20:34:14 +02:00
|
|
|
public static byte get(String arg, Material material) {
|
|
|
|
if (material == null) {
|
2011-06-14 15:07:44 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2011-07-02 20:34:14 +02:00
|
|
|
|
2011-06-13 00:59:10 +02:00
|
|
|
arg = arg.toUpperCase().replace(" ", "_");
|
|
|
|
|
|
|
|
|
|
|
|
MaterialData materialData = null;
|
|
|
|
|
2011-07-15 21:45:26 +02:00
|
|
|
try {
|
|
|
|
switch (material) {
|
|
|
|
case SAPLING:
|
|
|
|
case LOG:
|
|
|
|
materialData = new Tree(TreeSpecies.valueOf(arg));
|
|
|
|
break;
|
|
|
|
case STEP:
|
|
|
|
case DOUBLE_STEP:
|
|
|
|
materialData = new Step(Items.getMaterial(arg));
|
|
|
|
break;
|
|
|
|
case WOOL:
|
|
|
|
case INK_SACK:
|
|
|
|
materialData = new Wool(DyeColor.valueOf(arg));
|
|
|
|
break;
|
|
|
|
case COAL:
|
|
|
|
materialData = new Coal(CoalType.valueOf(arg));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
return 0;
|
2011-06-13 00:59:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (materialData == null ? 0 : materialData.getData());
|
|
|
|
}
|
|
|
|
}
|