perbuild/pervisit +-name now matches

This commit is contained in:
UnknownShadow200 2017-02-06 15:29:42 +11:00
parent 69a6ae0927
commit e473598c92
3 changed files with 7 additions and 9 deletions

View File

@ -54,6 +54,10 @@ namespace MCGalaxy.Commands.World {
if (name == "") { if (name == "") {
Player.Message(p, "You must provide a player name to {0}.", mode); return; 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)) { if (p != null && name.CaselessEq(p.name)) {
Player.Message(p, "You cannot {0} yourself.", mode); return; Player.Message(p, "You cannot {0} yourself.", mode); return;
} }

View File

@ -55,9 +55,7 @@ namespace MCGalaxy {
public static string FindMapMatches(Player pl, string name, out int matches) { public static string FindMapMatches(Player pl, string name, out int matches) {
matches = 0; matches = 0;
if (!Player.ValidName(name)) { if (!Formatter.ValidName(pl, name, "level")) return null;
Player.Message(pl, "\"{0}\" is not a valid level name.", name); return null;
}
string[] files = Directory.GetFiles("levels", "*.lvl"); string[] files = Directory.GetFiles("levels", "*.lvl");
string map = Matcher.Find<string>(pl, name, out matches, files, string map = Matcher.Find<string>(pl, name, out matches, files,

View File

@ -59,9 +59,7 @@ namespace MCGalaxy {
public static Player FindMatches(Player pl, string name, public static Player FindMatches(Player pl, string name,
out int matches, bool onlyCanSee = true) { out int matches, bool onlyCanSee = true) {
matches = 0; matches = 0;
if (!Player.ValidName(name)) { if (!Formatter.ValidName(pl, name, "player")) return null;
Player.Message(pl, "\"{0}\" is not a valid player name.", name); return null;
}
return Matcher.Find<Player>(pl, name, out matches, Online.Items, return Matcher.Find<Player>(pl, name, out matches, Online.Items,
p => Entities.CanSee(pl, p) || !onlyCanSee, p => Entities.CanSee(pl, p) || !onlyCanSee,
@ -69,9 +67,7 @@ namespace MCGalaxy {
} }
public static string FindMatchesPreferOnline(Player p, string name) { public static string FindMatchesPreferOnline(Player p, string name) {
if (!Player.ValidName(name)) { if (!Formatter.ValidName(p, name, "player")) return null;
Player.Message(p, "\"{0}\" is not a valid player name.", name); return null;
}
int matches = 0; int matches = 0;
Player target = FindMatches(p, name, out matches); Player target = FindMatches(p, name, out matches);