Cleanup /kill.

This commit is contained in:
UnknownShadow200 2016-01-23 00:01:25 +11:00
parent f1926f8874
commit 02b09db0d5
4 changed files with 48 additions and 115 deletions

View File

@ -25,84 +25,38 @@ namespace MCGalaxy.Commands
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public CmdKill() { }
static char[] trimChars = { ' ' };
public override void Use(Player p, string message)
{
public override void Use(Player p, string message) {
if (message == "") { Help(p); return; }
bool explode = false;
string deathMessage;
string killer = p == null ? "(console)" : p.color + p.DisplayName;
string[] args = message.Split(trimChars, 2);
Player who; string killMsg; int killMethod = 0;
if (message.IndexOf(' ') == -1)
{
who = Player.Find(message);
Player who = Player.Find(args[0]);
if (args.Length >= 2) {
if(args[1].ToLower() == "explode") {
deathMessage = " was exploded by " + killer;
explode = true;
} else {
deathMessage = " " + args[1];
}
} else {
deathMessage = " was killed by " + killer;
}
if (who == null) {
if (p != null)
{
killMsg = " was killed by " + p.color + p.DisplayName;
}
else
{
killMsg = " was killed by " + "the Console.";
}
}
else
{
who = Player.Find(message.Split(' ')[0]);
message = message.Substring(message.IndexOf(' ') + 1);
if (message.IndexOf(' ') == -1)
{
if (message.ToLower() == "explode")
{
if (p != null)
{
killMsg = " was exploded by " + p.color + p.DisplayName;
}
else
{
killMsg = " was exploded by the Console.";
}
killMethod = 1;
}
else
{
killMsg = " " + message;
}
}
else
{
if (message.Split(' ')[0].ToLower() == "explode")
{
killMethod = 1;
message = message.Substring(message.IndexOf(' ') + 1);
p.HandleDeath(Block.rock, " killed themselves in their confusion");
Player.SendMessage(p, "Could not find player"); return;
}
killMsg = " " + message;
}
}
if (who == null)
{
if (p != null)
{
p.HandleDeath(Block.rock, " killed itself in its confusion");
}
Player.SendMessage(p, "Could not find player");
return;
}
if (p != null)
{
if (who.group.Permission > p.group.Permission)
{
if (p != null && who.group.Permission > p.group.Permission) {
p.HandleDeath(Block.rock, " was killed by " + who.color + who.DisplayName);
Player.SendMessage(p, "Cannot kill someone of higher rank");
return;
Player.SendMessage(p, "Cannot kill someone of higher rank"); return;
}
}
if (killMethod == 1)
who.HandleDeath(Block.rock, killMsg, true);
else
who.HandleDeath(Block.rock, killMsg);
who.HandleDeath(Block.rock, deathMessage, explode);
}
public override void Help(Player p)
{

View File

@ -231,11 +231,5 @@ namespace MCGalaxy
public void ClearBlockchange() { Blockchange = null; }
public bool HasBlockchange() { return (Blockchange == null); }
public object blockchangeObject = null;
//lolwut
public delegate void BecomeBrony(Player p);
public delegate void SonicRainboom(Player p);
public static event BecomeBrony OnBecomeBrony;
public static event SonicRainboom OnSonicRainboom;
}
}

View File

@ -2057,8 +2057,6 @@ return;
else {
SendMessage("You have used this command 2 times. You cannot use it anymore! Sorry, Brony!");
}
if ( OnBecomeBrony != null )
OnBecomeBrony(this);
return;
}
if ( cmd.ToLower() == "rainbowdashlikescoolthings" ) {
@ -2069,8 +2067,6 @@ return;
else {
SendMessage("You have used this command 2 times. You cannot use it anymore! Sorry, Brony!");
}
if ( OnSonicRainboom != null )
OnSonicRainboom(this);
return;
}
@ -2408,30 +2404,19 @@ return;
{
if (p.Loading && p != from) { return; }
if (p.level != from.level || (from.hidden && !self)) { return; }
if (p != from)
{
if (Server.ZombieModeOn && !p.aka)
{
if (from.infected)
{
if (Server.ZombieModeOn && !p.aka) {
if (from.infected) {
if (Server.ZombieName != "")
p.SendSpawn(from.id, c.red + Server.ZombieName + possession, x, y, z, rotx, roty);
else
p.SendSpawn(from.id, c.red + from.name + possession, x, y, z, rotx, roty);
return;
}
else if (from.referee)
{
return;
}
else
{
} else if (!from.referee) {
p.SendSpawn(from.id, from.color + from.name + possession, x, y, z, rotx, roty);
return;
}
}
else
{
} else {
p.SendSpawn(from.id, from.color + from.name + possession, x, y, z, rotx, roty);
}
}