diff --git a/MCGalaxy/Commands/Moderation/ModActionCmd.cs b/MCGalaxy/Commands/Moderation/ModActionCmd.cs index 07bc3d569..c2fe1fee9 100644 --- a/MCGalaxy/Commands/Moderation/ModActionCmd.cs +++ b/MCGalaxy/Commands/Moderation/ModActionCmd.cs @@ -79,34 +79,37 @@ namespace MCGalaxy.Commands.Moderation { } } - /// Changes the rank of the given player from the old to the new rank. - internal static void ChangeRank(string name, Group oldRank, Group newRank, - Player who, bool saveToNewRank = true) { - Server.reviewlist.Remove(name); - oldRank.Players.Remove(name); - oldRank.Players.Save(); - - if (saveToNewRank) { - newRank.Players.Add(name); - newRank.Players.Save(); - } - if (who == null) return; - - Entities.DespawnEntities(who, false); - string dbCol = PlayerDB.FindColor(who); - if (dbCol.Length == 0) who.color = newRank.Color; - + static void ChangeOnlineRank(Player who, Group newRank) { who.group = newRank; who.AllowBuild = who.level.BuildAccess.CheckAllowed(who); if (who.hidden && who.hideRank < who.Rank) who.hideRank = who.Rank; + // If player has explicit /color, don't change it + string dbCol = PlayerDB.FindColor(who); + if (dbCol.Length == 0) who.color = newRank.Color; who.SetPrefix(); + + Entities.DespawnEntities(who, false); who.Send(Packet.UserType(who)); who.SendCurrentBlockPermissions(); Entities.SpawnEntities(who, false); CheckBlockBindings(who); } + /// Changes the rank of the given player from the old to the new rank. + internal static void ChangeRank(string name, Group oldRank, Group newRank, + Player who, bool saveToNewRank = true) { + if (who != null) ChangeOnlineRank(who, newRank); + Server.reviewlist.Remove(name); + + oldRank.Players.Remove(name); + oldRank.Players.Save(); + + if (!saveToNewRank) return; + newRank.Players.Add(name); + newRank.Players.Save(); + } + static void CheckBlockBindings(Player who) { BlockID block = who.ModeBlock; if (block != Block.Invalid && !CommandParser.IsBlockAllowed(who, "place", block)) { diff --git a/MCGalaxy/Economy/RankItem.cs b/MCGalaxy/Economy/RankItem.cs index f19fa0a73..160ee36d8 100644 --- a/MCGalaxy/Economy/RankItem.cs +++ b/MCGalaxy/Economy/RankItem.cs @@ -92,10 +92,10 @@ namespace MCGalaxy.Eco { p.Message("%WYou don't have enough &3" + Server.Config.Currency + " %Wto buy the next rank"); return; } - string rankName = Group.Find(nextRank.Perm).Name; // TODO: What if null reference happens here - Command.Find("SetRank").Use(Player.Console, p.name + " " + rankName); - p.Message("You bought the rank " + p.group.ColoredName); - Economy.MakePurchase(p, nextRank.Price, "&3Rank: " + p.group.ColoredName); + Group rank = Group.Find(nextRank.Perm); // TODO: What if null reference happens here + Command.Find("SetRank").Use(Player.Console, p.name + " " + rank.Name); + p.Message("You bought the rank " + rank.ColoredName); + Economy.MakePurchase(p, nextRank.Price, "&3Rank: " + rank.ColoredName); } protected internal override void OnSetupCommand(Player p, string[] args) {