Beispiel #1
0
        public void AddOrIgnoreDetails(Auction a)
        {
            var id = NBT.ItemID(a.ItemBytes);

            if (id == null)
            {
                if (a.ItemName == "Revive Stone")
                {
                    // known item, has no tag, nothing to do
                    return;
                }
                Logger.Instance.Error($"item has no tag {JsonConvert.SerializeObject(a)}");
                return;
            }

            var name = ItemReferences.RemoveReforgesAndLevel(a.ItemName);

            if (ToFillDetails.TryRemove(id, out DBItem i))
            {
                Console.WriteLine("Filling details for " + i.Tag + i.Id);
                AddNewItem(a, name, id, i);
                return;
            }
            if (Items.ContainsKey(id))
            {
                var tragetItem = Items[id];
                if (tragetItem.AltNames == null)
                {
                    tragetItem.AltNames = new HashSet <string>();
                }

                // try to get shorter lore
                if (Items[id]?.Description?.Length > a?.ItemLore?.Length && a.ItemLore.Length > 10)
                {
                    Items[id].Description = a.ItemLore;
                }
                tragetItem.AltNames.Add(name);
                return;
            }
            // legacy item names
            if (Items.ContainsKey(name))
            {
                var item = Items[name];
                item.Id = id;
                if (item.AltNames == null)
                {
                    item.AltNames = new HashSet <string>();
                }
                item.AltNames.Add(name);
                Items[id] = item;
                Items.Remove(name);

                return;
            }

            // new item, add it
            AddNewItem(a, name, id, i);
        }
Beispiel #2
0
        private static void ProcessAuction(HypixelContext context, Dictionary <string, SaveAuction> inDb, BidComparer comparer, SaveAuction auction)
        {
            try
            {
                var id = auction.Uuid;
                MigrateAuction(auction);

                if (inDb.TryGetValue(id, out SaveAuction dbauction))
                {
                    UpdateAuction(context, comparer, auction, dbauction);
                }
                else
                {
                    if (auction.AuctioneerId == null)
                    {
                        Logger.Instance.Error($"auction removed bevore in db " + auction.Uuid);
                        return;
                    }
                    context.Auctions.Add(auction);
                    try
                    {
                        auction.NBTLookup = NBT.CreateLookup(auction.NbtData);
                    }
                    catch (Exception e)
                    {
                        Logger.Instance.Error($"Error on CreateLookup: {e.Message} \n{e.StackTrace} \n{JSON.Stringify(auction.NbtData.Data)}");
                        throw e;
                    }
                }

                count++;
                if (!minimumOutput && count % 5 == 0)
                {
                    Console.Write($"\r         Indexed: {count} Saved: {StorageManager.SavedOnDisc} \tcache: {StorageManager.CacheItems}  NameRequests: {Program.RequestsSinceStart}");
                }
            }
            catch (Exception e)
            {
                Logger.Instance.Error($"Error {e.Message} on {auction.ItemName} {auction.Uuid} from {auction.AuctioneerId}");
                Logger.Instance.Error(e.StackTrace);
            }
        }
Beispiel #3
0
        public static void GrabAuctions(HypixelApi hypixelApi)
        {
            var expired  = hypixelApi.getAuctionsEnded();
            var auctions = expired.Auctions.Select(item =>
            {
                var a = new SaveAuction()
                {
                    Uuid         = item.Uuid,
                    AuctioneerId = item.Seller,
                    Bids         = new List <SaveBids>()
                    {
                        new SaveBids()
                        {
                            Amount    = item.Price,
                            Bidder    = item.Buyer,
                            Timestamp = item.TimeStamp,
                            ProfileId = "unknown"
                        }
                    },
                    HighestBidAmount = item.Price,
                    Bin = item.BuyItemNow,
                    End = DateTime.Now,
                    UId = AuctionService.Instance.GetId(item.Uuid)
                };

                NBT.FillDetails(a, item.ItemBytes);
                return(a);
            }).ToList();

            SoldLastMin = auctions;
            Indexer.AddToQueue(auctions);

            Task.Run(() =>
            {
                foreach (var item in auctions)
                {
                    SubscribeEngine.Instance.BinSold(item);
                    Flipper.FlipperEngine.Instance.AuctionSold(item);
                }
            }).ConfigureAwait(false);
            Console.WriteLine($"Updated {expired.Auctions.Count} bin sells eg {expired.Auctions.First().Uuid}");
        }
Beispiel #4
0
 private static void SetIconUrl(Auction a, IItem i)
 {
     if (i.MinecraftType == "skull")
     {
         try
         {
             i.IconUrl = $"https://mc-heads.net/head/{Path.GetFileName(NBT.SkullUrl(a.ItemBytes))}/50";
         }
         catch (Exception e)
         {
             Console.WriteLine($"Error :O \n {e.Message} \n {e.StackTrace}");
         }
         // Console.WriteLine(i.IconUrl);
     }
     else
     {
         var t = MinecraftTypeParser.Instance.GetDetails(i.MinecraftType);
         i.IconUrl = $"https://sky.coflnet.com/static/{t?.type}-{t?.meta}.png";
     }
 }
Beispiel #5
0
        public SaveAuction(Hypixel.NET.SkyblockApi.Auction auction)
        {
            ClaimedBids = auction.ClaimedBidders.Select(s => new UuId((string)s)).ToList();
            Claimed     = auction.Claimed;
            //ItemBytes = auction.ItemBytes;
            StartingBid = auction.StartingBid;
            if (Enum.TryParse(auction.Tier, true, out Tier tier))
            {
                Tier = tier;
            }
            else
            {
                OldTier = auction.Tier;
            }
            if (Enum.TryParse(auction.Category, true, out Category category))
            {
                Category = category;
            }
            else
            {
                OldCategory = auction.Category;
            }
            // make sure that the lenght is shorter than max
            ItemName = auction.ItemName;
            End      = auction.End;
            Start    = auction.Start;
            Coop     = auction.Coop;

            ProfileId        = auction.ProfileId == auction.Auctioneer ? null : auction.ProfileId;
            AuctioneerId     = auction.Auctioneer;
            Uuid             = auction.Uuid;
            HighestBidAmount = auction.HighestBidAmount;
            Bids             = new List <SaveBids>();
            foreach (var item in auction.Bids)
            {
                Bids.Add(new SaveBids(item));
            }
            NBT.FillDetails(this, auction.ItemBytes);
            Bin = auction.BuyItNow; // missing from nuget package
            UId = AuctionService.Instance.GetId(auction.Uuid);
        }
        public async Task DoBatch()
        {
            await Task.Delay(TimeSpan.FromMinutes(5));

            var batchSize = 2000;

            using (var context = new HypixelContext())
            {
                var select = context.Auctions
                             .Where(a => a.Id < minId)
                             .OrderByDescending(a => a.Id)
                             .Include(a => a.NBTLookup)
                             .Include(a => a.NbtData)
                             .Take(batchSize);
                foreach (var auction in select)
                {
                    if (auction.NBTLookup != null && auction.NBTLookup.Count > 0)
                    {
                        continue;
                    }
                    try
                    {
                        auction.NBTLookup = NBT.CreateLookup(auction.NbtData);
                        context.Update(auction);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine($"could not generate nbtlookup for {auction.Uuid} {e.Message} \n{e.StackTrace} \n {e.InnerException?.Message} {e.InnerException.StackTrace}");
                    }
                }
                int updated = await context.SaveChangesAsync();

                Console.WriteLine($"updated nbt lookup for {updated} auctions, highest: {minId}");
                minId -= batchSize;
            }
        }
Beispiel #7
0
 public NbtFile Content()
 {
     return(NBT.File(data, NbtCompression.None));
 }
Beispiel #8
0
 public void SetData(NbtFile data)
 {
     this.data = NBT.Extra(data);
 }
Beispiel #9
0
 public void SetData(string data)
 {
     this.data = NBT.Extra(data);
 }
Beispiel #10
0
        /// <summary>
        /// returns true if application should be closed
        /// </summary>
        /// <param name="mode"></param>
        /// <returns></returns>
        static bool runSubProgram(char mode)
        {
            switch (mode)
            {
            case 't':
                // test
                //NotificationService.Instance.NotifyAsync("dPRj0dnG2NcY_kMTdNbpjz:APA91bHJINgv1SjuUlv-sGM21wLlHX5ISC5nYgl8DKP2r0fm273Cs0ujcESW6NR1RyGvFDtTBdQLK0SSq5TY_guLgc57VylKk8AAnH_xKq3zDIrdA1F6UhJNTu-Q0wNDKKIIQkYoVcyj","test","click me","https://sky.coflnet.com").Wait();
                SetGoogleIdCommand.ValidateToken("eyJhbGciOiJSUzI1NiIsImtpZCI6IjI1MmZjYjk3ZGY1YjZiNGY2ZDFhODg1ZjFlNjNkYzRhOWNkMjMwYzUiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiYXpwIjoiNTcwMzAyODkwNzYwLW5sa2dkOTliNzFxNGQ2MWFtNGxwcWRoZW4xcGVuZGR0LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiYXVkIjoiNTcwMzAyODkwNzYwLW5sa2dkOTliNzFxNGQ2MWFtNGxwcWRoZW4xcGVuZGR0LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwic3ViIjoiMTAxOTkzNTcwNzI0MDg4NDMyMjk4IiwiZW1haWwiOiJ0by5jb2ZsbmV0QGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJhdF9oYXNoIjoiYWdLN21RM2YySFZQclZNQ3l1UVVmdyIsIm5hbWUiOiJFa3dhdiBDb2ZsbmV0IiwicGljdHVyZSI6Imh0dHBzOi8vbGgzLmdvb2dsZXVzZXJjb250ZW50LmNvbS9hLS9BT2gxNEdobEx6TjV5U1o3VDZWYnpYRnFhUlR4c3dNRXJLaW1VQk1uem41Nz1zOTYtYyIsImdpdmVuX25hbWUiOiJFa3dhdiIsImZhbWlseV9uYW1lIjoiQ29mbG5ldCIsImxvY2FsZSI6ImRlIiwiaWF0IjoxNjEwMjk4MTE5LCJleHAiOjE2MTAzMDE3MTksImp0aSI6ImIzMWYzODUwNDMwYjNhOWMxNTQ5YTRjMDFiNTFiNTBlZjBhZTkwYTAifQ.cvsqp0GaYca---qkBAm-nS3QI-x_ZTGkzZh7sk-SsYctubikHqJz9VpafY_ih88ouOFTg_CWHKPMvS9dTrR8T4W_iY65cYp2hxsc-iMignDBgxbP6KlUCm3MvpRTHTdLAtL3Eq4JeXAL6_BN21AetRMaOhsWMgvz6yprhTkirOgFSuDt386Q8NXr19csjDhAW6bb2bRwEYJp4ZlBXD77zfzP_kZaF2y671M_lZUXnrqKrDqF7sFL2Jx4r6htKV_e86IuKhx0N1ttNTuEOeqccIZHdRQasivVO9Nq0twjhFIWn-5-azkPyz0VstxzIuYc7mTi2LSVjF4QDl-aLiOlPQ");
                break;

            case 'b':
                //var key = System.Text.Encoding.UTF8.GetString (FileController.ReadAllBytes ("apiKey")).Trim ();
                BazaarUpdater.NewUpdate(apiKey).Wait();
                break;

            case 'f':
                FullServer();
                break;

            case 's':
                var server = new Server();
                server.Start().Wait();
                break;

            case 'u':
                var updater = new Updater(apiKey);
                updater.Update().Wait();
                break;

            case '7':
                displayMode = false;
                StorageManager.Migrate();
                var auction = StorageManager.GetOrCreateAuction("00e45a19c27848829612be8edf53bd71");
                Console.WriteLine(auction.ItemName);
                //Console.WriteLine(ItemReferences.RemoveReforges("Itchy Bat man"));
                break;

            case 'i':
                Flipper.FlipperEngine.Instance.Test();
                break;

            case 'p':
                Indexer.LastHourIndex().Wait();
                //StorageManager.Migrate();
                break;

            case 'n':
                Console.WriteLine(NBT.Pretty("H4sIAAA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JYq8B6okQg5DkP4PnF5MvJybtJJb/AXg4OBqfn48vRNE+yCi/MTUfzHNPykKQPfLO207RYWyIrl2Ezi7SIaf2m1/mCmxBknRWrPJ0Vq2y0l6GqHpe1gD0L8t0ufqrzx902BrpOV7OMVL3mLbvddjtOHTvYrrfsZrfOXR/rnPdmlt12vRl3yZ3LhYimZtXIfYPSJF1IuxnPYbO713D2GhZr922bDd4CrMCzxy7Dvy+PLTX1BQAA"));
                //Console.WriteLine (JsonConvert.SerializeObject (.Instance.Items.Where (item => item.Value.AltNames != null && item.Value.AltNames.Count > 3 && !item.Key.Contains("DRAGON")).Select((item)=>new P(item.Value))));
                break;

            case 'g':
                var ds = new DataSyncer();
                ds.Sync("e5bac11a8cc04ca4bae539aed6500823");
                break;

            case 'm':
                Migrator.Migrate();
                break;

            default:
                return(true);
            }
            return(false);
        }