Example #1
0
        /// <summary>
        /// Gets whether a CommandSender has a permission.
        /// </summary>
        /// <returns><c>true</c>, if the CommandSender has the permission, <c>false</c> otherwise.</returns>
        /// <param name="senderId">The CommandSender id.</param>
        /// <param name="permission">The permission to check.</param>
        public override bool isPermitted(string senderId, string permission)
        {
            /*string[] permissionSub = permission.Split(new string[]{ "." }, StringSplitOptions.None);
             * string[] permissions = new string[permissionSub.Length + 1];
             *
             * for (int i = 0; i < permissionSub.Length; i++) {
             *      System.Text.StringBuilder builder = new System.Text.StringBuilder();
             *      for (int i_ = 0; i_ < i; i_++) {
             *              builder.Append(permissionSub[i_]);
             *              builder.Append(".");
             *      }
             *      builder.Append("*");
             *      permissions[i] = builder.ToString();
             * }
             * permissions[permissions.Length - 1] = permission;*/

            string definiteName = PlayerCommandSender.MakeDefiniteName(senderId);

            if (definiteName == null)
            {
                return(false);
            }
            return(this.permissionFile.senderIsAllowedTo(definiteName, permission));

            /*foreach (string curPermission in permissions)
             * {
             *      if (this.permissionFile.senderIsAllowedTo(definiteName, curPermission))
             *              return true;
             * }
             * return false;*/
        }
Example #2
0
        /// <summary>
        /// Removes a CommandSender from a group.
        /// </summary>
        /// <returns><c>true</c>, command sender was removed from the group, <c>false</c> otherwise.</returns>
        /// <param name="senderId">The CommandSender id.</param>
        /// <param name="groupName">The group to add the CommandSender to.</param>
        public override bool removeCommandSenderFromGroup(string senderId, string groupName)
        {
            string definiteName = PlayerCommandSender.MakeDefiniteName(senderId);

            if (definiteName == null)
            {
                return(false);
            }
            return(this.permissionFile.removeSenderFromGroup(definiteName, groupName));
        }
Example #3
0
        /// <summary>
        /// Adds a CommandSender to a group.
        /// </summary>
        /// <param name="senderId">The CommandSender id.</param>
        /// <param name="groupName">The group to add the CommandSender to.</param>
        /// <param name="append">If <c>true</c>, append the group import, otherwise prepend it.</param>
        public override void addCommandSenderToGroup(string senderId, string groupName, bool append)
        {
            string definiteName = PlayerCommandSender.MakeDefiniteName(senderId);

            if (definiteName == null)
            {
                return;
            }
            this.permissionFile.addSenderToGroup(definiteName, groupName, append);
        }
Example #4
0
        /// <summary>
        /// Removes a permission from a CommandSender
        /// </summary>
        /// <param name="senderId">The CommandSender id to remove a permission from.</param>
        /// <param name="permission">The permission to remove.</param>
        public override void removePermissionFrom(string senderId, string permission)
        {
            string definiteName = PlayerCommandSender.MakeDefiniteName(senderId);

            if (definiteName == null)
            {
                return;
            }
            this.permissionFile.removePermissionFromSender(definiteName, permission);
        }
Example #5
0
        /// <summary>
        /// Adds a permission to a CommandSender
        /// </summary>
        /// <param name="senderId">The CommandSender id to add a permission to.</param>
        /// <param name="permission">The permission to add.</param>
        /// <param name="append">If <c>true</c>, append the permission, otherwise prepend the permission.</param>
        public override void addPermissionTo(string senderId, string permission, bool append)
        {
            string definiteName = PlayerCommandSender.MakeDefiniteName(senderId);

            if (definiteName == null)
            {
                return;
            }
            this.permissionFile.addPermissionToSender(definiteName, permission, append);
        }
Example #6
0
        /// <summary>
        /// Gets whether a CommandSender has a permission.
        /// </summary>
        /// <returns><c>true</c>, if the CommandSender has the permission, <c>false</c> otherwise.</returns>
        /// <param name="senderId">The CommandSender id.</param>
        /// <param name="permission">The permission to check.</param>
        /// <param name="isExplicitly">(Out) Set to <c>true</c>, if the permission was set explicitly, <c>false</c> if the permission is set by default (currently only false).</param>
        public override bool isPermitted(string senderId, string permission, out bool isExplicitly)
        {
            string definiteName = PlayerCommandSender.MakeDefiniteName(senderId);

            if (definiteName == null)
            {
                isExplicitly = false;
                return(false);
            }
            return(this.permissionFile.senderIsAllowedTo(definiteName, permission, out isExplicitly));
        }