コード例 #1
0
        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));
                }
            }
        }
コード例 #2
0
        /// <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);
                }
            }
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        /// <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"));
        }
コード例 #5
0
        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"));
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
ファイル: ChatTokens.cs プロジェクト: netzbasis/MCGalaxy
        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());
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        /// <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);
                }
            }
        }
コード例 #10
0
ファイル: Entities.cs プロジェクト: IceCruelStuff/MCGalaxy
 public static bool CanSee(Player p, Player target)
 {
     return(p.CanSee(target));
 }