예제 #1
0
 private void handleOptions(Player player, Packet packet) {
   player.setInterfaceId(
       packet.getIn().readShort(StreamBuffer.ValueType.A, StreamBuffer.ByteOrder.LITTLE));
   packet.getIn().readByte(StreamBuffer.ValueType.C);
   int fromSlot =
       packet.getIn().readShort(StreamBuffer.ValueType.A, StreamBuffer.ByteOrder.LITTLE);
   int toSlot = packet.getIn().readShort(StreamBuffer.ByteOrder.LITTLE);
   RSInterface inter = RSInterface.forId(player.getInterfaceId());
   if (!player.hasInterfaceOpen(inter)) {
     // player.getActionSender().removeInterfaces();
     return;
   }
   switch (player.getInterfaceId()) {
     case 5382:
       BankManager.handleBankOptions(player, fromSlot, toSlot);
       break;
     case 3214:
       Item item = player.getInventory().getItemContainer().get(fromSlot);
       if (item == null) return;
       if (player.getInventory().playerHasItem(item)) {
         player.getInventory().swap(fromSlot, toSlot);
         player.getInventory().refresh();
       }
       break;
   }
 }
예제 #2
0
 private void handleCastedSpellOnItem(Player player, Packet packet) {
   StreamBuffer.InBuffer in = packet.getIn();
   player.setSlot(in.readShort());
   int itemId = in.readShort(StreamBuffer.ValueType.A);
   player.setInterfaceId(in.readShort());
   int magicId = in.readShort(StreamBuffer.ValueType.A);
   Spell spell = player.getMagicBookType().getSpells().get(magicId);
   Item item = player.getInventory().getItemContainer().get(player.getSlot());
   if (item == null || item.getId() != itemId || !item.validItem()) return;
   if (spell != null) {
     MagicSkill.spellOnItem(player, spell, itemId, player.getSlot());
   }
   if (player.getEnchantingChamber().isInEnchantingChamber()) {
     player.getEnchantingChamber().enchantItem(magicId, itemId);
     return;
   }
   if (player.getAlchemistPlayground().isInAlchemistPlayGround()) {
     player.getAlchemistPlayground().alchemyItem(itemId);
     return;
   } else if (player.getStaffRights() > 1 && Constants.SERVER_DEBUG)
     System.out.println(
         "Slot: "
             + player.getSlot()
             + " Item id: "
             + itemId
             + " Interface ID: "
             + player.getInterfaceId()
             + " magic id: "
             + magicId);
 }
예제 #3
0
 private void handleEquipItem(Player player, Packet packet) {
   int itemId = packet.getIn().readShort(); // Item ID.
   player.setSlot(packet.getIn().readShort(StreamBuffer.ValueType.A));
   player.setInterfaceId(packet.getIn().readShort(StreamBuffer.ValueType.A)); // Interface ID.
   RSInterface inter = RSInterface.forId(player.getInterfaceId());
   if (!player.hasInterfaceOpen(inter)) {
     return;
   }
   if (itemId == 6541) {
     player.getPets().registerPet(6541, 901);
     return;
   }
   if (itemId == 5608) {
     player.getEquipment().equip(player.getSlot());
     return;
   }
   if (itemId == 5609) {
     player.getEquipment().equip(player.getSlot());
     return;
   }
   if (GoblinDiplomacy.itemHandling(player, itemId)) {
     return;
   }
   if (AnimalMagnetism.itemHandling(player, itemId)) {
     return;
   }
   if (itemId == 11664)
     if (player.hasFullVoidRange()
         && player.getSkill().getLevel()[4] <= player.getSkill().getPlayerLevel(4)) {
       player.getSkill().getLevel()[4] = (int) (player.getSkill().getPlayerLevel(4) * 1.1);
       return;
     }
   if (new Item(itemId).getDefinition().getSlot() == -1) {
     return;
   }
   if (player.getDuelMainData().getOpponent() != null && !player.inDuelArena()) {
     player.getDuelInteraction().endDuelInteraction(true);
     return;
   }
   // player.getActionSender().removeInterfaces();
   Item item = player.getInventory().getItemContainer().get(player.getSlot());
   if (item == null || item.getId() != itemId || !item.validItem()) {
     return;
   }
   player.getEquipment().equip(player.getSlot());
 }