summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2013-05-26 22:00:35 +0100
committerKHobbits <rob@khobbits.co.uk>2013-05-26 22:00:35 +0100
commit1a4c2e8484feb7b1c23c701b81bf06e79b40c485 (patch)
tree0eae57757e5542744bbab699a15973109c8496cd
parent84874c9855bad9a3751b35aaa7490e2f9311ee08 (diff)
downloadEssentials-1a4c2e8484feb7b1c23c701b81bf06e79b40c485.tar
Essentials-1a4c2e8484feb7b1c23c701b81bf06e79b40c485.tar.gz
Essentials-1a4c2e8484feb7b1c23c701b81bf06e79b40c485.tar.lz
Essentials-1a4c2e8484feb7b1c23c701b81bf06e79b40c485.tar.xz
Essentials-1a4c2e8484feb7b1c23c701b81bf06e79b40c485.zip
Exempt [repair] signs from 'essentials.repair.all' permissions check.
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandfeed.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandrepair.java86
-rw-r--r--Essentials/src/com/earth2me/essentials/signs/SignRepair.java21
3 files changed, 65 insertions, 44 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java b/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java
index feb148893..167bfccef 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java
@@ -90,7 +90,7 @@ public class Commandfeed extends EssentialsCommand
private void feedPlayer(CommandSender sender, Player player) throws QuietAbortException
{
- final int amount = 100;
+ final int amount = 30;
final FoodLevelChangeEvent flce = new FoodLevelChangeEvent(player, amount);
ess.getServer().getPluginManager().callEvent(flce);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java
index 54452a600..a0a0513c2 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java
@@ -22,55 +22,65 @@ public class Commandrepair extends EssentialsCommand
{
if (args.length < 1 || args[0].equalsIgnoreCase("hand") || !user.isAuthorized("essentials.repair.all"))
{
- final ItemStack item = user.getItemInHand();
- if (item == null || item.getType().isBlock() || item.getDurability() == 0)
- {
- throw new Exception(_("repairInvalidType"));
- }
+ repairHand(user);
+ }
+ else if (args[0].equalsIgnoreCase("all"))
+ {
+ final Trade charge = new Trade("repair-all", ess);
+ charge.isAffordableFor(user);
+ repairAll(user);
+ charge.charge(user);
+ }
+ else
+ {
+ throw new NotEnoughArgumentsException();
+ }
+ }
- if (!item.getEnchantments().isEmpty()
- && !ess.getSettings().getRepairEnchanted()
- && !user.isAuthorized("essentials.repair.enchanted"))
- {
- throw new Exception(_("repairEnchanted"));
- }
+ public void repairHand(User user) throws Exception
+ {
+ final ItemStack item = user.getItemInHand();
+ if (item == null || item.getType().isBlock() || item.getDurability() == 0)
+ {
+ throw new Exception(_("repairInvalidType"));
+ }
- final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
- final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-" + item.getTypeId(), new Trade("repair-item", ess), ess), ess);
+ if (!item.getEnchantments().isEmpty()
+ && !ess.getSettings().getRepairEnchanted()
+ && !user.isAuthorized("essentials.repair.enchanted"))
+ {
+ throw new Exception(_("repairEnchanted"));
+ }
- charge.isAffordableFor(user);
+ final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
+ final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-" + item.getTypeId(), new Trade("repair-item", ess), ess), ess);
- repairItem(item);
+ charge.isAffordableFor(user);
- charge.charge(user);
+ repairItem(item);
- user.sendMessage(_("repair", itemName.replace('_', ' ')));
- }
- else if (args[0].equalsIgnoreCase("all"))
- {
- final Trade charge = new Trade("repair-all", ess);
- charge.isAffordableFor(user);
- final List<String> repaired = new ArrayList<String>();
- repairItems(user.getInventory().getContents(), user, repaired);
+ charge.charge(user);
- if (user.isAuthorized("essentials.repair.armor"))
- {
- repairItems(user.getInventory().getArmorContents(), user, repaired);
- }
+ user.sendMessage(_("repair", itemName.replace('_', ' ')));
+ }
- if (repaired.isEmpty())
- {
- throw new Exception(_("repairNone"));
- }
- else
- {
- user.sendMessage(_("repair", Util.joinList(repaired)));
- }
- charge.charge(user);
+ public void repairAll(User user) throws Exception
+ {
+ final List<String> repaired = new ArrayList<String>();
+ repairItems(user.getInventory().getContents(), user, repaired);
+
+ if (user.isAuthorized("essentials.repair.armor"))
+ {
+ repairItems(user.getInventory().getArmorContents(), user, repaired);
+ }
+
+ if (repaired.isEmpty())
+ {
+ throw new Exception(_("repairNone"));
}
else
{
- throw new NotEnoughArgumentsException();
+ user.sendMessage(_("repair", Util.joinList(repaired)));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/signs/SignRepair.java b/Essentials/src/com/earth2me/essentials/signs/SignRepair.java
index f09d94536..63c2563dd 100644
--- a/Essentials/src/com/earth2me/essentials/signs/SignRepair.java
+++ b/Essentials/src/com/earth2me/essentials/signs/SignRepair.java
@@ -6,6 +6,7 @@ import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.commands.Commandrepair;
+import com.earth2me.essentials.commands.NotEnoughArgumentsException;
public class SignRepair extends EssentialsSign
@@ -40,18 +41,28 @@ public class SignRepair extends EssentialsSign
Commandrepair command = new Commandrepair();
command.setEssentials(ess);
- String[] args = new String[]
- {
- sign.getLine(1)
- };
+
try
{
- command.run(ess.getServer(), player, "repair", args);
+ if (sign.getLine(1).equalsIgnoreCase("hand"))
+ {
+ command.repairHand(player);
+ }
+ else if (sign.getLine(1).equalsIgnoreCase("all"))
+ {
+ command.repairAll(player);
+ }
+ else
+ {
+ throw new NotEnoughArgumentsException();
+ }
+
}
catch (Exception ex)
{
throw new SignException(ex.getMessage(), ex);
}
+
charge.charge(player);
Trade.log("Sign", "Repair", "Interact", username, null, username, charge, sign.getBlock().getLocation(), ess);
return true;