diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-09-24 00:19:39 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-09-24 00:19:39 +0100 |
commit | f1930e76d6940bb3ff1e526c7eff8dfc51a60e99 (patch) | |
tree | c462a76c43db55c7925dad607acf1a48a0b30a9a /Essentials | |
parent | d722e6a9f02fbb6a4fb2beb2c67f15e3e0909d33 (diff) | |
download | Essentials-f1930e76d6940bb3ff1e526c7eff8dfc51a60e99.tar Essentials-f1930e76d6940bb3ff1e526c7eff8dfc51a60e99.tar.gz Essentials-f1930e76d6940bb3ff1e526c7eff8dfc51a60e99.tar.lz Essentials-f1930e76d6940bb3ff1e526c7eff8dfc51a60e99.tar.xz Essentials-f1930e76d6940bb3ff1e526c7eff8dfc51a60e99.zip |
Fix and give better sign errors.
Diffstat (limited to 'Essentials')
6 files changed, 21 insertions, 2 deletions
diff --git a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java index f3faa2de0..1e1b87ff7 100644 --- a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java +++ b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java @@ -438,11 +438,13 @@ public class EssentialsSign { private final transient SignChangeEvent event; private final transient Block block; + private final transient Sign sign; public EventSign(final SignChangeEvent event) { this.event = event; this.block = event.getBlock(); + this.sign = (Sign)block.getState(); } @Override @@ -455,6 +457,8 @@ public class EssentialsSign public final void setLine(final int index, final String text) { event.setLine(index, text); + sign.setLine(index, text); + updateSign(); } @Override @@ -466,6 +470,7 @@ public class EssentialsSign @Override public void updateSign() { + sign.update(); } } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignEnchant.java b/Essentials/src/com/earth2me/essentials/signs/SignEnchant.java index e1eb7825e..37203555c 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignEnchant.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignEnchant.java @@ -21,11 +21,13 @@ public class SignEnchant extends EssentialsSign final String[] enchantLevel = sign.getLine(2).split(":"); if (enchantLevel.length != 2) { + sign.setLine(2, "§c<enchant>"); throw new SignException(_("invalidSignLine", 3)); } final Enchantment enchantment = Enchantments.getByName(enchantLevel[0]); if (enchantment == null) { + sign.setLine(2, "§c<enchant>"); throw new SignException(_("enchantmentNotFound")); } int level; @@ -35,6 +37,7 @@ public class SignEnchant extends EssentialsSign } catch (NumberFormatException ex) { + sign.setLine(2, "§c<enchant>"); throw new SignException(ex.getMessage(), ex); } if (level < 1 || level > enchantment.getMaxLevel()) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignFree.java b/Essentials/src/com/earth2me/essentials/signs/SignFree.java index 781cbd33b..b5dd3fa73 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignFree.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignFree.java @@ -19,7 +19,14 @@ public class SignFree extends EssentialsSign @Override protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException { - getItemStack(sign.getLine(1), 1, ess); + try { + getItemStack(sign.getLine(1), 1, ess); + } + catch (SignException ex) + { + sign.setLine(1, "§c<item>"); + throw new SignException(ex.getMessage(), ex); + } return true; } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignRepair.java b/Essentials/src/com/earth2me/essentials/signs/SignRepair.java index 361cd4c55..7e76309f1 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignRepair.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignRepair.java @@ -25,6 +25,7 @@ public class SignRepair extends EssentialsSign } else if (!repairTarget.equalsIgnoreCase("all") && !repairTarget.equalsIgnoreCase("hand") ) { + sign.setLine(1, "§c<hand|all>"); throw new SignException(_("invalidSignLine", 2)); } validateTrade(sign, 2, ess); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignWarp.java b/Essentials/src/com/earth2me/essentials/signs/SignWarp.java index 76e8e730b..ae49f743b 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignWarp.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignWarp.java @@ -17,12 +17,14 @@ public class SignWarp extends EssentialsSign @Override protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException { + ess.getLogger().info("triggered warp sign create"); validateTrade(sign, 3, ess); final String warpName = sign.getLine(1); if (warpName.isEmpty()) { - sign.setLine(1, "§dWarp name!"); + ess.getLogger().info("trying to change sign to show error"); + sign.setLine(1, "§c<Warp name>"); return false; } else diff --git a/Essentials/src/com/earth2me/essentials/signs/SignWeather.java b/Essentials/src/com/earth2me/essentials/signs/SignWeather.java index 559fcc2e3..9be677143 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignWeather.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignWeather.java @@ -29,6 +29,7 @@ public class SignWeather extends EssentialsSign sign.setLine(1, "§2Storm"); return true; } + sign.setLine(1, "§c<sun|storm>"); throw new SignException(_("onlySunStorm")); } |