mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-11 19:02:02 +01:00
Exempt [repair] signs from 'essentials.repair.all' permissions check.
This commit is contained in:
parent
84874c9855
commit
1a4c2e8484
@ -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);
|
||||
|
@ -22,50 +22,13 @@ 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"));
|
||||
}
|
||||
|
||||
if (!item.getEnchantments().isEmpty()
|
||||
&& !ess.getSettings().getRepairEnchanted()
|
||||
&& !user.isAuthorized("essentials.repair.enchanted"))
|
||||
{
|
||||
throw new Exception(_("repairEnchanted"));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
charge.isAffordableFor(user);
|
||||
|
||||
repairItem(item);
|
||||
|
||||
charge.charge(user);
|
||||
|
||||
user.sendMessage(_("repair", itemName.replace('_', ' ')));
|
||||
repairHand(user);
|
||||
}
|
||||
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);
|
||||
|
||||
if (user.isAuthorized("essentials.repair.armor"))
|
||||
{
|
||||
repairItems(user.getInventory().getArmorContents(), user, repaired);
|
||||
}
|
||||
|
||||
if (repaired.isEmpty())
|
||||
{
|
||||
throw new Exception(_("repairNone"));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("repair", Util.joinList(repaired)));
|
||||
}
|
||||
repairAll(user);
|
||||
charge.charge(user);
|
||||
}
|
||||
else
|
||||
@ -74,6 +37,53 @@ public class Commandrepair extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
if (!item.getEnchantments().isEmpty()
|
||||
&& !ess.getSettings().getRepairEnchanted()
|
||||
&& !user.isAuthorized("essentials.repair.enchanted"))
|
||||
{
|
||||
throw new Exception(_("repairEnchanted"));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
charge.isAffordableFor(user);
|
||||
|
||||
repairItem(item);
|
||||
|
||||
charge.charge(user);
|
||||
|
||||
user.sendMessage(_("repair", itemName.replace('_', ' ')));
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
user.sendMessage(_("repair", Util.joinList(repaired)));
|
||||
}
|
||||
}
|
||||
|
||||
private void repairItem(final ItemStack item) throws Exception
|
||||
{
|
||||
final Material material = Material.getMaterial(item.getTypeId());
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user