<commit_before>using System;
using System.Collections.Generic;
using System.IO;
using Terraria.ModLoader;

namespace Terraria.ModLoader.Default
{
	public class MysteryPlayer : ModPlayer
	{
		private IList<UnloadedData> data = new List<UnloadedData>();

		internal void AddData(string mod, string name, byte[] newData)
		{
			data.Add(new UnloadedData(mod, name, newData));
		}

		internal void RestoreData(Player player)
		{
			int k = 0;
			while (k < data.Count)
			{
				Mod mod = ModLoader.GetMod(data[k].modName);
				ModPlayer modPlayer = mod == null ? null : player.GetModPlayer(mod, data[k].name);
				if (modPlayer == null)
				{
					k++;
				}
				else
				{
					using (MemoryStream memoryStream = new MemoryStream(data[k].data))
					{
						using (BinaryReader reader = new BinaryReader(memoryStream))
						{
							modPlayer.LoadCustomData(reader);
						}
					}
					data.RemoveAt(k);
				}
			}
		}

		public override void SaveCustomData(BinaryWriter writer)
		{
			if (data.Count > 0)
			{
				writer.Write((ushort)data.Count);
				foreach (UnloadedData unloadedData in data)
				{
					writer.Write(unloadedData.modName);
					writer.Write(unloadedData.name);
					writer.Write((ushort)unloadedData.data.Length);
					writer.Write(unloadedData.data);
				}
			}
		}

		public override void LoadCustomData(BinaryReader reader)
		{
			int count = reader.ReadUInt16();
			for (int k = 0; k < count; k++)
			{
				string modName = reader.ReadString();
				string name = reader.ReadString();
				byte[] unloadedData = reader.ReadBytes(reader.ReadUInt16());<commit_msg>:angry: Stupid Bug.<commit_after>using System;
using System.Collections.Generic;
using System.IO;
using Terraria.ModLoader;

namespace Terraria.ModLoader.Default
{
	public class MysteryPlayer : ModPlayer
	{
		private IList<UnloadedData> data = new List<UnloadedData>();

		internal void AddData(string mod, string name, byte[] newData)
		{
			data.Add(new UnloadedData(mod, name, newData));
		}

		internal void RestoreData(Player player)
		{
			int k = 0;
			while (k < data.Count)
			{
				Mod mod = ModLoader.GetMod(data[k].modName);
				ModPlayer modPlayer = mod == null ? null : player.GetModPlayer(mod, data[k].name);
				if (modPlayer == null)
				{
					k++;
				}
				else
				{
					using (MemoryStream memoryStream = new MemoryStream(data[k].data))
					{
						using (BinaryReader reader = new BinaryReader(memoryStream))
						{
							modPlayer.LoadCustomData(reader);
						}
					}
					data.RemoveAt(k);
				}
			}
		}

		public override void SaveCustomData(BinaryWriter writer)
		{
			if (data.Count > 0)
			{
				writer.Write((ushort)data.Count);
				foreach (UnloadedData unloadedData in data)
				{
					writer.Write(unloadedData.modName);
					writer.Write(unloadedData.name);
					writer.Write((ushort)unloadedData.data.Length);
					writer.Write(unloadedData.data);
				}
			}
			data.Clear();
		}

		public override void LoadCustomData(BinaryReader reader)
		{
			data.Clear();
			int count = reader.ReadUInt16();
			for (int k = 0; k < count; k++)
			{
				string modName = reader.ReadString();
				string name = reader.ReadString();
				byte[] unloadedData = reader.ReadBytes(reader.ReadUInt16());
{'fraction_non_alphanumeric': 0.12188279301745636, 'fraction_numerical': 0.004364089775561097, 'mean_word_length': 3.1675324675324674, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6344868', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1023, 'n_words': 223}