protected static int getFishToAdd(Player p, Spot fishingSpot)
        {
            int fishingLevel = p.getSkills().getGreaterLevel(Skills.SKILL.FISHING);

            int[] canCatch = new int[fishingSpot.getFish().Length];
            int   j        = 0;

            for (int i = 0; i < fishingSpot.getFish().Length; i++)
            {
                if (fishingLevel >= fishingSpot.getLevel()[i])
                {
                    canCatch[j] = fishingSpot.getFish()[i];
                    j++;
                }
            }
            int[] canCatch2 = new int[j];
            for (int i = 0; i < canCatch.Length; i++)
            {
                if (canCatch[i] > 0)
                {
                    canCatch2[i] = canCatch[i];
                }
            }
            int fish = misc.random(canCatch2.Length - 1);

            for (int i = 0; i < fishingSpot.getFish().Length; i++)
            {
                if (fish == fishingSpot.getFish()[i])
                {
                    return(i);
                }
            }
            return(misc.random(canCatch2.Length - 1));
        }
        private static void startFishing(Player p, int i, Npc npc, bool newFish, bool secondOption)
        {
            if (!newFish && p.getTemporaryAttribute("fishingSpot") == null)
            {
                return;
            }
            if (newFish)
            {
                int      j     = secondOption ? 1 : 0;
                int[]    fish  = secondOption ? SECOND_SPOT_FISH[i] : FIRST_SPOT_FISH[i];
                int[]    level = secondOption ? SECOND_SPOT_LEVEL[i] : FIRST_SPOT_LEVEL[i];
                double[] xp    = secondOption ? SECOND_SPOT_XP[i] : FIRST_SPOT_XP[i];
                p.setTemporaryAttribute("fishingSpot", new Spot(fish, level, i, SPOT_IDS[i], xp, npc.getLocation(), PRIMARY_ITEM[i][j], SECONDARY_ITEM[i][j], PRIMARY_NAME[i][j], SECONDARY_NAME[i][j], secondOption));
            }
            Spot fishingSpot = (Spot)p.getTemporaryAttribute("fishingSpot");
            int  k           = fishingSpot.isSecondOption() ? 1 : 0;
            int  index       = getFishToAdd(p, fishingSpot);

            if (!canFish(p, fishingSpot, null, index))
            {
                resetFishing(p);
                p.setLastAnimation(new Animation(65535));
                return;
            }
            if (newFish)
            {
                p.getPackets().sendMessage("You attempt to catch a fish...");
                p.setLastAnimation(new Animation(FISHING_ANIMATION[i][k]));
            }
            string name           = fishingSpot.isSecondOption() ? SECOND_CATCH_NAME[fishingSpot.getSpotindex()][index] : FIRST_CATCH_NAME[fishingSpot.getSpotindex()][index];
            string s              = fishingSpot.getSpotindex() == 1 && !fishingSpot.isSecondOption() ? "some" : "a";
            Event  doFishingEvent = new Event(getFishingDelay(p, fishingSpot));

            doFishingEvent.setAction(() => {
                doFishingEvent.stop();
                if (p.getTemporaryAttribute("fishingSpot") == null)
                {
                    resetFishing(p);
                    p.setLastAnimation(new Animation(65535));
                    return;
                }
                Spot fishingSpot2 = (Spot)p.getTemporaryAttribute("fishingSpot");
                if (!canFish(p, fishingSpot, fishingSpot2, index))
                {
                    resetFishing(p);
                    p.setLastAnimation(new Animation(65535));
                    return;
                }
                p.getPackets().closeInterfaces();
                p.getInventory().deleteItem(fishingSpot2.getSecondaryItem());
                p.setLastAnimation(new Animation(FISHING_ANIMATION2[fishingSpot2.getSpotindex()][k]));
                p.getPackets().sendMessage("You catch " + s + " " + name + ".");
                if (p.getInventory().addItem(fishingSpot2.getFish()[index]))
                {
                    p.getSkills().addXp(Skills.SKILL.FISHING, fishingSpot2.getFishingXp()[index]);
                }
                startFishing(p, i, null, false, secondOption);
            });
            Server.registerEvent(doFishingEvent);
        }
 protected static int getFishToAdd(Player p, Spot fishingSpot)
 {
     int fishingLevel = p.getSkills().getGreaterLevel(Skills.SKILL.FISHING);
     int[] canCatch = new int[fishingSpot.getFish().Length];
     int j = 0;
     for (int i = 0; i < fishingSpot.getFish().Length; i++) {
         if (fishingLevel >= fishingSpot.getLevel()[i]) {
             canCatch[j] = fishingSpot.getFish()[i];
             j++;
         }
     }
     int[] canCatch2 = new int[j];
     for (int i = 0; i < canCatch.Length; i++) {
         if (canCatch[i] > 0) {
             canCatch2[i] = canCatch[i];
         }
     }
     int fish = misc.random(canCatch2.Length-1);
     for (int i = 0; i < fishingSpot.getFish().Length; i++) {
         if (fish == fishingSpot.getFish()[i]) {
             return i;
         }
     }
     return misc.random(canCatch2.Length-1);
 }