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.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();
}

View File

@ -62,6 +62,11 @@ namespace MCGalaxy.Games {
return false;
}
public void RemoveIfEmpty() {
if (Members.Count > 0) return;
TeamsList.Remove(Name);
}
public void UpdatePrefix() {
foreach (string name in Members) {
Player p = PlayerInfo.FindExact(name);