mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-18 03:39:04 -04:00
Redesigned demote to record reasons for ranking
This commit is contained in:
parent
23ba41f02f
commit
896b763099
@ -1,20 +1,6 @@
|
|||||||
/*
|
using System;
|
||||||
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
|
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
|
namespace MCGalaxy.Commands
|
||||||
{
|
{
|
||||||
public sealed class CmdDemote : Command
|
public sealed class CmdDemote : Command
|
||||||
@ -28,43 +14,87 @@ namespace MCGalaxy.Commands
|
|||||||
|
|
||||||
public override void Use(Player p, string message)
|
public override void Use(Player p, string message)
|
||||||
{
|
{
|
||||||
if (message == "" || message.IndexOf(' ') != -1) { Help(p); return; }
|
string name;
|
||||||
Player who = Player.Find(message);
|
string reason;
|
||||||
string foundName;
|
Group group;
|
||||||
Group foundGroup;
|
string demoter;
|
||||||
if (who == null)
|
demoter = (p == null) ? "&a<CONSOLE>" : p.color + p.name;
|
||||||
|
Player player = Player.Find(message.Split(new char[] { ' ' })[0]);
|
||||||
|
|
||||||
|
if (message == "")
|
||||||
{
|
{
|
||||||
foundName = message;
|
Help(p); return;
|
||||||
foundGroup = Group.findPlayerGroup(message);
|
}
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
Help(p); return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foundName = who.name;
|
name = player.name;
|
||||||
foundGroup = who.group;
|
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--)
|
for (int i = Group.GroupList.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
Group grp = Group.GroupList[i];
|
Group group3 = Group.GroupList[i];
|
||||||
if (nextOne)
|
if (flag)
|
||||||
{
|
{
|
||||||
if (grp.Permission <= LevelPermission.Banned) break;
|
if (group3.Permission <= LevelPermission.Banned) break;
|
||||||
nextGroup = grp;
|
group2 = group3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (grp == foundGroup)
|
if (group3 == group)
|
||||||
nextOne = true;
|
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
|
else
|
||||||
|
{
|
||||||
Player.SendMessage(p, "No higher ranks exist");
|
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)
|
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\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user