示例#1
0
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write((int)0); //Version

            ChatPersistance.Serialize(writer);
        }
示例#2
0
        public static void ClearExpiredSquelchEntries()
        {
            bool removedSquelch = false;

            Queue m_Queue = new Queue();

            foreach (PlayerSquelchEntry squelchEntry in ChatPersistance.m_PlayersSquelched)
            {
                if (DateTime.UtcNow >= squelchEntry.m_SquelchExpiration)
                {
                    m_Queue.Enqueue(squelchEntry);

                    removedSquelch = true;
                }
            }

            while (m_Queue.Count > 0)
            {
                PlayerSquelchEntry squelchEntry = (PlayerSquelchEntry)m_Queue.Dequeue();
                ChatPersistance.m_PlayersSquelched.Remove(squelchEntry);
            }

            if (removedSquelch)
            {
                ChatPersistance.UpdateAdminGumps();
            }
        }
示例#3
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            Movable = false;

            ChatPersistance.PersistanceItem = this;
            ChatPersistance.Deserialize(reader);
        }
示例#4
0
        public static void WorldChatAdmin(CommandEventArgs e)
        {
            Mobile from = e.Mobile;

            PlayerMobile player = from as PlayerMobile;

            if (player == null)
            {
                return;
            }

            ChatPersistance.CheckAndCreateWorldChatAccountEntry(player);

            player.CloseGump(typeof(WorldChatAdminGump));
            player.SendGump(new WorldChatAdminGump(player));
        }
示例#5
0
        public static void UpdateAdminGumps()
        {
            ChatPersistance.ClearExpiredSquelchEntries();

            foreach (NetState state in NetState.Instances)
            {
                Mobile       mobile = state.Mobile;
                PlayerMobile player = mobile as PlayerMobile;

                if (player == null)
                {
                    continue;
                }

                if (player.HasGump(typeof(WorldChatAdminGump)))
                {
                    player.CloseGump(typeof(WorldChatAdminGump));
                    player.SendGump(new WorldChatAdminGump(player));
                }
            }
        }
示例#6
0
        public static void OnLogin(PlayerMobile player)
        {
            if (player == null)
            {
                return;
            }

            Account account = player.Account as Account;

            if (account == null)
            {
                return;
            }

            player.m_WorldChatAccountEntry = ChatPersistance.FindWorldChatAccountEntry(player);

            if (player.m_WorldChatAccountEntry == null)
            {
                player.m_WorldChatAccountEntry = new WorldChatAccountEntry(account.Username);
            }

            if (player.m_WorldChatAccountEntry.Deleted)
            {
                player.m_WorldChatAccountEntry = new WorldChatAccountEntry(account.Username);
            }

            Timer.DelayCall(TimeSpan.FromSeconds(2), delegate
            {
                if (!ChatPersistance.Enabled)
                {
                    return;
                }

                if (player.m_WorldChatAccountEntry.Enabled)
                {
                    player.SendMessage(ChatPersistance.GlobalTextHue, "WorldChat is currently enabled. Type [WorldChat to access worldchat options.");
                }
            });
        }
示例#7
0
            protected override void OnTarget(Mobile from, object target)
            {
                if (from == null)
                {
                    return;
                }

                PlayerMobile playerTarget = target as PlayerMobile;

                if (playerTarget == null)
                {
                    from.SendMessage("That is not a player.");
                    return;
                }

                ChatPersistance.CheckAndCreateWorldChatAccountEntry(playerTarget);

                Account playerAccount = playerTarget.Account as Account;

                if (playerAccount == null)
                {
                    return;
                }

                PlayerSquelchEntry entryToRemove = null;

                foreach (PlayerSquelchEntry squelchEntry in ChatPersistance.m_PlayersSquelched)
                {
                    if (squelchEntry.m_Player == null)
                    {
                        continue;
                    }
                    if (squelchEntry.m_Player.Account == null)
                    {
                        continue;
                    }

                    Account squelchAccount = squelchEntry.m_Player.Account as Account;

                    if (squelchAccount == null)
                    {
                        continue;
                    }

                    if (playerAccount == squelchAccount)
                    {
                        entryToRemove = squelchEntry;
                        break;
                    }
                }

                if (entryToRemove != null)
                {
                    ChatPersistance.m_PlayersSquelched.Remove(entryToRemove);
                    from.SendMessage("Squelch for " + playerTarget.Name + " has been lifted.");
                }

                else
                {
                    from.SendMessage("No Squelch entry found for that player's account.");
                }

                UpdateAdminGumps();
            }
示例#8
0
            protected override void OnTarget(Mobile from, object target)
            {
                PlayerMobile pm_From = from as PlayerMobile;

                if (pm_From == null)
                {
                    return;
                }

                PlayerMobile playerTarget = target as PlayerMobile;

                if (playerTarget == null)
                {
                    pm_From.SendMessage("That is not a player.");
                    return;
                }

                if (pm_From.AccessLevel <= playerTarget.AccessLevel)
                {
                    pm_From.SendMessage("You do not have enough access to Squelch that player.");
                    return;
                }

                ChatPersistance.CheckAndCreateWorldChatAccountEntry(playerTarget);

                Account playerAccount = playerTarget.Account as Account;

                if (playerAccount == null)
                {
                    return;
                }

                string accountName = "";

                PlayerSquelchEntry entryToRemove = null;

                foreach (PlayerSquelchEntry squelchEntry in ChatPersistance.m_PlayersSquelched)
                {
                    if (squelchEntry.m_Player == null)
                    {
                        continue;
                    }
                    if (squelchEntry.m_Player.Account == null)
                    {
                        continue;
                    }

                    Account squelchAccount = squelchEntry.m_Player.Account as Account;

                    if (squelchAccount == null)
                    {
                        continue;
                    }

                    if (playerAccount == squelchAccount)
                    {
                        accountName   = playerAccount.Username;
                        entryToRemove = squelchEntry;

                        break;
                    }
                }

                if (entryToRemove != null)
                {
                    if (entryToRemove.m_SquelchExpiration >= DateTime.UtcNow + TimeSpan.FromHours(24))
                    {
                        pm_From.SendMessage("That player's account (" + accountName + ") is already squelched for longer than 24 hours. Use [WorldChatAdmin to manage current Squelches.");
                    }

                    else
                    {
                        ChatPersistance.m_PlayersSquelched.Remove(entryToRemove);
                        ChatPersistance.m_PlayersSquelched.Add(new PlayerSquelchEntry(playerTarget, true, DateTime.UtcNow + TimeSpan.FromHours(24)));

                        pm_From.SendMessage("Squelch for " + playerTarget.Name + " set for 24 hours.");
                    }
                }

                else
                {
                    ChatPersistance.m_PlayersSquelched.Add(new PlayerSquelchEntry(playerTarget, true, DateTime.UtcNow + TimeSpan.FromHours(24)));

                    pm_From.SendMessage("Squelch for " + playerTarget.Name + " set for 24 hours.");
                }

                UpdateAdminGumps();

                pm_From.CloseGump(typeof(WorldChatAdminGump));
                pm_From.SendGump(new WorldChatAdminGump(pm_From));
            }