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);
|
||||
|
@ -21,6 +21,23 @@ public class Commandrepair extends EssentialsCommand
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1 || args[0].equalsIgnoreCase("hand") || !user.isAuthorized("essentials.repair.all"))
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public void repairHand(User user) throws Exception
|
||||
{
|
||||
final ItemStack item = user.getItemInHand();
|
||||
if (item == null || item.getType().isBlock() || item.getDurability() == 0)
|
||||
@ -46,10 +63,9 @@ public class Commandrepair extends EssentialsCommand
|
||||
|
||||
user.sendMessage(_("repair", itemName.replace('_', ' ')));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("all"))
|
||||
|
||||
public void repairAll(User user) throws Exception
|
||||
{
|
||||
final Trade charge = new Trade("repair-all", ess);
|
||||
charge.isAffordableFor(user);
|
||||
final List<String> repaired = new ArrayList<String>();
|
||||
repairItems(user.getInventory().getContents(), user, repaired);
|
||||
|
||||
@ -66,12 +82,6 @@ public class Commandrepair extends EssentialsCommand
|
||||
{
|
||||
user.sendMessage(_("repair", Util.joinList(repaired)));
|
||||
}
|
||||
charge.charge(user);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
|
||||
private void repairItem(final ItemStack item) throws Exception
|
||||
|
@ -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