/// <summary> /// Remove Player by Name /// </summary> /// <param name="Name">Player Name</param> /// <param name="Reason">Reason</param> public void Remove(string Name, string Reason) { Player Player = GetPlayer(Name); Player.Network.IsActive = false; if (Player.isGameJoltPlayer) { Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "left the server."), null)); Core.Logger.Log(Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "left the server with the following reason: " + Reason), Logger.LogTypes.Info); OnlineSetting OnlineSetting = (from OnlineSetting p in Core.Setting.OnlineSettingListData where p.GameJoltID == Player.GameJoltID select p).FirstOrDefault(); OnlineSetting.Save(); Core.Setting.OnlineSettingListData.Remove(OnlineSetting); } else { Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "left the server."), null)); Core.Logger.Log(Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "left the server with the following reason: " + Reason), Logger.LogTypes.Info); } Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.DestroyPlayer, Player.ID.ToString(), null)); if (Reason != Core.Setting.Token("SERVER_PLAYERLEFT")) { Core.Player.SentToPlayer(new Package(Package.PackageTypes.Kicked, Reason, Player.Network.Client)); } Core.RCONPlayer.SendToAllPlayer(new RCON_Client_Listener.Packages.Package(RCON_Client_Listener.Packages.Package.PackageTypes.RemovePlayer, $"{Player.ID},{Player.ToString()}", null)); Player.Network.ThreadPool3.WaitForIdle(); PlayerEvent.Invoke(PlayerEvent.Types.Remove, $"{Player.ID},{Player.ToString()}"); Core.Player.Remove(Player); }
/// <summary> /// Return if the player is muted. /// </summary> /// <param name="Player">Player to check.</param> /// <param name="PlayerList">Player List to check. Null == Global.</param> public static bool IsMuteListed(this Player Player, Player PlayerList = null) { if (PlayerList == null) { // Use Global List if (Core.Setting.MuteList) { MuteList MuteList = Player.GetMuteList(); if (MuteList == null) { return(false); } else { if (MuteList.Duration == -1 || DateTime.Now < MuteList.StartTime.AddSeconds(MuteList.Duration)) { return(true); } else { Core.Setting.MuteListData.Remove(MuteList); Core.Setting.Save(); return(false); } } } else { return(false); } } else { // Use PlayerList if (Core.Setting.OnlineSettingList) { MuteList MuteList = Player.GetMuteList(PlayerList); if (MuteList == null) { return(false); } else { if (MuteList.Duration == -1 || DateTime.Now < MuteList.StartTime.AddSeconds(MuteList.Duration)) { return(true); } else { OnlineSetting OnlineSetting = PlayerList.GetOnlineSetting(); OnlineSetting.MuteListData.Remove(MuteList); OnlineSetting.Save(); return(false); } } } else { return(false); } } }