try {
switch (args.length){
case 0:
case 1:
case 2:
throw new MissingOrIncorrectArgumentException();
case 3:
is = Utilities.getItemStack(player, args[1]);
ex = Utilities.getItemStack(player, args[2]);
break;
case 4:
is = Utilities.getItemStack(player, args[1]);
ex = Utilities.getItemStack(player, args[2]);
if (args[3].equalsIgnoreCase("unlimited"))
unlimited = true;
else
amount = Integer.parseInt(args[3]);
break;
case 5:
is = Utilities.getItemStack(player, args[1]);
ex = Utilities.getItemStack(player, args[2]);
if (args[3].equalsIgnoreCase("unlimited"))
unlimited = true;
else
amount = Integer.parseInt(args[3]);
price = Integer.parseInt(args[4]);
if (price <= 0)
throw new MissingOrIncorrectArgumentException();
break;
}
} catch (Exception e) {
throw new MissingOrIncorrectArgumentException ();
}
if (is == null || is.getTypeId() == 0 || ex == null || ex.getTypeId() == 0) {
throw new MissingOrIncorrectArgumentException (Term.ITEM_MISSING.get()+",is="+is+",ex="+ex);
}
// if the id already exists, the ShopHandler will set a new one
ExchangeShop shop = new ExchangeShop(UUID.randomUUID(), player.getName(), null, is.clone(), ex.clone());