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
|
|
|
|
*/
|
2011-08-13 12:08:34 +02:00
|
|
|
public class DataValue {
|
|
|
|
public static byte get(String type, Material material) {
|
2011-07-23 21:00:47 +02:00
|
|
|
if (material == null) return 0;
|
2011-07-02 20:34:14 +02:00
|
|
|
|
2011-08-13 12:08:34 +02:00
|
|
|
type = type.toUpperCase().replace(" ", "_");
|
2011-06-13 00:59:10 +02:00
|
|
|
MaterialData materialData = null;
|
|
|
|
|
2011-07-15 21:45:26 +02:00
|
|
|
try {
|
|
|
|
switch (material) {
|
|
|
|
case SAPLING:
|
|
|
|
case LOG:
|
2011-08-13 12:08:34 +02:00
|
|
|
materialData = new Tree(TreeSpecies.valueOf(type));
|
2011-07-15 21:45:26 +02:00
|
|
|
break;
|
|
|
|
case STEP:
|
|
|
|
case DOUBLE_STEP:
|
2011-08-13 12:08:34 +02:00
|
|
|
materialData = new Step(Items.getMaterial(type));
|
2011-07-15 21:45:26 +02:00
|
|
|
break;
|
|
|
|
case WOOL:
|
|
|
|
case INK_SACK:
|
2011-08-13 12:08:34 +02:00
|
|
|
materialData = new Wool(DyeColor.valueOf(type));
|
2011-07-15 21:45:26 +02:00
|
|
|
break;
|
|
|
|
case COAL:
|
2011-08-13 12:08:34 +02:00
|
|
|
materialData = new Coal(CoalType.valueOf(type));
|
2011-07-15 21:45:26 +02:00
|
|
|
break;
|
|
|
|
}
|
2011-08-13 12:08:34 +02:00
|
|
|
} catch (Exception e) { return 0; }
|
2011-06-13 00:59:10 +02:00
|
|
|
|
|
|
|
return (materialData == null ? 0 : materialData.getData());
|
|
|
|
}
|
|
|
|
}
|