mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 20:16:36 -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>
|
static void ChangeOnlineRank(Player who, Group newRank) {
|
||||||
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;
|
|
||||||
|
|
||||||
who.group = newRank;
|
who.group = newRank;
|
||||||
who.AllowBuild = who.level.BuildAccess.CheckAllowed(who);
|
who.AllowBuild = who.level.BuildAccess.CheckAllowed(who);
|
||||||
if (who.hidden && who.hideRank < who.Rank) who.hideRank = who.Rank;
|
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();
|
who.SetPrefix();
|
||||||
|
|
||||||
|
Entities.DespawnEntities(who, false);
|
||||||
who.Send(Packet.UserType(who));
|
who.Send(Packet.UserType(who));
|
||||||
who.SendCurrentBlockPermissions();
|
who.SendCurrentBlockPermissions();
|
||||||
Entities.SpawnEntities(who, false);
|
Entities.SpawnEntities(who, false);
|
||||||
CheckBlockBindings(who);
|
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) {
|
static void CheckBlockBindings(Player who) {
|
||||||
BlockID block = who.ModeBlock;
|
BlockID block = who.ModeBlock;
|
||||||
if (block != Block.Invalid && !CommandParser.IsBlockAllowed(who, "place", block)) {
|
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;
|
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
|
Group rank = Group.Find(nextRank.Perm); // TODO: What if null reference happens here
|
||||||
Command.Find("SetRank").Use(Player.Console, p.name + " " + rankName);
|
Command.Find("SetRank").Use(Player.Console, p.name + " " + rank.Name);
|
||||||
p.Message("You bought the rank " + p.group.ColoredName);
|
p.Message("You bought the rank " + rank.ColoredName);
|
||||||
Economy.MakePurchase(p, nextRank.Price, "&3Rank: " + p.group.ColoredName);
|
Economy.MakePurchase(p, nextRank.Price, "&3Rank: " + rank.ColoredName);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal override void OnSetupCommand(Player p, string[] args) {
|
protected internal override void OnSetupCommand(Player p, string[] args) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user