@Override protected void execute() { int newAmount = 0; for (int i = 1; i <= amount; i++) { if (hasRequirements(player, buttonId, false, 1, pouchData)) { player.getInventory().remove(new Item(POUCH_ID, 1)); player.getInventory().remove(new Item(SHARD_ID, 1)); player.getInventory().remove(new Item(pouchData.getCharmId(), 1)); player.getInventory().remove(new Item(pouchData.getSecondIngredientId(), 1)); player.getInventory().add(new Item(pouchData.getPouchId(), 1)); newAmount++; } else { break; } } if (newAmount == 0) { abort(); return; } player.playAnimation(new Animation(725)); player.playGraphics(new Graphic(1207)); player .getSkill() .addExperience( Skill.SUMMONING, pouchData.getExp() * newAmount * Constants.SUMMONING_EXPERIENCE); player.sendMessage( "You infuse " + newAmount + " " + new Item(pouchData.getPouchId()).getDefinition().getName() + (newAmount > 1 ? "s" : "") + "."); abort(); }
/** Process interface functions */ public static boolean processInterfaceFunctions(Player c, int buttonId) { if (buttonId < 205231 || buttonId > 207109) { return false; } PouchData pouch = PouchData.getByButton(buttonId); if (pouch == null) { return false; } switch (buttonId - pouch.getButtonId()) { case 1: hasRequirements(c, pouch.getButtonId(), true, 5, pouch); return true; case 2: hasRequirements(c, pouch.getButtonId(), true, 10, pouch); return true; case 3: hasRequirements(c, pouch.getButtonId(), true, 28, pouch); return true; case 4: c.getInterfaceState().openValueInput(52700, pouch.getButtonId(), pouch.getPouchId()); return true; default: hasRequirements(c, pouch.getButtonId(), true, 1, pouch); return true; } }