private void CmdUnmute(IPlayer player, string cmd, string[] args) { if (args.Length != 1) { player.Reply(lang.GetMessage("Invalid Syntax Unmute", this, player.Id)); return; } IPlayer target = GetPlayer(args[0], player); if (target == null) { return; } if (!MuteInfo.IsMuted(target)) { player.Reply(lang.GetMessage("Not Muted", this, player.Id).Replace("{player}", target.Name)); return; } mutes.Remove(target.Id); SaveData(mutes); Interface.CallHook("OnBetterChatUnmuted", target, player); PublicMessage("Unmuted", new KeyValuePair <string, string>("initiator", player.Name), new KeyValuePair <string, string>("player", target.Name)); }
private void SetExpireDate(MuteInfo info, DateTime expireDate) { if (info != null) { info.ExpireDate = expireDate; } }
private void SetMessageSent(MuteInfo info, bool sent) { if (info != null) { info.Sent = sent; } }
private void SetReason(MuteInfo info, string reason, bool addReason = false) { if (info != null) { info.Reason = (addReason ? $"{info.Reason} | {reason}" : reason); } }
private object OnUserChat(IPlayer player, string message) { object result = HandleChat(player); if (result is bool && !(bool)result) { if (!MuteInfo.IsMuted(player) && globalMute) { player.Reply(lang.GetMessage("Global Mute Active", this, player.Id)); } else if (mutes[player.Id].Timed) { player.Reply( lang.GetMessage("Time Muted Player Chat", this, player.Id) .Replace("{time}", FormatTime(mutes[player.Id].ExpireDate - DateTime.UtcNow)) ); } else { player.Reply(lang.GetMessage("Muted Player Chat", this, player.Id)); } } return(result); }
private void SetAdmin(MuteInfo info, IPlayer admin) { if (info != null) { info.Admin = admin.Name; } }
private void RemoveMute(MuteInfo info) { if (info == null) { return; } Mutes.Remove(info.PlayerId); }
private DateTime?GetExpireDate(MuteInfo info) { if (info != null) { return(info.ExpireDate); } return(null); }
private string GetAdmin(MuteInfo info) { if (info != null) { return(info.Admin); } return(null); }
private string GetReason(MuteInfo info) { if (info != null) { return(info.Reason); } return(null); }
private string GetPlayerId(MuteInfo info) { if (info != null) { return(info.PlayerId); } return(null); }
private bool MessageSent(MuteInfo info) { if (info != null) { return(info.Sent); } return(false); }
private bool IsExpired(MuteInfo info) { if (info != null) { return(info.ExpireDate < DateTime.UtcNow); } return(false); }
private bool MuteExists(MuteInfo info) { if (info != null) { return(true); } return(false); }
private void UpdateMuteStatus(IPlayer player) { if (MuteInfo.IsMuted(player) && mutes[player.Id].Expired) { mutes.Remove(player.Id); SaveData(mutes); PublicMessage("Mute Expired", new KeyValuePair <string, string>("player", players.FindPlayerById(player.Id)?.Name)); Interface.CallHook("OnBetterChatMuteExpired", player); } }
private void OnUserInit(IPlayer player) { UpdateMuteStatus(player); if (MuteInfo.IsMuted(player)) { if (mutes[player.Id].Timed) { PublicMessage("Time Muted Player Joined", new KeyValuePair <string, string>("player", player.Name), new KeyValuePair <string, string>("time", FormatTime(mutes[player.Id].ExpireDate - DateTime.UtcNow))); } else { PublicMessage("Muted Player Joined", new KeyValuePair <string, string>("player", player.Name)); } } }
private object HandleChat(IPlayer player, bool isPublicChat) { if (!isPublicChat) { return(null); } UpdateMuteStatus(player); var result = Interface.CallHook("OnBetterChatMuteHandle", player, MuteInfo.IsMuted(player) ? JObject.FromObject(_mutes[player.Id]) : null); if (result != null) { return(result); } if (MuteInfo.IsMuted(player)) { if (_mutes[player.Id].Timed) { player.Reply(lang.GetMessage("Time Muted Player Chat", this, player.Id) .Replace("{time}", FormatTime(_mutes[player.Id].ExpireDate - DateTime.UtcNow)) ); } else { player.Reply(lang.GetMessage("Muted Player Chat", this, player.Id)); } return(true); } if (_globalMute && !permission.UserHasPermission(player.Id, "betterchatmute.use.global")) { player.Reply(lang.GetMessage("Global Mute Active", this, player.Id)); return(true); } return(null); }
private object HandleChat(IPlayer player) { UpdateMuteStatus(player); var result = Interface.CallHook("OnBetterChatMuteHandle", player, MuteInfo.IsMuted(player) ? JObject.FromObject(mutes[player.Id]) : null); if (result != null) { return(null); } if (MuteInfo.IsMuted(player)) { return(false); } if (globalMute && !permission.UserHasPermission(player.Id, "betterchatmute.use.global")) { return(false); } return(null); }
public MuteInfo AddMute(IPlayer target, string adminName, DateTime expireDate, string reason = null, bool addReason = false) { MuteInfo info; if (Mutes.ContainsKey(target.Id)) { MuteInfo m = GetMute(target); if (m == null) { return(null); } m.ExpireDate = expireDate; m.Reason = (addReason ? $"{m.Reason} | {reason}" : reason); return(null); } info = new MuteInfo(target, adminName, expireDate, reason); Mutes.Add(target.Id, info); return(info); }
private bool API_Unmute(IPlayer target, IPlayer player, bool callHook = true, bool broadcast = true) { if (!MuteInfo.IsMuted(target)) { return(false); } mutes.Remove(target.Id); SaveData(mutes); if (callHook) { Interface.CallHook("OnBetterChatUnmuted", target, player); } if (broadcast) { PublicMessage("Unmuted", new KeyValuePair <string, string>("initiator", player.Name), new KeyValuePair <string, string>("player", target.Name)); } return(true); }