当前位置: 首页>>代码示例>>C#>>正文


C# Session.HasRight方法代码示例

本文整理汇总了C#中Snowlight.Game.Sessions.Session.HasRight方法的典型用法代码示例。如果您正苦于以下问题:C# Session.HasRight方法的具体用法?C# Session.HasRight怎么用?C# Session.HasRight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Snowlight.Game.Sessions.Session的用法示例。


在下文中一共展示了Session.HasRight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Compose

        public static ServerMessage Compose(Session Session, Dictionary<int, CatalogPage> Pages)
        {
            ServerMessage Message = new ServerMessage(OpcodesOut.CATALOG_INDEX);
            SerializePage(Message, Pages[-1], CalcTreeSize(Session, Pages, -1));

            foreach (CatalogPage Page in Pages.Values)
            {
                if (Page.ParentId != -1 || (Page.RequiredRight.Length > 0 && !Session.HasRight(Page.RequiredRight)))
                {
                    continue;
                }

                SerializePage(Message, Page, CalcTreeSize(Session, Pages, Page.Id));

                foreach (CatalogPage ChildPage in Pages.Values)
                {
                    if (ChildPage.ParentId != Page.Id || (ChildPage.RequiredRight.Length > 0 && !Session.HasRight(ChildPage.RequiredRight)))
                    {
                        continue;
                    }

                    SerializePage(Message, ChildPage, 0);
                }
            }

            return Message;
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:27,代码来源:CatalogIndexComposer.cs

示例2: CheckUserRights

        public bool CheckUserRights(Session Session, bool RequireOwnership = false)
        {
            bool IsOwner = (Session.HasRight("room_rights_owner") || Session.CharacterId == Info.OwnerId);

            if (RequireOwnership)
            {
                return IsOwner;
            }

            return (IsOwner || Session.HasRight("room_rights") || mUsersWithRights.Contains(Session.CharacterId));
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:11,代码来源:Rights.cs

示例3: GetWardrobeSlotAmountForSession

        public static int GetWardrobeSlotAmountForSession(Session Session)
        {
            int WardrobeSlots = 0;

            if (Session.HasRight("club_regular"))
            {
                WardrobeSlots += 5;
            }

            if (Session.HasRight("club_vip"))
            {
                WardrobeSlots += 5;
            }

            return WardrobeSlots;
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:16,代码来源:Inventory.cs

示例4: BanUser

        private static void BanUser(Session Session, ClientMessage Message)
        {
            if (!Session.HasRight("moderation_tool"))
            {
                return;
            }

            uint UserId = Message.PopWiredUInt32();
            string MessageText = Message.PopString();
            double Length = (Message.PopWiredInt32() * 3600);

            Session TargetSession = SessionManager.GetSessionByCharacterId(UserId);

            if (TargetSession == null || TargetSession.HasRight("moderation_tool"))
            {
                Session.SendData(NotificationMessageComposer.Compose("This user is not online or you do not have permission to ban them.\nPlease use housekeeping to ban users that are offline."));
                return;
            }

            SessionManager.StopSession(TargetSession.Id);

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                ModerationBanManager.BanUser(MySqlClient, UserId, MessageText, Session.CharacterId, Length);
                ModerationLogs.LogModerationAction(MySqlClient, Session, "Banned user",
                    "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ") for " +
                    Length + " hours: '" + MessageText + "'");
            }
        }
开发者ID:fuding,项目名称:Snowlight,代码行数:29,代码来源:ModerationHandler.cs

示例5: AlertRoom

        private static void AlertRoom(Session Session, ClientMessage Message)
        {
            if (!Session.HasRight("moderation_tool"))
            {
                return;
            }

            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null)
            {
                Session.SendData(NotificationMessageComposer.Compose("Could not send room alert."));
                return;
            }

            int Unknown1 = Message.PopWiredInt32();
            int AlertMode = Message.PopWiredInt32();
            string AlertMessage = Message.PopString();
            bool IsCaution = AlertMode != 3;

            Instance.SendModerationAlert(AlertMessage, IsCaution);

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                ModerationLogs.LogModerationAction(MySqlClient, Session, "Sent room " + (IsCaution ? "caution" : "message"),
                    "Room " + Instance.Info.Name + " (ID " + Instance.RoomId + "): '" + AlertMessage + "'");
            }
        }
开发者ID:fuding,项目名称:Snowlight,代码行数:28,代码来源:ModerationHandler.cs

示例6: Compose

        public static ServerMessage Compose(Session Session)
        {
            ServerMessage Message = new ServerMessage(OpcodesOut.USER_RIGHTS);

            if (Session.HasRight("club_vip"))
            {
                Message.AppendInt32(2);
            }
            else if (Session.HasRight("club_regular"))
            {
                Message.AppendInt32(1);
            }
            else
            {
                Message.AppendInt32(0);
            }

            // TODO: Dig in to the mod tool and other staff stuff further to figure out how much this does

            Message.AppendInt32(Session.HasRight("hotel_admin") ? 1000 : 0);

            return Message;
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:23,代码来源:FuseRightsListComposer.cs

示例7: CalcTreeSize

        private static int CalcTreeSize(Session Session, Dictionary<int, CatalogPage> Pages, int ParentId)
        {
            int Num = 0;

            foreach (CatalogPage Page in Pages.Values)
            {
                if (Page.RequiredRight.Length > 0 && !Session.HasRight(Page.RequiredRight))
                {
                    continue;
                }

                if (Page.ParentId == ParentId)
                {
                    Num++;
                }
            }

            return Num;
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:19,代码来源:CatalogIndexComposer.cs

示例8: GetUserInfo

        private static void GetUserInfo(Session Session, ClientMessage Message)
        {
            if (!Session.HasRight("moderation_tool"))
            {
                return;
            }

            CharacterInfo Info = null;

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                 Info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, Message.PopWiredUInt32());
            }

            if (Info == null)
            {
                Session.SendData(NotificationMessageComposer.Compose("Could not retrieve user information."));
                return;
            }

            Session.SendData(ModerationUserInfoComposer.Compose(Info, SessionManager.GetSessionByCharacterId(Info.Id)));
        }
开发者ID:fuding,项目名称:Snowlight,代码行数:22,代码来源:ModerationHandler.cs

示例9: GetVisits

        private static void GetVisits(Session Session, ClientMessage Message)
        {
            if (!Session.HasRight("moderation_tool"))
            {
                return;
            }

            uint UserId = Message.PopWiredUInt32();

            Session.SendData(ModerationUserVisitsComposer.Compose(UserId, ModerationLogs.GetRoomVistsForUser(UserId,
                UnixTimestamp.GetCurrent() - 3600)));
        }
开发者ID:fuding,项目名称:Snowlight,代码行数:12,代码来源:ModerationHandler.cs

示例10: GetTicketChatlog

        private static void GetTicketChatlog(Session Session, ClientMessage Message)
        {
            if (!Session.HasRight("chatlogs"))
            {
                Session.SendData(NotificationMessageComposer.Compose("You are not allowed to use this!"));
                return;
            }

            ModerationTicket Ticket = ModerationTicketManager.GetTicket(Message.PopWiredUInt32());

            if (Ticket == null || Ticket.ModeratorUserId != Session.CharacterId)
            {
                Session.SendData(NotificationMessageComposer.Compose("Ticket not found or ticket is not assigned to you."));
                return;
            }

            RoomInfo Info = null;

            if (Ticket.RoomId > 0)
            {
                Info = RoomInfoLoader.GetRoomInfo(Ticket.RoomId);
            }

            Session.SendData(ModerationTicketChatlogsComposer.Compose(Ticket, Info, ModerationLogs.GetLogsForRoom(Ticket.RoomId,
                (Ticket.CreatedTimestamp - 600), UnixTimestamp.GetCurrent())));
        }
开发者ID:fuding,项目名称:Snowlight,代码行数:26,代码来源:ModerationHandler.cs

示例11: GetUserChatlog

        private static void GetUserChatlog(Session Session, ClientMessage Message)
        {
            if (!Session.HasRight("chatlogs"))
            {
                Session.SendData(NotificationMessageComposer.Compose("You are not allowed to use this!"));
                return;
            }

            uint UserId = Message.PopWiredUInt32();

            Session.SendData(ModerationUserChatlogsComposer.Compose(UserId, ModerationLogs.GetLogsForUser(UserId,
                (UnixTimestamp.GetCurrent() - 3600))));
        }
开发者ID:fuding,项目名称:Snowlight,代码行数:13,代码来源:ModerationHandler.cs

示例12: UserChat

        private static void UserChat(Session Session, ClientMessage Message)
        {
            if (Session.CharacterInfo.IsMuted)
            {
                return;
            }

            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null)
            {
                return;
            }

            RoomActor Actor = Instance.GetActorByReferenceId(Session.CharacterId);

            if (Actor == null)
            {
                return;
            }

            bool Shout = (Message.Id == OpcodesIn.ROOM_CHAT_SHOUT);
            string MessageText = UserInputFilter.FilterString(Message.PopString());

            if (MessageText.Length == 0)
            {
                return;
            }

            if (MessageText.Length > 100)
            {
                MessageText = MessageText.Substring(0, 100);
            }

            MessageText = Wordfilter.Filter(MessageText);

            if (MessageText.StartsWith(":") && (ChatCommands.HandleCommand(Session, MessageText) ||
                Session.HasRight("moderation_tool")))
            {
                return;
            }

            if (Instance.WiredManager.HandleChat(MessageText, Actor))
            {
                Actor.Whisper(MessageText, 0);
                return;
            }

            Actor.Chat(MessageText, Shout, Session.HasRight("mute"));

            if (Instance.HumanActorCount > 1)
            {
                QuestManager.ProgressUserQuest(Session, QuestType.SOCIAL_CHAT);
            }
        }
开发者ID:DaimOwns,项目名称:Snowlight,代码行数:55,代码来源:RoomHandler.cs

示例13: GetRoomInfo

        private static void GetRoomInfo(Session Session, ClientMessage Message)
        {
            if (!Session.HasRight("moderation_tool"))
            {
                return;
            }

            RoomInfo Info = RoomInfoLoader.GetRoomInfo(Message.PopWiredUInt32());

            if (Info == null)
            {
                Session.SendData(NotificationMessageComposer.Compose("Could not retrieve room information."));
                return;
            }

            Session.SendData(ModerationRoomInfoComposer.Compose(Info, RoomManager.GetInstanceByRoomId(Info.Id)));
        }
开发者ID:fuding,项目名称:Snowlight,代码行数:17,代码来源:ModerationHandler.cs

示例14: HandleCommand

        public static bool HandleCommand(Session Session, string Input)
        {
            Input = Input.Substring(1, Input.Length - 1);
            string[] Bits = Input.Split(' ');

            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);
            RoomActor Actor = (Instance == null ? null : Instance.GetActorByReferenceId(Session.CharacterId));
            Session TargetSession = null;
            RoomActor TargetActor = null;
            String TargetName = "";

            switch (Bits[0].ToLower())
            {
                #region users
                #region misc
                case "commands":
                    {
                        Session.SendData(NotificationMessageComposer.Compose(Localization.GetValue("command.commands.info") + ":\n\n:commands\n:online\n:about\n:pickall"));
                        return true;
                    }
                case "online":
                    {
                        List<string> OnlineUsers = SessionManager.ConnectedUserData.Values.ToList();
                        StringBuilder MessageText = new StringBuilder(Localization.GetValue("command.online", OnlineUsers.Count.ToString()) + "\n");

                        foreach (string OnlineUser in OnlineUsers)
                        {
                            MessageText.Append('\n');
                            MessageText.Append("- " + OnlineUser);
                        }

                        Session.SendData(NotificationMessageComposer.Compose(MessageText.ToString()));
                        return true;
                    }
                case "about":

                    Session.SendData(UserAlertModernComposer.Compose("Powered by Snowlight", "This hotel is proudly powered by Snowlight,\nedited by flx5. \nCredits to Meth0d."));
                    return true;
                #endregion
                #region furni
                case "empty":
                case "emptyinv":

                    if (Bits.Length > 2)
                    {
                        return false;
                    }

                    if (!Session.HasRight("hotel_admin") && Bits.Length == 2)
                    {
                        return false;
                    }

                    Session Targetuser = Session;

                    if (Bits.Length == 2)
                    {
                        uint userid = CharacterResolverCache.GetUidFromName(Bits[1]);
                        Targetuser = SessionManager.GetSessionByCharacterId(userid);
                    }

                    Targetuser.PetInventoryCache.ClearAndDeleteAll();
                    Targetuser.InventoryCache.ClearAndDeleteAll();
                    Targetuser.SendData(InventoryRefreshComposer.Compose());
                    Targetuser.SendData(NotificationMessageComposer.Compose(Localization.GetValue("command.emptyinv.sucess")));
                    return true;

                case "pickall":

                    if (!Instance.CheckUserRights(Session, true))
                    {
                        Session.SendData(NotificationMessageComposer.Compose(Localization.GetValue("command.pickall.error")));
                        return true;
                    }
                    Instance.PickAllToUserInventory(Session);
                    return true;
                #endregion
                #region extra
                case "moonwalk":
                    if (!Session.CharacterInfo.IsPremium)
                    {
                        return false;
                    }

                    Actor.WalkingBackwards = !Actor.WalkingBackwards;
                    Actor.Dance(Actor.WalkingBackwards ? 4 : 0);
                    Session.SendData(RoomChatComposer.Compose(Actor.Id, "TEST " + Actor.WalkingBackwards, 0, ChatType.Whisper));
                    return true;

                #region push
                case "push":
                    if (!Session.CharacterInfo.IsPremium || Bits.Length != 2)
                    {
                        return false;
                    }
                    TargetName = UserInputFilter.FilterString(Bits[1].Trim());
                    TargetActor = Instance.GetActorByReferenceId(CharacterResolverCache.GetUidFromName(TargetName));

                    if (TargetActor == null || TargetActor.IsMoving)
                    {
//.........这里部分代码省略.........
开发者ID:fuding,项目名称:Snowlight,代码行数:101,代码来源:ChatCommands.cs

示例15: PerformRoomAction

        private static void PerformRoomAction(Session Session, ClientMessage Message)
        {
            if (!Session.HasRight("moderation_tool"))
            {
                return;
            }

            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Message.PopWiredUInt32());

            if (Instance == null)
            {
                Session.SendData(NotificationMessageComposer.Compose("Could not perform room action."));
                return;
            }

            bool SetLock = Message.PopWiredBoolean();
            bool SetName = Message.PopWiredBoolean();
            bool KickAll = Message.PopWiredBoolean();

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

            if (!SetName)
            {
                foreach (string Tag in Instance.Info.Tags)
                {
                    Tags.Add(Tag);
                }
            }

            Instance.Info.EditRoom(SetName ? "Inappropriate to hotel management" : Instance.Info.Name, SetName ?
                "Inappropriate to hotel management" : Instance.Info.Description, SetLock ? RoomAccessType.Locked :
                Instance.Info.AccessType, SetLock ? string.Empty : Instance.Info.Password, Instance.Info.MaxUsers,
                SetName ? 0 : Instance.Info.CategoryId, Tags, Instance.Info.AllowPets, Instance.Info.AllowPets,
                Instance.Info.DisableRoomBlocking, Instance.Info.HideWalls, Instance.Info.WallThickness,
                Instance.Info.FloorThickness);

            if (KickAll)
            {
                Instance.KickRoom(true);
            }

            if (KickAll || SetName || SetLock)
            {
                using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                {
                    StringBuilder Details = new StringBuilder();

                    Details.Append("Room '" + Instance.Info.Name + "' (ID " + Instance.Info.Id + "): ");
                    int i = 0;

                    if (SetName)
                    {
                        Details.Append("Name set to 'Inappropriate to hotel management'");
                        i++;
                    }

                    if (KickAll)
                    {
                        if (i > 0)
                        {
                            Details.Append(", ");
                        }

                        Details.Append("Kicked all users from room");
                        i++;
                    }

                    if (SetLock)
                    {
                        if (i > 0)
                        {
                            Details.Append(", ");
                        }

                        Details.Append("Locked room");
                        i++;
                    }

                    ModerationLogs.LogModerationAction(MySqlClient, Session, "Performed room moderation action",
                        Details.ToString());
                }
            }
        }
开发者ID:fuding,项目名称:Snowlight,代码行数:83,代码来源:ModerationHandler.cs


注:本文中的Snowlight.Game.Sessions.Session.HasRight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。