Exemple #1
0
        private void OnNewSave(string filename)
        {
            // Ensure config is loaded
            LoadConfig();

            if (!_config.ClearBackpacksOnWipe)
            {
                return;
            }

            _backpacks.Clear();

            IEnumerable <string> fileNames = Interface.Oxide.DataFileSystem.GetFiles(Name)
                                             .Select(fn => {
                return(fn.Split(Path.DirectorySeparatorChar).Last()
                       .Replace(".json", string.Empty));
            });

            foreach (var fileName in fileNames)
            {
                ulong userId;

                if (!ulong.TryParse(fileName, out userId))
                {
                    continue;
                }

                var backpack = new Backpack(userId);
                backpack.SaveData();
            }

            PrintWarning("New save created. All backpacks were cleared. This can be disabled in the configuration file.");
        }
Exemple #2
0
        private void OnNewSave(string filename)
        {
            // Ensure config is loaded
            LoadConfig();

            if (!_config.ClearBackpacksOnWipe)
            {
                return;
            }

            _backpacks.Clear();

            IEnumerable <string> fileNames = Interface.Oxide.DataFileSystem.GetFiles(Name)
                                             .Select(fn => {
                return(fn.Split(Path.DirectorySeparatorChar).Last()
                       .Replace(".json", string.Empty));
            });

            int skippedBackpacks = 0;

            foreach (var fileName in fileNames)
            {
                ulong userId;

                if (!ulong.TryParse(fileName, out userId))
                {
                    continue;
                }

                if (permission.UserHasPermission(fileName, KeepOnWipePermission))
                {
                    skippedBackpacks++;
                    continue;
                }

                var backpack = new Backpack(userId);
                backpack.SaveData();
            }

            string skippedBackpacksMessage = skippedBackpacks > 0 ? $", except {skippedBackpacks} due to being exempt" : string.Empty;

            PrintWarning($"New save created. All backpacks were cleared{skippedBackpacksMessage}. Players with the '{KeepOnWipePermission}' permission are exempt. Clearing backpacks can be disabled for all players in the configuration file.");
        }