mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Combine fakerank/hackrank shared code
This commit is contained in:
parent
b062fbefa4
commit
6a11995882
@ -77,16 +77,6 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Gets a formatted rank change message for the given name. </summary>
|
||||
internal static string FormatRankChange(Group curRank, Group newRank, string name, string reason) {
|
||||
string direction = newRank.Permission >= curRank.Permission ? " %Swas promoted to " : " %Swas demoted to ";
|
||||
Player who = PlayerInfo.FindExact(name);
|
||||
|
||||
if (who != null) name = who.ColoredName;
|
||||
return name + direction + newRank.ColoredName + "%S. (" + reason + "%S)";
|
||||
}
|
||||
|
||||
/// <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) {
|
||||
|
@ -34,15 +34,16 @@ namespace MCGalaxy.Commands.Misc {
|
||||
if (p != null && who.Rank > p.Rank) {
|
||||
MessageTooHighRank(p, "fakerank", true); return;
|
||||
}
|
||||
|
||||
DoFakerank(p, who, newRank);
|
||||
}
|
||||
|
||||
internal static void DoFakerank(Player p, Player who, Group newRank) {
|
||||
if (newRank.Permission == LevelPermission.Banned) {
|
||||
string banner = p == null ? "console" : p.ColoredName;
|
||||
Chat.MessageGlobal("{0} %Swas &8banned %Sby {1}%S.",
|
||||
who.ColoredName, banner);
|
||||
Chat.MessageGlobal("{0} %Swas &8banned%S.", who.ColoredName);
|
||||
} else {
|
||||
string reason = newRank.Permission >= who.Rank ?
|
||||
ServerConfig.DefaultPromoteMessage : ServerConfig.DefaultDemoteMessage;
|
||||
string rankMsg = ModActionCmd.FormatRankChange(who.group, newRank, who.name, reason);
|
||||
string reason = newRank.Permission >= who.Rank ? ServerConfig.DefaultPromoteMessage : ServerConfig.DefaultDemoteMessage;
|
||||
string direction = newRank.Permission >= who.Rank ? " %Swas promoted to " : " %Swas demoted to ";
|
||||
string rankMsg = who.ColoredName + direction + newRank.ColoredName + "%S. (" + reason + "%S)";
|
||||
|
||||
Chat.MessageGlobal(rankMsg);
|
||||
Player.Message(who, "You are now ranked {0}%S, type /help for your new set of commands.",
|
||||
@ -51,7 +52,7 @@ namespace MCGalaxy.Commands.Misc {
|
||||
|
||||
who.color = newRank.Color;
|
||||
Entities.GlobalRespawn(who);
|
||||
who.SetPrefix();
|
||||
who.SetPrefix();
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -44,15 +44,7 @@ namespace MCGalaxy.Commands.Misc {
|
||||
|
||||
void DoFakeRank(Player p, Group newRank) {
|
||||
p.hackrank = true;
|
||||
string rankMsg = ModActionCmd.FormatRankChange(p.group, newRank, p.name, "Congratulations!");
|
||||
Chat.MessageGlobal(rankMsg);
|
||||
|
||||
Player.Message(p, "You are now ranked " + newRank.ColoredName + "%S, type /help for your new set of commands.");
|
||||
p.color = newRank.Color;
|
||||
|
||||
Entities.GlobalRespawn(p);
|
||||
p.SetPrefix();
|
||||
|
||||
CmdFakeRank.DoFakerank(p, p, newRank);
|
||||
DoKick(p, newRank);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user