Ejemplo n.º 1
0
        public static void LoadAll()
        {
            GroupList = new List <Group>();
            if (File.Exists(Paths.RankPropsFile))
            {
                GroupProperties.InitAll();
            }
            else
            {
                // Add some default ranks
                Register(new Group(LevelPermission.Builder, 4096, 300, "Builder", '2'));            // 16^3 draw volume
                Register(new Group(LevelPermission.AdvBuilder, 262144, 900, "AdvBuilder", '3'));    // 64^3
                Register(new Group(LevelPermission.Operator, 2097152, 5400, "Operator", 'c'));      // 128^3
                Register(new Group(LevelPermission.Admin, 16777216, int.MaxValue, "SuperOP", 'e')); // 256^3
            }

            if (BannedRank == null)
            {
                Register(new Group(LevelPermission.Banned, 1, 1, "Banned", '8'));
            }
            if (GuestRank == null)
            {
                Register(new Group(LevelPermission.Guest, 1, 120, "Guest", '7'));
            }
            if (NobodyRank == null)
            {
                Register(new Group(LevelPermission.Nobody, 65536, int.MaxValue, "Nobody", '0'));
            }

            GroupList.Sort((a, b) => a.Permission.CompareTo(b.Permission));
            DefaultRank = Find(ServerConfig.DefaultRankName);
            if (DefaultRank == null)
            {
                DefaultRank = GuestRank;
            }

            OnGroupLoadEvent.Call();
            reloading = true;
            SaveAll(GroupList);

            Player.Console.group = NobodyRank;
            Player[] players = PlayerInfo.Online.Items;
            foreach (Player p in players)
            {
                p.group = Group.Find(p.group.Permission);
                if (p.group == null)
                {
                    p.group = DefaultRank;
                }
                if (PlayerDB.FindColor(p).Length > 0 || p.color == p.group.Color)
                {
                    continue;
                }

                p.color = p.group.Color;
                Entities.GlobalRespawn(p);
                p.SetPrefix();
            }
        }
Ejemplo n.º 2
0
        static void UpdateGroup(Player p)
        {
            Group grp = Group.Find(p.group.Permission);

            if (grp == null)
            {
                grp = DefaultRank;
            }
            p.group = grp;

            if (PlayerDB.FindColor(p).Length == 0 && p.color != grp.Color)
            {
                p.color = grp.Color;
                Entities.GlobalRespawn(p);
            }
            p.SetPrefix();
        }
Ejemplo n.º 3
0
        /// <summary> Calculates default color for the given player. </summary>
        public static string DefaultColor(Player p)
        {
            string col = PlayerDB.FindColor(p);

            return(col.Length > 0 ? col : p.group.Color);
        }