summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/signs/SignRepair.java57
-rw-r--r--Essentials/src/com/earth2me/essentials/signs/Signs.java1
-rw-r--r--Essentials/src/config.yml1
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