*/
public ItemStack getItem(Material mat) {
while (mat == null) {
mat = dropPicker();
}
ItemStack ci = null;
Tier tier = getTier();
while (tier == null) {
tier = getTier();
}
if ((tier.getMaterials().size() > 0)
&& !tier.getMaterials().contains(mat)) {
mat = tier.getMaterials().get(
plugin.getSingleRandom()
.nextInt(tier.getMaterials().size()));
}
int e = tier.getAmount();
int l = tier.getLevels();
short damage = 0;
if (plugin.getConfig().getBoolean("DropFix.Damage", true)) {
damage = damageItemStack(mat);
}
List<String> startList = new ArrayList<String>();
if (plugin.getSettings().isColorBlindCompat()) {
startList.add("Material: " + getPrettyMaterialName(mat));
}
if (plugin.getConfig().getBoolean("Display.TierName", true)
&& !tier.getColor().equals(ChatColor.MAGIC)) {
startList.add(tier.getColor() + "Tier: " + tier.getDisplayName());
} else if (plugin.getConfig().getBoolean("Display.TierName", true)
&& tier.getColor().equals(ChatColor.MAGIC)) {
startList.add(ChatColor.WHITE + "Tier: " + tier.getDisplayName());
}
ci = new Drop(mat, tier.getColor(), ChatColor.stripColor(name(mat)),
damage, startList.toArray(new String[0]));
if (tier.getColor().equals(ChatColor.MAGIC))
return ci;
ItemStack tool = new ItemStack(ci);
List<Enchantment> eStack = Arrays.asList(Enchantment.values());
List<String> list = new ArrayList<String>();
for (String s : tier.getLore())
if (s != null) {
list.add(s);
}
boolean safe = plugin.getConfig().getBoolean("SafeEnchant.Enabled",
true);
if (safe) {
eStack = getEnchantStack(tool);
}
for (; e > 0; e--) {
int lvl = plugin.getSingleRandom().nextInt(l + 1);
int size = eStack.size();
if (size < 1) {
continue;
}
Enchantment ench = eStack.get(plugin.getSingleRandom()
.nextInt(size));
if (!tool.containsEnchantment(ench))
if ((lvl != 0) && (ench != null)
&& !tier.getColor().equals(ChatColor.MAGIC))
if (safe) {
if ((lvl >= ench.getStartLevel())
&& (lvl <= ench.getMaxLevel())) {
try {
tool.addEnchantment(ench, lvl);
} catch (Exception e1) {
if (plugin.getDebug()) {
plugin.log.warning(e1.getMessage());
}
e++;
}
}
} else {
tool.addUnsafeEnchantment(ench, lvl);
}
}
ItemMeta meta;
if (tool.hasItemMeta())
meta = tool.getItemMeta();
else
meta = Bukkit.getItemFactory().getItemMeta(tool.getType());
if (plugin.getConfig().getBoolean("Lore.Enabled", true)
&& (plugin.getSingleRandom().nextInt(10000) <= plugin
.getSettings().getLoreChance())
&& !tier.getColor().equals(ChatColor.MAGIC)) {
for (int i = 0; i < plugin.getConfig().getInt("Lore.EnhanceAmount",
2); i++)
if (plugin.getItemAPI().isArmor(mat)) {
list.add(colorPicker()
+ plugin.defenselore.get(plugin.getSingleRandom()
.nextInt(plugin.defenselore.size())));
} else if (plugin.getItemAPI().isTool(mat)) {
list.add(colorPicker()
+ plugin.offenselore.get(plugin.getSingleRandom()
.nextInt(plugin.offenselore.size())));
}
}
meta.setLore(list);
tool.setItemMeta(meta);
if (plugin.getItemAPI().isLeather(tool.getType())) {
LeatherArmorMeta lam = (LeatherArmorMeta) tool.getItemMeta();
lam.setColor(Color.fromRGB(plugin.getSingleRandom().nextInt(255),
plugin.getSingleRandom().nextInt(255), plugin
.getSingleRandom().nextInt(255)));
tool.setItemMeta(lam);
}
return tool;
}