Guest User

Untitled

a guest
Sep 1st, 2014
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 21.05 KB | None | 0 0
  1. package com.ew.net.decoders.handlers;
  2.  
  3. import java.util.List;
  4.  
  5. import com.ew.Settings;
  6. import com.ew.cores.WorldThread;
  7. import com.ew.game.Animation;
  8. import com.ew.game.World;
  9. import com.ew.game.WorldTile;
  10. import com.ew.game.item.Item;
  11. import com.ew.game.npc.NPC;
  12. import com.ew.game.npc.familiar.Familiar.SpecialAttack;
  13. import com.ew.game.npc.pet.Pet;
  14. import com.ew.game.player.CoordsEvent;
  15. import com.ew.game.player.Equipment;
  16. import com.ew.game.player.Inventory;
  17. import com.ew.game.player.Player;
  18. import com.ew.game.player.actions.BoxAction;
  19. import com.ew.game.player.actions.BoxAction.HunterEquipment;
  20. import com.ew.game.player.actions.Firemaking;
  21. import com.ew.game.player.actions.Fletching;
  22. import com.ew.game.player.actions.Fletching.Fletch;
  23. import com.ew.game.player.actions.GemCutting;
  24. import com.ew.game.player.actions.GemCutting.Gem;
  25. import com.ew.game.player.actions.HerbCleaning;
  26. import com.ew.game.player.actions.LeatherCrafting;
  27. import com.ew.game.player.actions.Summoning;
  28. import com.ew.game.player.actions.Summoning.Pouches;
  29. import com.ew.game.player.content.AncientEffigies;
  30. import com.ew.game.player.content.ArmourSets;
  31. import com.ew.game.player.content.ArmourSets.Sets;
  32. import com.ew.game.player.content.Burying.Bone;
  33. import com.ew.game.player.content.Dicing;
  34. import com.ew.game.player.content.Foods;
  35. import com.ew.game.player.content.Herblore;
  36. import com.ew.game.player.content.ItemTeleport;
  37. import com.ew.game.player.content.Magic;
  38. import com.ew.game.player.content.Pots;
  39. import com.ew.game.player.content.Runecrafting;
  40. import com.ew.game.player.content.SkillCapeCustomizer;
  41. import com.ew.game.player.content.misc.CreateSpiritShield;
  42. import com.ew.game.player.content.misc.CrystalChest;
  43. import com.ew.game.player.content.misc.ItemCreation;
  44. import com.ew.game.player.content.misc.ScatterAshes;
  45. import com.ew.game.player.content.misc.ScatterAshes.AshesData;
  46. import com.ew.game.player.content.misc.XpLamps;
  47. import com.ew.game.player.controlers.Barrows;
  48. import com.ew.game.player.controlers.FightKiln;
  49. import com.ew.game.player.controlers.Wilderness;
  50. import com.ew.game.randomevents.RandomEvent;
  51. import com.ew.game.tasks.WorldTask;
  52. import com.ew.game.tasks.WorldTasksManager;
  53. import com.ew.io.InputStream;
  54. import com.ew.utils.Logger;
  55. import com.ew.utils.Utils;
  56. import com.ew.content.utils.ToyHorsey;
  57. import com.ew.game.player.ClueScrolls;
  58. import com.ew.net.decoders.handlers.ButtonHandler;
  59.  
  60. public class InventoryOptionsHandler {
  61.  
  62.     public static void handleItemOption2(final Player player, final int slotId,
  63.             final int itemId, Item item) {
  64.         if (Firemaking.isFiremaking(player, itemId))
  65.             return;
  66.  
  67.         if (itemId == 5733) {
  68.             player.getDialogueManager().startDialogue("RottenPotato");
  69.             return;
  70.         }
  71.        
  72.         if (itemId >= 5509 && itemId <= 5514) {
  73.             int pouch = -1;
  74.             if (itemId == 5509)
  75.                 pouch = 0;
  76.             if (itemId == 5510)
  77.                 pouch = 1;
  78.             if (itemId == 5512)
  79.                 pouch = 2;
  80.             if (itemId == 5514)
  81.                 pouch = 3;
  82.             Runecrafting.emptyPouch(player, pouch);
  83.             player.stopAll(false);
  84.         } else if (itemId >= 15086 && itemId <= 15100) {
  85.             Dicing.handleRoll(player, itemId, true);
  86.             return;
  87.         } else {
  88.             if (player.isEquipDisabled())
  89.                 return;
  90.             long passedTime = Utils.currentTimeMillis()
  91.                     - WorldThread.LAST_CYCLE_CTM;
  92.             WorldTasksManager.schedule(new WorldTask() {
  93.  
  94.                 @Override
  95.                 public void run() {
  96.                     List<Integer> slots = player.getSwitchItemCache();
  97.                     int[] slot = new int[slots.size()];
  98.                     for (int i = 0; i < slot.length; i++)
  99.                         slot[i] = slots.get(i);
  100.                     player.getSwitchItemCache().clear();
  101.                     ButtonHandler.sendWear(player, slot);
  102.                     player.stopAll(false, true, false);
  103.                 }
  104.             }, passedTime >= 600 ? 0 : passedTime > 330 ? 1 : 0);
  105.             if (player.getSwitchItemCache().contains(slotId))
  106.                 return;
  107.             player.getSwitchItemCache().add(slotId);
  108.         }
  109.     }
  110.    
  111.     public static void dig(final Player player) {
  112.         player.resetWalkSteps();
  113.         player.setNextAnimation(new Animation(830));
  114.         player.lock();
  115.         WorldTasksManager.schedule(new WorldTask() {
  116.  
  117.             @Override
  118.             public void run() {
  119.                 player.unlock();
  120.                 if (Barrows.digIntoGrave(player))
  121.                     return;
  122.                 if(player.getX() == 3005 && player.getY() == 3376
  123.                         || player.getX() == 2999 && player.getY() == 3375
  124.                         || player.getX() == 2996 && player.getY() == 3377
  125.                         || player.getX() == 2989 && player.getY() == 3378
  126.                         || player.getX() == 2987 && player.getY() == 3387
  127.                         || player.getX() == 2984 && player.getY() == 3387) {
  128.                     if (ClueScrolls.digSpot(player)){
  129.                         return;
  130.                     }
  131.                     //mole
  132.                     player.setNextWorldTile(new WorldTile(1752, 5137, 0));
  133.                     player.getPackets().sendGameMessage("You seem to have dropped down into a network of mole tunnels.");
  134.                     return;
  135.                 }
  136.                 player.getPackets().sendGameMessage("You find nothing.");
  137.             }
  138.            
  139.         });
  140.     }
  141.  
  142.     public static void handleItemOption1(Player player, final int slotId,
  143.             final int itemId, Item item) {
  144.         long time = Utils.currentTimeMillis();
  145.         if (player.getLockDelay() >= time
  146.                 || player.getEmotesManager().getNextEmoteEnd() >= time)
  147.             return;
  148.         player.stopAll(false);
  149.         for (int i: ClueScrolls.ScrollIds){
  150.             if (itemId == i){
  151.                 if (ClueScrolls.Scrolls.getMap(itemId) != null){
  152.                     ClueScrolls.showMap(player, ClueScrolls.Scrolls.getMap(itemId));
  153.                     return;
  154.                 }
  155.                 if (ClueScrolls.Scrolls.getObjMap(itemId) != null){
  156.                     ClueScrolls.showObjectMap(player, ClueScrolls.Scrolls.getObjMap(itemId));
  157.                     return;
  158.                 }
  159.                 if (ClueScrolls.Scrolls.getRiddles(itemId) != null){
  160.                     ClueScrolls.showRiddle(player, ClueScrolls.Scrolls.getRiddles(itemId));
  161.                     return;
  162.                 }
  163.             }
  164.            
  165.         }
  166.         /*Mystery Box*/
  167.         if (itemId == 6199) {
  168.             int[] Common = {995, 4151}; //dont forget to put "," between item id's!
  169.             int[] Uncommon = {5764, 8764};
  170.             int[] Rare = {8773, 6273, 20000};
  171.             int[] SuperRare = {23948, 23423};
  172.             int[] Legendary = {23434, 23423};
  173.             player.getInventory().deleteItem(6199, 1);
  174.             int rarity = Utils.getRandom(1000);
  175.             if (rarity > 0 && rarity <= 600)  {
  176.                 int length = Common.length;
  177.                 length--;
  178.                 int reward = Utils.getRandom(length);
  179.                 player.getInventory().addItem(Common[reward], 1);
  180.             player.getPackets().sendGameMessage("You've recieved a Common item from the Mystery Box!");        
  181.             }
  182.             if (rarity > 600 && rarity <= 900)  {
  183.                 int length = Uncommon.length;
  184.                 length--;
  185.                 int reward = Utils.getRandom(length);
  186.                 player.getInventory().addItem(Uncommon[reward], 2);
  187.             player.getPackets().sendGameMessage("You've recieved a uncommon item from the Mystery Box!");
  188.             }
  189.             if (rarity > 900 && rarity <= 970)  {
  190.                 int length = Rare.length;
  191.                 length--;
  192.                 int reward = Utils.getRandom(length);
  193.                 player.getInventory().addItem(Rare[reward], 3);
  194.             player.getPackets().sendGameMessage("You've recieved a rare item from the Mystery Box!");
  195.             }
  196.             if (rarity > 970 && rarity <= 997)  {
  197.                 int length = SuperRare.length;
  198.                 length--;
  199.                 int reward = Utils.getRandom(length);
  200.                 player.getInventory().addItem(SuperRare[reward], 4);
  201.             player.getPackets().sendGameMessage("You've recieved a super rare item from the Mystery Box!");
  202.             }
  203.             if (rarity > 997 && rarity <= 1000)  {
  204.                 int length = Legendary.length;
  205.                 length--;
  206.                 int reward = Utils.getRandom(length);
  207.                 player.getInventory().addItem(Legendary[reward], 5);
  208.             player.getPackets().sendGameMessage("You've recieved a ultra rare item from the Mystery Box!");
  209.             }
  210.             return;
  211.             }
  212.                 if (itemId == 2717){
  213.                     ClueScrolls.giveReward(player);
  214.                 }
  215.         if (Foods.eat(player, item, slotId))
  216.             return;
  217.         if (itemId >= 15086 && itemId <= 15100) {
  218.             Dicing.handleRoll(player, itemId, false);
  219.             return;
  220.         }
  221.         if (Pots.pot(player, item, slotId))
  222.             return;
  223.         if (itemId >= 5509 && itemId <= 5514) {
  224.             int pouch = -1;
  225.             if (itemId == 5509)
  226.                 pouch = 0;
  227.             if (itemId == 5510)
  228.                 pouch = 1;
  229.             if (itemId == 5512)
  230.                 pouch = 2;
  231.             if (itemId == 5514)
  232.                 pouch = 3;
  233.             Runecrafting.fillPouch(player, pouch);
  234.             return;
  235.         }
  236.         if (itemId == 2520) {
  237.             ToyHorsey.play(player);
  238.         }
  239.         if (itemId == 2522) {
  240.             ToyHorsey.play(player);
  241.         }
  242.    
  243.         if (itemId == 2524) {
  244.             ToyHorsey.play(player);
  245.         }
  246.        
  247.         if (itemId == 2526) {
  248.             ToyHorsey.play(player);
  249.         }
  250.         if (itemId == 22370) {
  251.             Summoning.openDreadnipInterface(player);
  252.         }
  253.         if (itemId == 952) {// spade
  254.             dig(player);
  255.             return;
  256.         }
  257.         if (HerbCleaning.clean(player, item, slotId))
  258.             return;
  259.         Bone bone = Bone.forId(itemId);
  260.         if (bone != null) {
  261.             Bone.bury(player, slotId);
  262.             return;
  263.         }
  264.         if (Magic.useTabTeleport(player, itemId))
  265.             return;
  266.         if (itemId == AncientEffigies.SATED_ANCIENT_EFFIGY
  267.                 || itemId == AncientEffigies.GORGED_ANCIENT_EFFIGY
  268.                 || itemId == AncientEffigies.NOURISHED_ANCIENT_EFFIGY
  269.                 || itemId == AncientEffigies.STARVED_ANCIENT_EFFIGY)
  270.             player.getDialogueManager().startDialogue("AncientEffigiesD",
  271.                     itemId);
  272.         else if (itemId == 4155)
  273.             player.getDialogueManager().startDialogue("EnchantedGemDialouge");
  274.         else if (itemId >= 23653 && itemId <= 23658)
  275.             FightKiln.useCrystal(player, itemId);
  276.         else if (itemId == 1856) {// Information Book
  277.             player.getInterfaceManager().sendInterface(275);
  278.             player.getPackets()
  279.                     .sendIComponentText(275, 2, Settings.SERVER_NAME);
  280.             player.getPackets().sendIComponentText(275, 16,
  281.                     "Welcome to " + Settings.SERVER_NAME + ".");
  282.             player.getPackets().sendIComponentText(275, 17,
  283.                     "If want some an item use command ::item id.");
  284.             player.getPackets().sendIComponentText(275, 18,
  285.                     "If you don't have an item list you can find ids");
  286.             player.getPackets().sendIComponentText(275, 19,
  287.                     "at http://itemdb.biz");
  288.             player.getPackets().sendIComponentText(275, 20,
  289.                     "You can change your prayers and spells at home.");
  290.             player.getPackets().sendIComponentText(275, 21,
  291.                     "If you need any help, do ::ticket. (Don't abuse it)");
  292.             player.getPackets().sendIComponentText(275, 22,
  293.                     "at start of your message on public chat.");
  294.             player.getPackets().sendIComponentText(275, 22,
  295.                     "By the way you can compare your ::score with your mates.");
  296.             player.getPackets().sendIComponentText(275, 23,
  297.                     "Oh and ye, don't forget to ::vote and respect rules.");
  298.             player.getPackets().sendIComponentText(275, 24, "");
  299.             player.getPackets().sendIComponentText(275, 25,
  300.                     "Forums: " + Settings.WEBSITE_LINK);
  301.             player.getPackets().sendIComponentText(275, 26, "");
  302.             player.getPackets().sendIComponentText(275, 27,
  303.                     "Enjoy your time on " + Settings.SERVER_NAME + ".");
  304.             player.getPackets().sendIComponentText(275, 28,
  305.                     "<img=1> Staff Team");
  306.             player.getPackets().sendIComponentText(275, 29, "");
  307.             player.getPackets().sendIComponentText(275, 30, "");
  308.             player.getPackets().sendIComponentText(275, 14,
  309.                     "<u>Visit Website</u>");
  310.             for (int i = 31; i < 300; i++)
  311.                 player.getPackets().sendIComponentText(275, i, "");
  312.         } else if (itemId == HunterEquipment.BOX.getId()) // almost done
  313.             player.getActionManager().setAction(new BoxAction(HunterEquipment.BOX));
  314.         else if (itemId == HunterEquipment.BRID_SNARE.getId())
  315.             player.getActionManager().setAction(
  316.                     new BoxAction(HunterEquipment.BRID_SNARE));
  317.         else if (item.getDefinitions().getName().startsWith("Burnt"))
  318.             player.getDialogueManager().startDialogue("SimplePlayerMessage", "Ugh, this is inedible.");
  319.        
  320.         if (Settings.DEBUG)
  321.             Logger.log("ItemHandler", "Item Select:" + itemId + ", Slot Id:"
  322.                     + slotId);
  323.     }
  324.  
  325.     /*
  326.      * returns the other
  327.      */
  328.     public static Item contains(int id1, Item item1, Item item2) {
  329.         if (item1.getId() == id1)
  330.             return item2;
  331.         if (item2.getId() == id1)
  332.             return item1;
  333.         return null;
  334.     }
  335.  
  336.     public static boolean contains(int id1, int id2, Item... items) {
  337.         boolean containsId1 = false;
  338.         boolean containsId2 = false;
  339.         for (Item item : items) {
  340.             if (item.getId() == id1)
  341.                 containsId1 = true;
  342.             else if (item.getId() == id2)
  343.                 containsId2 = true;
  344.         }
  345.         return containsId1 && containsId2;
  346.     }
  347.  
  348.     public static void handleItemOnItem(final Player player, InputStream stream) {
  349.         int itemUsedWithId = stream.readShort();
  350.         int toSlot = stream.readShortLE128();
  351.         int interfaceId = stream.readInt() >> 16;
  352.         int interfaceId2 = stream.readInt() >> 16;
  353.         int fromSlot = stream.readShort();
  354.         int itemUsedId = stream.readShortLE128();
  355.         if ((interfaceId2 == 747 || interfaceId2 == 662)
  356.                 && interfaceId == Inventory.INVENTORY_INTERFACE) {
  357.             if (player.getFamiliar() != null) {
  358.                 player.getFamiliar().setSpecial(true);
  359.                 if (player.getFamiliar().getSpecialAttack() == SpecialAttack.ITEM) {
  360.                     if (player.getFamiliar().hasSpecialOn())
  361.                         player.getFamiliar().submitSpecial(toSlot);
  362.                 }
  363.             }
  364.             return;
  365.         }
  366.         if (interfaceId == Inventory.INVENTORY_INTERFACE
  367.                 && interfaceId == interfaceId2
  368.                 && !player.getInterfaceManager().containsInventoryInter()) {
  369.             if (toSlot >= 28 || fromSlot >= 28)
  370.                 return;
  371.             Item usedWith = player.getInventory().getItem(toSlot);
  372.             Item itemUsed = player.getInventory().getItem(fromSlot);
  373.             if (itemUsed == null || usedWith == null
  374.                     || itemUsed.getId() != itemUsedId
  375.                     || usedWith.getId() != itemUsedWithId)
  376.                 return;
  377.             player.stopAll();
  378.             if (!player.getControlerManager().canUseItemOnItem(itemUsed,
  379.                     usedWith))
  380.                 return;
  381.             Fletch fletch = Fletching.isFletching(usedWith, itemUsed);
  382.             if (fletch != null) {
  383.                 player.getDialogueManager().startDialogue("FletchingD", fletch);
  384.                 return;
  385.             }
  386.             int herblore = Herblore.isHerbloreSkill(itemUsed, usedWith);
  387.             if (herblore > -1) {
  388.                 player.getDialogueManager().startDialogue("HerbloreD",
  389.                         herblore, itemUsed, usedWith);
  390.                 return;
  391.             }
  392.             if (itemUsed.getId() == LeatherCrafting.NEEDLE.getId()
  393.                     || usedWith.getId() == LeatherCrafting.NEEDLE.getId()) {
  394.                 if (LeatherCrafting
  395.                         .handleItemOnItem(player, itemUsed, usedWith)) {
  396.                     return;
  397.                 }
  398.             }
  399.             Sets set = ArmourSets.getArmourSet(itemUsedId, itemUsedWithId);
  400.             if (set != null) {
  401.                 ArmourSets.exchangeSets(player, set);
  402.                 return;
  403.             }
  404.             if (Firemaking.isFiremaking(player, itemUsed, usedWith))
  405.                 return;
  406.             else if (contains(1755, Gem.OPAL.getUncut(), itemUsed, usedWith))
  407.                 GemCutting.cut(player, Gem.OPAL);
  408.             else if (contains(1755, Gem.JADE.getUncut(), itemUsed, usedWith))
  409.                 GemCutting.cut(player, Gem.JADE);
  410.             else if (contains(1755, Gem.RED_TOPAZ.getUncut(), itemUsed,
  411.                     usedWith))
  412.                 GemCutting.cut(player, Gem.RED_TOPAZ);
  413.             else if (contains(1755, Gem.SAPPHIRE.getUncut(), itemUsed, usedWith))
  414.                 GemCutting.cut(player, Gem.SAPPHIRE);
  415.             else if (contains(1755, Gem.EMERALD.getUncut(), itemUsed, usedWith))
  416.                 GemCutting.cut(player, Gem.EMERALD);
  417.             else if (contains(1755, Gem.RUBY.getUncut(), itemUsed, usedWith))
  418.                 GemCutting.cut(player, Gem.RUBY);
  419.             else if (contains(1755, Gem.DIAMOND.getUncut(), itemUsed, usedWith))
  420.                 GemCutting.cut(player, Gem.DIAMOND);
  421.             else if (contains(1755, Gem.DRAGONSTONE.getUncut(), itemUsed,
  422.                     usedWith))
  423.                 GemCutting.cut(player, Gem.DRAGONSTONE);
  424.             else if (contains(1755, Gem.ONYX.getUncut(), itemUsed, usedWith))
  425.                 GemCutting.cut(player, Gem.ONYX);
  426.             else
  427.                 player.getPackets().sendGameMessage(
  428.                         "Nothing interesting happens.");
  429.             if (Settings.DEBUG)
  430.                 Logger.log("ItemHandler", "Used:" + itemUsed.getId()
  431.                         + ", With:" + usedWith.getId());
  432.         }
  433.     }
  434.  
  435.     public static void handleItemOption3(Player player, int slotId, int itemId,
  436.             Item item) {
  437.         long time = Utils.currentTimeMillis();
  438.         if (player.getLockDelay() >= time
  439.                 || player.getEmotesManager().getNextEmoteEnd() >= time)
  440.             return;
  441.         player.stopAll(false);
  442.         if (itemId == 20767 || itemId == 20769 || itemId == 20771)
  443.             SkillCapeCustomizer.startCustomizing(player, itemId);
  444.         else if(itemId >= 15084 && itemId <= 15100)
  445.             player.getDialogueManager().startDialogue("DiceBag", itemId);
  446.         else if(itemId == 24437 || itemId == 24439 || itemId == 24440 || itemId == 24441)
  447.             player.getDialogueManager().startDialogue("FlamingSkull", item, slotId);
  448.         else if (Equipment.getItemSlot(itemId) == Equipment.SLOT_AURA)
  449.             player.getAuraManager().sendTimeRemaining(itemId);
  450.     }
  451.  
  452.     public static void handleItemOption4(Player player, int slotId, int itemId,
  453.             Item item) {
  454.         System.out.println("Option 4");
  455.     }
  456.  
  457.     public static void handleItemOption5(Player player, int slotId, int itemId,
  458.             Item item) {
  459.         System.out.println("Option 5");
  460.     }
  461.  
  462.     public static void handleItemOption6(Player player, int slotId, int itemId,
  463.             Item item) {
  464.         long time = Utils.currentTimeMillis();
  465.         if (player.getLockDelay() >= time
  466.                 || player.getEmotesManager().getNextEmoteEnd() >= time)
  467.             return;
  468.         player.stopAll(false);
  469.         Pouches pouches = Pouches.forId(itemId);
  470.         if (pouches != null)
  471.             Summoning.spawnFamiliar(player, pouches);
  472.         else if (itemId == 1438)
  473.             Runecrafting.locate(player, 3127, 3405);
  474.         else if (itemId == 1440)
  475.             Runecrafting.locate(player, 3306, 3474);
  476.         else if (itemId == 1442)
  477.             Runecrafting.locate(player, 3313, 3255);
  478.         else if (itemId == 1444)
  479.             Runecrafting.locate(player, 3185, 3165);
  480.         else if (itemId == 1446)
  481.             Runecrafting.locate(player, 3053, 3445);
  482.         else if (itemId == 1448)
  483.             Runecrafting.locate(player, 2982, 3514);
  484.         else if (itemId <= 1712 && itemId >= 1706 || itemId >= 10354
  485.                 && itemId <= 10362)
  486.             player.getDialogueManager().startDialogue("Transportation",
  487.                     "Edgeville", new WorldTile(3087, 3496, 0), "Karamja",
  488.                     new WorldTile(2918, 3176, 0), "Draynor Village",
  489.                     new WorldTile(3105, 3251, 0), "Al Kharid",
  490.                     new WorldTile(3293, 3163, 0), itemId);
  491.         else if (itemId == 995) {
  492.             if (item.getAmount() < 0) {
  493.                 return;
  494.             }
  495.             player.getMoneyPouch().handleMoneyPouch(false, false, false,
  496.                     player.getInventory().getNumberOf(995), 0);
  497.         }
  498.         else if (itemId == 1704 || itemId == 10352)
  499.             player.getPackets()
  500.                     .sendGameMessage(
  501.                             "The amulet has ran out of charges. You need to recharge it if you wish it use it once more.");
  502.         else if (itemId >= 3853 && itemId <= 3867)
  503.             player.getDialogueManager().startDialogue("Transportation",
  504.                     "Burthrope Games Room", new WorldTile(2880, 3559, 0),
  505.                     "Barbarian Outpost", new WorldTile(2519, 3571, 0),
  506.                     "Gamers' Grotto", new WorldTile(2970, 9679, 0),
  507.                     "Corporeal Beast", new WorldTile(2886, 4377, 0), itemId);
  508.     }
  509.  
  510.     public static void handleItemOption7(Player player, int slotId, int itemId,
  511.             Item item) {
  512.         long time = Utils.currentTimeMillis();
  513.         if (player.getLockDelay() >= time
  514.                 || player.getEmotesManager().getNextEmoteEnd() >= time)
  515.             return;
  516.         if (!player.getControlerManager().canDropItem(item))
  517.             return;
  518.         player.stopAll(false);
  519.         if (item.getDefinitions().isOverSized()) {
  520.             player.getPackets().sendGameMessage("The item appears to be oversized.");
  521.             player.getInventory().deleteItem(item);
  522.             return;
  523.         }
  524.         if (item.getDefinitions().isDestroyItem()) {
  525.             player.getDialogueManager().startDialogue("DestroyItemOption",
  526.                     slotId, item);
  527.             return;
  528.         }
  529.         if (player.getPetManager().spawnPet(itemId, true)) {
  530.             return;
  531.         }
  532.         player.getInventory().deleteItem(slotId, item);
  533.         if (player.getCharges().degradeCompletly(item))
  534.             return;
  535.         World.addGroundItem(item, new WorldTile(player), player, false, 180,
  536.                 true);
  537.         player.getPackets().sendSound(2739, 0, 1);
  538.     }
  539.    
  540.     public static void handleItemOption8(Player player, int slotId, int itemId,
  541.             Item item) {
  542.         player.getInventory().sendExamine(slotId);
  543.     }
  544.  
  545.     public static void handleItemOnNPC(final Player player, final NPC npc, final Item item) {
  546.         if (item == null) {
  547.             return;
  548.         }
  549.         player.setCoordsEvent(new CoordsEvent(npc, new Runnable() {
  550.             @Override
  551.             public void run() {
  552.                 if (!player.getInventory().containsItem(item.getId(), item.getAmount())) {
  553.                     return;
  554.                 }
  555.                 if (npc instanceof Pet) {
  556.                     player.faceEntity(npc);
  557.                     player.getPetManager().eat(item.getId(), (Pet) npc);
  558.                     return;
  559.                 }
  560.             }
  561.         }, npc.getSize()));
  562.     }
  563.  
  564. public static void handleItemOnPlayer(final Player player,
  565.         final Player usedOn, final int itemId) {
  566.     player.setCoordsEvent(new CoordsEvent(usedOn, new Runnable() {
  567.         public void run() {
  568.             player.faceEntity(usedOn);
  569.             if (usedOn.getInterfaceManager().containsScreenInter()) {
  570.                 player.getPackets().sendGameMessage(usedOn.getDisplayName() + " is busy at the moment.");
  571.                 return;
  572.             }
  573. //          if (!usedOn.hasAcceptAid()) {
  574. //              player.getPackets().sendGameMessage(usedOn.getDisplayName()
  575. //                      + " doesn't want to accept your items.");
  576. //              return;
  577. //          }
  578.             switch (itemId) {
  579.             case 962: // Christmas cracker
  580.                 if (player.getInventory().getFreeSlots() < 3
  581.                         || usedOn.getInventory().getFreeSlots() < 3) {
  582.                     player.getPackets().sendGameMessage((player.getInventory()
  583.                             .getFreeSlots() < 3 ? "You do"
  584.                             : "The other player does")
  585.                             + " not have enough inventory space to pull this cracker.");
  586.                     return;
  587.                 }
  588.                 player.getDialogueManager().startDialogue(
  589.                         "ChristmasCracker", usedOn, itemId);
  590.                 break;
  591.             default:
  592.                 player.getPackets().sendGameMessage("Nothing interesting happens.");
  593.                 break;
  594.             }
  595.         }
  596.     }, usedOn.getSize()));
  597. }
  598.  
  599. }
Add Comment
Please, Sign In to add comment