コード例 #1
0
        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");
        }