}
}
}
private ItemStack addItemMeta(ItemStack is, String meta) {
ItemMeta ismeta = is.getItemMeta();
String[] msplit = meta.split("#");
//Let's see if we've got new meta or the old way of handling it.
if(msplit[0].equals("NM")) {
HashMap<String, String> itemdata = new HashMap<String,String>();
int potionint = 0;
int effectint = 0;
int fireworkint = 0;
for(String data : msplit) {
if(data.equals("NM")) continue;
if(data.length() > 1) {
String key = data.substring(0, 1);
//There can be multiple potion effects, let's add an identifier
if(key.equals("P")) {
key = "P" + String.valueOf(potionint);
potionint++;
}else if(key.equals("E")) {
key = "E" + String.valueOf(effectint);
effectint++;
}else if(key.equals("F")) {
key = "F" + String.valueOf(fireworkint);
fireworkint++;
}
String value = data.substring(1);
itemdata.put(key, value);
}
}
String data = itemdata.get("N");
if(data != null) {
ismeta.setDisplayName(base64Decode(data));
}
data = itemdata.get("L");
if(data != null) {
ismeta.setLore(decodeLore(data));
}
if(ismeta instanceof SkullMeta) {
data = itemdata.get("O");
if(data != null) {
((SkullMeta) ismeta).setOwner(data);
}
} else if(ismeta instanceof LeatherArmorMeta) {
data = itemdata.get("C");
if(data != null) {
int color = Integer.parseInt(data);
((LeatherArmorMeta) ismeta).setColor(Color.fromRGB(color));
}
} else if(ismeta instanceof PotionMeta) {
PotionMeta pmeta = (PotionMeta) ismeta;
for(int i = 0; (data = itemdata.get("P" + String.valueOf(i))) != null; i++) {
String[] potion = data.split("\\+");
PotionEffectType type = PotionEffectType.getByName(potion[0]);
int amplifier = Integer.parseInt(potion[1]);
int duration = Integer.parseInt(potion[2]);
PotionEffect pe = new PotionEffect(type, duration, amplifier);
pmeta.addCustomEffect(pe, true);
}
}else if(ismeta instanceof EnchantmentStorageMeta) {
EnchantmentStorageMeta emeta = (EnchantmentStorageMeta) ismeta;
for(int i = 0; (data = itemdata.get("E" + String.valueOf(i))) != null; i++) {
String[] enchant = data.split("\\+");
Enchantment enchantenum = Enchantment.getByName(enchant[0]);
if(enchantenum != null) {
int value = Integer.parseInt(enchant[1]);
emeta.addStoredEnchant(enchantenum, value, true);
}
}
}else if(ismeta instanceof FireworkMeta) {
FireworkMeta fmmeta = (FireworkMeta) ismeta;
for(int i = 0; (data = itemdata.get("F" + String.valueOf(i))) != null; i++) {
String[] fedata = data.split("\\+");
Type effect = FireworkEffect.Type.valueOf(fedata[0]);
Builder ef = FireworkEffect.builder();
ef.with(effect);
if(effect != null) {
String[] colors = fedata[1].split("-");
for(String color : colors) {
try {
ef.withColor(Color.fromRGB(Integer.parseInt(color)));
}catch (Exception e) {
}
}
String[] fadecolors = fedata[2].split("-");
for(String fadecolor : fadecolors) {
try {
ef.withFade(Color.fromRGB(Integer.parseInt(fadecolor)));
}catch (Exception e) {
}
}
ef.flicker(Boolean.parseBoolean(fedata[3]));
ef.trail(Boolean.parseBoolean(fedata[4]));
fmmeta.addEffect(ef.build());
}
}
data = itemdata.get("G");
try {
fmmeta.setPower(Integer.parseInt(data));
}catch (Exception e) {
}
}else if(ismeta instanceof FireworkEffectMeta) {
data = itemdata.get("F0");
if(data != null) {
String[] fedata = data.split("\\+");
Type effect = FireworkEffect.Type.valueOf(fedata[0]);
Builder ef = FireworkEffect.builder();
ef.with(effect);
if(effect != null) {
String[] colors = fedata[1].split("-");
for(String color : colors) {
try {
ef.withColor(Color.fromRGB(Integer.parseInt(color)));
}catch (Exception e) {
}
}
String[] fadecolors = fedata[2].split("-");
for(String fadecolor : fadecolors) {
try {
ef.withFade(Color.fromRGB(Integer.parseInt(fadecolor)));
}catch (Exception e) {
}
}
ef.flicker(Boolean.parseBoolean(fedata[3]));
ef.trail(Boolean.parseBoolean(fedata[4]));
((FireworkEffectMeta) ismeta).setEffect(ef.build());
}
}
}
if(ismeta instanceof Repairable) {
data = itemdata.get("R");
if(data != null) {
Repairable rmeta = (Repairable) ismeta;
rmeta.setRepairCost(Integer.parseInt(data));
}
}
}else {
//Old item meta here
int repairableindex = 2;
if(msplit.length > 1) {
if(!msplit[0].equals("")) {
ismeta.setDisplayName(base64Decode(msplit[0]));
}
if(!msplit[1].equals("")) {
ismeta.setLore(decodeLore(msplit[1]));
}
if(ismeta instanceof SkullMeta) {
if(!msplit[2].isEmpty()) {
((SkullMeta) ismeta).setOwner(msplit[2]);
}