public static void ReloadAll(Level lvl, Player src, bool announce) { Player[] players = PlayerInfo.Online.Items; foreach (Player p in players) { if (p.level != lvl) { continue; } PlayerActions.ReloadMap(p); if (!announce) { continue; } if (src == null || !p.CanSee(src)) { p.Message("&bMap reloaded"); } else { p.Message("&bMap reloaded by " + p.FormatNick(src)); } if (src.CanSee(p)) { src.Message("&4Finished reloading for " + src.FormatNick(p)); } } }
/// <summary> Updates the tab list entry for this player to all other players /// (whose clients support it) who can see the player in the tab list. </summary> internal static void Update(Player p, bool self) { Player[] players = PlayerInfo.Online.Items; foreach (Player other in players) { if (p == other) { if (self) { Add(other, p, Entities.SelfID); } continue; } if (!Server.Config.TablistGlobal && p.level != other.level) { continue; } if (other.CanSee(p)) { Add(other, p, p.id); } if (p.CanSee(other)) { Add(p, other, other.id); } } }
public static string GetColoredName(Player p, string name) { Player target = FindExact(name); // TODO: select color from database? return(target != null && p.CanSee(target) ? target.ColoredName : Group.GroupIn(name).Color + name.RemoveLastPlus()); }
/// <summary> Matches given name against the names of all online players that the given player can see </summary> /// <param name="matches"> Outputs the number of matching players </param> /// <returns> A Player instance if exactly one match was found </returns> public static Player FindMatches(Player pl, string name, out int matches, bool _useless = false) { matches = 0; if (!Formatter.ValidPlayerName(pl, name)) { return(null); } // Try to exactly match name first (because names have + at end) Player exact = FindExact(name); if (exact != null && pl.CanSee(exact)) { matches = 1; return(exact); } return(Matcher.Find(pl, name, out matches, Online.Items, p => pl.CanSee(p), p => p.name, "online players")); }
public static Player FindMatches(Player pl, string name, out int matches, bool onlyCanSee = true) { matches = 0; if (!Formatter.ValidName(pl, name, "player")) { return(null); } return(Matcher.Find(pl, name, out matches, Online.Items, p => pl.CanSee(p) || !onlyCanSee, p => p.name, "online players")); }
/// <summary> Filters input list to only players that the source player can see. </summary> internal static List <Player> OnlyCanSee(Player p, LevelPermission plRank, IEnumerable <Player> players) { List <Player> list = new List <Player>(); foreach (Player pl in players) { if (p.CanSee(pl, plRank)) { list.Add(pl); } } return(list); }
static string TokenOnline(Player p) { Player[] players = PlayerInfo.Online.Items; int count = 0; foreach (Player pl in players) { if (p == pl || p.CanSee(pl)) { count++; } } return(count.ToString()); }
static OnlineListEntry OnlineOfRank(Player p, LevelPermission plRank, Group group) { OnlineListEntry entry = new OnlineListEntry(); entry.group = group; entry.players = new List <Player>(); Player[] online = PlayerInfo.Online.Items; foreach (Player pl in online) { if (pl.group != group || !p.CanSee(pl, plRank)) { continue; } entry.players.Add(pl); } return(entry); }
/// <summary> Removes this tab list entry for this player to all other players /// (whose clients support it) in the server. </summary> internal static void RemoveAll(Player p, bool self, bool toVisible) { if (!Server.Config.TablistGlobal) { return; } Player[] players = PlayerInfo.Online.Items; foreach (Player other in players) { if (p == other) { if (self) { Remove(other, p); } continue; } bool despawn = other.CanSee(p); if (!toVisible) { despawn = !despawn; } if (despawn) { Remove(other, p); } despawn = p.CanSee(other); if (!toVisible) { despawn = !despawn; } if (despawn) { Remove(p, other); } } }
public static bool CanSee(Player p, Player target) { return(p.CanSee(target)); }