Exemplo n.º 1
0
        static void SetOldReview()
        {
            if (old.clearPerm == -1 && old.nextPerm == -1 && old.viewPerm == -1 &&
                old.opchatPerm == -1 && old.adminchatPerm == -1)
            {
                return;
            }

            // Apply backwards compatibility
            if (old.viewPerm != -1)
            {
                CommandExtraPerms.Find("Review", 1).MinRank = (LevelPermission)old.viewPerm;
            }
            if (old.nextPerm != -1)
            {
                CommandExtraPerms.Find("Review", 2).MinRank = (LevelPermission)old.nextPerm;
            }
            if (old.clearPerm != -1)
            {
                CommandExtraPerms.Find("Review", 3).MinRank = (LevelPermission)old.clearPerm;
            }
            if (old.opchatPerm != -1)
            {
                Chat.OpchatPerms.MinRank = (LevelPermission)old.opchatPerm;
            }
            if (old.adminchatPerm != -1)
            {
                Chat.AdminchatPerms.MinRank = (LevelPermission)old.adminchatPerm;
            }
            CommandExtraPerms.Save();
        }
Exemplo n.º 2
0
 void UpdateExtraPerms(LevelPermission perm, int num)
 {
     CommandExtraPerms.Load();
     CommandExtraPerms.Set("lavasurvival", perm, "temp desc", num);
     CommandExtraPerms.Save();
     needsSaveSettings = true;
 }
Exemplo n.º 3
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);
     }
 }
Exemplo n.º 4
0
        void SaveProperties()
        {
            try {
                ApplyGeneralProps();
                ApplyChatProps();
                ApplyIrcSqlProps();
                ApplyMiscProps();
                ApplyRankProps();
                ApplySecurityProps();
                zsSettings.ApplyToServer();
                lsSettings.ApplyToServer();

                SrvProperties.Save();
                CommandExtraPerms.Save();
            } catch (Exception ex) {
                Logger.LogError(ex);
                Logger.Log(LogType.Warning, "SAVE FAILED! properties/server.properties");
            }
        }
Exemplo n.º 5
0
        void SaveCommands()
        {
            if (!CommandsChanged())
            {
                LoadCommands(); return;
            }

            foreach (CommandPerms changed in commandPermsChanged)
            {
                CommandPerms.Set(changed.CmdName, changed.MinRank,
                                 changed.Allowed, changed.Disallowed);
            }
            foreach (CommandExtraPerms changed in commandExtraPermsChanged)
            {
                CommandExtraPerms orig = CommandExtraPerms.Find(changed.CmdName, changed.Num);
                orig.MinRank = changed.MinRank;
            }

            CommandExtraPerms.Save();
            CommandPerms.Save();
            CommandPerms.Load();
            LoadCommands();
        }
Exemplo n.º 6
0
        public override void Use(Player p, string message)
        {
            string[] args = message.SplitSpaces();
            if (args.Length == 1)
            {
                Help(p); return;
            }

            Command cmd = Command.all.Find(args[0]);

            if (cmd == null)
            {
                Player.Message(p, "Could not find command entered"); return;
            }
            if (p != null && !p.group.CanExecute(cmd))
            {
                Player.Message(p, "Your rank cannot use this command."); return;
            }

            if (args.Length == 2 && args[1][0] == '+')
            {
                Group grp = GetGroup(p, args[1].Substring(1));
                if (grp == null)
                {
                    return;
                }
                CommandPerms perms = CommandPerms.Find(cmd.name);

                if (perms.Disallowed.Contains(grp.Permission))
                {
                    perms.Disallowed.Remove(grp.Permission);
                }
                else if (!perms.Allowed.Contains(grp.Permission))
                {
                    perms.Allowed.Add(grp.Permission);
                }

                UpdatePermissions(cmd, p, " can now be used by " + grp.ColoredName);
            }
            else if (args.Length == 2 && args[1][0] == '-')
            {
                Group grp = GetGroup(p, args[1].Substring(1));
                if (grp == null)
                {
                    return;
                }
                CommandPerms perms = CommandPerms.Find(cmd.name);

                if (p != null && p.Rank == grp.Permission)
                {
                    Player.Message(p, "You cannot disallow your own rank from using a command."); return;
                }

                if (perms.Allowed.Contains(grp.Permission))
                {
                    perms.Allowed.Remove(grp.Permission);
                }
                else if (!perms.Disallowed.Contains(grp.Permission))
                {
                    perms.Disallowed.Add(grp.Permission);
                }

                UpdatePermissions(cmd, p, " is no longer usable by " + grp.ColoredName);
            }
            else if (args.Length == 2)
            {
                Group grp = GetGroup(p, args[1]);
                if (grp == null)
                {
                    return;
                }
                CommandPerms perms = CommandPerms.Find(cmd.name);

                perms.MinRank = grp.Permission;
                UpdatePermissions(cmd, p, "'s permission was set to " + grp.ColoredName);
            }
            else
            {
                int otherPermIndex = 0;
                if (!CommandParser.GetInt(p, args[2], "Extra permission number", ref otherPermIndex))
                {
                    return;
                }

                CommandExtraPerms perms = CommandExtraPerms.Find(cmd.name, otherPermIndex);
                if (perms == null)
                {
                    Player.Message(p, "This command has no extra permission by that number."); return;
                }
                if (p != null && p.Rank < perms.MinRank)
                {
                    Player.Message(p, "Your rank cannot modify this extra permission."); return;
                }

                Group grp = GetGroup(p, args[1]);
                if (grp == null)
                {
                    return;
                }
                perms.MinRank = grp.Permission;
                CommandExtraPerms.Save();

                string permName = "extra permission " + otherPermIndex;
                Chat.MessageGlobal("&d{0}%S's {1} was set to {2}", cmd.name, permName, grp.ColoredName);
                if (Player.IsSuper(p))
                {
                    Player.Message(p, "{0}'s {1} was set to {2}", cmd.name, permName, grp.ColoredName);
                }
            }
        }