use of com.earth2me.essentials.commands.NotEnoughArgumentsException in project Essentials by drtshock.
the class Commandspawn method run.
@Override
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
if (args.length < 1) {
throw new NotEnoughArgumentsException();
}
final User user = getPlayer(server, args, 0, true, false);
respawn(sender, null, user, null);
user.sendMessage(tl("teleportAtoB", Console.NAME, "spawn"));
}
use of com.earth2me.essentials.commands.NotEnoughArgumentsException in project Essentials by EssentialsX.
the class SignRepair method onSignInteract.
@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);
try {
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;
}
use of com.earth2me.essentials.commands.NotEnoughArgumentsException in project Essentials by EssentialsX.
the class Worth method getAmount.
public int getAmount(IEssentials ess, User user, ItemStack is, String[] args, boolean isBulkSell) throws Exception {
if (is == null || is.getType() == Material.AIR) {
throw new Exception(tl("itemSellAir"));
}
int id = is.getTypeId();
int amount = 0;
if (args.length > 1) {
try {
amount = Integer.parseInt(args[1].replaceAll("[^0-9]", ""));
} catch (NumberFormatException ex) {
throw new NotEnoughArgumentsException(ex);
}
if (args[1].startsWith("-")) {
amount = -amount;
}
}
boolean stack = args.length > 1 && args[1].endsWith("s");
boolean requireStack = ess.getSettings().isTradeInStacks(id);
if (requireStack && !stack) {
throw new Exception(tl("itemMustBeStacked"));
}
int max = 0;
for (ItemStack s : user.getBase().getInventory().getContents()) {
if (s == null || !s.isSimilar(is)) {
continue;
}
max += s.getAmount();
}
if (stack) {
amount *= is.getType().getMaxStackSize();
}
if (amount < 1) {
amount += max;
}
if (requireStack) {
amount -= amount % is.getType().getMaxStackSize();
}
if (amount > max || amount < 1) {
if (!isBulkSell) {
user.sendMessage(tl("itemNotEnough2"));
user.sendMessage(tl("itemNotEnough3"));
throw new Exception(tl("itemNotEnough1"));
} else {
return amount;
}
}
return amount;
}
use of com.earth2me.essentials.commands.NotEnoughArgumentsException in project Essentials by EssentialsX.
the class Commandxmppspy method run.
@Override
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws NotEnoughArgumentsException {
if (args.length < 1) {
throw new NotEnoughArgumentsException();
}
final List<Player> matches = server.matchPlayer(args[0]);
if (matches.isEmpty()) {
sender.sendMessage("§cThere are no players matching that name.");
}
for (Player p : matches) {
try {
final boolean toggle = EssentialsXMPP.getInstance().toggleSpy(p);
sender.sendMessage("XMPP Spy " + (toggle ? "enabled" : "disabled") + " for " + p.getDisplayName());
} catch (Exception ex) {
sender.sendMessage("Error: " + ex.getMessage());
}
}
}
use of com.earth2me.essentials.commands.NotEnoughArgumentsException in project Essentials by drtshock.
the class SignRepair method onSignInteract.
@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);
try {
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;
}
Aggregations