From dc9b1b4ca1e13be9e4433f74e93f977a5908f329 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 5 Apr 2016 17:29:53 +1000 Subject: [PATCH] Fix being able to unmute yourself and a NullReferenceException being thrown when no online player matches the given name. Also /tree should not overwrite existing blocks. (Thanks goodlyay) Closes #122 --- Commands/Moderation/CmdMute.cs | 81 ++++++++++++---------------------- Commands/building/CmdTree.cs | 1 - 2 files changed, 27 insertions(+), 55 deletions(-) diff --git a/Commands/Moderation/CmdMute.cs b/Commands/Moderation/CmdMute.cs index 2a340716b..dcc31fde4 100644 --- a/Commands/Moderation/CmdMute.cs +++ b/Commands/Moderation/CmdMute.cs @@ -1,28 +1,23 @@ /* - Copyright 2011 MCForge - - 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 MCForge + + 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. */ using System.IO; namespace MCGalaxy.Commands { - /// - /// Bug: - /// Doesn't save mute.txt - /// Players with the defaultRank can unmute themself - /// public sealed class CmdMute : Command { public override string name { get { return "mute"; } } @@ -35,51 +30,29 @@ namespace MCGalaxy.Commands public override void Use(Player p, string message) { if (message == "" || message.Split(' ').Length > 2) { Help(p); return; } - Player who = PlayerInfo.Find(message); - - if (who == null) - { - if (Server.muted.Contains(message)) - { + Player who = PlayerInfo.FindOrShowMatches(p, message); + if (who == null) { + if (Server.muted.Contains(message)) { Server.muted.Remove(message); Player.GlobalMessage(message + Server.DefaultColor + " is not online but is now &bun-muted"); Extensions.DeleteLineWord("ranks/muted.txt", who.name.ToLower()); - return; - } - } - - if (who == p) - { - if (p.muted) - { - p.muted = false; - Player.SendMessage(p, "You &bun-muted" + Server.DefaultColor + " yourself!"); - Extensions.DeleteLineWord("ranks/muted.txt", p.name.ToLower()); - return; - } - else - { - Player.SendMessage(p, "You cannot mute yourself!"); } return; } - if (who.muted) - { + if (who == p) { Player.SendMessage(p, "You cannot mute or unmute yourself."); return; } + + if (who.muted) { who.muted = false; - Player.SendChatFrom(who, who.color + who.DisplayName + Server.DefaultColor + " has been &bun-muted", false); + Player.SendChatFrom(who, who.color + who.DisplayName + " %Shas been &bun-muted", false); Extensions.DeleteLineWord("ranks/muted.txt", who.name.ToLower()); - } - else - { - if (p != null) - { - if (who != p) if (who.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot mute someone of a higher or equal rank."); return; } + } else { + if (p != null && who.group.Permission >= p.group.Permission) { + Player.SendMessage(p, "Cannot mute someone of a higher or equal rank."); return; } who.muted = true; - Player.SendChatFrom(who, who.color + who.DisplayName + Server.DefaultColor + " has been &8muted", false); - using (StreamWriter writer = new StreamWriter("ranks/muted.txt", true)) - { + Player.SendChatFrom(who, who.color + who.DisplayName + " %Shas been &8muted", false); + using (StreamWriter writer = new StreamWriter("ranks/muted.txt", true)) { writer.WriteLine(who.name.ToLower()); } Server.s.Log("SAVED: ranks/muted.txt"); diff --git a/Commands/building/CmdTree.cs b/Commands/building/CmdTree.cs index d441ac89e..f64835678 100644 --- a/Commands/building/CmdTree.cs +++ b/Commands/building/CmdTree.cs @@ -64,7 +64,6 @@ namespace MCGalaxy.Commands { TreeDrawOp op = new TreeDrawOp(); op.Type = cpos.mode; op.random = p.random; - op.overwrite = true; Brush brush = null; if (cpos.brushMsg != "") {