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) {
|
static void SetOwner(Player p, Level lvl, string value) {
|
||||||
lvl.Config.RealmOwner = value.Replace(", ", ",").Replace(" ", ",");
|
if (value.Length == 0) {
|
||||||
if (value.Length == 0) p.Message("Removed realm owner for this level.");
|
lvl.Config.RealmOwner = "";
|
||||||
else p.Message("Set realm owner/owners of this level to {0}.", value);
|
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) {
|
static void SetTree(Player p, Level lvl, string value) {
|
||||||
|
@ -72,6 +72,11 @@ namespace MCGalaxy
|
|||||||
p => pl.CanSee(p), p => p.name, p => p.color + p.name, "online players");
|
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) {
|
public static string FindMatchesPreferOnline(Player p, string name) {
|
||||||
if (!Formatter.ValidPlayerName(p, name)) return null;
|
if (!Formatter.ValidPlayerName(p, name)) return null;
|
||||||
int matches;
|
int matches;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user