Пример #1
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; }
     */
  }
Пример #2
0
  private void useItemOnItem(Player player, Packet packet) {
    int itemSecondClickSlot = packet.getIn().readShort();
    int itemFirstClickSlot = packet.getIn().readShort(StreamBuffer.ValueType.A);
    packet.getIn().readShort();
    packet.getIn().readShort();
    if (itemFirstClickSlot > 28 || itemSecondClickSlot > 28) {
      return;
    }
    Item firstClickItem = player.getInventory().getItemContainer().get(itemFirstClickSlot);
    Item secondClickItem = player.getInventory().getItemContainer().get(itemSecondClickSlot);
    if (firstClickItem == null
        || secondClickItem == null
        || !firstClickItem.validItem()
        || !secondClickItem.validItem()) return;
    int firstItem = firstClickItem.getId();
    int secondItem = secondClickItem.getId();
    if (player.getDuelMainData().getOpponent() != null) {
      player.getDuelInteraction().endDuelInteraction(true);
      return;
    }
    if (OneIngredients.mixItems(
        player, firstItem, secondItem, itemFirstClickSlot, itemSecondClickSlot)) return;
    if (TwoIngredients.mixItems(
        player, firstItem, secondItem, itemFirstClickSlot, itemSecondClickSlot)) return;
    if (ThreeIngredients.mixItems(
        player, firstItem, secondItem, itemFirstClickSlot, itemSecondClickSlot)) return;
    if (DoughHandler.handleInterface(
        player, firstItem, secondItem, itemFirstClickSlot, itemSecondClickSlot)) return;
    /* Fletching */
    if (ArrowMaking.perform(player, firstItem, secondItem)) return;
    if (BowStringing.perform(player, firstItem, secondItem)) return;
    if (LogCuttingInterfaces.handleItemOnItem(player, firstItem, secondItem)) return;
    if (CbowFletching.attachLimbs(player, firstItem, secondItem)
        || CbowFletching.stringCbow(player, firstItem, secondItem)) return;
    if (GemTips.handleCutting(
        player,
        firstItem,
        secondItem,
        firstItem != GemTips.CHISEL ? itemFirstClickSlot : itemSecondClickSlot)) return;
    /* Crafting */
    if (GemCutting.handleCutting(
        player,
        firstItem,
        secondItem,
        firstItem != GemCutting.CHISEL ? itemFirstClickSlot : itemSecondClickSlot)) return;
    if (LeatherMakingHandler.handleItemOnItem(
        player, firstItem, secondItem, itemFirstClickSlot, itemSecondClickSlot)) return;
    if (BasicCraft.handleItemOnItem(player, firstItem, secondItem)) return;
    if ((firstItem == GlassMaking.GLASSBLOWING_PIPE && secondItem == GlassMaking.MOLTEN_GLASS)
        || (secondItem == GlassMaking.GLASSBLOWING_PIPE && firstItem == GlassMaking.MOLTEN_GLASS)) {
      Menus.sendSkillMenu(player, "glassMaking");
      return;
    }
    /* STRINGING AMULETS */
    for (int i = 0; i < GemData.stringItems.length; i++) {
      if (GemData.stringItems[i][0] == firstItem || GemData.stringItems[i][0] == secondItem) {
        GemCrafting.string(player, i);
        return;
      }
    }
    if (ElementalWorkshop.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (ShieldOfArrav.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (DragonSlayer.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (GoblinDiplomacy.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (PiratesTreasure.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (ErnestTheChicken.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (GhostsAhoy.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (AnimalMagnetism.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (TabHandler.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (wetClayHandler.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    /* Farming */
    if (player
        .getSeedling()
        .placeSeedInPot(
            firstClickItem.getId(),
            secondClickItem.getId(),
            itemFirstClickSlot,
            itemSecondClickSlot)) {
      return;
    }
    if (player
        .getSeedling()
        .waterSeedling(
            firstClickItem.getId(),
            secondClickItem.getId(),
            itemFirstClickSlot,
            itemSecondClickSlot)) {
      return;
    }
    if (player
        .getItemOnItem()
        .handleItemOnItem(
            firstClickItem, secondClickItem, itemFirstClickSlot, itemSecondClickSlot)) {
      return;
    }
    if (Tools.attachTool(player, firstItem, secondItem)) {
      player.getActionSender().sendMessage("You put together the head and handle.");
      return;
    }
    /*Slayer*/
    if (player.getSlayer().handleItemOnItem(firstItem, secondItem)) {
      return;
    }
    /* Herblore */
    if (PotionMaking.createPotion(
        player, firstClickItem, secondClickItem, itemFirstClickSlot, itemSecondClickSlot)) {
      return;
    }
    if (Grinding.createProduct(
        player, firstClickItem, secondClickItem, itemFirstClickSlot, itemSecondClickSlot)) {
      return;
    }
    if (PoisoningWeapon.handlePoison(player, firstClickItem, secondClickItem)) {
      return;
    }
    if (Coconut.handleCoconut(player, firstClickItem, secondClickItem)) {
      return;
    }
    if (PotionMaking.combineDose(
        player, firstItem, secondItem, itemFirstClickSlot, itemSecondClickSlot)) {
      return;
    }
    /* Firemaking */
    if (firstItem == 590 || secondItem == 590) {
      if (firstItem == 596 && secondItem == 596) {
        if (player.getInventory().removeItem(new Item(596))) {
          player.getInventory().addItem(new Item(594));
          player.getActionSender().sendMessage("You light the torch.");
          return;
        }
      }
      if (firstItem == 36 && secondItem == 36) {
        if (player.getInventory().removeItem(new Item(36))) {
          player.getInventory().addItem(new Item(33));
          player.getActionSender().sendMessage("You light the candle.");
          return;
        }
      }
      player
          .getFiremaking()
          .attemptFire(
              firstItem,
              secondItem,
              false,
              player.getPosition().getX(),
              player.getPosition().getY(),
              player.getPosition().getZ());
      return;
    }

    if (GodBook.addPageToBook(
        player, firstClickItem, secondClickItem, itemFirstClickSlot, itemSecondClickSlot)) {
      return;
    }
    if (firstClickItem.getId() == 1765 && secondClickItem.getId() == 2421) {
      player.getActionSender().sendMessage("You carefully dye the wig blonde.");
      player.getInventory().removeItem(new Item(2421));
      player.getInventory().removeItem(new Item(1765));
      player.getInventory().addItem(new Item(2419));
      return;
    }
    if (firstClickItem.getId() == 1973 && secondClickItem.getId() == 233) {
      player
          .getActionSender()
          .sendMessage("You use your pestle and mortar to turn the chocolate to dust.");
      player.getInventory().removeItem(new Item(1973));
      player.getInventory().addItem(new Item(1975));
      return;
    }
    if (firstClickItem.getId() == 946 && secondClickItem.getId() == 1973) {
      player.getActionSender().sendMessage("You use your knife to turn the chocolate to dust.");
      player.getInventory().removeItem(new Item(1973));
      player.getInventory().addItem(new Item(1975));
      return;
    }
    player.getActionSender().sendMessage("Nothing interesting happens.");
  }