if (item.getType() != Material.POTION || item.getDurability() == 0) {
return;
}
Potion potion;
try {
potion = Potion.fromItemStack(item);
} catch (IllegalArgumentException ex) {
return;
}
StringBuilder message = new StringBuilder(50);
message.append(ChatColor.GRAY);
if (potion.getType() == null) {
return;
}
if (potion.isSplash()) {
message.append("Splash ");
}
message.append("Potion of ");
message.append(capitalizeFirstLetter(potion.getType().name(), '_')).append(' ');
message.append(toRoman(potion.getLevel()));
CommandSender sender = event.getSender();
sender.sendMessage(message.toString());
for (PotionEffect effect : potion.getEffects()) {
sender.sendMessage(ChatColor.DARK_GRAY + capitalizeFirstLetter(effect.getType().getName(), '_') + ' ' + toTime(effect.getDuration() / 20));
}
}