More user feedback on enchant sign.

This commit is contained in:
KHobbits 2013-01-05 07:24:02 +00:00
parent 6497db837d
commit ef7b940e96

View File

@ -17,7 +17,16 @@ public class SignEnchant extends EssentialsSign
@Override
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException
{
final ItemStack stack = sign.getLine(1).equals("*") || sign.getLine(1).equalsIgnoreCase("any") ? null : getItemStack(sign.getLine(1), 1, ess);
final ItemStack stack;
try
{
stack = sign.getLine(1).equals("*") || sign.getLine(1).equalsIgnoreCase("any") ? null : getItemStack(sign.getLine(1), 1, ess);
}
catch (SignException e)
{
sign.setLine(1, "§c<item|any>");
throw e;
}
final String[] enchantLevel = sign.getLine(2).split(":");
if (enchantLevel.length != 2)
{
@ -132,6 +141,16 @@ public class SignEnchant extends EssentialsSign
throw new SignException(ex.getMessage(), ex);
}
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
if (level == 0)
{
player.sendMessage(_("enchantmentRemoved", enchantmentName.replace('_', ' ')));
}
else
{
player.sendMessage(_("enchantmentApplied", enchantmentName.replace('_', ' ')));
}
charge.charge(player);
Trade.log("Sign", "Enchant", "Interact", username, charge, username, charge, sign.getBlock().getLocation(), ess);
player.updateInventory();