Redesigned demote to record reasons for ranking

This commit is contained in:
Venom983 2015-10-06 23:01:57 -04:00
parent 23ba41f02f
commit 896b763099

View File

@ -1,20 +1,6 @@
/*
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
using System;
using System.IO;
Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at
http://www.opensource.org/licenses/ecl2.php
http://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
namespace MCGalaxy.Commands
{
public sealed class CmdDemote : Command
@ -28,43 +14,87 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message)
{
if (message == "" || message.IndexOf(' ') != -1) { Help(p); return; }
Player who = Player.Find(message);
string foundName;
Group foundGroup;
if (who == null)
string name;
string reason;
Group group;
string demoter;
demoter = (p == null) ? "&a<CONSOLE>" : p.color + p.name;
Player player = Player.Find(message.Split(new char[] { ' ' })[0]);
if (message == "")
{
foundName = message;
foundGroup = Group.findPlayerGroup(message);
Help(p); return;
}
if (player == null)
{
Help(p); return;
}
else
{
foundName = who.name;
foundGroup = who.group;
name = player.name;
group = player.group;
}
Group nextGroup = null; bool nextOne = false;
if (message.Split(new char[] { ' ' }).Length == 1)
{
reason = "Unknown";
Group group2 = null;
bool flag = false;
for (int i = Group.GroupList.Count - 1; i >= 0; i--)
{
Group grp = Group.GroupList[i];
if (nextOne)
Group group3 = Group.GroupList[i];
if (flag)
{
if (grp.Permission <= LevelPermission.Banned) break;
nextGroup = grp;
if (group3.Permission <= LevelPermission.Banned) break;
group2 = group3;
break;
}
if (grp == foundGroup)
nextOne = true;
if (group3 == group)
flag = true;
}
if (group2 != null)
{
Command.all.Find("setrank").Use(p, name + " " + group2.name + " " + Server.customPromoteMessage);
player.RankReason(DateTime.Now, "&c[DEMOTED]", group2.name, reason, demoter);
}
if (nextGroup != null)
Command.all.Find("setrank").Use(p, foundName + " " + nextGroup.name + " " + Server.customDemoteMessage);
else
{
Player.SendMessage(p, "No higher ranks exist");
}
}
else
{
reason = message.Substring(message.IndexOf(' ') + 1).Trim();
Group group2 = null;
bool flag = false;
for (int i = Group.GroupList.Count - 1; i >= 0; i--)
{
Group group3 = Group.GroupList[i];
if (flag)
{
if (group3.Permission <= LevelPermission.Banned) break;
group2 = group3;
break;
}
if (group3 == group)
flag = true;
}
if (group2 != null)
{
Command.all.Find("setrank").Use(p, name + " " + group2.name + " " + Server.customPromoteMessage);
player.RankReason(DateTime.Now, "&c[DEMOTED]", group2.name, reason, demoter);
}
else
{
Player.SendMessage(p, "No higher ranks exist");
}
}
}
public override void Help(Player p)
{
Player.SendMessage(p, "/demote <name> - Demotes <name> down a rank");
Player.SendMessage(p, "/demote <name> <reason> - Demotes <name> down a rank");
Player.SendMessage(p, "If <reason> is left blank, the server will use \"Unknown\"");
}
}
}