public void Run() { foreach (var i in filter) { ref var mess = ref filter.Get1(i); if (commands.IsCommand(mess.FirstWord, commands.Hats) == false) { continue; } if (!runtimeData.IsSavedPlayer(mess.Sender)) { SendMessage($"@{mess.Sender} , your character not spawned. Type {commands.Enter[0]}"); } else if (string.IsNullOrEmpty(mess.Args)) { if (runtimeData.IsSavedPlayer(mess.Sender)) { var playerStats = runtimeData.GetSavedPlayer(mess.Sender); var hats = PrintHatsList(playerStats); var text = playerStats.Hats.Count == 0 ? "no have hats." : $"your hats: {hats}"; SendMessage($"@{playerStats.Name} {text}"); } } else if (int.TryParse(mess.Args, out var hatIndex)) { --hatIndex; if (runtimeData.ContainsPlayer(mess.Sender)) { var playerEnt = runtimeData.GetPlayer(mess.Sender); ref var hatChanger = ref playerEnt.Set <ChangeHatComponent>(); hatChanger.HatIndex = hatIndex; } else { var playerStats = runtimeData.GetSavedPlayer(mess.Sender); playerStats.CurrentHatIndex = hatIndex; } }