Skip to content
Permalink
Browse files

Make /maxcaps usable from console and actually save changes

  • Loading branch information...
UnknownShadow200 committed Jul 18, 2017
1 parent 8666b66 commit 26f51256c5aeb10d0787ed12c4375ae095bfafed
Showing with 35 additions and 78 deletions.
  1. +35 −78 fCraft/Commands/ModerationCommands.cs
@@ -1724,92 +1724,49 @@ static void JoinOnRankWorldHandler(Player player, CommandReader cmd)
Aliases = new[] { "caps" },
Permissions = new[] { Permission.Chat },
Category = CommandCategory.New | CommandCategory.Moderation | CommandCategory.Chat,
IsConsoleSafe = true,
Help = "Changes/Displays the max amount of uppercase letters a rank can use in a message.",
Usage = "/MaxCaps <Rank> <Amount>",
Handler = MaxCapsHandler
};

static void MaxCapsHandler(Player player, CommandReader cmd)
{
string rname = cmd.Next();
string rmax = cmd.Next();
Rank prank = player.Info.Rank;
if (player.Info.Rank.Can(Permission.ShutdownServer))
{
if (rname == null)
{
if (prank.MaxCaps != 0 && prank.MaxCaps != 1)
{
player.Message("Rank ({0}&S) has a max of {1} uppercase letters/message.", prank.ClassyName, prank.MaxCaps);
return;
}
else if (prank.MaxCaps == 0)
{
player.Message("Rank ({0}&S) has no max.", prank.ClassyName);
return;
}
else if (prank.MaxCaps == 1)
{
player.Message("Rank ({0}&S) has a max of (RawMessage.Length / 2) uppercase letters/message.", prank.ClassyName);
return;
}
}
Rank rank = RankManager.FindRank(rname);
if (rank == null)
{
player.MessageNoRank(rname);
return;
}
if (rmax == null)
{
if (rank.MaxCaps != 0 && rank.MaxCaps != 1)
{
player.Message("Rank ({0}&S) has a max of {1} uppercase letters/message.", rank.ClassyName, rank.MaxCaps);
return;
}
else if (rank.MaxCaps == 0)
{
player.Message("Rank ({0}&S) has no max.", rank.ClassyName);
return;
}
else if (rank.MaxCaps == 1)
{
player.Message("Rank ({0}&S) has a max of (RawMessage.Length / 2) uppercase letters/message.", rank.ClassyName);
return;
}
}
int mcaps;
if (!int.TryParse(rmax, out mcaps))
{
CdMaxCaps.PrintUsage(player);
return;
}
if (rank != null)
{
rank.MaxCaps = mcaps;
player.Message("Set MaxCaps for rank ({0}&S) to {1} uppercase letters/message.", rank.ClassyName, rank.MaxCaps);
return;
}
static void MaxCapsHandler(Player player, CommandReader cmd) {
string rankName = cmd.Next();
if (!player.Info.Rank.Can(Permission.ShutdownServer) || rankName == null) {
PrintRankMaxCaps(player, player.Info.Rank);
return;
}
else
{
if (prank.MaxCaps != 0 && prank.MaxCaps != 1)
{
player.Message("Rank ({0}&S) has a max of {1} uppercase letters/message.", prank.ClassyName, prank.MaxCaps);
return;
}
else if (prank.MaxCaps == 0)
{
player.Message("Rank ({0}&S) has no max.", prank.ClassyName);
return;
}
else if (prank.MaxCaps == 1)
{
player.Message("Rank ({0}&S) has a max of (RawMessage.Length / 2) uppercase letters/message.", prank.ClassyName);
return;
}

Rank rank = RankManager.FindRank(rankName);
if (rank == null) {
player.MessageNoRank(rankName);
return;
}

if (!cmd.HasNext) {
PrintRankMaxCaps(player, rank);
return;
}
int maxCaps;
if (!cmd.NextInt(out maxCaps)) {
CdMaxCaps.PrintUsage(player);
return;
}

rank.MaxCaps = maxCaps;
Config.Save();
player.Message("Set MaxCaps for rank ({0}&S) to {1} uppercase letters/message.", rank.ClassyName, rank.MaxCaps);
return;
}

static void PrintRankMaxCaps(Player player, Rank rank) {
if (rank.MaxCaps == 0) {
player.Message("Rank ({0}&S) has no max.", rank.ClassyName);
} else if (rank.MaxCaps == 1) {
player.Message("Rank ({0}&S) has a max of (RawMessage.Length / 2) uppercase letters/message.", rank.ClassyName);
} else if (rank.MaxCaps != 0 && rank.MaxCaps != 1) {
player.Message("Rank ({0}&S) has a max of {1} uppercase letters/message.", rank.ClassyName, rank.MaxCaps);
}
}

#endregion

0 comments on commit 26f5125

Please sign in to comment.
You can’t perform that action at this time.