From 02b09db0d595a042fbf11c18bdcfbb2cf77fb7fb Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 23 Jan 2016 00:01:25 +1100 Subject: [PATCH] Cleanup /kill. --- Commands/Moderation/CmdAka.cs | 2 +- Commands/other/CmdKill.cs | 130 +++++++++++----------------------- Player/Player.Events.cs | 6 -- Player/Player.cs | 25 ++----- 4 files changed, 48 insertions(+), 115 deletions(-) diff --git a/Commands/Moderation/CmdAka.cs b/Commands/Moderation/CmdAka.cs index a0cc1748d..f7b3e16e8 100644 --- a/Commands/Moderation/CmdAka.cs +++ b/Commands/Moderation/CmdAka.cs @@ -51,7 +51,7 @@ namespace MCGalaxy.Commands } foreach (Player pl in Player.players) { - if (pl.level != p.level || p == pl || pl.hidden ||pl.referee) + if (pl.level != p.level || p == pl || pl.hidden || pl.referee) continue; string name = null; diff --git a/Commands/other/CmdKill.cs b/Commands/other/CmdKill.cs index 399e14268..4f7bd2129 100644 --- a/Commands/other/CmdKill.cs +++ b/Commands/other/CmdKill.cs @@ -1,20 +1,20 @@ /* - Copyright 2011 MCGalaxy - - 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. -*/ + Copyright 2011 MCGalaxy + + 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 CmdKill : Command @@ -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) - { - if (message == "") { Help(p); return; } + 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 = 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; + } - Player who; string killMsg; int killMethod = 0; - if (message.IndexOf(' ') == -1) - { - who = Player.Find(message); + 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); - } - - killMsg = " " + message; - } + p.HandleDeath(Block.rock, " killed themselves in their confusion"); + Player.SendMessage(p, "Could not find player"); return; } - 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 && 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; } - - if (p != null) - { - if (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; - } - } - - 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) { diff --git a/Player/Player.Events.cs b/Player/Player.Events.cs index 0b241fcd4..6ddf8cfaa 100644 --- a/Player/Player.Events.cs +++ b/Player/Player.Events.cs @@ -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; } } diff --git a/Player/Player.cs b/Player/Player.cs index b38c65df9..d9cb9e4c6 100644 --- a/Player/Player.cs +++ b/Player/Player.cs @@ -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); } }