@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(); }
@Override public void handle(Player player, GamePacket packet) { int skill = packet.readShort(); int goal = -1; int type = 0; int initialExp = 0; if (packet.getOpcode() == 63) { type = packet.readByte(); long val = packet.readLong(); if (skill < 0 || skill >= Skill.SKILL_COUNT) { return; } goal = (int) (val > 200_000_000 || val < 0 ? type == 1 ? 200_000_000 : 1 : val); initialExp = player.getSkill().getExperience(skill); if (type == 0) { if (goal <= player.getSkill().getLevel(skill)) { return; } } else if (type == 1) { if (goal <= player.getSkill().getExperience(skill)) { return; } } } if (skill < 0 || skill >= Skill.SKILL_COUNT) { return; } player.getSkill().setGoalData(skill, goal, type, initialExp); player.getSession().send(new SendSkillGoalPacket(skill)); }
/** * Checks whether or not that player has requirements to make the pouch. * * @param c The Player. * @param itemId The item id. * @param slot The slot of the item. */ public static boolean hasRequirements( final Player player, final int buttonId, boolean inform, int amount, PouchData pouch) { if (inform) { if (player.getSkill().getLevelForExperience(Skill.SUMMONING) < pouch.getLevelRequired()) { player.sendMessage( "You need a summoning level of " + pouch.getLevelRequired() + " to create this pouch"); return false; } } if (!player.getInventory().contains(POUCH_ID)) { if (inform) { player.sendMessage("You dont have a pouch to create this item."); } return false; } if (!player.getInventory().hasItem(new Item(SHARD_ID, pouch.getShardsRequired()))) { if (inform) { player.sendMessage( "You need " + pouch.getShardsRequired() + " shards to create this pouch."); } return false; } if (!player.getInventory().contains(pouch.getCharmId())) { if (inform) { player.sendMessage( "You need a " + new Item(pouch.getCharmId()).getDefinition().getName() + " to create this pouch."); } return false; } if (!player.getInventory().contains(pouch.getSecondIngredientId())) { if (inform) { player.sendMessage( "You need " + new Item(pouch.getSecondIngredientId()).getDefinition().getName() + " to create this pouch."); } return false; } player.setCurrentSkill(new CreatePouch(player, buttonId, amount)); player.getCurrentSkill().start(); return true; }