From 77f574431402d6e52c8f91887b825cdc1ff30ead Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 19 Apr 2017 17:01:33 +1000 Subject: [PATCH] Fix /notes not matching properly against own name --- MCGalaxy/Commands/Moderation/CmdNotes.cs | 29 ++++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/MCGalaxy/Commands/Moderation/CmdNotes.cs b/MCGalaxy/Commands/Moderation/CmdNotes.cs index b059fdba2..eac8dd766 100644 --- a/MCGalaxy/Commands/Moderation/CmdNotes.cs +++ b/MCGalaxy/Commands/Moderation/CmdNotes.cs @@ -18,8 +18,8 @@ using System; using System.Collections.Generic; -namespace MCGalaxy.Commands { - public class CmdNotes : Command { +namespace MCGalaxy.Commands { + public class CmdNotes : Command { public override string name { get { return "notes"; } } public override string type { get { return CommandTypes.Moderation; } } public override bool museumUsable { get { return true; } } @@ -29,14 +29,23 @@ namespace MCGalaxy.Commands { if (!Server.LogNotes) { Player.Message(p, "The server does not have notes logging enabled."); return; } + if (CheckSuper(p, message, "player name")) return; if (message == "") message = p.name; + string name = PlayerInfo.FindMatchesPreferOnline(p, message); + if (name == null) return; - List notes = Server.Notes.FindMatches(p, message, "notes"); - if (notes == null) return; + List notes = new List(); + foreach (string note in Server.Notes.Find(name)) { + notes.Add(note); + } - string target = PlayerMetaList.GetName(notes[0]); - Player.Message(p, " Notes for {0}:", PlayerInfo.GetColoredName(p, target)); + string target = PlayerInfo.GetColoredName(p, name); + if (notes.Count == 0) { + Player.Message(p, "{0} %Shas no notes.", target); return; + } else { + Player.Message(p, " Notes for {0}:", target); + } foreach (string line in notes) { string[] args = line.SplitSpaces(); @@ -46,7 +55,7 @@ namespace MCGalaxy.Commands { Player.Message(p, Action(args[1]) + " by " + args[2] + " on " + args[3]); } else { Player.Message(p, Action(args[1]) + " by " + args[2] + " on " + args[3] - + " - " + args[4].Replace("%20", " ")); + + " - " + args[4].Replace("%20", " ")); } } } @@ -63,12 +72,12 @@ namespace MCGalaxy.Commands { } public override void Help(Player p) { - Player.Message(p, "%T/notes [name] %H- views that player's notes."); - Player.Message(p, "%HNotes are things such as bans, kicks, warns, mutes."); + Player.Message(p, "%T/notes [name] %H- views that player's notes."); + Player.Message(p, "%HNotes are things such as bans, kicks, warns, mutes."); } } - public sealed class CmdMyNotes : CmdNotes { + public sealed class CmdMyNotes : CmdNotes { public override string name { get { return "mynotes"; } } public override string type { get { return CommandTypes.Other; } } public override bool museumUsable { get { return true; } }