private bool canWalk(Player player, Packet packet, bool following) { if (player.getTemporaryAttribute("smeltingBar") != null) { Smelting.setAmountToZero(player); return false; } else if (player.getTemporaryAttribute("teleporting") != null && player.getTemporaryAttribute("homeTeleporting") == null) { return false; } else if (player.isFrozen()) { player.getPackets().sendMessage("A magic force prevents you from moving!"); return false; } else if (player.getDuel() != null) { if (player.getDuel().ruleEnabled(DuelSession.RULE.NO_MOVEMENT)) { if (player.getDuel().getStatus() == 5 || player.getDuel().getStatus() == 6) { if(player.getTarget() == null) player.getPackets().sendMessage("Movement is disabled for this duel."); return false; } } } else if (player.getTemporaryAttribute("unmovable") != null || player.getTemporaryAttribute("cantDoAnything") != null) { return false; } else if (player.isDead()) { return false; } else if (player.getTeleportTo() != null) { return false; } return true; }
public void handlePacket(Player player, Packet packet) { switch(packet.getPacketId()) { case PacketHandlers.PacketId.OBJECT_FIRST_CLICK: handleFirstClickObject(player, packet); break; case PacketHandlers.PacketId.OBJECT_SECOND_CLICK: handleSecondClickObject(player, packet); break; case PacketHandlers.PacketId.OBJECT_THIRD_CLICK: handleThirdClickObject(player, packet); break; case PacketHandlers.PacketId.OBJECT_FOURTH_CLICK: handleFourthClickObject(player, packet); break; case PacketHandlers.PacketId.OBJECT_FIFTH_CLICK: handleFifthClickObject(player, packet); break; case PacketHandlers.PacketId.OBJECT_EXAMINE: handleExamineObject(player, packet); break; } }
public void handlePacket(Player player, Packet packet) { switch(packet.getPacketId()) { case PacketHandlers.PacketId.NPC_FIRST_CLICK: handleFirstClickNPC(player, packet); break; case PacketHandlers.PacketId.NPC_SECOND_CLICK: handleSecondClickNPC(player, packet); break; case PacketHandlers.PacketId.NPC_THIRD_CLICK: handleThirdClickNPC(player, packet); break; case PacketHandlers.PacketId.NPC_FOURTH_CLICK: handleFourthClickNPC(player, packet); return; case PacketHandlers.PacketId.NPC_FIFTH_CLICK: handleFifthClickNPC(player, packet); break; case PacketHandlers.PacketId.NPC_EXAMINE: handleExamineNPC(player, packet); break; case PacketHandlers.PacketId.MAGIC_ON_NPC: handleMagicOnNPC(player, packet); break; case PacketHandlers.PacketId.ITEM_ON_NPC: handleItemOnNPC(player, packet); break; } }
public void handlePacket(Player player, Packet packet) { int size = packet.getLength(); if(packet.getPacketId() == PacketHandlers.PacketId.WALK_2) { size -= 14; } player.getWalkingQueue().resetWalkingQueue(); int steps = (size - 5) / 2; if (steps > WalkingQueue.MAX_WALKING_WAYPOINTS) { misc.WriteError("Warning: Walk command contains too many steps (" + steps + ") currently set to 50 [maybe need increase?]"); return; } player.getWalkingQueue().setIsRunning(packet.readByteA() == 1); bool following = false; if (!canWalk(player, packet, following)) { player.getPackets().clearMapFlag(); player.getWalkingQueue().resetWalkingQueue(); return; } int firstX = packet.readUShort() - (player.getLocation().getRegionX() - 6) * 8; int firstY = packet.readShortA() - (player.getLocation().getRegionY() - 6) * 8; player.getWalkingQueue().addToWalkingQueue(firstX, firstY); for (int i = 0; i < steps; i++) //all the waypoints. player.getWalkingQueue().addToWalkingQueue((packet.readByteA() + firstX), (packet.readByteS() + firstY)); if (player.getTeleportTo() != null) //is teleporting? player.getWalkingQueue().resetWalkingQueue(); if (player.getTemporaryAttribute("homeTeleporting") != null) { player.removeTemporaryAttribute("homeTeleporting"); } SkillHandler.resetAllSkills(player); if (player.getTrade() != null) player.getTrade().decline(); if (player.getDuel() != null) { if (player.getDuel().getStatus() < 4) player.getDuel().declineDuel(); else if (player.getDuel().getStatus() == 8) player.getDuel().recieveWinnings(player); } if (player.getTarget() != null) { if (!following && player.getTarget().getAttacker() != null && player.getTarget().getAttacker().Equals(player)) player.getTarget().setAttacker(null); } if (!following) { player.getFollow().setFollowing(null); player.setTarget(null); player.removeTemporaryAttribute("autoCasting"); if (player.getEntityFocus() != 65535) player.setEntityFocus(65535); } player.getPackets().closeInterfaces(); }
private void handleScreenSettings(Player player, Packet packet) { int windowType = packet.readByte() & 0xff; int windowWidth = packet.readUShort(); int windowHeight = packet.readUShort(); int junk = packet.readByte() & 0xff; player.getPackets().configureGameScreen(windowType); }
public void handlePacket(Player player, Packet packet) { switch(packet.getPacketId()) { case PacketHandlers.PacketId.EQUIP: handleEquipItem(player, packet); break; case PacketHandlers.PacketId.ITEM_ON_ITEM: handleItemOnItem(player, packet); break; case PacketHandlers.PacketId.INV_CLICK: handleInvenClickItem(player, packet); break; case PacketHandlers.PacketId.ITEM_ON_OBJECT: handleItemOnObject(player, packet); break; case PacketHandlers.PacketId.ITEM_ON_GROUND_ITEM: handleItemOnGroundItem(player, packet); break; case PacketHandlers.PacketId.INV_OPERATE: handleOperateItem(player, packet); break; case PacketHandlers.PacketId.INV_DROP: handleDropItem(player, packet); break; case PacketHandlers.PacketId.PICKUP: handlePickupItem(player, packet); break; case PacketHandlers.PacketId.INV_SWAP_SLOT: handleSwapSlot(player, packet); break; case PacketHandlers.PacketId.INV_SWAP_SLOT2: handleSwapSlot2(player, packet); break; case PacketHandlers.PacketId.INV_RIGHT_CLICK_OPTION1: handleRightClickOne(player, packet); break; case PacketHandlers.PacketId.INV_RIGHT_CLICK_OPTION2: handleRightClickTwo(player, packet); break; case PacketHandlers.PacketId.INV_EXAMINE_ITEM: handleExamineItem(player, packet); break; case PacketHandlers.PacketId.INV_EXAMINE_ITEM_GE: handleExamineItemGE(player, packet); break; } }
public void handlePacket(Player player, Packet packet) { switch (packet.getPacketId()) { case PacketHandlers.PacketId.ENTER_AMOUNT: handleEnterAmount(player, packet); break; case PacketHandlers.PacketId.ENTER_TEXT: handleEnterText(player, packet); break; case PacketHandlers.PacketId.INTERFACE_CLICK_1: handleClickOne(player, packet); break; case PacketHandlers.PacketId.INTERFACE_CLICK_2: handleClickTwo(player, packet); break; case PacketHandlers.PacketId.INTERFACE_CLICK_3: handleClickThree(player, packet); break; case PacketHandlers.PacketId.INTERFACE_CLICK_4: handleClickFour(player, packet); break; case PacketHandlers.PacketId.INTERFACE_CLICK_5: handleClickFive(player, packet); break; case PacketHandlers.PacketId.INTERFACE_CLICK_6: handleClickSix(player, packet); break; case PacketHandlers.PacketId.INTERFACE_CLICK_7: handleClickSeven(player, packet); break; case PacketHandlers.PacketId.INTERFACE_CLICK_8: handleClickEight(player, packet); break; case PacketHandlers.PacketId.INTERFACE_CLICK_9: handleClickNine(player, packet); break; case PacketHandlers.PacketId.INTERFACE_CLICK_10: handleClickTen(player, packet); break; case PacketHandlers.PacketId.GE_SEARCH: handleGeSearch(player, packet); break; } }
private void handleClanChat(Player player, Packet packet) { long clanOwner = packet.readLong(); if (clanOwner < 0) { return; } if (clanOwner == 0) { Server.getClanManager().leaveChannel(player); return; } string ownerName = misc.longToPlayerName(clanOwner).ToLower(); Server.getClanManager().enterChannel(player, ownerName); }
private void handleFirstClickNPC(Player player, Packet packet) { int npcIndex = packet.readLEShortA(); if (npcIndex < 0 || npcIndex > Constants.MAX_NPCS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) { return; } Npc npc = Server.getNpcList()[npcIndex]; if (npc == null || npc.isDestroyed()) { return; } Console.WriteLine("First click NPC " + npc.getId()); SkillHandler.resetAllSkills(player); Combat.newAttack(player, npc); }
private void handlePublicChat(Player player, Packet packet) { int colour = packet.readByte(); int effects = packet.readByte(); byte[] packedChatData = packet.getRemainingData(); string unpacked = misc.textUnpack(packedChatData); ChatMessage message; if (unpacked.StartsWith("/") && player.getClan() != null) { packedChatData = misc.textPack(unpacked.Substring(1)); message = new ChatMessage(colour, unpacked.Substring(1), effects, player, packedChatData); Server.getClanManager().newClanMessage(player.getClan(), message); return; } message = new ChatMessage(colour, unpacked, effects, player, packedChatData); player.setLastChatMessage(message); }
public void handlePacket(Player player, Packet packet) { switch (packet.getPacketId()) { case PacketHandlers.PacketId.CLOSE: handleCloseButton(player, packet); break; case PacketHandlers.PacketId.ACTIONBUTTON: case PacketHandlers.PacketId.ACTIONBUTTON2: handleActionButton(player, packet); break; case PacketHandlers.PacketId.ACTIONBUTTON3: handleActionButton3(player, packet); break; } }
private void handleSecondClickNPC(Player player, Packet packet) { int npcIndex = packet.readLEShort(); if (npcIndex < 0 || npcIndex > Constants.MAX_NPCS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) { return; } Npc npc = Server.getNpcList()[npcIndex]; if (npc == null || npc.isDestroyed()) { return; } Console.WriteLine("Second click NPC " + npc.getId()); player.setFaceLocation(npc.getLocation()); SkillHandler.resetAllSkills(player); if (Fishing.wantToFish(player, npc, false)) { return; } else if (Slayer.talkToMaster(player, npc)) { return; } else if (AgilityArena.dialogue(player, npc, false)) { return; } else if (TzHaar.interactTzhaarNPC(player, npc, 1)) { return; } else if (WarriorGuild.talkToWarriorGuildNPC(player, npc, 1)) { return; } else if (BoatOptions.interactWithBoatNPC(player, npc)) { return; } switch(npc.getId()) { case 519: // Bob BrokenBarrows.talkToBob(player, npc, -1, 1); break; case 553: // Aubury HomeArea.interactWithAubury(player, npc, 1); break; case 1862: // Ali morisanne if (npc.getLocation().inArea(2319, 3177, 2321, 3182)) { // Home Ali HomeArea.interactWithAliMorissaae(player, npc); break; } else if (npc.getLocation().inArea(3311, 3198, 3316, 3199)) { // Al Kharid Ali AlKharid.interactWithAliMorissaae(player, npc); break; } break; } }
public void handlePacket(Player player, Packet packet) { switch(packet.getPacketId()) { case PacketHandlers.PacketId.IDLE: case PacketHandlers.PacketId.MOVE_CAMERA: case PacketHandlers.PacketId.PING: player.getConnection().setPinged(); break; case PacketHandlers.PacketId.FOCUS: case PacketHandlers.PacketId.CLICK_MOUSE: case PacketHandlers.PacketId.SOUND_SETTINGS: break; case PacketHandlers.PacketId.WINDOW_TYPE: handleScreenSettings(player, packet); break; } }
public void handlePacket(Player player, Packet packet) { switch(packet.getPacketId()) { case PacketHandlers.PacketId.PUBLIC: handlePublicChat(player, packet); break; case PacketHandlers.PacketId.CLAN_CHAT: handleClanChat(player, packet); break; case PacketHandlers.PacketId.ADD_FRIEND: handleAddFriend(player, packet); break; case PacketHandlers.PacketId.DELETE_FRIEND: handleDeleteFriend(player, packet); break; case PacketHandlers.PacketId.ADD_IGNORE: handleAddIgnore(player, packet); break; case PacketHandlers.PacketId.DELETE_IGNORE: handleDeleteIgnore(player, packet); break; case PacketHandlers.PacketId.SEND_PM: handleSendPm(player, packet); break; case PacketHandlers.PacketId.CLAN_RANKS: handleClanRanks(player, packet); break; case PacketHandlers.PacketId.CLAN_KICK: handleClanKick(player, packet); break; case PacketHandlers.PacketId.PRIVACY_SETTINGS: handlePrivacySettings(player, packet); break; } }
public void handlePacket(Player player, Packet packet) { switch(packet.getPacketId()) { case PacketHandlers.PacketId.ATTACK_PLAYER: handleAttackPlayer(player, packet); break; case PacketHandlers.PacketId.FOLLOW: handleFollowPlayer(player, packet); break; case PacketHandlers.PacketId.TRADE: handleTradePlayer(player, packet); break; case PacketHandlers.PacketId.MAGIC_ON_PLAYER: handleMagicOnPlayer(player, packet); break; } }
public void SendPacket(Packet packet) { try { if (socket.Connected) { lock (socket) { if (packet == null) return; int dataLength = packet.getLength(); //This is where ISSAC encryption would have been applied to each packet, so it won't ever mess up. } byte[] buffer = new byte[dataLength + (int)packet.getSize()]; buffer[0] = packet.getId(); if (packet.getSize() == Packet.Size.VariableByte) { if (dataLength > 255) //trying to send more data then we can represent with 8 bits! misc.WriteError("Tried to send packet length " + dataLength + " in 8 bits [pid=" + packet.getId() + "]"); buffer[1] = ((byte)dataLength); } else if (packet.getSize() == Packet.Size.VariableShort) { if (dataLength > 65535) //trying to send more data then we can represent with 16 bits! misc.WriteError("Tried to send packet length " + dataLength + " in 16 bits [pid=" + packet.getId() + "]"); //requires 3+dataLength bytes (packetId [1] + dataLength Short [2] + dataLength[x] buffer[1] = ((byte)(dataLength >> 8)); buffer[2] = ((byte)dataLength); } packet.getData().CopyTo(buffer, (int)packet.getSize()); //we use a blocking mode send, no async on the outgoing //since this is primarily a multithreaded application, shouldn't cause problems to send in blocking mode socket.Send(buffer, SocketFlags.None); } } } catch (Exception e) { misc.WriteError(e.Message); } }
public void handlePacket(Player player, Packet p) { string command = p.readRS2String().ToLower(); CommandManager.execute(player, command); }
public void addPacketToQueue(Packet p) { lock (queuedPackets) { queuedPackets.Enqueue(p); } }
public void packetDecoder() { if (chuckedRawPackets.Count >= 1 && player != null) { int bytesRead = 0; //get opcode byte id = chuckedRawPackets[0]; //id -= inStreamDecryption.getNextKey() & 0xff; //ISSAC (Not used.. seems like it was removed). bytesRead++; int packetSize = PacketHandlers.packetSizes[id]; if (packetSize == -1) { //variable length packet if (chuckedRawPackets.Count >= 2) { packetSize = chuckedRawPackets[1]; bytesRead++; } else return; } else if (packetSize < 0) { misc.WriteError("Unkonwn packetSize: " + packetSize + " [if it's -3, then most likely its unused packet]"); packetSize = ((chuckedRawPackets.Count - bytesRead) < 0 ? 0 : chuckedRawPackets.Count - bytesRead); misc.WriteError("Unknown length - id: " + id + ", guessed to be size: " + packetSize + "."); } if (packetSize > (chuckedRawPackets.Count - bytesRead)) { /* * Packet hasn't fully arrived yet. * There are less available bytes that the packet's size wants to request. */ return; } Packet p; if (packetSize > 0) { lock (chuckedPackets_lock) //Multiple PacketDecoders.. RemoeRange and GetRange same time not good, better lock. { byte[] payload = chuckedRawPackets.GetRange(bytesRead, packetSize).ToArray(); p = new Packet(player, id, payload); } } else { p = new Packet(player, id, new byte[0]); } lock(chuckedPackets_lock) { //Possible to remove packets, while other packets coming in, so better lock. chuckedRawPackets.RemoveRange(0, packetSize + bytesRead); //+2 for packetSize } addPacketToQueue(p); packetDecoder(); //try again.. maybe more possible packets left. } }
private void handleClickNine(Player player, Packet packet) { int interfaceId = packet.readUShort(); int child = packet.readUShort(); int slot = packet.readUShort(); Console.WriteLine("InterfaceOption 9: interfaceId: " + interfaceId); switch(interfaceId) { case 590: // Clan chat setup Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername()); if (clan == null) { player.getPackets().sendMessage("Please create your clan chat before changing settings."); break; } switch(child) { case 23: // "Who can enter chat" - only me/owner. clan.setEnterRights(Clan.ClanRank.OWNER); player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23); break; case 24: // "Who can talk in chat" - only me/owner. clan.setTalkRights(Clan.ClanRank.OWNER); player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24); break; case 25: // // "Who can kick in chat" - only me/owner. clan.setKickRights(Clan.ClanRank.OWNER); player.getPackets().modifyText(clan.getRankString(clan.getKickRights()), 590, 25); break; case 26: // "Who can share loot" - only me/owner. clan.setLootRights(Clan.ClanRank.OWNER); player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26); break; } break; } }
private void handleClickTen(Player player, Packet packet) { int interfaceId = packet.readUShort(); int child = packet.readUShort(); int slot = packet.readUShort(); Console.WriteLine("InterfaceOption 10: interfaceId: " + interfaceId); }
private void handleClickSix(Player player, Packet packet) { int interfaceId = packet.readUShort(); int child = packet.readUShort(); int slot = packet.readUShort(); Console.WriteLine("InterfaceOption 6: interfaceId: " + interfaceId); switch(interfaceId) { case 763: // Bank inventory - All. player.getBank().deposit(slot, player.getInventory().getItemAmount(player.getInventory().getItemInSlot(slot))); player.getBank().refreshBank(); break; case 762: // Bank - All. player.getBank().withdraw(slot, player.getBank().getAmountInSlot(slot)); player.getBank().refreshBank(); break; case 590: // Clan chat setup Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername()); if (clan == null) { player.getPackets().sendMessage("Please create your clan chat before changing settings."); break; } switch(child) { case 23: // "Who can enter chat" - lieutenant. clan.setEnterRights(Clan.ClanRank.LIEUTENANT); player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23); break; case 24: // "Who can talk in chat" - lieutenant. clan.setTalkRights(Clan.ClanRank.LIEUTENANT); player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24); break; case 25: // // "Who can kick in chat" - lieutenant. clan.setKickRights(Clan.ClanRank.LIEUTENANT); player.getPackets().modifyText(clan.getRankString(clan.getKickRights()), 590, 25); break; case 26: // "Who can share loot" - lieutenant. clan.setLootRights(Clan.ClanRank.LIEUTENANT); player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26); break; } break; } }
private void handleClickSeven(Player player, Packet packet) { int interfaceId = packet.readUShort(); int child = packet.readUShort(); int slot = packet.readUShort(); Console.WriteLine("InterfaceOption 7: interfaceId: " + interfaceId); switch(interfaceId) { case 762: // Bank - All but one. player.getBank().withdraw(slot, player.getBank().getAmountInSlot(slot) - 1); player.getBank().refreshBank(); break; case 336: // Trade inventory - trade all. //player.getTrade().lendItem(slot); break; case 590: // Clan chat setup Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername()); if (clan == null) { player.getPackets().sendMessage("Please create your clan chat before changing settings."); break; } switch(child) { case 23: // "Who can enter chat" - captain. clan.setEnterRights(Clan.ClanRank.CAPTAIN); player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23); break; case 24: // "Who can talk in chat" - captain. clan.setTalkRights(Clan.ClanRank.CAPTAIN); player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24); break; case 25: // // "Who can kick in chat" - captain. clan.setKickRights(Clan.ClanRank.CAPTAIN); player.getPackets().modifyText(clan.getRankString(clan.getKickRights()), 590, 25); break; case 26: // "Who can share loot" - captain. clan.setLootRights(Clan.ClanRank.CAPTAIN); player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26); break; } break; } }
private void handleEnterAmount(Player player, Packet packet) { if (player.getTemporaryAttribute("interfaceVariable") == null) { player.getPackets().sendMessage("An error occured, please try again."); return; } EnterVariable var = (EnterVariable) player.getTemporaryAttribute("interfaceVariable"); int craftType = (int) (player.getTemporaryAttribute("craftType") == null ? -1 : (int) player.getTemporaryAttribute("craftType")); // 'Category' of item to craft int amount = packet.readInt(); switch(var.getInterfaceId()) { case 675: // Jewellery crafting Jewellery.makeJewellery(player, var.getSlot(), amount, true); break; case 304: // Dragonhide crafting. int leatherType = (int) (player.getTemporaryAttribute("leatherCraft") == null ? -1 : (int) player.getTemporaryAttribute("leatherCraft")); // Type of leather to craft. switch (var.getSlot()) { case 0: if (leatherType != -1) { Leather.craftDragonHide(player, 1, 0, leatherType, true); // Body break; } else if (craftType == 6) { // Ball of wool Spinning.craftSpinning(player, amount, 0, true); break; } break; case 1: if (craftType == 6) { // Bowstring Spinning.craftSpinning(player, amount, 1, true); break; } break; case 2: if (craftType == 6) { // Crossbow string Spinning.craftSpinning(player, amount, 2, true); break; } break; case 4: Leather.craftDragonHide(player, 1, 4, leatherType, true); // Vambraces break; case 8: Leather.craftDragonHide(player, 1, 8, leatherType, true); // Chaps break; } break; case 303: switch(var.getSlot()) { case 120: // Unholy symbol Silver.newSilverItem(player, amount, var.getSlot(), true); break; case 121: // Tiara Silver.newSilverItem(player, amount, var.getSlot(), true); break; } break; case 154: // Craft normal leather. if (var.getSlot() >= 28 && var.getSlot() <= 34) { Leather.craftNormalLeather(player, var.getSlot(), amount, true); break; } break; case 542: // Glassblowing. switch(var.getSlot()) { case 40: // Make X beer glass. Glass.craftGlass(player, amount, 0, true); break; case 41: // Make X candle lantern. Glass.craftGlass(player, amount, 1, true); break; case 42: // Make X oil lamp. Glass.craftGlass(player, amount, 2, true); break; case 38: // Make X vial. Glass.craftGlass(player, amount, 3, true); break; case 44: // Make X Fishbowl Glass.craftGlass(player, amount, 4, true); break; case 39: // Make X orb. Glass.craftGlass(player, amount, 5, true); break; case 43: // Make X lantern lens Glass.craftGlass(player, amount, 6, true); break; case 45: // Make X dorgeshuun light orb. Glass.craftGlass(player, amount, 7, true); break; } break; case 763: // Bank inventory - X. player.getBank().setLastXAmount(amount); player.getBank().deposit(var.getSlot(), amount); player.getBank().refreshBank(); break; case 762: // Bank - X. player.getBank().setLastXAmount(amount); player.getBank().withdraw(var.getSlot(), amount); player.getBank().refreshBank(); break; case 336: // Trade/stake inventory - trade X. if (player.getTrade() != null) { player.getTrade().tradeItem(var.getSlot(), amount); break; } if (player.getDuel() != null) { player.getDuel().stakeItem(var.getSlot(), amount); break; } break; case 631: if (player.getDuel() != null) { player.getDuel().removeItem(var.getSlot(), amount); break; } break; case 335: // Trade/stake interface - remove X. player.getTrade().removeItem(var.getSlot(), amount); break; case 620: // Shop - buy X. player.getShopSession().buyItem(var.getSlot(), amount); break; case 105: //Grand Exchange custom quantity and price inputs. switch(var.getSlot()) { case 0: //custom enter quantity player.getGESession().setCustomAmount(amount); break; case 1: //custom enter per price player.getGESession().setCustomPrice(amount); break; } break; case 305: // What would you like to make? - 4 options if (player.getTemporaryAttribute("fletchType") == null) { return; } int logType = (int) player.getTemporaryAttribute("fletchType"); switch(var.getSlot()) { case 0: MakeBows.cutLog(player, amount, logType, 0, (player.getTemporaryAttribute("stringingBow") == null ? false : (bool)player.getTemporaryAttribute("stringingBow")), true); break; case 1: MakeBows.cutLog(player, amount, logType, 1, (player.getTemporaryAttribute("stringingBow") == null ? false : (bool)player.getTemporaryAttribute("stringingBow")), true); break; case 2: MakeBows.cutLog(player, amount, 0, 2, false, true); break; case 3: MakeBows.cutLog(player, amount, 0, 3, false, true); break; } break; case 306: // What would you like to make? - 5 options switch(var.getSlot()) { case 0: Clay.craftClay(player, amount, craftType, var.getSlot(), true); break; case 1: Clay.craftClay(player, amount, craftType, var.getSlot(), true); break; case 2: Clay.craftClay(player, amount, craftType, var.getSlot(), true); break; case 3: Clay.craftClay(player, amount, craftType, var.getSlot(), true); break; case 4: Clay.craftClay(player, amount, craftType, var.getSlot(), true); break; } break; case 309: // What would you like to make - 1 option if (var.getSlot() >= 50 && var.getSlot() <= 60) { // Cut gem Jewellery.cutGem(player, craftType, amount, true); break; } else if (var.getSlot() >= 100 && var.getSlot() <= 110) { // String amulet Jewellery.stringAmulet(player, craftType, amount, true); break; } switch(var.getSlot()) { case 0: MakeXbow.createXbow(player, amount, (int) (player.getTemporaryAttribute("bowType2") == null ? -1 : (int) player.getTemporaryAttribute("bowType2")), (bool) (player.getTemporaryAttribute("stringingBow") == null ? false :(bool) player.getTemporaryAttribute("stringingBow")), true); break; case 1: MakeBows.cutLog(player, amount, (int) (player.getTemporaryAttribute("fletchType") == null ? -1 : (int) player.getTemporaryAttribute("fletchType")), (int) (player.getTemporaryAttribute("bowType") == null ? -1 : (int) player.getTemporaryAttribute("bowType")), true, true); break; case 2: Herblore.grindIngredient(player, amount, true); break; case 3: Herblore.makeUnfinishedPotion(player, amount, true); break; case 4: Herblore.completePotion(player, amount, true); break; case 5: Cooking.cookItem(player, amount, true, player.getTemporaryAttribute("cookingFireLocation") != null); break; case 6: MakeAmmo.makeBoltTip(player, (int) (player.getTemporaryAttribute("boltTips") == null ? -1 : (int) player.getTemporaryAttribute("boltTips")), amount, true); break; } break; case 311: // Smelting interface switch(var.getSlot()) { case 13: // Bronze Smelting.smeltOre(player, var.getSlot(), true, amount); break; case 17: // Blurite Smelting.smeltOre(player, var.getSlot(), true, amount); break; case 21: // Iron Smelting.smeltOre(player, var.getSlot(), true, amount); break; case 25: // Silver Smelting.smeltOre(player, var.getSlot(), true, amount); break; case 29: // Steel Smelting.smeltOre(player, var.getSlot(), true, amount); break; case 33: // Gold Smelting.smeltOre(player, var.getSlot(), true, amount); break; case 37: // Mithril Smelting.smeltOre(player, var.getSlot(), true, amount); break; case 41: // Adamant Smelting.smeltOre(player, var.getSlot(), true, amount); break; case 45: // Rune Smelting.smeltOre(player, var.getSlot(), true, amount); break; } break; case 300: // Smithing interface. if (player.getTemporaryAttribute("smithingItem") == null) { return; } SmithBar item = (SmithBar) player.getTemporaryAttribute("smithingItem"); if (item != null) { item.setAmount(amount); } Smithing.smithItem(player, var.getSlot(), amount, false); break; } player.removeTemporaryAttribute("interfaceVariable"); }
private void handleClickFive(Player player, Packet packet) { int interfaceId = packet.readUShort(); int child = packet.readUShort(); int slot = packet.readUShort(); Console.WriteLine("InterfaceOption 5: interfaceId: " + interfaceId); switch(interfaceId) { case 763: // Bank inventory - X. player.getPackets().displayEnterAmount(); player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot)); break; case 762: // Bank - X. player.getPackets().displayEnterAmount(); player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot)); break; case 336: // Trade inventory - trade X. player.getPackets().displayEnterAmount(); player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot)); break; case 335: // Trade interface - remove X. player.getPackets().displayEnterAmount(); player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot)); break; case 631: // Duel interface - remove All if (player.getDuel() != null) { player.getPackets().displayEnterAmount(); player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot)); break; } break; case 620: // Shop - buy X/buy 50. if (player.getShopSession().isInMainStock()) { player.getPackets().displayEnterAmount(); player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot)); } else { player.getShopSession().buyItem(slot, 50); } break; case 621: // Shop - Sell 50. player.getShopSession().sellItem(slot, 50); break; case 590: // Clan chat setup Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername()); if (clan == null) { player.getPackets().sendMessage("Please create your clan chat before changing settings."); break; } switch(child) { case 23: // "Who can enter chat" - sergeant. clan.setEnterRights(Clan.ClanRank.SERGEANT); player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23); break; case 24: // "Who can talk in chat" - sergeant. clan.setTalkRights(Clan.ClanRank.SERGEANT); player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24); break; case 25: // // "Who can kick in chat" - sergeant. clan.setKickRights(Clan.ClanRank.SERGEANT); player.getPackets().modifyText(clan.getRankString(clan.getKickRights()), 590, 25); break; case 26: // "Who can share loot" - sergeant. clan.setLootRights(Clan.ClanRank.SERGEANT); player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26); break; } break; } }
private void handleClickFour(Player player, Packet packet) { int interfaceId = packet.readUShort(); int child = packet.readUShort(); int slot = packet.readUShort(); Console.WriteLine("InterfaceOption 4: interfaceId: " + interfaceId); switch(interfaceId) { case 763: // Bank inventory - Custom amount. player.getBank().deposit(slot, player.getBank().getLastXAmount()); player.getBank().refreshBank(); break; case 762: // Bank - Custom amount. player.getBank().withdraw(slot, player.getBank().getLastXAmount()); player.getBank().refreshBank(); break; case 154: // Craft normal leather. player.getPackets().displayEnterAmount(); player.setTemporaryAttribute("interfaceVariable", new EnterVariable(154, child)); break; case 542: // Glassblowing. switch(child) { case 40: // Make X beer glass. case 41: // Make X candle lantern. case 42: // Make X oil lamp. case 38: // Make X vial. case 44: // Make X Fishbowl case 39: // Make X orb. case 43: // Make X lantern lens case 45: // Make X dorgeshuun light orb. player.getPackets().displayEnterAmount(); player.setTemporaryAttribute("interfaceVariable", new EnterVariable(542, child)); break; } break; case 336: // Trade/stake inventory - trade all. if (player.getTrade() != null) { player.getTrade().tradeItem(slot, player.getInventory().getItemAmount(player.getInventory().getItemInSlot(slot))); break; } if (player.getDuel() != null) { player.getDuel().stakeItem(slot, player.getInventory().getItemAmount(player.getInventory().getItemInSlot(slot))); break; } break; case 335: // Trade interface - remove all. player.getTrade().removeItem(slot, player.getTrade().getItemAmount(player.getTrade().getItemInSlot(slot))); break; case 631: // Duel interface - remove All if (player.getDuel() != null) { player.getDuel().removeItem(slot, player.getDuel().getItemAmount(player.getDuel().getItemInSlot(slot))); break; } break; case 620: // Shop - buy 10. player.getShopSession().buyItem(slot, 10); break; case 621: // Shop - sell 10. player.getShopSession().sellItem(slot, 10); break; case 590: // Clan chat setup Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername()); if (clan == null) { player.getPackets().sendMessage("Please create your clan chat before changing settings."); break; } switch(child) { case 23: // "Who can enter chat" - corporal. clan.setEnterRights(Clan.ClanRank.CORPORAL); player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23); break; case 24: // "Who can talk in chat" - corporal. clan.setTalkRights(Clan.ClanRank.CORPORAL); player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24); break; case 25: // // "Who can kick in chat" - corporal. clan.setKickRights(Clan.ClanRank.CORPORAL); player.getPackets().modifyText(clan.getRankString(clan.getKickRights()), 590, 25); break; case 26: // "Who can share loot" - corporal. clan.setLootRights(Clan.ClanRank.CORPORAL); player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26); break; } break; } }
private void handleEnterText(Player player, Packet packet) { if (player.getTemporaryAttribute("interfaceVariable") == null) { player.getPackets().sendMessage("An error occured, please try again."); return; } long textAsLong = packet.readLong(); EnterVariable var = (EnterVariable) player.getTemporaryAttribute("interfaceVariable"); switch(var.getInterfaceId()) { case 590: // Clan chat setup Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername()); if (clan != null) { clan.setClanName(misc.longToPlayerName(textAsLong)); Server.getClanManager().updateClan(clan); player.getPackets().modifyText(misc.formatPlayerNameForDisplay(clan.getClanName()), 590, 22); break; } player.getPackets().sendMessage("Please set up a clan channel before trying to change the name."); break; } player.removeTemporaryAttribute("interfaceVariable"); }
private void handleClickOne(Player player, Packet packet) { int slot = packet.readShortA(); int item = packet.readUShort(); int childId = packet.readUShort(); int interfaceId = packet.readUShort(); if (slot < 0 || slot > 28 || player.isDead()) { return; } Console.WriteLine("Click One Slot = " + slot); player.getPackets().closeInterfaces(); Console.WriteLine("InterfaceOption 1: interfaceId: " + interfaceId); switch(interfaceId) { case 387: // Unequip item if (slot < 14 && player.getEquipment().getItemInSlot((ItemData.EQUIP)slot) == item) { player.getEquipment().unequipItem((ItemData.EQUIP)slot); } break; } }
private void handleClickTwo(Player player, Packet packet) { int interfaceId = packet.readUShort(); int child = packet.readUShort(); int slot = packet.readUShort(); Console.WriteLine("InterfaceOption 2: interfaceId: " + interfaceId); switch(interfaceId) { case 105: // GE Interface switch(child) { case 209: // "Collect" and "Collect-items" option player.getGESession().collectSlot1(false); break; case 211: // Left box "Collect" option (coins) player.getGESession().collectSlot2(); break; } break; case 154: // Craft normal leather. Leather.craftNormalLeather(player, child, 5, true); break; case 542: // Glassblowing. switch(child) { case 40: // Make 5 beer glass. Glass.craftGlass(player, 5, 0, true); break; case 41: // Make 5 candle lantern. Glass.craftGlass(player, 5, 1, true); break; case 42: // Make 5 oil lamp. Glass.craftGlass(player, 5, 2, true); break; case 38: // Make 5 vial. Glass.craftGlass(player, 5, 3, true); break; case 44: // Make 5 Fishbowl Glass.craftGlass(player, 5, 4, true); break; case 39: // Make 5 orb. Glass.craftGlass(player, 5, 5, true); break; case 43: // Make 5 lantern lens Glass.craftGlass(player, 5, 6, true); break; case 45: // Make 5 dorgeshuun light orb. Glass.craftGlass(player, 5, 7, true); break; } break; case 763: // Bank inventory - 5. player.getBank().deposit(slot, 5); player.getBank().refreshBank(); break; case 762: // Bank - 5. player.getBank().withdraw(slot, 5); player.getBank().refreshBank(); break; case 336: // Trade/stake inventory - trade 5. if (player.getTrade() != null) { player.getTrade().tradeItem(slot, 5); break; } if (player.getDuel() != null) { player.getDuel().stakeItem(slot, 5); break; } break; case 631: // Duel interface - remove 5 if (player.getDuel() != null) { player.getDuel().removeItem(slot, 5); break; } break; case 335: // Trade interface - remove 5. player.getTrade().removeItem(slot, 5); break; case 620: // Shop - buy 1. player.getShopSession().buyItem(slot, 1); break; case 621: // Shop - sell 1. player.getShopSession().sellItem(slot, 1); break; case 590: // Clan chat setup Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername()); if (clan == null) { player.getPackets().sendMessage("Please create your clan chat before changing settings."); break; } switch(child) { case 23: // "Who can enter chat" - any friends. clan.setEnterRights(Clan.ClanRank.FRIEND); player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23); break; case 24: // "Who can talk in chat" - any friends. clan.setTalkRights(Clan.ClanRank.FRIEND); player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24); break; case 26: // "Who can share loot" - any friends. clan.setLootRights(Clan.ClanRank.FRIEND); player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26); break; } break; } }
private void handleClickThree(Player player, Packet packet) { int interfaceId = packet.readUShort(); int child = packet.readUShort(); int slot = packet.readUShort(); Console.WriteLine("InterfaceOption 3: interfaceId: " + interfaceId); switch(interfaceId) { case 154: // Craft normal leather. Leather.craftNormalLeather(player, child, player.getInventory().getItemAmount(1741), true); break; case 542: // Glassblowing. int totalGlass = player.getInventory().getItemAmount(1775); switch(child) { case 40: // Make all beer glass. Glass.craftGlass(player, totalGlass, 0, true); break; case 41: // Make all candle lantern. Glass.craftGlass(player, totalGlass, 1, true); break; case 42: // Make all oil lamp. Glass.craftGlass(player, totalGlass, 2, true); break; case 38: // Make all vial. Glass.craftGlass(player, totalGlass, 3, true); break; case 44: // Make all Fishbowl Glass.craftGlass(player, totalGlass, 4, true); break; case 39: // Make all orb. Glass.craftGlass(player, totalGlass, 5, true); break; case 43: // Make all lantern lens Glass.craftGlass(player, totalGlass, 6, true); break; case 45: // Make all dorgeshuun light orb. Glass.craftGlass(player, totalGlass, 7, true); break; } break; case 763: // Bank inventory - 10. player.getBank().deposit(slot, 10); player.getBank().refreshBank(); break; case 762: // Bank - 10. player.getBank().withdraw(slot, 10); player.getBank().refreshBank(); break; case 336: // Trade/stake inventory - trade 10. if (player.getTrade() != null) { player.getTrade().tradeItem(slot, 10); break; } if (player.getDuel() != null) { player.getDuel().stakeItem(slot, 10); break; } break; case 335: // Trade interface - remove 10. player.getTrade().removeItem(slot, 10); break; case 631: // Duel interface - remove 10. if (player.getDuel() != null) { player.getDuel().removeItem(slot, 5); break; } break; case 620: // Shop - buy 5. player.getShopSession().buyItem(slot, 5); break; case 621: // Shop - sell 5. player.getShopSession().sellItem(slot, 5); break; case 590: // Clan chat setup Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername()); if (clan == null) { player.getPackets().sendMessage("Please create your clan chat before changing settings."); break; } switch(child) { case 23: // "Who can enter chat" - recruit. clan.setEnterRights(Clan.ClanRank.RECRUIT); player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23); break; case 24: // "Who can talk in chat" - recruit. clan.setTalkRights(Clan.ClanRank.RECRUIT); player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24); break; case 26: // "Who can share loot" - recruit. clan.setLootRights(Clan.ClanRank.RECRUIT); player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26); break; } break; } }