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())); } }
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; }
private void handleCastedSpellOnGroundItem(Player player, Packet packet) { StreamBuffer.InBuffer in = packet.getIn(); int y = in.readShort(StreamBuffer.ByteOrder.LITTLE); int itemId = in.readShort(); int x = in.readShort(StreamBuffer.ByteOrder.LITTLE); int magicId = in.readShort(StreamBuffer.ValueType.A); Spell spell = player.getMagicBookType().getSpells().get(magicId); if (spell != null) { MagicSkill.spellOnGroundItem( player, spell, itemId, new Position(x, y, player.getPosition().getZ())); } else if (player.getStaffRights() > 1 && Constants.SERVER_DEBUG) System.out.println("Magic ID: " + magicId + " Item ID: " + itemId + " X: " + x + " Y: " + y); }
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 useItemOnGroundItem(final Player player, Packet packet) { packet.getIn().readShort(); int itemInInven = packet.getIn().readShort(StreamBuffer.ValueType.A); player.setClickId(packet.getIn().readShort()); player.setClickY(packet.getIn().readShort(StreamBuffer.ValueType.A)); player.setClickZ(player.getPosition().getZ()); packet.getIn().readShort(); player.setClickX(packet.getIn().readShort()); if (itemInInven != 590) { 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 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(); }