Пример #1
0
        public override void Help(Player p)
        {
            p.Message("%T/Patrol");
            ItemPerms except = CommandExtraPerms.Find(name, 1);

            p.Message("%HTeleports you to a random player. {0} %Hare not patrolled", except.Describe());
            p.Message("%HPlayers patrolled within the last 15 seconds are ignored");
        }
Пример #2
0
 public void Update(ItemPerms perms)
 {
     SupressEvents = true;
     GuiPerms.SetDefaultIndex(MinBox, perms.MinRank);
     SetSpecificPerms(perms.Allowed, AllowBoxes);
     SetSpecificPerms(perms.Disallowed, DisallowBoxes);
     SupressEvents = false;
 }
Пример #3
0
        static void LogIPAction(ModAction e, string type)
        {
            ItemPerms perms = CommandExtraPerms.Find("WhoIs", 1);

            Chat.Message(ChatScope.Global, e.FormatMessage("An IP", type), perms,
                         FilterNotItemPerms, true);
            Chat.Message(ChatScope.Global, e.FormatMessage(e.Target, type), perms,
                         Chat.FilterPerms, true);
        }
Пример #4
0
        public void OnSpecificChanged(ComboBox box)
        {
            int idx = box.SelectedIndex;

            if (idx == -1 || SupressEvents)
            {
                return;
            }
            ItemPerms curPerms = GetCurPerms();

            List <LevelPermission> perms;

            ComboBox[] boxes;
            int        boxIdx = Array.IndexOf <ComboBox>(AllowBoxes, box);

            if (boxIdx == -1)
            {
                if (curPerms.Disallowed == null)
                {
                    curPerms.Disallowed = new List <LevelPermission>();
                }

                perms  = curPerms.Disallowed;
                boxes  = DisallowBoxes;
                boxIdx = Array.IndexOf <ComboBox>(DisallowBoxes, box);
            }
            else
            {
                if (curPerms.Allowed == null)
                {
                    curPerms.Allowed = new List <LevelPermission>();
                }

                perms = curPerms.Allowed;
                boxes = AllowBoxes;
            }

            if (idx == box.Items.Count - 1)
            {
                if (boxIdx >= perms.Count)
                {
                    return;
                }
                perms.RemoveAt(boxIdx);

                SupressEvents = true;
                SetSpecificPerms(perms, boxes);
                SupressEvents = false;
            }
            else
            {
                SetSpecific(boxes, boxIdx, perms, idx);
            }
        }
Пример #5
0
        public void OnMinRankChanged(ComboBox box)
        {
            int idx = box.SelectedIndex;

            if (idx == -1 || SupressEvents)
            {
                return;
            }
            ItemPerms curPerms = GetCurPerms();

            curPerms.MinRank = GuiPerms.RankPerms[idx];
        }
Пример #6
0
        public void OnMinRankChanged(ComboBox box)
        {
            GuiRank rank = (GuiRank)box.SelectedItem;

            if (rank == null || SupressEvents)
            {
                return;
            }
            ItemPerms curPerms = GetCurPerms();

            curPerms.MinRank = rank.Permission;
        }
Пример #7
0
        void HandleAdd(Player p, string[] args)
        {
            if (args.Length != 2)
            {
                p.Message("You need to provide a reason for the report."); return;
            }

            string target = PlayerDB.MatchNames(p, args[0]);

            if (target == null)
            {
                return;
            }
            string nick = p.FormatNick(target);

            List <string> reports = new List <string>();

            if (HasReports(target))
            {
                reports = Utils.ReadAllLinesList(ReportPath(target));
            }
            ItemPerms checkPerms = CommandExtraPerms.Find(name, 1);

            if (reports.Count >= 5)
            {
                p.Message("{0} &Walready has 5 reports! Please wait until an {1} &Whas reviewed these reports first!",
                          nick, CommandExtraPerms.Find(name, 1).Describe());
                return;
            }

            string reason = ModActionCmd.ExpandReason(p, args[1]);

            if (reason == null)
            {
                return;
            }

            reports.Add(reason + " - Reported by " + p.name + " at " + DateTime.Now);
            File.WriteAllLines(ReportPath(target), reports.ToArray());
            p.Message("&aReport sent! It should be viewed when a {0} &ais online",
                      checkPerms.Describe());

            string opsMsg = "λNICK &Sreported " + nick + "&S. Reason: " + reason;

            Chat.MessageFrom(ChatScope.Perms, p, opsMsg, checkPerms, null, true);
            string allMsg = "Use &T/Report check " + target + " &Sto see all of their reports";

            Chat.MessageFrom(ChatScope.Perms, p, allMsg, checkPerms, null, true);
        }
Пример #8
0
        void HandleEnter(Player p, CommandData data)
        {
            if (p.IsSuper)
            {
                p.Message("{0} cannot enter the review queue.", p.SuperName); return;
            }
            TimeSpan delta = p.NextReviewTime - DateTime.UtcNow;

            if (delta.TotalSeconds >= 0)
            {
                p.Message("You must wait {0} before you can request another review",
                          delta.Shorten(true, true));
                return;
            }

            if (Server.reviewlist.CaselessContains(p.name))
            {
                p.Message("You are already in the review queue!"); return;
            }

            bool opsOn = false;

            Player[]  players   = PlayerInfo.Online.Items;
            ItemPerms nextPerms = CommandExtraPerms.Find("Review", 2);

            foreach (Player pl in players)
            {
                if (nextPerms.UsableBy(pl.Rank) && Entities.CanSee(data, p, pl))
                {
                    opsOn = true; break;
                }
            }

            Server.reviewlist.Add(p.name);
            int pos = Server.reviewlist.IndexOf(p.name) + 1;

            p.Message("You entered the &creview %Squeue at &aposition #" + pos);

            string msg = opsOn ?
                         "The online staff have been notified. Someone should be with you shortly." :
                         "There are currently no staff online. Staff will be notified when they join the server.";

            p.Message(msg);

            Chat.MessageFrom(ChatScope.Perms, p,
                             "λNICK %Srequested a review! &c(Total " + pos + " waiting)", nextPerms, null, true);

            p.NextReviewTime = DateTime.UtcNow.Add(ServerConfig.ReviewCooldown);
        }
Пример #9
0
            public static bool CanEditAny(Player p)
            {
                if (LevelInfo.IsRealmOwner(p.name, p.level.name))
                {
                    return(true);
                }
                ItemPerms perms = CommandExtraPerms.Find("EffectSpawner", 1);

                perms = perms == null ? new ItemPerms(LevelPermission.Operator, null, null) : perms;
                if (perms.UsableBy(p.Rank))
                {
                    return(true);
                }
                return(false);
            }
Пример #10
0
 static void Disallow(ItemPerms perms, LevelPermission rank)
 {
     if (perms.Allowed != null && perms.Allowed.Contains(rank))
     {
         perms.Allowed.Remove(rank);
     }
     else if (perms.Disallowed == null || !perms.Disallowed.Contains(rank))
     {
         if (perms.Disallowed == null)
         {
             perms.Disallowed = new List <LevelPermission>();
         }
         perms.Disallowed.Add(rank);
     }
 }
Пример #11
0
        protected void SetPerms(Player p, string[] args, CommandData data, ItemPerms perms, string type)
        {
            string grpName = args[1];

            if (!perms.UsableBy(data.Rank))
            {
                p.Message("You rank cannot use this {0}.", type); return;
            }

            if (grpName[0] == '+')
            {
                Group grp = GetGroup(p, data, grpName.Substring(1));
                if (grp == null)
                {
                    return;
                }

                Allow(perms, grp.Permission);
                UpdatePerms(perms, p, " &Scan now be used by " + grp.ColoredName);
            }
            else if (grpName[0] == '-')
            {
                Group grp = GetGroup(p, data, grpName.Substring(1));
                if (grp == null)
                {
                    return;
                }

                if (data.Rank == grp.Permission)
                {
                    p.Message("You cannot disallow your own rank from using a {0}.", type); return;
                }

                Disallow(perms, grp.Permission);
                UpdatePerms(perms, p, " &Sis no longer usable by " + grp.ColoredName);
            }
            else
            {
                Group grp = GetGroup(p, data, grpName);
                if (grp == null)
                {
                    return;
                }

                perms.MinRank = grp.Permission;
                UpdatePerms(perms, p, " &Sis now usable by " + grp.ColoredName + "&S+");
            }
        }
Пример #12
0
 protected override void UpdatePerms(ItemPerms perms, Player p, string msg)
 {
     if (perms is CommandPerms)
     {
         CommandPerms.Save();
         CommandPerms.ApplyChanges();
         Announce(p, perms.ItemName + msg);
     }
     else
     {
         CommandExtraPerms.Save();
         CommandExtraPerms ex = (CommandExtraPerms)perms;
         //Announce(p, cmd.name + "&S's extra permission " + idx + " was set to " + grp.ColoredName);
         Announce(p, ex.CmdName + " extra permission #" + ex.Num + msg);
     }
 }
Пример #13
0
        protected override void UpdatePerms(ItemPerms perms, Player p, string msg)
        {
            BlockPerms.Save();
            BlockPerms.ApplyChanges();

            BlockID block = ((BlockPerms)perms).ID;

            if (!Block.IsPhysicsType(block))
            {
                BlockPerms.ResendAllBlockPermissions();
            }

            string name = Block.GetName(p, block);

            Announce(p, name + msg);
        }
Пример #14
0
        void HandleAdd(Player p, string[] args)
        {
            if (args.Length != 2)
            {
                p.Message("You need to provide a reason for the report."); return;
            }
            string target = PlayerDB.MatchNames(p, args[0]);

            if (target == null)
            {
                return;
            }

            List <string> reports = new List <string>();

            if (File.Exists("extra/reported/" + target + ".txt"))
            {
                reports = Utils.ReadAllLinesList("extra/reported/" + target + ".txt");
            }

            ItemPerms checkPerms = CommandExtraPerms.Find(name, 1);

            if (reports.Count >= 5)
            {
                p.Message("{0} %Walready has 5 reports! Please wait until an {1} %Whas reviewed these reports first!",
                          p.FormatNick(target), checkPerms.Describe());
                return;
            }

            string reason = args[1];

            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }

            reports.Add(reason + " - Reported by " + p.name + " at " + DateTime.Now);
            File.WriteAllLines("extra/reported/" + target + ".txt", reports.ToArray());
            p.Message("&aReport sent! It should be viewed when a {0} &ais online",
                      checkPerms.Describe());

            string opsMsg = "λNICK %Smade a report, view it with %T/Report check " + target;

            Chat.MessageFrom(ChatScope.Perms, p, opsMsg, checkPerms, null, true);
        }
Пример #15
0
        public static void IPLine(Player p, string name, string ip)
        {
            ItemPerms seeIpPerms = CommandExtraPerms.Find("WhoIs", 1);

            if (!seeIpPerms.UsableBy(p.Rank))
            {
                return;
            }

            string ipMsg = ip;

            if (Server.bannedIP.Contains(ip))
            {
                ipMsg = "&8" + ip + ", which is banned";
            }

            p.Message("  The IP of " + ipMsg);
            if (Server.Config.WhitelistedOnly && Server.whiteList.Contains(name))
            {
                p.Message("  Player is &fWhitelisted");
            }
        }
Пример #16
0
        List <Player> GetPatrolCandidates(Player p, CommandData data)
        {
            List <Player> candidates = new List <Player>();
            ItemPerms     except     = CommandExtraPerms.Find(name, 1);

            Player[] players = PlayerInfo.Online.Items;
            DateTime cutoff  = DateTime.UtcNow.AddSeconds(-15);

            foreach (Player target in players)
            {
                if (except.UsableBy(target.Rank) || !Entities.CanSee(data, p, target))
                {
                    continue;
                }
                if (target == p || target.LastPatrol > cutoff)
                {
                    continue;
                }
                candidates.Add(target);
            }
            return(candidates);
        }
Пример #17
0
        static void CheckReviewList(Player p)
        {
            if (!p.group.CanExecute("Review"))
            {
                return;
            }
            ItemPerms checkPerms = CommandExtraPerms.Find("Review", 1);

            if (!checkPerms.UsableBy(p.Rank))
            {
                return;
            }

            int count = Server.reviewlist.Count;

            if (count == 0)
            {
                return;
            }

            string suffix = count == 1 ? " player is " : " players are ";

            p.Message(count + suffix + "waiting for a review. Type %T/Review view");
        }
Пример #18
0
        static void AnnounceOps(Player p, string msg)
        {
            ItemPerms perms = new ItemPerms(p.hideRank, null, null);

            Chat.MessageFrom(ChatScope.Perms, p, msg, perms, null, true);
        }
Пример #19
0
 protected abstract void UpdatePerms(ItemPerms perms, Player p, string msg);