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; } }
public boolean handleInterface(int item, int objectId, int objectX, int objectY) { CookingItems cook = CookingItems.forId(item); if (cook == null) return false; player.getActionSender().removeInterfaces(); if (!Constants.COOKING_ENABLED) { player.getActionSender().sendMessage("This skill is currently disabled."); return true; } player.setOldObject(objectId); final CacheObject obj = ObjectLoader.object(objectId, objectX, objectY, player.getPosition().getZ()); final GameObjectDef def = SkillHandler.getObject(objectId, objectX, objectY, player.getPosition().getZ()); if (obj != null || def != null) { String name = GameObjectData.forId(obj != null ? obj.getDef().getId() : def.getId()) .getName() .toLowerCase(); if (name.equalsIgnoreCase("fire") || name.equalsIgnoreCase("fireplace")) { player.setNewSkillTask(); player.setStatedInterface("cookFire"); firePosition = new Position(objectX, objectY, player.getPosition().getZ()); player.setTempInteger(item); if (player.getNewComersSide().isInTutorialIslandStage() || player.getInventory().getItemAmount(item) == 1) { handleCookingTick(player, 1); return true; } Item itemDef = new Item(item); player.getActionSender().sendItemOnInterface(13716, 200, item); player.getActionSender().sendString("" + itemDef.getDefinition().getName() + "", 13717); player.getActionSender().sendChatInterface(1743); return true; } if (name.equalsIgnoreCase("stove") || name.equalsIgnoreCase("range") || name.equalsIgnoreCase("cooking range") || name.equalsIgnoreCase("cooking pot")) { player.setNewSkillTask(); player.setStatedInterface("cookRange"); player.setTempInteger(item); if (player.getNewComersSide().isInTutorialIslandStage() || player.getInventory().getItemAmount(item) == 1) { handleCookingTick(player, 1); player .getUpdateFlags() .sendFaceToDirection( new Position(player.getPosition().getX(), player.getPosition().getY() - 1)); return true; } Item itemDef = new Item(item); player.getActionSender().sendItemOnInterface(13716, 200, item); player.getActionSender().sendString("" + itemDef.getDefinition().getName() + "", 13717); player.getActionSender().sendChatInterface(1743); return true; } } return true; }
public static boolean itemOnItemHandling(Player player, int firstItem, int secondItem) { if (firstItem == 946 && secondItem == 2886) { player.getInventory().removeItem(new Item(2886)); player.getDialogue().sendStatement("You cut apart the book to find a key."); player.getInventory().addItem(new Item(2887)); if (player.getQuestStage(12) == 1) { player.setQuestStage(12, 2); } return true; } return false; }
private void handlePickupItem(Player player, Packet packet) { player.setClickY(packet.getIn().readShort(StreamBuffer.ByteOrder.LITTLE)); player.setClickId(packet.getIn().readShort()); player.setClickX(packet.getIn().readShort(StreamBuffer.ByteOrder.LITTLE)); player.setClickZ(player.getPosition().getZ()); if (!player.getInventory().canAddItem(new Item(player.getClickId()))) { return; } if (ClueScroll.hasClue(player) && new Item(player.getClickId()) .getDefinition() .getName() .toLowerCase() .contains("clue scroll")) { player.getActionSender().sendMessage("You can only pick up one scroll at a time."); return; } if (DemonSlayer.itemPickupHandling(player, player.getClickId())) { return; } if ((Boolean) player.getAttributes().get("canPickup")) { ItemManager.getInstance() .pickupItem( player, player.getClickId(), new Position(player.getClickX(), player.getClickY(), player.getPosition().getZ())); } }
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); }
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)); } }
public void getReward(Player player) { for (int[] rewards : reward) { player.getInventory().addItem(new Item(rewards[0], rewards[1])); } for (int[] expRewards : expReward) { player.getSkill().addExp(expRewards[0], (expRewards[1])); } player.addQuestPoints(questPointReward); player.getActionSender().QPEdit(player.getQuestPoints()); }
private void handleClick10(Player player, Packet packet) { int interfaceID = packet.getIn().readShort(StreamBuffer.ByteOrder.LITTLE); int itemId = packet.getIn().readShort(StreamBuffer.ValueType.A); player.setSlot(packet.getIn().readShort(StreamBuffer.ValueType.A)); RSInterface inter = RSInterface.forId(interfaceID); switch (interfaceID) { case 4233: // make 10 ring crafting GemCrafting.startCrafter(player, GemData.getGemSlot()[player.getSlot()], 10, 0); break; case 4239: // make 10 neckalce crafting GemCrafting.startCrafter(player, GemData.getGemSlot()[player.getSlot()], 10, 1); break; case 4245: // make 10 amulet crafting GemCrafting.startCrafter(player, GemData.getGemSlot()[player.getSlot()], 10, 2); break; case 18821: // make 10 bracelet crafting GemCrafting.startCrafter(player, GemData.getGemSlot()[player.getSlot()], 10, 3); break; } if (!player.hasInterfaceOpen(inter)) { // player.getActionSender().removeInterfaces(); return; } if (interfaceID == 5064 || interfaceID == 7423) { BankManager.bankItem(player, player.getSlot(), itemId, 10); } else if (interfaceID == 5382) { BankManager.withdrawItem(player, player.getSlot(), itemId, 10); } else if (interfaceID == 3900) { ShopManager.buyItem(player, player.getSlot(), itemId, 5); } else if (interfaceID == 3823) { ShopManager.sellItem(player, player.getSlot(), itemId, 5); } else if (interfaceID == 3322) { if (player.getStatedInterface() == "duel") player.getDuelMainData().stakeItem(new Item(itemId, 10), player.getSlot()); else TradeManager.offerItem(player, player.getSlot(), itemId, 10); } else if (interfaceID == 3415) { TradeManager.removeTradeItem(player, player.getSlot(), itemId, 10); } else if (interfaceID == 15682 || interfaceID == 15683) { player.getFarmingTools().withdrawItems(itemId, 255); } else if (interfaceID == 15594 || interfaceID == 15595) { player.getFarmingTools().storeItems(itemId, player.getInventory().getItemAmount(itemId)); } else if (interfaceID == 1119 || interfaceID == 1120 || interfaceID == 1121 || interfaceID == 1122 || interfaceID == 1123) { // player.getSmithing().smithItem(itemId, 10); SmithBars.startSmithing(player, itemId, 10); } else if (interfaceID == 6669) { player.getDuelMainData().removeStakedItem(new Item(itemId, 10)); } }
public static void giveRewards(Player player, int item, boolean forcedBurn) { CookingItems food = CookingItems.forId(item); if ((cookedSuccessfully( player, food.getCookLevel(), food.getBurnStopLevelWith(), food.getBurnStopLevel()) && !forcedBurn) || (player.getNewComersSide().isInTutorialIslandStage() && !forcedBurn)) { player.getInventory().addItem(new Item(food.getCookedId())); player.getSkill().addExp(Skill.COOKING, food.getExperience()); player .getActionSender() .sendMessage( "You successfully cook a " + ItemDefinition.forId(food.getCookedId()).getName().toLowerCase() + "."); } else { player.getInventory().addItem(new Item(food.getBurntID())); player .getActionSender() .sendMessage( "You accidentally burn the " + ItemDefinition.forId(food.getCookedId()).getName().toLowerCase() + "."); } }
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()); }
// TODO sounds + correct message & amount interface which is a basic version // you can see above ^ // the ground public static void handleCooking(final Player player) { final CookingItems toCook = CookingItems.forId(player.getTempInteger()); if (toCook == null) return; // Means the item exists in cooking enum if (player.getSkill().getLevel()[Skill.COOKING] < toCook.getCookLevel()) { player .getDialogue() .sendStatement("You need a cooking level of " + toCook.getCookLevel() + " to cook this."); return; } player.getActionSender().removeInterfaces(); player.getInventory().removeItem(new Item(player.getTempInteger())); if (player.getStatedInterface() == "cookFire") player.getUpdateFlags().sendAnimation(897); else if (player.getStatedInterface() == "cookRange") player.getUpdateFlags().sendAnimation(883); player.getActionSender().sendSound(357, 0, 0); if (player.getNewComersSide().isInTutorialIslandStage()) { if (player.getNewComersSide().getTutorialIslandStage() == 12) { player .getNewComersSide() .setTutorialIslandStage(player.getNewComersSide().getTutorialIslandStage() + 1, true); giveRewards(player, player.getTempInteger(), true); } else if (player.getNewComersSide().getTutorialIslandStage() == 13) { player .getNewComersSide() .setTutorialIslandStage(player.getNewComersSide().getTutorialIslandStage() + 1, true); giveRewards(player, player.getTempInteger(), false); } else if (player.getNewComersSide().getTutorialIslandStage() == 18 && player.getTempInteger() == 2307) { player .getNewComersSide() .setTutorialIslandStage(player.getNewComersSide().getTutorialIslandStage() + 1, true); giveRewards(player, player.getTempInteger(), false); } return; } if (!toCook.fireCook() && player.getStatedInterface() == "cookFire") giveRewards(player, player.getTempInteger(), true); else giveRewards(player, player.getTempInteger(), false); /* some food always burns on fire */ }
private void handlePickupSecondItem(final Player player, Packet packet) { player.setClickX(packet.getIn().readShort(StreamBuffer.ByteOrder.LITTLE)); player.setClickY( packet.getIn().readShort(StreamBuffer.ValueType.A, StreamBuffer.ByteOrder.LITTLE)); player.setClickId(packet.getIn().readShort(StreamBuffer.ValueType.A)); player.setClickZ(player.getPosition().getZ()); if (player.getStaffRights() > 1 && Constants.SERVER_DEBUG) System.out.println(player.getClickX() + " " + player.getClickY()); if (!player.getInventory().canAddItem(new Item(player.getClickId()))) { return; } 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() == player.getClickX() && player.getPosition().getY() == player.getClickY()) { player .getFiremaking() .attemptFire( player.getClickId(), 0, true, player.getClickX(), player.getClickY(), player.getPosition().getZ()); container.stop(); } } @Override public void stop() {} }); CycleEventHandler.getInstance().addEvent(player, player.getSkilling(), 1); }
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; } }
public static void startSmithing(final Player player, final int item, final int amount) { final int id = getArrayForFullName(player, item); if (id > -1) { final Item finalItem = new Item(item); final String itemName = finalItem.getDefinition().getName().toLowerCase(); if (!SkillHandler.hasRequiredLevel( player, Skill.SMITHING, smithLevel(id, player.getSmithInterface()), "smith " + itemName)) { return; } if (!player.getInventory().getItemContainer().contains(2347)) { player.getActionSender().sendMessage("You need a hammer to smith on an anvil."); return; } final Item bar = new Item(player.getOldItem(), smithInfo[id][2]); if (!player.getInventory().playerHasItem(bar)) { player .getActionSender() .sendMessage( "You need at least " + smithInfo[id][2] + " bars to make " + itemName + "."); return; } if (player.getNewComersSide().isInTutorialIslandStage()) { // TutorialIsland.sendStartInfo(player); } else { player.getActionSender().removeInterfaces(); } final int task = player.getTask(); player.getUpdateFlags().sendAnimation(898); player.getActionSender().sendSound(468, 0, 0); player.setSkilling( new CycleEvent() { int amounts = amount; @Override public void execute(CycleEventContainer container) { if (player.getOldItem() < 1 || !player.checkTask(task)) { container.stop(); return; } if (!player.getInventory().playerHasItem(bar)) { player.getActionSender().sendMessage("You have run out of bars!"); container.stop(); return; } player.getInventory().removeItem(bar); if (itemName.contains("arrowtips") || itemName.contains("nails")) { player.getInventory().addItem(new Item(item, 15)); } else if (itemName.contains("dart tip") || itemName.contains("bolts")) { player.getInventory().addItem(new Item(item, 10)); } else if (itemName.contains("knife")) { player.getInventory().addItem(new Item(item, 5)); } else { player.getInventory().addItem(new Item(item, 1)); } player .getSkill() .addExp( Skill.SMITHING, smithInfo[id][1] + 12.5 * smithInfo[id][2] * player.getSmithInterface() + 0.5); if (player.getNewComersSide().isInTutorialIslandStage()) { if (player.getNewComersSide().getTutorialIslandStage() == 36) player .getNewComersSide() .setTutorialIslandStage( player.getNewComersSide().getTutorialIslandStage() + 1, true); player.setClickId(0); player .getDialogue() .sendStatement( "You hammer the " + bar.getDefinition().getName().toLowerCase() + " and make " + finalItem.getDefinition().getName().toLowerCase() + "."); } else { player .getActionSender() .sendMessage( "You hammer the " + bar.getDefinition().getName().toLowerCase() + " and make " + finalItem.getDefinition().getName().toLowerCase() + "."); } amounts--; if (amounts < 1) { container.stop(); return; } if (!player.getInventory().playerHasItem(bar)) { player.getActionSender().sendMessage("You have run out of bars!"); container.stop(); return; } player.getUpdateFlags().sendAnimation(898); player.getActionSender().sendSound(468, 0, 0); } @Override public void stop() { player.getTask(); player.resetAnimation(); } }); CycleEventHandler.getInstance().addEvent(player, player.getSkilling(), 4); } }
private static String checkBars(int item, int amount, Player player) { if (player.getInventory().playerHasItem(item, amount)) { return "@gre@"; } return ""; }
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; } */ }
public static void smithInterface(Player player, int itemId) { if (!Constants.SMITHING_ENABLED) { player.getActionSender().sendMessage("This skill is currently disabled."); return; } if (!player.getInventory().playerHasItem(2347)) { player.getDialogue().sendStatement("You need a hammer to start smithing."); return; } if (itemId == 9467) { Dialogues.startDialogue(player, 10201); return; } if (itemId == 2349) { player.setSmithInterface(0); } else if (itemId == 2351) { player.setSmithInterface(1); } else if (itemId == 2353) { player.setSmithInterface(2); } else if (itemId == 2359) { player.setSmithInterface(3); } else if (itemId == 2361) { player.setSmithInterface(4); } else if (itemId == 2363) { player.setSmithInterface(5); } else { return; } if (!SkillHandler.hasRequiredLevel( player, Skill.SMITHING, smithLevel(0, player.getSmithInterface()), "smith this bar")) { player.getTask(); player.resetAnimation(); return; } player.setOldItem(itemId); String fiveb = checkBars(itemId, 5, player); String threeb = checkBars(itemId, 3, player); String twob = checkBars(itemId, 2, player); String oneb = checkBars(itemId, 1, player); player.getActionSender().sendString(fiveb + "5bars" + fiveb, 1112); player.getActionSender().sendString(threeb + "3bars" + threeb, 1109); player.getActionSender().sendString(threeb + "3bars" + threeb, 1110); player.getActionSender().sendString(threeb + "3bars" + threeb, 1118); player.getActionSender().sendString(threeb + "3bars" + threeb, 1111); player.getActionSender().sendString(threeb + "3bars" + threeb, 1095); player.getActionSender().sendString(threeb + "3bars" + threeb, 1115); player.getActionSender().sendString(threeb + "3bars" + threeb, 1090); player.getActionSender().sendString(twob + "2bars" + twob, 1113); player.getActionSender().sendString(twob + "2bars" + twob, 1116); player.getActionSender().sendString(twob + "2bars" + twob, 1114); player.getActionSender().sendString(twob + "2bars" + twob, 1089); player.getActionSender().sendString(twob + "2bars" + twob, 8428); player.getActionSender().sendString(oneb + "1bar" + oneb, 1124); player.getActionSender().sendString(oneb + "1bar" + oneb, 1125); player.getActionSender().sendString(oneb + "1bar" + oneb, 1126); player.getActionSender().sendString(oneb + "1bar" + oneb, 1127); player.getActionSender().sendString(oneb + "1bar" + oneb, 1128); player.getActionSender().sendString(oneb + "1bar" + oneb, 1129); player.getActionSender().sendString(oneb + "1bar" + oneb, 1130); player.getActionSender().sendString(oneb + "1bar" + oneb, 1131); player.getActionSender().sendString(oneb + "1bar" + oneb, 13357); player.getActionSender().sendString(checkLevel(player, "platebody", "Plate body"), 1101); player.getActionSender().sendString(checkLevel(player, "platelegs", "Plate legs"), 1099); player.getActionSender().sendString(checkLevel(player, "plateskirt", "Plate skirt"), 1100); player.getActionSender().sendString(checkLevel(player, "2h sword", "2 hand sword"), 1088); player.getActionSender().sendString(checkLevel(player, "claws", "Claws"), 8429); player.getActionSender().sendString(checkLevel(player, "kiteshield", "Kite shield"), 1105); player.getActionSender().sendString(checkLevel(player, "chainbody", "Chain body"), 1098); player.getActionSender().sendString(checkLevel(player, "battleaxe", "Battle axe"), 1092); player.getActionSender().sendString(checkLevel(player, "warhammer", "Warhammer"), 1083); player.getActionSender().sendString(checkLevel(player, "sq shield", "Square shield"), 1104); player.getActionSender().sendString(checkLevel(player, "knife", "Throwing knives"), 1106); player.getActionSender().sendString(checkLevel(player, "full helm", "Full helm"), 1103); player.getActionSender().sendString(checkLevel(player, "longsword", "Long sword"), 1086); player.getActionSender().sendString(checkLevel(player, "scimitar", "Scimitar"), 1087); player.getActionSender().sendString(checkLevel(player, "arrowtips", "Arrowtips"), 1108); player.getActionSender().sendString(checkLevel(player, "dart tip", "Dart tips"), 1107); player.getActionSender().sendString(checkLevel(player, "nails", "Nails"), 13358); player.getActionSender().sendString(checkLevel(player, "sword", "Sword"), 1085); player.getActionSender().sendString(checkLevel(player, "med helm", "Medium helm"), 1102); player.getActionSender().sendString(checkLevel(player, "mace", "Mace"), 1093); player.getActionSender().sendString(checkLevel(player, "axe", "Axe"), 1091); player.getActionSender().sendString(checkLevel(player, "dagger", "Dagger"), 1094); player.getActionSender().sendUpdateItem(getItemType(player, "dagger"), 0, 1119, 1); player.getActionSender().sendUpdateItem(getItemType(player, "axe"), 0, 1120, 1); player.getActionSender().sendUpdateItem(getItemType(player, "chainbody"), 0, 1121, 1); player.getActionSender().sendUpdateItem(getItemType(player, "med helm"), 0, 1122, 1); player.getActionSender().sendUpdateItem(getItemType(player, "dart tip"), 0, 1123, 10); player.getActionSender().sendUpdateItem(getItemType(player, "sword"), 1, 1119, 1); player.getActionSender().sendUpdateItem(getItemType(player, "mace"), 1, 1120, 1); player.getActionSender().sendUpdateItem(getItemType(player, "platelegs"), 1, 1121, 1); player.getActionSender().sendUpdateItem(getItemType(player, "full helm"), 1, 1122, 1); player.getActionSender().sendUpdateItem(getItemType(player, "arrowtips"), 1, 1123, 15); player.getActionSender().sendUpdateItem(getItemType(player, "scimitar"), 2, 1119, 1); player.getActionSender().sendUpdateItem(getItemType(player, "warhammer"), 2, 1120, 1); player.getActionSender().sendUpdateItem(getItemType(player, "plateskirt"), 2, 1121, 1); player.getActionSender().sendUpdateItem(getItemType(player, "sq shield"), 2, 1122, 1); player.getActionSender().sendUpdateItem(getItemType(player, "knife"), 2, 1123, 5); player.getActionSender().sendUpdateItem(getItemType(player, "longsword"), 3, 1119, 1); player.getActionSender().sendUpdateItem(getItemType(player, "battleaxe"), 3, 1120, 1); player.getActionSender().sendUpdateItem(getItemType(player, "platebody"), 3, 1121, 1); player.getActionSender().sendUpdateItem(getItemType(player, "kiteshield"), 3, 1122, 1); player.getActionSender().sendUpdateItem(getItemType(player, "2h sword"), 4, 1119, 1); player.getActionSender().sendUpdateItem(getItemType(player, "claws"), 4, 1120, 1); player.getActionSender().sendUpdateItem(getItemType(player, "nails"), 4, 1122, 15); if (smithMetal[player.getSmithInterface()].equalsIgnoreCase("steel")) { player.getActionSender().sendString(oneb + "1bar" + oneb, 11459); player.getActionSender().sendString(checkLevel(player, "Steel studs", "Steel studs"), 11461); player.getActionSender().sendUpdateItem(getItemType(player, "Steel studs"), 4, 1121, 1); } else { player.getActionSender().sendString("", 11461); player.getActionSender().sendString("", 11459); player.getActionSender().sendUpdateItem(new Item(-1, 0), 4, 1121, 1); } player.getActionSender().sendString(oneb + "1bar" + oneb, 1132); player.getActionSender().sendString(checkLevel(player, "bolts (unf)", "Bolts (unf)"), 1096); player.getActionSender().sendUpdateItem(getItemType(player, "bolts (unf)"), 3, 1123, 10); player.getActionSender().sendString(oneb + "1bar" + oneb, 1135); player.getActionSender().sendString(checkLevel(player, "limbs", "Limbs"), 1134); player.getActionSender().sendUpdateItem(getItemType(player, "limbs"), 4, 1123, 1); player.getActionSender().sendInterface(994); }
public static boolean doItemOnObject(Player player, int object, int item) { switch (object) { case 3402: // elemental workshop workbench if (item == 2893 && player.getQuestStage(12) >= 10 && player.getSkill().getLevel()[Skill.SMITHING] >= 20) { if (player.getInventory().playerHasItem(2347)) { player.getInventory().removeItem(new Item(2893)); player.getInventory().addItem(new Item(2890)); if (player.getQuestStage(12) == 10) { player.setQuestStage(12, 11); QuestHandler.completeQuest(player, 12); return true; } return true; } else { player.getDialogue().sendStatement("You need a hammer to smith!"); return true; } } else if (player.getSkill().getLevel()[Skill.SMITHING] < 20) { player.getDialogue().sendStatement("You need 20 smithing to smith and elemental shield."); return true; } break; case 3413: // elemental workshop furnace if (item == 2889 && player.getQuestStage(12) == 8) { player .getDialogue() .sendStatement("The furnace flares dramatically as you pour the lava in."); player.getInventory().replaceItemWithItem(new Item(2889), new Item(2888)); player.setQuestStage(12, 9); return true; } else if (item == 2892 && player.getQuestStage(12) >= 9) { if (player.getInventory().playerHasItem(453, 4)) { player.getInventory().removeItem(new Item(2892)); player.getInventory().removeItem(new Item(453, 4)); player.getInventory().addItem(new Item(2893)); player.getActionSender().sendMessage("You smelt the elemental ore in the furnace."); player.getActionSender().sendMessage("You retrieve elemental metal from the furnace."); player.getUpdateFlags().sendAnimation(899); player.getActionSender().sendSound(469, 0, 0); if (player.getQuestStage(12) == 9) { player.setQuestStage(12, 10); } return true; } else { player.getDialogue().sendStatement("You need 4 coal to smelt Elemental Ore."); return true; } } else if (player.getQuestStage(12) >= 7) { if (item == GlassMaking.BUCKET_OF_SAND) GlassMaking.makeMoltenGlass(player); else if (item == GemCrafting.GOLD_BAR) GemCrafting.openInterface(player); else if (item == SilverCrafting.SILVER_BAR) Menus.sendSkillMenu(player, "silverCrafting"); else if (ItemManager.getInstance().getItemName(item).toLowerCase().endsWith("ore") && item != 668) Smelting.smeltInterface(player); else if (item == 668) Dialogues.startDialogue(player, 10200); return true; } break; case 3414: // elemental workshop lava trough if (item == 2888 && player.getQuestStage(12) == 8) { player.getDialogue().sendStatement("You carefully fill the bowl with lava."); player.getInventory().replaceItemWithItem(new Item(2888), new Item(2889)); return true; } break; } return false; }
public static boolean doObjectClicking(Player player, int object, int x, int y) { switch (object) { case 3389: // elemental workshop bookshelf if (x == 2716 && y == 3481 && !player.getInventory().ownsItem(2886)) { if (player.getQuestStage(12) < 1) { player.setQuestStage(12, 1); QuestHandler.getQuests()[12].startQuest(player); } player.getDialogue().sendStatement("You find an old, beaten book."); player.getInventory().addItem(new Item(2886)); return true; } break; case 3390: case 3391: // elemental workshop wall if (player.getInventory().playerHasItem(2887)) { player.fadeTeleport(new Position(2716, 9888)); if (player.getQuestStage(12) == 2) player.setQuestStage(12, 3); return true; } break; case 3397: // elemental workshop boxes if (player.getQuestStage(12) == 5 && !player.getInventory().playerHasItem(1741)) { player .getDialogue() .sendStatement("You find some leather after rummaging through the boxes."); player.getInventory().addItem(new Item(1741)); return true; } break; case 3409: // elemental workshop bellows lever if (player.getQuestStage(12) == 6) { player .getDialogue() .sendStatement("You hear the whoosh of air as the bellows come to life."); // player.getActionSender().animateObject(2734, 9882, 0, 469); player.setQuestStage(12, 7); return true; } break; case 3398: // elemental workshop crate for stone bowl if (player.getQuestStage(12) == 7 && !player.getInventory().playerHasItem(2888)) { player.getDialogue().sendStatement("You find an empty stone bowl."); player.getInventory().addItem(new Item(2888)); player.setQuestStage(12, 8); return true; } break; case 3410: // elemental workshop bellows if (player.getQuestStage(12) == 5) { if (player.getSkill().getLevel()[Skill.CRAFTING] < 20) { player .getDialogue() .sendStatement("You need a Crafting level of 20 to fix the bellows."); return true; } else if (player.getInventory().playerHasItem(1733) && player.getInventory().playerHasItem(1734) && player.getInventory().playerHasItem(1741)) { player.getInventory().removeItem(new Item(1734)); player.getInventory().removeItem(new Item(1741)); player .getDialogue() .sendStatement( "You patch up the bellows.", "You should be able to pull the lever now."); player.setQuestStage(12, 6); return true; } else { player .getDialogue() .sendStatement( "The hole looks rather large.", "You will need needle, thread, and a piece of regular leather."); return true; } } break; case 3404: case 3405: // elemental workshop water valve if (x == 2726 && y == 9908 && player.getQuestStage(12) == 3) { player.getDialogue().sendStatement("You turned the valve on. You hear water flowing."); return true; } else if (x == 2713 && y == 9908 && player.getQuestStage(12) == 3) { player .getDialogue() .sendStatement("You turned the valve on. You hear lots of water flowing."); player.setQuestStage(12, 4); return true; } break; case 3406: // elemental workshop water wheel if (player.getQuestStage(12) == 4) { player.getDialogue().sendStatement("You hear a lurch and a squeel as the wheel turns."); player.getActionSender().animateObject(2719, 9907, 0, 472); player.setQuestStage(12, 5); return true; } else { player.getDialogue().sendStatement("The lever won't budge without flowing water."); return true; } } return false; }
public static boolean perform(final Player player, int itemUsed, int usedWith) { final ArrowData arrowData = ArrowData.forId(itemUsed, usedWith); if (arrowData == null) return false; if (!Constants.FLETCHING_ENABLED) { player.getActionSender().sendMessage("This skill is currently disabled."); return false; } if (player.getSkill().getLevel()[Skill.FLETCHING] < arrowData.getLevel()) { player .getDialogue() .sendStatement("You need a fletching level of " + arrowData.getLevel() + " to do this"); return true; } if (!player.getInventory().getItemContainer().contains(arrowData.getItem1()) || !player.getInventory().getItemContainer().contains(arrowData.getItem2())) { player .getDialogue() .sendStatement( "You need " + ARROW_COUNT + " " + new Item(arrowData.getItem1()).getDefinition().getName().toLowerCase() + " and " + ARROW_COUNT + " " + new Item(arrowData.getItem2()).getDefinition().getName().toLowerCase() + "s to make this"); return true; } int factor = 1; if (player.getStatedInterface().contains("brutal")) { if (!player.getInventory().getItemContainer().contains(2347)) { player.getDialogue().sendStatement("You need a hammer to make brutal arrows"); return true; } factor = 4; } if (player.getInventory().getItemContainer().freeSlots() < 1 && !player.getInventory().playerHasItem(arrowData.getFinalItem())) { player.getActionSender().sendMessage("Not enough space in your inventory."); return true; } final int multiplier = factor; final int task = player.getTask(); int count1 = player.getInventory().getItemContainer().getCount(arrowData.getItem1()) < ARROW_COUNT ? player.getInventory().getItemContainer().getCount(arrowData.getItem1()) : ARROW_COUNT; int count2 = player.getInventory().getItemContainer().getCount(arrowData.getItem2()) < ARROW_COUNT ? player.getInventory().getItemContainer().getCount(arrowData.getItem2()) : ARROW_COUNT; final int count = count1 < count2 ? count1 : count2; player.setSkilling( new CycleEvent() { @Override public void execute(CycleEventContainer container) { if (!player.checkTask(task) || !player.getInventory().playerHasItem(new Item(arrowData.getItem1(), count)) || !player.getInventory().playerHasItem(new Item(arrowData.getItem2(), count))) { container.stop(); return; } player .getActionSender() .sendMessage( "You attach the " + new Item(arrowData.getItem1()).getDefinition().getName().toLowerCase() + " to " + count / multiplier + " " + new Item(arrowData.getItem2()).getDefinition().getName().toLowerCase() + "s."); player.getInventory().removeItem(new Item(arrowData.getItem1(), count)); player.getInventory().removeItem(new Item(arrowData.getItem2(), count)); player.getInventory().addItem(new Item(arrowData.getFinalItem(), count / multiplier)); player .getSkill() .addExp(Skill.FLETCHING, count / multiplier * (arrowData.getExperience())); container.stop(); } @Override public void stop() { player.resetAnimation(); } }); CycleEventHandler.getInstance().addEvent(player, player.getSkilling(), 1); return true; }
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."); }
private void handleDropItem(Player player, Packet packet) { int itemId = packet.getIn().readShort(StreamBuffer.ValueType.A); packet.getIn().readShort(); player.setSlot(packet.getIn().readShort(StreamBuffer.ValueType.A)); Item item = player.getInventory().getItemContainer().get(player.getSlot()); if (Puzzle.moveSlidingPiece(player, itemId)) return; if (item == null || item.getId() != itemId || !item.validItem()) return; if (item.getDefinition().isStackable()) { item.setCount(player.getInventory().getItemContainer().getCount(item.getId())); } else { item.setCount(1); } if (!player.getInventory().getItemContainer().contains(item.getId())) { return; } if (item.getId() == 530 && player.getPosition().getX() == 2780 && player.getPosition().getY() == 3515) { if (player.getInventory().playerHasItem(32)) { player.getInventory().removeItem(new Item(530)); MerlinsCrystal.summon(player); return; } else { player .getDialogue() .sendStatement("Nothing happens. Perhaps you should light the candle first."); return; } } if (WarriorsGuild.itemHandling(player, itemId)) { return; } if (item.getId() == 10592) { player.getActionSender().sendMessage("Play the bongos instead."); return; } if (item.getId() == 6541) { player.getActionSender().sendMessage("You don't want to destroy your pet!"); return; } for (int[] element : Pets.PET_IDS) { if (item.getDefinition().getId() == element[0]) { player.getPets().registerPet(element[0], element[1]); return; } } if (item.getDefinition().isUntradable() || item.getId() == 763 || item.getId() == 765 || item.getId() == 769 || item.getId() == 288 || item.getId() == 10498 || item.getId() == 10499) { if (BarrowsItems.notDroppable(BarrowsItems.getBarrowsItem(item), item)) { String[][] info = { {"Are you sure you want to drop this item?", "14174"}, {"Yes.", "14175"}, {"No.", "14176"}, {"", "14177"}, {"Dropping this item will make it break completely.", "14182"}, {"", "14183"}, {item.getDefinition().getName(), "14184"} }; for (String[] element : info) { player.getActionSender().sendString(element[0], Integer.parseInt(element[1])); } } else { String[][] info = { {"Are you sure you want to drop this item?", "14174"}, {"Yes.", "14175"}, {"No.", "14176"}, {"", "14177"}, {"Dropping this item will make you lose it forever.", "14182"}, {"", "14183"}, {item.getDefinition().getName(), "14184"} }; for (String[] element : info) { player.getActionSender().sendString(element[0], Integer.parseInt(element[1])); } } player.getActionSender().sendUpdateItem(item, 0, 14171, 1); player.setDestroyItem(item); player.getActionSender().sendChatInterface(14170); return; } if (player.getInventory().getItemContainer().contains(item.getId())) { player.getActionSender().sendSound(376, 1, 0); if (!Constants.ADMINS_CAN_INTERACT && player.getStaffRights() >= 2) { player .getActionSender() .sendMessage("Your item disappears because you're an administrator."); } else { GroundItemManager.getManager() .dropItem(new GroundItem(new Item(item.getId(), item.getCount()), player)); } if (!player.getInventory().removeItemSlot(item, player.getSlot())) { player.getInventory().removeItem(item); } player.getActionSender().removeInterfaces(); player.getDialogue().resetDialogue(); } player.getEquipment().updateWeight(); }
public static void startSmithingBlurite(final Player player, final int item, final int amount) { final int id = 0; if (id > -1) { final Item finalItem = new Item(item); if (!player.getInventory().getItemContainer().contains(2347)) { player.getActionSender().sendMessage("You need a hammer to smith on an anvil."); return; } final Item bar = new Item(9467, 1); if (player.getNewComersSide().isInTutorialIslandStage()) { // TutorialIsland.sendStartInfo(player); } else { player.getActionSender().removeInterfaces(); } final int task = player.getTask(); player.getUpdateFlags().sendAnimation(898); player.getActionSender().sendSound(468, 0, 0); player.setSkilling( new CycleEvent() { int amounts = amount; @Override public void execute(CycleEventContainer container) { if (!player.checkTask(task)) { container.stop(); return; } if (!player.getInventory().playerHasItem(bar)) { player.getActionSender().sendMessage("You have run out of bars!"); container.stop(); return; } player.getInventory().removeItem(bar); if (item == 9376) { player.getInventory().addItem(new Item(item, 10)); } else { player.getInventory().addItem(new Item(item, 1)); } player.getSkill().addExp(Skill.SMITHING, 5); if (player.getNewComersSide().isInTutorialIslandStage()) { if (player.getNewComersSide().getTutorialIslandStage() == 36) player .getNewComersSide() .setTutorialIslandStage( player.getNewComersSide().getTutorialIslandStage() + 1, true); player.setClickId(0); player .getDialogue() .sendStatement( "You hammer the " + bar.getDefinition().getName().toLowerCase() + " and make " + finalItem.getDefinition().getName().toLowerCase() + "."); } else { player .getActionSender() .sendMessage( "You hammer the " + bar.getDefinition().getName().toLowerCase() + " and make " + finalItem.getDefinition().getName().toLowerCase() + "."); } amounts--; if (amounts < 1) { container.stop(); return; } if (!player.getInventory().playerHasItem(bar)) { player.getActionSender().sendMessage("You have run out of bars!"); container.stop(); return; } player.getUpdateFlags().sendAnimation(898); player.getActionSender().sendSound(468, 0, 0); } @Override public void stop() { player.getTask(); player.resetAnimation(); } }); CycleEventHandler.getInstance().addEvent(player, player.getSkilling(), 4); } }
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; } }