public static boolean stakeItem(Player player, int itemId, int amount, int slot) { if (!player.getInventory().contains(itemId) || !player.getDuel().isDueling()) { return false; } if (player.getInterfaceState().getCurrentInterface() != 37888) { return false; } if (new Item(itemId).getDefinition().isUntradeable()) { player.sendMessage("This item is currently untradeable and cannot be staked."); return false; } Player playerToDuel = GameService.getWorld().getByUsername(player.getDuel().getDuelingWith()).get(); if (playerToDuel == null) { return false; } if (player.getDuel().getStatus() != DuelingStatus.WAITING_FIRST_ACCEPT && player.getDuel().getStatus() != DuelingStatus.ACCEPTED_FIRST_INTERFACE || playerToDuel.getDuel().getStatus() != DuelingStatus.WAITING_FIRST_ACCEPT && playerToDuel.getDuel().getStatus() != DuelingStatus.ACCEPTED_FIRST_INTERFACE) { DuelArenaHandler.declineDuel(player, true); return false; } if (player.getInventory().getItemAmount(itemId) < amount) { amount = player.getInventory().getItemAmount(itemId); if (amount == 0 || player.getInventory().getItemAmount(itemId) < amount) { return false; } } if (player.getDuel().getStakeInventory().add(new Item(itemId, amount))) { player.getInventory().remove(new Item(itemId, amount)); } DuelArenaHandler.updateStakedItems(player, playerToDuel); player.getSession().send(new SendStringPacket("", 6684)); playerToDuel.getSession().send(new SendStringPacket("", 6684)); player.getDuel().setStatus(DuelingStatus.WAITING_FIRST_ACCEPT); playerToDuel.getDuel().setStatus(DuelingStatus.WAITING_FIRST_ACCEPT); player.setAttribute("stake_change_delay", System.currentTimeMillis()); return true; }
@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)); }