if (!b.hasTitle() || !b.hasAuthor())
return;
if (b.getTitle().contains("Identity Tome")
&& findColor(b.getAuthor()).equals(ChatColor.MAGIC)) {
Player p = e.getPlayer();
PlayerInventory pi = p.getInventory();
p.updateInventory();
Iterator<ItemStack> itis = pi.iterator();
while (itis.hasNext()) {
ItemStack tool = itis.next();
if ((tool == null)
|| !plugin.getDropAPI().canBeItem(tool.getType())) {
continue;
}
ItemMeta meta;
if (tool.hasItemMeta())
meta = tool.getItemMeta();
else
meta = plugin.getServer().getItemFactory()
.getItemMeta(tool.getType());
String name;
if (meta.hasDisplayName())
name = meta.getDisplayName();
else
name = tool.getType().name();
if ((ChatColor.getLastColors(name) == null || (!ChatColor
.getLastColors(name).equalsIgnoreCase(
ChatColor.MAGIC.name()) && !ChatColor
.getLastColors(name).equalsIgnoreCase(
ChatColor.MAGIC.toString()))
&& (!name.contains(ChatColor.MAGIC.name()) && !name
.contains(ChatColor.MAGIC.toString())))) {
continue;
}
IdentifyItemEvent iie = new IdentifyItemEvent(tool);
plugin.getServer().getPluginManager().callEvent(iie);
if (iie.isCancelled()) {
p.sendMessage(ChatColor.RED
+ "You are unable to identify right now.");
p.closeInventory();
e.setUseItemInHand(Result.DENY);
e.setCancelled(true);
return;
}
pi.setItemInHand(null);
ItemStack item = plugin.getDropAPI().getItem(tool);
while ((item == null)
|| !item.hasItemMeta()
|| !item.getItemMeta().hasDisplayName()
|| item.getItemMeta().getDisplayName()
.contains(ChatColor.MAGIC.toString())) {
item = plugin.getDropAPI().getItem(tool);
}
pi.removeItem(tool);
pi.addItem(item);
p.sendMessage(ChatColor.GREEN
+ "You have identified an item!");
p.updateInventory();
e.setUseItemInHand(Result.DENY);
e.setCancelled(true);