mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 03:55:18 -04:00
Fix getting ranked to same rank multiple times, if spamming /buy rank and saving list takes a long time
This commit is contained in:
parent
be9145bd8d
commit
0129e4179a
@ -79,34 +79,37 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Changes the rank of the given player from the old to the new rank. </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary> Changes the rank of the given player from the old to the new rank. </summary>
|
||||
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)) {
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user