mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Error check and autocomplete player names provided to /map realmowner
This commit is contained in:
parent
69ef58fd9c
commit
852ccb0e65
@ -102,9 +102,23 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
static void SetOwner(Player p, Level lvl, string value) {
|
||||
lvl.Config.RealmOwner = value.Replace(", ", ",").Replace(" ", ",");
|
||||
if (value.Length == 0) p.Message("Removed realm owner for this level.");
|
||||
else p.Message("Set realm owner/owners of this level to {0}.", value);
|
||||
if (value.Length == 0) {
|
||||
lvl.Config.RealmOwner = "";
|
||||
p.Message("Removed realm owner for this level.");
|
||||
return;
|
||||
}
|
||||
|
||||
value = value.Replace(", ", ",");
|
||||
value = value.Replace(",", " ");
|
||||
|
||||
string[] names = value.SplitSpaces();
|
||||
for (int i = 0; i < names.Length; i++) {
|
||||
names[i] = PlayerInfo.FindMatchesPreferOnline(p, names[i]);
|
||||
if (names[i] == null) return;
|
||||
}
|
||||
|
||||
lvl.Config.RealmOwner = names.Join(","); ;
|
||||
p.Message("Set realm owner/owners of this level to {0}.", names.Join((n) => p.FormatNick(n)));
|
||||
}
|
||||
|
||||
static void SetTree(Player p, Level lvl, string value) {
|
||||
|
@ -71,7 +71,12 @@ namespace MCGalaxy
|
||||
return Matcher.Find(pl, name, out matches, Online.Items,
|
||||
p => pl.CanSee(p), p => p.name, p => p.color + p.name, "online players");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Matches given name against the names of all online players that the given player can see.
|
||||
/// If no online player is matched, attempts to find an offline player name match.
|
||||
/// </summary>
|
||||
/// <returns>A player name if exactly one found. Otherwise, null.</returns>
|
||||
public static string FindMatchesPreferOnline(Player p, string name) {
|
||||
if (!Formatter.ValidPlayerName(p, name)) return null;
|
||||
int matches;
|
||||
|
Loading…
x
Reference in New Issue
Block a user