コード例 #1
0
        public void Save()
        {
            var toSave          = new Dictionary <ulong, PlayerCooldown>();
            var playerIds       = new HashSet <ulong>();
            var kitCooldowns    = CommandKit.Cooldowns;
            var globalCooldowns = CommandKit.GlobalCooldown;

            kitCooldowns.ForEach(k => playerIds.Add(k.Key));
            globalCooldowns.ForEach(k => playerIds.Add(k.Key));

            playerIds.ForEach(id => {
                ClearCooldowns(id);

                var pCooldown = new PlayerCooldown();
                kitCooldowns.TryGetValue(id, out pCooldown.Kits);
                globalCooldowns.TryGetValue(id, out pCooldown.Global);

                toSave.Add(id, pCooldown);
            });

            JsonUtil.Serialize(FilePath, toSave);
        }