Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.ew.net.decoders.handlers;
- import java.util.List;
- import com.ew.Settings;
- import com.ew.cores.WorldThread;
- import com.ew.game.Animation;
- import com.ew.game.World;
- import com.ew.game.WorldTile;
- import com.ew.game.item.Item;
- import com.ew.game.npc.NPC;
- import com.ew.game.npc.familiar.Familiar.SpecialAttack;
- import com.ew.game.npc.pet.Pet;
- import com.ew.game.player.CoordsEvent;
- import com.ew.game.player.Equipment;
- import com.ew.game.player.Inventory;
- import com.ew.game.player.Player;
- import com.ew.game.player.actions.BoxAction;
- import com.ew.game.player.actions.BoxAction.HunterEquipment;
- import com.ew.game.player.actions.Firemaking;
- import com.ew.game.player.actions.Fletching;
- import com.ew.game.player.actions.Fletching.Fletch;
- import com.ew.game.player.actions.GemCutting;
- import com.ew.game.player.actions.GemCutting.Gem;
- import com.ew.game.player.actions.HerbCleaning;
- import com.ew.game.player.actions.LeatherCrafting;
- import com.ew.game.player.actions.Summoning;
- import com.ew.game.player.actions.Summoning.Pouches;
- import com.ew.game.player.content.AncientEffigies;
- import com.ew.game.player.content.ArmourSets;
- import com.ew.game.player.content.ArmourSets.Sets;
- import com.ew.game.player.content.Burying.Bone;
- import com.ew.game.player.content.Dicing;
- import com.ew.game.player.content.Foods;
- import com.ew.game.player.content.Herblore;
- import com.ew.game.player.content.ItemTeleport;
- import com.ew.game.player.content.Magic;
- import com.ew.game.player.content.Pots;
- import com.ew.game.player.content.Runecrafting;
- import com.ew.game.player.content.SkillCapeCustomizer;
- import com.ew.game.player.content.misc.CreateSpiritShield;
- import com.ew.game.player.content.misc.CrystalChest;
- import com.ew.game.player.content.misc.ItemCreation;
- import com.ew.game.player.content.misc.ScatterAshes;
- import com.ew.game.player.content.misc.ScatterAshes.AshesData;
- import com.ew.game.player.content.misc.XpLamps;
- import com.ew.game.player.controlers.Barrows;
- import com.ew.game.player.controlers.FightKiln;
- import com.ew.game.player.controlers.Wilderness;
- import com.ew.game.randomevents.RandomEvent;
- import com.ew.game.tasks.WorldTask;
- import com.ew.game.tasks.WorldTasksManager;
- import com.ew.io.InputStream;
- import com.ew.utils.Logger;
- import com.ew.utils.Utils;
- import com.ew.content.utils.ToyHorsey;
- import com.ew.game.player.ClueScrolls;
- import com.ew.net.decoders.handlers.ButtonHandler;
- public class InventoryOptionsHandler {
- public static void handleItemOption2(final Player player, final int slotId,
- final int itemId, Item item) {
- if (Firemaking.isFiremaking(player, itemId))
- return;
- if (itemId == 5733) {
- player.getDialogueManager().startDialogue("RottenPotato");
- return;
- }
- if (itemId >= 5509 && itemId <= 5514) {
- int pouch = -1;
- if (itemId == 5509)
- pouch = 0;
- if (itemId == 5510)
- pouch = 1;
- if (itemId == 5512)
- pouch = 2;
- if (itemId == 5514)
- pouch = 3;
- Runecrafting.emptyPouch(player, pouch);
- player.stopAll(false);
- } else if (itemId >= 15086 && itemId <= 15100) {
- Dicing.handleRoll(player, itemId, true);
- return;
- } else {
- if (player.isEquipDisabled())
- return;
- long passedTime = Utils.currentTimeMillis()
- - WorldThread.LAST_CYCLE_CTM;
- WorldTasksManager.schedule(new WorldTask() {
- @Override
- public void run() {
- List<Integer> slots = player.getSwitchItemCache();
- int[] slot = new int[slots.size()];
- for (int i = 0; i < slot.length; i++)
- slot[i] = slots.get(i);
- player.getSwitchItemCache().clear();
- ButtonHandler.sendWear(player, slot);
- player.stopAll(false, true, false);
- }
- }, passedTime >= 600 ? 0 : passedTime > 330 ? 1 : 0);
- if (player.getSwitchItemCache().contains(slotId))
- return;
- player.getSwitchItemCache().add(slotId);
- }
- }
- public static void dig(final Player player) {
- player.resetWalkSteps();
- player.setNextAnimation(new Animation(830));
- player.lock();
- WorldTasksManager.schedule(new WorldTask() {
- @Override
- public void run() {
- player.unlock();
- if (Barrows.digIntoGrave(player))
- return;
- if(player.getX() == 3005 && player.getY() == 3376
- || player.getX() == 2999 && player.getY() == 3375
- || player.getX() == 2996 && player.getY() == 3377
- || player.getX() == 2989 && player.getY() == 3378
- || player.getX() == 2987 && player.getY() == 3387
- || player.getX() == 2984 && player.getY() == 3387) {
- if (ClueScrolls.digSpot(player)){
- return;
- }
- //mole
- player.setNextWorldTile(new WorldTile(1752, 5137, 0));
- player.getPackets().sendGameMessage("You seem to have dropped down into a network of mole tunnels.");
- return;
- }
- player.getPackets().sendGameMessage("You find nothing.");
- }
- });
- }
- public static void handleItemOption1(Player player, final int slotId,
- final int itemId, Item item) {
- long time = Utils.currentTimeMillis();
- if (player.getLockDelay() >= time
- || player.getEmotesManager().getNextEmoteEnd() >= time)
- return;
- player.stopAll(false);
- for (int i: ClueScrolls.ScrollIds){
- if (itemId == i){
- if (ClueScrolls.Scrolls.getMap(itemId) != null){
- ClueScrolls.showMap(player, ClueScrolls.Scrolls.getMap(itemId));
- return;
- }
- if (ClueScrolls.Scrolls.getObjMap(itemId) != null){
- ClueScrolls.showObjectMap(player, ClueScrolls.Scrolls.getObjMap(itemId));
- return;
- }
- if (ClueScrolls.Scrolls.getRiddles(itemId) != null){
- ClueScrolls.showRiddle(player, ClueScrolls.Scrolls.getRiddles(itemId));
- return;
- }
- }
- }
- /*Mystery Box*/
- if (itemId == 6199) {
- int[] Common = {995, 4151}; //dont forget to put "," between item id's!
- int[] Uncommon = {5764, 8764};
- int[] Rare = {8773, 6273, 20000};
- int[] SuperRare = {23948, 23423};
- int[] Legendary = {23434, 23423};
- player.getInventory().deleteItem(6199, 1);
- int rarity = Utils.getRandom(1000);
- if (rarity > 0 && rarity <= 600) {
- int length = Common.length;
- length--;
- int reward = Utils.getRandom(length);
- player.getInventory().addItem(Common[reward], 1);
- player.getPackets().sendGameMessage("You've recieved a Common item from the Mystery Box!");
- }
- if (rarity > 600 && rarity <= 900) {
- int length = Uncommon.length;
- length--;
- int reward = Utils.getRandom(length);
- player.getInventory().addItem(Uncommon[reward], 2);
- player.getPackets().sendGameMessage("You've recieved a uncommon item from the Mystery Box!");
- }
- if (rarity > 900 && rarity <= 970) {
- int length = Rare.length;
- length--;
- int reward = Utils.getRandom(length);
- player.getInventory().addItem(Rare[reward], 3);
- player.getPackets().sendGameMessage("You've recieved a rare item from the Mystery Box!");
- }
- if (rarity > 970 && rarity <= 997) {
- int length = SuperRare.length;
- length--;
- int reward = Utils.getRandom(length);
- player.getInventory().addItem(SuperRare[reward], 4);
- player.getPackets().sendGameMessage("You've recieved a super rare item from the Mystery Box!");
- }
- if (rarity > 997 && rarity <= 1000) {
- int length = Legendary.length;
- length--;
- int reward = Utils.getRandom(length);
- player.getInventory().addItem(Legendary[reward], 5);
- player.getPackets().sendGameMessage("You've recieved a ultra rare item from the Mystery Box!");
- }
- return;
- }
- if (itemId == 2717){
- ClueScrolls.giveReward(player);
- }
- if (Foods.eat(player, item, slotId))
- return;
- if (itemId >= 15086 && itemId <= 15100) {
- Dicing.handleRoll(player, itemId, false);
- return;
- }
- if (Pots.pot(player, item, slotId))
- return;
- if (itemId >= 5509 && itemId <= 5514) {
- int pouch = -1;
- if (itemId == 5509)
- pouch = 0;
- if (itemId == 5510)
- pouch = 1;
- if (itemId == 5512)
- pouch = 2;
- if (itemId == 5514)
- pouch = 3;
- Runecrafting.fillPouch(player, pouch);
- return;
- }
- if (itemId == 2520) {
- ToyHorsey.play(player);
- }
- if (itemId == 2522) {
- ToyHorsey.play(player);
- }
- if (itemId == 2524) {
- ToyHorsey.play(player);
- }
- if (itemId == 2526) {
- ToyHorsey.play(player);
- }
- if (itemId == 22370) {
- Summoning.openDreadnipInterface(player);
- }
- if (itemId == 952) {// spade
- dig(player);
- return;
- }
- if (HerbCleaning.clean(player, item, slotId))
- return;
- Bone bone = Bone.forId(itemId);
- if (bone != null) {
- Bone.bury(player, slotId);
- return;
- }
- if (Magic.useTabTeleport(player, itemId))
- return;
- if (itemId == AncientEffigies.SATED_ANCIENT_EFFIGY
- || itemId == AncientEffigies.GORGED_ANCIENT_EFFIGY
- || itemId == AncientEffigies.NOURISHED_ANCIENT_EFFIGY
- || itemId == AncientEffigies.STARVED_ANCIENT_EFFIGY)
- player.getDialogueManager().startDialogue("AncientEffigiesD",
- itemId);
- else if (itemId == 4155)
- player.getDialogueManager().startDialogue("EnchantedGemDialouge");
- else if (itemId >= 23653 && itemId <= 23658)
- FightKiln.useCrystal(player, itemId);
- else if (itemId == 1856) {// Information Book
- player.getInterfaceManager().sendInterface(275);
- player.getPackets()
- .sendIComponentText(275, 2, Settings.SERVER_NAME);
- player.getPackets().sendIComponentText(275, 16,
- "Welcome to " + Settings.SERVER_NAME + ".");
- player.getPackets().sendIComponentText(275, 17,
- "If want some an item use command ::item id.");
- player.getPackets().sendIComponentText(275, 18,
- "If you don't have an item list you can find ids");
- player.getPackets().sendIComponentText(275, 19,
- "at http://itemdb.biz");
- player.getPackets().sendIComponentText(275, 20,
- "You can change your prayers and spells at home.");
- player.getPackets().sendIComponentText(275, 21,
- "If you need any help, do ::ticket. (Don't abuse it)");
- player.getPackets().sendIComponentText(275, 22,
- "at start of your message on public chat.");
- player.getPackets().sendIComponentText(275, 22,
- "By the way you can compare your ::score with your mates.");
- player.getPackets().sendIComponentText(275, 23,
- "Oh and ye, don't forget to ::vote and respect rules.");
- player.getPackets().sendIComponentText(275, 24, "");
- player.getPackets().sendIComponentText(275, 25,
- "Forums: " + Settings.WEBSITE_LINK);
- player.getPackets().sendIComponentText(275, 26, "");
- player.getPackets().sendIComponentText(275, 27,
- "Enjoy your time on " + Settings.SERVER_NAME + ".");
- player.getPackets().sendIComponentText(275, 28,
- "<img=1> Staff Team");
- player.getPackets().sendIComponentText(275, 29, "");
- player.getPackets().sendIComponentText(275, 30, "");
- player.getPackets().sendIComponentText(275, 14,
- "<u>Visit Website</u>");
- for (int i = 31; i < 300; i++)
- player.getPackets().sendIComponentText(275, i, "");
- } else if (itemId == HunterEquipment.BOX.getId()) // almost done
- player.getActionManager().setAction(new BoxAction(HunterEquipment.BOX));
- else if (itemId == HunterEquipment.BRID_SNARE.getId())
- player.getActionManager().setAction(
- new BoxAction(HunterEquipment.BRID_SNARE));
- else if (item.getDefinitions().getName().startsWith("Burnt"))
- player.getDialogueManager().startDialogue("SimplePlayerMessage", "Ugh, this is inedible.");
- if (Settings.DEBUG)
- Logger.log("ItemHandler", "Item Select:" + itemId + ", Slot Id:"
- + slotId);
- }
- /*
- * returns the other
- */
- public static Item contains(int id1, Item item1, Item item2) {
- if (item1.getId() == id1)
- return item2;
- if (item2.getId() == id1)
- return item1;
- return null;
- }
- public static boolean contains(int id1, int id2, Item... items) {
- boolean containsId1 = false;
- boolean containsId2 = false;
- for (Item item : items) {
- if (item.getId() == id1)
- containsId1 = true;
- else if (item.getId() == id2)
- containsId2 = true;
- }
- return containsId1 && containsId2;
- }
- public static void handleItemOnItem(final Player player, InputStream stream) {
- int itemUsedWithId = stream.readShort();
- int toSlot = stream.readShortLE128();
- int interfaceId = stream.readInt() >> 16;
- int interfaceId2 = stream.readInt() >> 16;
- int fromSlot = stream.readShort();
- int itemUsedId = stream.readShortLE128();
- if ((interfaceId2 == 747 || interfaceId2 == 662)
- && interfaceId == Inventory.INVENTORY_INTERFACE) {
- if (player.getFamiliar() != null) {
- player.getFamiliar().setSpecial(true);
- if (player.getFamiliar().getSpecialAttack() == SpecialAttack.ITEM) {
- if (player.getFamiliar().hasSpecialOn())
- player.getFamiliar().submitSpecial(toSlot);
- }
- }
- return;
- }
- if (interfaceId == Inventory.INVENTORY_INTERFACE
- && interfaceId == interfaceId2
- && !player.getInterfaceManager().containsInventoryInter()) {
- if (toSlot >= 28 || fromSlot >= 28)
- return;
- Item usedWith = player.getInventory().getItem(toSlot);
- Item itemUsed = player.getInventory().getItem(fromSlot);
- if (itemUsed == null || usedWith == null
- || itemUsed.getId() != itemUsedId
- || usedWith.getId() != itemUsedWithId)
- return;
- player.stopAll();
- if (!player.getControlerManager().canUseItemOnItem(itemUsed,
- usedWith))
- return;
- Fletch fletch = Fletching.isFletching(usedWith, itemUsed);
- if (fletch != null) {
- player.getDialogueManager().startDialogue("FletchingD", fletch);
- return;
- }
- int herblore = Herblore.isHerbloreSkill(itemUsed, usedWith);
- if (herblore > -1) {
- player.getDialogueManager().startDialogue("HerbloreD",
- herblore, itemUsed, usedWith);
- return;
- }
- if (itemUsed.getId() == LeatherCrafting.NEEDLE.getId()
- || usedWith.getId() == LeatherCrafting.NEEDLE.getId()) {
- if (LeatherCrafting
- .handleItemOnItem(player, itemUsed, usedWith)) {
- return;
- }
- }
- Sets set = ArmourSets.getArmourSet(itemUsedId, itemUsedWithId);
- if (set != null) {
- ArmourSets.exchangeSets(player, set);
- return;
- }
- if (Firemaking.isFiremaking(player, itemUsed, usedWith))
- return;
- else if (contains(1755, Gem.OPAL.getUncut(), itemUsed, usedWith))
- GemCutting.cut(player, Gem.OPAL);
- else if (contains(1755, Gem.JADE.getUncut(), itemUsed, usedWith))
- GemCutting.cut(player, Gem.JADE);
- else if (contains(1755, Gem.RED_TOPAZ.getUncut(), itemUsed,
- usedWith))
- GemCutting.cut(player, Gem.RED_TOPAZ);
- else if (contains(1755, Gem.SAPPHIRE.getUncut(), itemUsed, usedWith))
- GemCutting.cut(player, Gem.SAPPHIRE);
- else if (contains(1755, Gem.EMERALD.getUncut(), itemUsed, usedWith))
- GemCutting.cut(player, Gem.EMERALD);
- else if (contains(1755, Gem.RUBY.getUncut(), itemUsed, usedWith))
- GemCutting.cut(player, Gem.RUBY);
- else if (contains(1755, Gem.DIAMOND.getUncut(), itemUsed, usedWith))
- GemCutting.cut(player, Gem.DIAMOND);
- else if (contains(1755, Gem.DRAGONSTONE.getUncut(), itemUsed,
- usedWith))
- GemCutting.cut(player, Gem.DRAGONSTONE);
- else if (contains(1755, Gem.ONYX.getUncut(), itemUsed, usedWith))
- GemCutting.cut(player, Gem.ONYX);
- else
- player.getPackets().sendGameMessage(
- "Nothing interesting happens.");
- if (Settings.DEBUG)
- Logger.log("ItemHandler", "Used:" + itemUsed.getId()
- + ", With:" + usedWith.getId());
- }
- }
- public static void handleItemOption3(Player player, int slotId, int itemId,
- Item item) {
- long time = Utils.currentTimeMillis();
- if (player.getLockDelay() >= time
- || player.getEmotesManager().getNextEmoteEnd() >= time)
- return;
- player.stopAll(false);
- if (itemId == 20767 || itemId == 20769 || itemId == 20771)
- SkillCapeCustomizer.startCustomizing(player, itemId);
- else if(itemId >= 15084 && itemId <= 15100)
- player.getDialogueManager().startDialogue("DiceBag", itemId);
- else if(itemId == 24437 || itemId == 24439 || itemId == 24440 || itemId == 24441)
- player.getDialogueManager().startDialogue("FlamingSkull", item, slotId);
- else if (Equipment.getItemSlot(itemId) == Equipment.SLOT_AURA)
- player.getAuraManager().sendTimeRemaining(itemId);
- }
- public static void handleItemOption4(Player player, int slotId, int itemId,
- Item item) {
- System.out.println("Option 4");
- }
- public static void handleItemOption5(Player player, int slotId, int itemId,
- Item item) {
- System.out.println("Option 5");
- }
- public static void handleItemOption6(Player player, int slotId, int itemId,
- Item item) {
- long time = Utils.currentTimeMillis();
- if (player.getLockDelay() >= time
- || player.getEmotesManager().getNextEmoteEnd() >= time)
- return;
- player.stopAll(false);
- Pouches pouches = Pouches.forId(itemId);
- if (pouches != null)
- Summoning.spawnFamiliar(player, pouches);
- else if (itemId == 1438)
- Runecrafting.locate(player, 3127, 3405);
- else if (itemId == 1440)
- Runecrafting.locate(player, 3306, 3474);
- else if (itemId == 1442)
- Runecrafting.locate(player, 3313, 3255);
- else if (itemId == 1444)
- Runecrafting.locate(player, 3185, 3165);
- else if (itemId == 1446)
- Runecrafting.locate(player, 3053, 3445);
- else if (itemId == 1448)
- Runecrafting.locate(player, 2982, 3514);
- else if (itemId <= 1712 && itemId >= 1706 || itemId >= 10354
- && itemId <= 10362)
- player.getDialogueManager().startDialogue("Transportation",
- "Edgeville", new WorldTile(3087, 3496, 0), "Karamja",
- new WorldTile(2918, 3176, 0), "Draynor Village",
- new WorldTile(3105, 3251, 0), "Al Kharid",
- new WorldTile(3293, 3163, 0), itemId);
- else if (itemId == 995) {
- if (item.getAmount() < 0) {
- return;
- }
- player.getMoneyPouch().handleMoneyPouch(false, false, false,
- player.getInventory().getNumberOf(995), 0);
- }
- else if (itemId == 1704 || itemId == 10352)
- player.getPackets()
- .sendGameMessage(
- "The amulet has ran out of charges. You need to recharge it if you wish it use it once more.");
- else if (itemId >= 3853 && itemId <= 3867)
- player.getDialogueManager().startDialogue("Transportation",
- "Burthrope Games Room", new WorldTile(2880, 3559, 0),
- "Barbarian Outpost", new WorldTile(2519, 3571, 0),
- "Gamers' Grotto", new WorldTile(2970, 9679, 0),
- "Corporeal Beast", new WorldTile(2886, 4377, 0), itemId);
- }
- public static void handleItemOption7(Player player, int slotId, int itemId,
- Item item) {
- long time = Utils.currentTimeMillis();
- if (player.getLockDelay() >= time
- || player.getEmotesManager().getNextEmoteEnd() >= time)
- return;
- if (!player.getControlerManager().canDropItem(item))
- return;
- player.stopAll(false);
- if (item.getDefinitions().isOverSized()) {
- player.getPackets().sendGameMessage("The item appears to be oversized.");
- player.getInventory().deleteItem(item);
- return;
- }
- if (item.getDefinitions().isDestroyItem()) {
- player.getDialogueManager().startDialogue("DestroyItemOption",
- slotId, item);
- return;
- }
- if (player.getPetManager().spawnPet(itemId, true)) {
- return;
- }
- player.getInventory().deleteItem(slotId, item);
- if (player.getCharges().degradeCompletly(item))
- return;
- World.addGroundItem(item, new WorldTile(player), player, false, 180,
- true);
- player.getPackets().sendSound(2739, 0, 1);
- }
- public static void handleItemOption8(Player player, int slotId, int itemId,
- Item item) {
- player.getInventory().sendExamine(slotId);
- }
- public static void handleItemOnNPC(final Player player, final NPC npc, final Item item) {
- if (item == null) {
- return;
- }
- player.setCoordsEvent(new CoordsEvent(npc, new Runnable() {
- @Override
- public void run() {
- if (!player.getInventory().containsItem(item.getId(), item.getAmount())) {
- return;
- }
- if (npc instanceof Pet) {
- player.faceEntity(npc);
- player.getPetManager().eat(item.getId(), (Pet) npc);
- return;
- }
- }
- }, npc.getSize()));
- }
- public static void handleItemOnPlayer(final Player player,
- final Player usedOn, final int itemId) {
- player.setCoordsEvent(new CoordsEvent(usedOn, new Runnable() {
- public void run() {
- player.faceEntity(usedOn);
- if (usedOn.getInterfaceManager().containsScreenInter()) {
- player.getPackets().sendGameMessage(usedOn.getDisplayName() + " is busy at the moment.");
- return;
- }
- // if (!usedOn.hasAcceptAid()) {
- // player.getPackets().sendGameMessage(usedOn.getDisplayName()
- // + " doesn't want to accept your items.");
- // return;
- // }
- switch (itemId) {
- case 962: // Christmas cracker
- if (player.getInventory().getFreeSlots() < 3
- || usedOn.getInventory().getFreeSlots() < 3) {
- player.getPackets().sendGameMessage((player.getInventory()
- .getFreeSlots() < 3 ? "You do"
- : "The other player does")
- + " not have enough inventory space to pull this cracker.");
- return;
- }
- player.getDialogueManager().startDialogue(
- "ChristmasCracker", usedOn, itemId);
- break;
- default:
- player.getPackets().sendGameMessage("Nothing interesting happens.");
- break;
- }
- }
- }, usedOn.getSize()));
- }
- }
Add Comment
Please, Sign In to add comment