From e473598c92a657f8b733e063ea8f32970534d9fe Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 6 Feb 2017 15:29:42 +1100 Subject: [PATCH] perbuild/pervisit +-name now matches --- MCGalaxy/Commands/World/PermissionCmd.cs | 4 ++++ MCGalaxy/Levels/LevelInfo.cs | 4 +--- MCGalaxy/Player/PlayerInfo.cs | 8 ++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/MCGalaxy/Commands/World/PermissionCmd.cs b/MCGalaxy/Commands/World/PermissionCmd.cs index f800a1476..a97768fcd 100644 --- a/MCGalaxy/Commands/World/PermissionCmd.cs +++ b/MCGalaxy/Commands/World/PermissionCmd.cs @@ -54,6 +54,10 @@ namespace MCGalaxy.Commands.World { if (name == "") { Player.Message(p, "You must provide a player name to {0}.", mode); return; } + if (!Formatter.ValidName(p, name, "player")) return; + name = PlayerInfo.FindMatchesPreferOnline(p, name); + if (name == null) return; + if (p != null && name.CaselessEq(p.name)) { Player.Message(p, "You cannot {0} yourself.", mode); return; } diff --git a/MCGalaxy/Levels/LevelInfo.cs b/MCGalaxy/Levels/LevelInfo.cs index 6a5b868de..0e117ca1a 100644 --- a/MCGalaxy/Levels/LevelInfo.cs +++ b/MCGalaxy/Levels/LevelInfo.cs @@ -55,9 +55,7 @@ namespace MCGalaxy { public static string FindMapMatches(Player pl, string name, out int matches) { matches = 0; - if (!Player.ValidName(name)) { - Player.Message(pl, "\"{0}\" is not a valid level name.", name); return null; - } + if (!Formatter.ValidName(pl, name, "level")) return null; string[] files = Directory.GetFiles("levels", "*.lvl"); string map = Matcher.Find(pl, name, out matches, files, diff --git a/MCGalaxy/Player/PlayerInfo.cs b/MCGalaxy/Player/PlayerInfo.cs index 89457197d..89e73b36e 100644 --- a/MCGalaxy/Player/PlayerInfo.cs +++ b/MCGalaxy/Player/PlayerInfo.cs @@ -59,9 +59,7 @@ namespace MCGalaxy { public static Player FindMatches(Player pl, string name, out int matches, bool onlyCanSee = true) { matches = 0; - if (!Player.ValidName(name)) { - Player.Message(pl, "\"{0}\" is not a valid player name.", name); return null; - } + if (!Formatter.ValidName(pl, name, "player")) return null; return Matcher.Find(pl, name, out matches, Online.Items, p => Entities.CanSee(pl, p) || !onlyCanSee, @@ -69,9 +67,7 @@ namespace MCGalaxy { } public static string FindMatchesPreferOnline(Player p, string name) { - if (!Player.ValidName(name)) { - Player.Message(p, "\"{0}\" is not a valid player name.", name); return null; - } + if (!Formatter.ValidName(p, name, "player")) return null; int matches = 0; Player target = FindMatches(p, name, out matches);