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(); } }
public static void Deserialize(GenericReader reader) { int version = reader.ReadEncodedInt(); //Version 0 if (version >= 0) { m_Enabled = reader.ReadBool(); } m_PlayersSquelchedAdminPage = reader.ReadInt(); m_AdminFilterMode = (WorldChatAccountEntry.FilterMode)reader.ReadInt(); int squelchedPlayerCount = reader.ReadInt(); for (int a = 0; a < squelchedPlayerCount; a++) { PlayerMobile player = (PlayerMobile)reader.ReadMobile(); bool squelchEntireAccount = reader.ReadBool(); DateTime dateSquelched = reader.ReadDateTime(); PlayerSquelchEntry squelchEntry = new PlayerSquelchEntry(player, squelchEntireAccount, dateSquelched); m_PlayersSquelched.Add(squelchEntry); } //----- }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); //Version 0 if (version >= 0) { m_AccountUsername = reader.ReadString(); m_Enabled = reader.ReadBool(); m_LastMessageSent = reader.ReadDateTime(); m_PlayersSquelchedPage = reader.ReadInt(); m_FilterMode = (FilterMode)reader.ReadInt(); m_GlobalTextHue = reader.ReadInt(); m_PrivateTextHue = reader.ReadInt(); int squelchedPlayerCount = reader.ReadInt(); for (int a = 0; a < squelchedPlayerCount; a++) { PlayerMobile player = (PlayerMobile)reader.ReadMobile(); bool squelchEntireAccount = reader.ReadBool(); DateTime dateSquelched = reader.ReadDateTime(); PlayerSquelchEntry squelchEntry = new PlayerSquelchEntry(player, squelchEntireAccount, dateSquelched); m_PlayersSquelched.Add(squelchEntry); } } //--------- ChatPersistance.m_WorldChatAccountEntries.Add(this); }
public static void Serialize(GenericWriter writer) { writer.WriteEncodedInt(0); //Version //Version 0 writer.Write(m_Enabled); writer.Write(m_PlayersSquelchedAdminPage); writer.Write((int)(m_AdminFilterMode)); writer.Write(m_PlayersSquelched.Count); for (int a = 0; a < m_PlayersSquelched.Count; a++) { PlayerSquelchEntry squelchEntry = m_PlayersSquelched[a]; writer.Write(squelchEntry.m_Player); writer.Write(squelchEntry.m_SquelchEntireAccount); writer.Write(squelchEntry.m_SquelchExpiration); } }
public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)1); //Version //Version 0 writer.Write(m_AccountUsername); writer.Write(m_Enabled); writer.Write(m_LastMessageSent); writer.Write(m_PlayersSquelchedPage); writer.Write((int)m_FilterMode); writer.Write(m_GlobalTextHue); writer.Write(m_PrivateTextHue); writer.Write(m_PlayersSquelched.Count); for (int a = 0; a < m_PlayersSquelched.Count; a++) { PlayerSquelchEntry squelchEntry = m_PlayersSquelched[a]; writer.Write(squelchEntry.m_Player); writer.Write(squelchEntry.m_SquelchEntireAccount); writer.Write(squelchEntry.m_SquelchExpiration); } }
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(); }
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)); }