Remove obsolete parseString methods in ItemParser.

This follows from the removal of the set class command being removed and the cascading removal of the methods in ArenaMasterImpl that referenced the parseString methods in ItemParser.
This commit is contained in:
Andreas Troelsen 2018-07-03 01:30:59 +02:00
parent e572fc3dae
commit 16f08ef9a0

View File

@ -8,7 +8,6 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.material.MaterialData;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
@ -16,7 +15,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public class ItemParser
{
@ -39,91 +37,7 @@ public class ItemParser
POTION_TYPE_MAP.put((short) 8205, PotionType.WATER_BREATHING);
POTION_TYPE_MAP.put((short) 8206, PotionType.INVISIBILITY);
}
public static String parseString(ItemStack... stacks) {
String result = "";
// Parse each stack
for (ItemStack stack : stacks) {
if (stack == null || stack.getTypeId() == 0) continue;
result += ", " + parseString(stack);
}
// Trim off the leading ', ' if it is there
if (!result.equals("")) {
result = result.substring(2);
}
return result;
}
public static String parseString(ItemStack stack) {
if (stack.getTypeId() == 0) return null;
// <item> part
String type = stack.getType().toString().toLowerCase();
// <data> part
MaterialData md = stack.getData();
short data = (md != null ? md.getData() : 0);
// Take wool into account
if (stack.getType() == Material.WOOL) {
data = (byte) (15 - data);
}
// Take potions into account
else if (stack.getType() == Material.POTION) {
data = stack.getDurability();
}
// <amount> part
int amount = stack.getAmount();
// Enchantments
Map<Enchantment,Integer> enchants = null;
if (stack.getType() == Material.ENCHANTED_BOOK) {
EnchantmentStorageMeta esm = (EnchantmentStorageMeta) stack.getItemMeta();
enchants = esm.getStoredEnchants();
} else {
enchants = stack.getEnchantments();
}
String enchantments = "";
for (Entry<Enchantment,Integer> entry : enchants.entrySet()) {
int id = entry.getKey().getId();
int lvl = entry.getValue();
// <eid>:<level>;
enchantments += ";" + id + ":" + lvl;
}
// Trim off the leading ';' if it is there
if (!enchantments.equals("")) {
enchantments = enchantments.substring(1);
}
// <item>
String result = type;
// <item>(:<data>)
if (data != 0) {
result += ":" + data;
}
// <item>((:<data>):<amount>) - force if there is data
if (amount > 1 || data != 0) {
result += ":" + amount;
}
// <item>((:<data>):<amount>) (<eid>:<level>(;<eid>:<level>(; ... )))
if (!enchantments.equals("")) {
result += " " + enchantments;
}
return result;
}
public static List<ItemStack> parseItems(String s) {
if (s == null) {
return new ArrayList<>(1);