diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-08-06 00:33:29 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-08-06 00:33:29 +0100 |
commit | ee608d944a8592c2d92b06a984d78c08c2a507e8 (patch) | |
tree | 5f4eebe70baf64a7bcadf97eeccf7e7df85bc600 | |
parent | 9e975568bef61c44783c6320b3176ce069f57ec7 (diff) | |
download | Essentials-ee608d944a8592c2d92b06a984d78c08c2a507e8.tar Essentials-ee608d944a8592c2d92b06a984d78c08c2a507e8.tar.gz Essentials-ee608d944a8592c2d92b06a984d78c08c2a507e8.tar.lz Essentials-ee608d944a8592c2d92b06a984d78c08c2a507e8.tar.xz Essentials-ee608d944a8592c2d92b06a984d78c08c2a507e8.zip |
New Sign: Repair
Syntax: [repair] / <hand|all> / [cost]
-rw-r--r-- | Essentials/src/com/earth2me/essentials/signs/SignRepair.java | 57 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/signs/Signs.java | 1 | ||||
-rw-r--r-- | Essentials/src/config.yml | 1 |
3 files changed, 59 insertions, 0 deletions
diff --git a/Essentials/src/com/earth2me/essentials/signs/SignRepair.java b/Essentials/src/com/earth2me/essentials/signs/SignRepair.java new file mode 100644 index 000000000..dd1b3ae0d --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/signs/SignRepair.java @@ -0,0 +1,57 @@ +package com.earth2me.essentials.signs; + +import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.ChargeException; +import com.earth2me.essentials.IEssentials; +import com.earth2me.essentials.Trade; +import com.earth2me.essentials.User; +import com.earth2me.essentials.commands.Commandrepair; + + +public class SignRepair extends EssentialsSign +{ + public SignRepair() + { + super("Repair"); + } + + @Override + protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException + { + final String repairTarget = sign.getLine(1); + if (repairTarget.isEmpty()) + { + sign.setLine(1, "Hand"); + } + else if (!repairTarget.equalsIgnoreCase("all") && !repairTarget.equalsIgnoreCase("hand") ) + { + throw new SignException(_("invalidSignLine", 2)); + } + validateTrade(sign, 2, ess); + return true; + } + + @Override + protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException + { + final Trade charge = getTrade(sign, 2, ess); + charge.isAffordableFor(player); + + Commandrepair command = new Commandrepair(); + command.setEssentials(ess); + String[] args = new String[] + { + sign.getLine(1) + }; + try + { + command.run(ess.getServer(), player, "repair", args); + } + catch (Exception ex) + { + throw new SignException(ex.getMessage(), ex); + } + charge.charge(player); + return true; + } +} diff --git a/Essentials/src/com/earth2me/essentials/signs/Signs.java b/Essentials/src/com/earth2me/essentials/signs/Signs.java index 2cf05ee77..e30daa9a3 100644 --- a/Essentials/src/com/earth2me/essentials/signs/Signs.java +++ b/Essentials/src/com/earth2me/essentials/signs/Signs.java @@ -13,6 +13,7 @@ public enum Signs KIT(new SignKit()), MAIL(new SignMail()), PROTECTION(new SignProtection()), + REPAIR(new SignRepair()), SELL(new SignSell()), SPAWNMOB(new SignSpawnmob()), TIME(new SignTime()), diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 84d8a4401..5ca2ce2d1 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -219,6 +219,7 @@ enabledSigns: #- gamemode #- heal #- spawnmob + #- repair #- time #- weather #- protection |