From 4a6f46d62621f08d21d27c15fcec5645965aea18 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 1 Mar 2017 10:45:34 +1100 Subject: [PATCH] Fix empty teams not being removed. (Thanks goodlyay) --- MCGalaxy/Commands/Fun/CmdTeam.cs | 4 ++++ MCGalaxy/Games/Team.cs | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/MCGalaxy/Commands/Fun/CmdTeam.cs b/MCGalaxy/Commands/Fun/CmdTeam.cs index 447f94345..ad4bf0606 100644 --- a/MCGalaxy/Commands/Fun/CmdTeam.cs +++ b/MCGalaxy/Commands/Fun/CmdTeam.cs @@ -89,6 +89,8 @@ namespace MCGalaxy.Commands { who.Game.Team = null; who.SetPrefix(); } + + team.RemoveIfEmpty(); Team.SaveList(); } else { Player.Message(p, "The given player was not found. You need to use their full account name."); @@ -168,6 +170,8 @@ namespace MCGalaxy.Commands { team.Action(p, "left the team."); team.Remove(p.name); p.Game.Team = null; + + team.RemoveIfEmpty(); p.SetPrefix(); Team.SaveList(); } diff --git a/MCGalaxy/Games/Team.cs b/MCGalaxy/Games/Team.cs index fa70f525d..67f1dd534 100644 --- a/MCGalaxy/Games/Team.cs +++ b/MCGalaxy/Games/Team.cs @@ -60,7 +60,12 @@ namespace MCGalaxy.Games { Members.RemoveAt(i); return true; } return false; - } + } + + public void RemoveIfEmpty() { + if (Members.Count > 0) return; + TeamsList.Remove(Name); + } public void UpdatePrefix() { foreach (string name in Members) {