Fix empty teams not being removed. (Thanks goodlyay)

This commit is contained in:
UnknownShadow200 2017-03-01 10:45:34 +11:00
parent cc5550fd8d
commit 4a6f46d626
2 changed files with 10 additions and 1 deletions

View File

@ -89,6 +89,8 @@ namespace MCGalaxy.Commands {
who.Game.Team = null; who.Game.Team = null;
who.SetPrefix(); who.SetPrefix();
} }
team.RemoveIfEmpty();
Team.SaveList(); Team.SaveList();
} else { } else {
Player.Message(p, "The given player was not found. You need to use their full account name."); 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.Action(p, "left the team.");
team.Remove(p.name); team.Remove(p.name);
p.Game.Team = null; p.Game.Team = null;
team.RemoveIfEmpty();
p.SetPrefix(); p.SetPrefix();
Team.SaveList(); Team.SaveList();
} }

View File

@ -60,7 +60,12 @@ namespace MCGalaxy.Games {
Members.RemoveAt(i); return true; Members.RemoveAt(i); return true;
} }
return false; return false;
} }
public void RemoveIfEmpty() {
if (Members.Count > 0) return;
TeamsList.Remove(Name);
}
public void UpdatePrefix() { public void UpdatePrefix() {
foreach (string name in Members) { foreach (string name in Members) {