Esempio n. 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;
   }
 }
Esempio n. 2
0
  private void handleClick1(Player player, Packet packet) {
    int interfaceID = packet.getIn().readShort(StreamBuffer.ValueType.A);
    player.setSlot(packet.getIn().readShort(StreamBuffer.ValueType.A));
    int itemId = packet.getIn().readShort(StreamBuffer.ValueType.A);
    RSInterface inter = RSInterface.forId(interfaceID);
    switch (interfaceID) {
      case 4233: // make 1 ring crafting
        GemCrafting.startCrafter(player, GemData.getGemSlot()[player.getSlot()], 1, 0);
        break;
      case 4239: // make 1 neckalce crafting
        GemCrafting.startCrafter(player, GemData.getGemSlot()[player.getSlot()], 1, 1);
        break;
      case 4245: // make 1 amulet crafting
        GemCrafting.startCrafter(player, GemData.getGemSlot()[player.getSlot()], 1, 2);
        break;
      case 18821: // make 1 bracelet crafting
        GemCrafting.startCrafter(player, GemData.getGemSlot()[player.getSlot()], 1, 3);
        break;
    }
    if (!player.hasInterfaceOpen(inter)) {
      // player.getActionSender().removeInterfaces();

      return;
    }
    if (interfaceID == 1119
        || interfaceID == 1120
        || interfaceID == 1121
        || interfaceID == 1122
        || interfaceID == 1123) {
      // player.getSmithing().smithItem(itemId, 1);
      SmithBars.startSmithing(player, itemId, 1);
    }
    if (interfaceID == 1688) {
      player.getEquipment().unequip(player.getSlot());
    } else if (interfaceID == 5064 || interfaceID == 7423) {
      BankManager.bankItem(player, player.getSlot(), itemId, 1);
    } else if (interfaceID == 5382) {
      BankManager.withdrawItem(player, player.getSlot(), itemId, 1);
    } else if (interfaceID == 3900) {
      ShopManager.getBuyValue(player, itemId);
    } else if (interfaceID == 3823) {
      ShopManager.getSellValue(player, itemId);
    } else if (interfaceID == 3322) {
      if (player.getStatedInterface() == "duel")
        player.getDuelMainData().stakeItem(new Item(itemId, 1), player.getSlot());
      else TradeManager.offerItem(player, player.getSlot(), itemId, 1);
    } else if (interfaceID == 3415) {
      TradeManager.removeTradeItem(player, player.getSlot(), itemId, 1);
    } else if (interfaceID == 15682 || interfaceID == 15683) {
      player.getFarmingTools().withdrawItems(itemId, 1);
    } else if (interfaceID == 15594 || interfaceID == 15595) {
      player.getFarmingTools().storeItems(itemId, 1);
    } else if (interfaceID == 6669) {
      player.getDuelMainData().removeStakedItem(new Item(itemId, 1));
    }
  }
Esempio n. 3
0
 private void handleClickAll(Player player, Packet packet) {
   player.setSlot(packet.getIn().readShort(StreamBuffer.ValueType.A));
   int interfaceID = packet.getIn().readShort();
   int itemId = packet.getIn().readShort(StreamBuffer.ValueType.A);
   RSInterface inter = RSInterface.forId(interfaceID);
   if (!player.hasInterfaceOpen(inter)) {
     // player.getActionSender().removeInterfaces();
     return;
   }
   if (interfaceID == 5064 || interfaceID == 7423) {
     BankManager.bankItem(
         player,
         player.getSlot(),
         itemId,
         player.getInventory().getItemContainer().getCount(itemId));
   } else if (interfaceID == 5382) {
     BankManager.withdrawItem(player, player.getSlot(), itemId, player.getBank().getCount(itemId));
   } else if (interfaceID == 3900) {
     ShopManager.buyItem(player, player.getSlot(), itemId, 10);
   } else if (interfaceID == 3823) {
     ShopManager.sellItem(player, player.getSlot(), itemId, 10);
   } else if (interfaceID == 3322) {
     if (player.getStatedInterface() == "duel")
       player
           .getDuelMainData()
           .stakeItem(
               new Item(itemId, player.getInventory().getItemContainer().getCount(itemId)),
               player.getSlot());
     else
       TradeManager.offerItem(
           player,
           player.getSlot(),
           itemId,
           player.getInventory().getItemContainer().getCount(itemId));
   } else if (interfaceID == 15594 || interfaceID == 15595) {
     player.getActionSender().openXInterface(interfaceID);
     player.setClickItem(itemId);
   } else if (interfaceID == 15682 || interfaceID == 15683) {
     player.getActionSender().openXInterface(interfaceID);
     player.setClickItem(itemId);
   } else if (interfaceID == 3415) {
     TradeManager.removeTradeItem(player, player.getSlot(), itemId, Integer.MAX_VALUE);
   } else if (interfaceID == 6669) {
     player.getDuelMainData().removeStakedItem(new Item(itemId, Integer.MAX_VALUE));
   }
 }
Esempio n. 4
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());
 }
Esempio n. 5
0
  private void handleSecondClickItem(Player player, Packet packet) {
    int itemId = packet.getIn().readShort(StreamBuffer.ValueType.A);
    player.setSlot(
        packet.getIn().readShort(StreamBuffer.ValueType.A, StreamBuffer.ByteOrder.LITTLE));
    int interfaceID =
        packet.getIn().readShort(StreamBuffer.ValueType.A, StreamBuffer.ByteOrder.LITTLE);
    RSInterface inter = RSInterface.forId(interfaceID);
    if (!player.hasInterfaceOpen(inter)) {
      // player.getActionSender().removeInterfaces();
      return;
    }
    Item item = player.getInventory().getItemContainer().get(player.getSlot());
    if (item == null || item.getId() != itemId) return;
    Pouches.checkEssencePouch(player, item.getId());
    switch (itemId) {
      case 4566: // rubber chicken
        player.getUpdateFlags().sendAnimation(1835);
        return;

      case 2568: // RING OF FORGING CHARGE CHECK
        player
            .getActionSender()
            .sendMessage(
                "You have "
                    + player.getRingOfForgingLife()
                    + " Ring of Forging charge(s) remaining.");
        return;
      case 11074: // BRACELET OF CLAY CHARGE CHECK
        player
            .getActionSender()
            .sendMessage(
                "You have "
                    + player.getClayBraceletLife()
                    + " Bracelet of Clay charge(s) remaining.");
        return;
    }
  }
Esempio n. 6
0
  private void handleFirstClickItem(final Player player, Packet packet) {
    int interfaceID =
        packet.getIn().readShort(StreamBuffer.ValueType.A, StreamBuffer.ByteOrder.LITTLE);
    player.setSlot(packet.getIn().readShort(StreamBuffer.ValueType.A));
    int itemId = packet.getIn().readShort(StreamBuffer.ByteOrder.LITTLE);
    RSInterface inter = RSInterface.forId(interfaceID);
    if (!player.hasInterfaceOpen(inter)) {
      // player.getActionSender().removeInterfaces();
      return;
    }
    Item item = player.getInventory().getItemContainer().get(player.getSlot());

    if (item == null || item.getId() != itemId) return;
    /*
     * if (player.getRunecrafting().fillEssencePouch(item)) { return; } if
     * (player.getHerblore().cleanHerb(item)) { return; }
     */
    if (itemId == 2329) {
      player.getInventory().replaceItemWithItem(new Item(2329), new Item(2313));
      player.getActionSender().sendMessage("You empty your burnt pie onto the ground.");
      return;
    }
    if (Nests.handleNest(player, itemId)) {
      return;
    }
    if (GhostsAhoy.itemHandling(player, itemId)) {
      return;
    }
    if (itemId == Slayer.ENCHANTED_GEM) {
      Dialogues.startDialogue(player, 10012);
      return;
    }
    if (Cleaning.handleCleaning(player, itemId, player.getSlot())) return;

    if (player.getBoneBurying().buryBone(itemId, player.getSlot())) {
      return;
    }
    if (itemId >= 5509 && itemId <= 5514) {
      Pouches.fillEssencePouch(player, itemId);
      return;
    }

    if (player.getPotion().isPotion(itemId)) {
      player.getPotion().drinkPotion(itemId, player.getSlot());
      return;
    }
    if (player.getFood().eatFood(itemId, player.getSlot())) {
      return;
    }
    ClueScroll.handleCasket(player, itemId);
    if (new Item(itemId).getDefinition().getName().toLowerCase().contains("clue scroll")
        || new Item(itemId).getDefinition().getName().toLowerCase().contains("challenge scroll")) {
      ClueScroll.cleanClueInterface(player);
    }
    if (Puzzle.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (CoordinateScrolls.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (DiggingScrolls.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (ChallengeScrolls.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (SpeakToScrolls.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (AnagramsScrolls.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (MapScrolls.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (SearchScrolls.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (TeleTabs.breakTab(player, itemId, player.getSlot())) {
      return;
    }
    if (TabHandler.breakEnchantTab(player, itemId, player.getSlot())) {
      return;
    }
    if (TabHandler.breakBonesTab(player, itemId, player.getSlot())) {
      return;
    }
    if (ElementalWorkshop.itemHandling(player, itemId)) {
      return;
    }
    if (ShieldOfArrav.itemHandling(player, itemId)) {
      return;
    }
    if (DragonSlayer.itemHandling(player, itemId)) {
      return;
    }
    if (BlackKnightsFortress.itemHandling(player, itemId)) {
      return;
    }
    if (PiratesTreasure.itemHandling(player, itemId)) {
      return;
    }
    if (AnimalMagnetism.itemHandling(player, itemId)) {
      return;
    }
    switch (itemId) {
      case 2528: // genie lamp
        player.setGenieSelect(-1);
        player.getActionSender().sendConfig(261, 0);
        player.getActionSender().sendInterface(2808);
        return;
      case 550: // newcomers map
        player.getActionSender().sendInterface(5392);
        return;
      case 33: // candle
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player.getActionSender().sendMessage("You extinguish the candle.");
          player.getInventory().addItemToSlot(new Item(36), player.getSlot());
        }
        return;
      case 594: // torch
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player.getActionSender().sendMessage("You extinguish the torch.");
          player.getInventory().addItemToSlot(new Item(596), player.getSlot());
        }
        return;
      case 4531: // candle lantern
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player.getActionSender().sendMessage("You extinguish the candle lantern.");
          player.getInventory().addItemToSlot(new Item(4529), player.getSlot());
        }
        return;
      case 4534: // black candle lantern
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player.getActionSender().sendMessage("You extinguish the black candle lantern.");
          player.getInventory().addItemToSlot(new Item(4532), player.getSlot());
        }
        return;
      case 4539: // oil lamp
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player.getActionSender().sendMessage("You extinguish the oil lamp.");
          player.getInventory().addItemToSlot(new Item(4537), player.getSlot());
        }
        return;
      case 4550: // bullseye lantern
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player.getActionSender().sendMessage("You extinguish the bullseye lantern.");
          player.getInventory().addItemToSlot(new Item(4548), player.getSlot());
        }
        return;
      case 405: // casket
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          Casket.openCasket(player);
        }
        return;
      case 2150: // swamp toad
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player
              .getActionSender()
              .sendMessage(
                  "You pull the legs off the toad. Poor toad. At least they'll grow back.");
          player.getInventory().addItemToSlot(new Item(2152), player.getSlot());
        }
        return;
      case 407: // oyster
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player.getActionSender().sendMessage("You open the oyster.");
          player.getInventory().addItemToSlot(new Item(411), player.getSlot());
        }
        return;
      case 4033:
        //  ShopManager.openShop(player, 39);
        player.getActionSender().sendMessage("You poke the monkey.");
        return;
      case 10592:
        player.getPets().registerPet(10592, 5428);
        return;
      case 952: // spade
        player.getUpdateFlags().sendAnimation(830);
        player.getActionSender().sendMessage("You dig into the ground...");

        final int task = player.getTask();
        player.setSkilling(
            new CycleEvent() {

              @Override
              public void execute(CycleEventContainer container) {
                if (!player.checkTask(task)) {
                  container.stop();
                  return;
                }
                if (player.getPosition().getX() == 2566
                    && (player.getPosition().getY() == 3331
                        || player.getPosition().getY() == 3333)) {
                  player.fadeTeleport(new Position(2530, 3303));
                  player.getActionSender().sendMessage("and find yourself in plague city.");
                  container.stop();
                  return;
                }
                if (player.getPosition().getX() == 2999
                    && player.getPosition().getY() == 3383
                    && (player.getQuestStage(20) == 6 || player.getQuestStage(20) == 7)) {
                  player.setQuestStage(20, 8);
                  QuestHandler.completeQuest(player, 20);
                  player.getInventory().addItem(new Item(PiratesTreasure.CHEST));
                  container.stop();
                  return;
                }
                if (player.getPosition().equals(GhostsAhoy.TREASURE_LOCATION)
                    && !player.getInventory().playerHasItem(GhostsAhoy.BOOK_OF_HARICANTO)) {
                  player
                      .getDialogue()
                      .sendGiveItemNpc(
                          "You unearth the Book of Haricanto.",
                          new Item(GhostsAhoy.BOOK_OF_HARICANTO));
                  player.getInventory().addItem(new Item(GhostsAhoy.BOOK_OF_HARICANTO));
                  container.stop();
                  return;
                }
                if (!MapScrolls.digClue(player)
                    && !DiggingScrolls.digClue(player)
                    && !CoordinateScrolls.digClue(player)
                    && !Barrows.digCrypt(player)) {
                  player.getActionSender().sendMessage("but do not find anything.");
                  container.stop();
                }
              }

              @Override
              public void stop() {
                player.resetAnimation();
              }
            });
        CycleEventHandler.getInstance().addEvent(player, player.getSkilling(), 2);
        return;
      case 2574: // sextant
        Sextant.initializeRandomSextantInterface(player);
        return;
      case 299:
        // MithrilSeeds.plantMithrilSeed(player);
        return;
    }

    player.getActionSender().sendMessage("Nothing interesting happens.");
    /*
     * if (item == 4155) { String slayerNpc = (String)
     * player.getSlayerTask()[0]; if (!slayerNpc.equalsIgnoreCase("")) {
     * player.getDialogue().sendStatement("Your existing task is to kill " +
     * player.getSlayerTask()[1] + " " + slayerNpc + "s.");
     * player.getDialogue().setNextDialogue(0); } else {
     * player.getDialogue().sendStatement("You don't have a slaver task.");
     * } return; }
     */
  }
Esempio n. 7
0
 private void handleThirdClickItem(Player player, Packet packet) {
   int interfaceID =
       packet.getIn().readShort(StreamBuffer.ValueType.A, StreamBuffer.ByteOrder.LITTLE);
   player.setSlot(packet.getIn().readShort(StreamBuffer.ByteOrder.LITTLE));
   player.setClickItem(packet.getIn().readShort(true, StreamBuffer.ValueType.A));
   RSInterface inter = RSInterface.forId(interfaceID);
   if (!player.hasInterfaceOpen(inter)) {
     // player.getActionSender().removeInterfaces();
     return;
   }
   Item item = player.getInventory().getItemContainer().get(player.getSlot());
   if (item == null || item.getId() != player.getClickItem()) return;
   if (PotionMaking.emptyPotion(player, new Item(player.getClickItem()), player.getSlot())) return;
   if (Runecrafting.clickTalisman(player, player.getClickItem())) {
     return;
   }
   for (int[] element : Pouches.POUCHES) {
     if (item.getId() == element[0]) {
       Pouches.emptyEssencePouch(player, item.getId());
       return;
     }
   }
   switch (item.getId()) {
     case 2552: // ring of duelling
     case 2554:
     case 2556:
     case 2558:
     case 2560:
     case 2562:
     case 2564:
     case 2566:
       Dialogues.startDialogue(player, 10004);
       break;
     case 431: // karamjan rum
       player.getActionSender().statEdit(Skill.ATTACK, -3, false);
       player.getActionSender().statEdit(Skill.STRENGTH, 2, true);
       player
           .getActionSender()
           .sendMessage("You drink your Karamjan Rum and drop the bottle, whoops!.");
       player.getInventory().removeItem(new Item(431));
       player.setDrunkState(true, 300);
       break;
     case 1712: // glory
     case 1710:
     case 1708:
     case 1706:
       Dialogues.startDialogue(player, 10003);
       break;
     case 11105: // glory
     case 11107:
     case 11109:
     case 11111:
       Dialogues.startDialogue(player, 10015);
       break;
     case 3853:
     case 3855:
     case 3857:
     case 3859:
     case 3861:
     case 3863:
     case 3865:
     case 3867:
       Dialogues.startDialogue(player, 10002);
       break;
     case 11118: // glory
     case 11120:
     case 11122:
     case 11124:
       Dialogues.startDialogue(player, 10014);
       break;
   }
 }