/// <summary> /// permanently ban a client /// </summary> /// <param name="banReason">reason for the ban</param> /// <param name="sender">client performing the ban</param> public GameEvent Ban(String banReason, EFClient sender, bool isEvade) { var e = new GameEvent() { Type = GameEvent.EventType.Ban, Message = banReason, Data = banReason, Origin = sender, Target = this, Owner = sender.CurrentServer, Extra = isEvade }; // enforce level restrictions if (sender.Level <= Level) { e.FailReason = GameEvent.EventFailReason.Permission; } if (Level == Permission.Banned) { e.FailReason = GameEvent.EventFailReason.Invalid; } State = ClientState.Disconnecting; sender.CurrentServer.Manager.AddEvent(e); return(e); }
/// <summary> /// sets the level of the client /// </summary> /// <param name="newPermission">new permission to set client to</param> /// <param name="sender">user performing the set level</param> /// <returns></returns> public GameEvent SetLevel(Permission newPermission, EFClient sender) { var e = new GameEvent() { Type = GameEvent.EventType.ChangePermission, Extra = newPermission, Origin = sender, Target = this, Owner = sender.CurrentServer }; if (Level > sender.Level) { e.FailReason = GameEvent.EventFailReason.Permission; } else if (Level == newPermission) { e.FailReason = GameEvent.EventFailReason.Invalid; } else { Level = newPermission; } sender.CurrentServer.Manager.AddEvent(e); return(e); }
/// <summary> /// unflag a client for a given reason /// </summary> /// <param name="unflagReason">reason to unflag a player for</param> /// <param name="sender">client performing the unflag</param> /// <returns>game event for the un flug</returns> public GameEvent Unflag(string unflagReason, EFClient sender) { var e = new GameEvent() { Type = GameEvent.EventType.Unflag, Origin = sender, Target = this, Data = unflagReason, Message = unflagReason, Owner = sender.CurrentServer }; if (sender.Level <= Level) { e.FailReason = GameEvent.EventFailReason.Permission; } else if (Level != Permission.Flagged || Level == Permission.Banned) { e.FailReason = GameEvent.EventFailReason.Invalid; } sender.CurrentServer.Manager.AddEvent(e); return(e); }
/// <summary> /// report a client for a given reason /// </summary> /// <param name="reportReason">reason for the report</param> /// <param name="sender">client performing the report</param> /// <returns></returns> public GameEvent Report(string reportReason, EFClient sender) { var e = new GameEvent() { Type = GameEvent.EventType.Report, Message = reportReason, Data = reportReason, Origin = sender, Target = this, Owner = sender.CurrentServer }; int reportCount = sender.GetAdditionalProperty <int>("_reportCount"); if (Equals(sender)) { e.FailReason = GameEvent.EventFailReason.Invalid; } else if (reportCount > 2) { e.FailReason = GameEvent.EventFailReason.Throttle; } else if (CurrentServer.Reports.Count(report => (report.Origin.NetworkId == sender.NetworkId && report.Target.NetworkId == NetworkId)) > 0) { e.FailReason = GameEvent.EventFailReason.Exception; } sender.SetAdditionalProperty("_reportCount", reportCount + 1); sender.CurrentServer.Manager.AddEvent(e); return(e); }
/// <summary> /// flag a client for a given reason /// </summary> /// <param name="flagReason">reason for flagging</param> /// <param name="sender">client performing the flag</param> /// <returns>game event for the flag</returns> public GameEvent Flag(string flagReason, EFClient sender, TimeSpan?flagLength = null) { var e = new GameEvent() { Type = GameEvent.EventType.Flag, Origin = sender, Data = flagReason, Message = flagReason, Extra = flagLength, Target = this, Owner = sender.CurrentServer }; if (Level >= sender.Level) { e.FailReason = GameEvent.EventFailReason.Permission; } else if (Level == Permission.Flagged || Level == Permission.Banned) { e.FailReason = GameEvent.EventFailReason.Invalid; } sender.CurrentServer.Manager.AddEvent(e); return(e); }
/// <summary> /// warn a client with given reason /// </summary> /// <param name="warnReason">reason for warn</param> /// <param name="sender">client performing the warn</param> public GameEvent Warn(String warnReason, EFClient sender) { var e = new GameEvent() { Type = GameEvent.EventType.Warn, Message = warnReason, Data = warnReason, Origin = sender, Target = this, Owner = sender.CurrentServer }; // enforce level restrictions if (Level > sender.Level) { e.FailReason = GameEvent.EventFailReason.Permission; } else { Warnings++; } sender.CurrentServer.Manager.AddEvent(e); return(e); }
/// <summary> /// flag a client for a given reason /// </summary> /// <param name="flagReason">reason for flagging</param> /// <param name="sender">client performing the flag</param> /// <returns>game event for the flag</returns> public GameEvent Flag(string flagReason, EFClient sender) { var e = new GameEvent() { Type = GameEvent.EventType.Flag, Origin = sender, Data = flagReason, Message = flagReason, Target = this, Owner = sender.CurrentServer }; if (this.Level >= sender.Level) { e.FailReason = GameEvent.EventFailReason.Permission; } else if (this.Level == Permission.Flagged) { e.FailReason = GameEvent.EventFailReason.Invalid; } sender.CurrentServer.Manager.GetEventHandler().AddEvent(e); return(e); }
/// <summary> /// unban a client /// </summary> /// <param name="unbanReason">reason for the unban</param> /// <param name="sender">client performing the unban</param> /// <returns></returns> public GameEvent Unban(string unbanReason, EFClient sender) { var e = new GameEvent() { Type = GameEvent.EventType.Unban, Message = unbanReason, Data = unbanReason, Origin = sender, Target = this, Owner = sender.CurrentServer }; // enforce level restrictions if (this.Level > sender.Level) { e.FailReason = GameEvent.EventFailReason.Permission; } sender.CurrentServer.Manager.GetEventHandler().AddEvent(e); return(e); }
/// <summary> /// clear all warnings for a client /// </summary> /// <param name="sender">client performing the warn clear</param> /// <returns></returns> public GameEvent WarnClear(EFClient sender) { var e = new GameEvent() { Type = GameEvent.EventType.WarnClear, Origin = sender, Target = this, Owner = sender.CurrentServer }; // enforce level restrictions if (sender.Level <= Level) { e.FailReason = GameEvent.EventFailReason.Permission; return(e); } Warnings = 0; sender.CurrentServer.Manager.AddEvent(e); return(e); }
/// <summary> /// permanently ban a client /// </summary> /// <param name="banReason">reason for the ban</param> /// <param name="sender">client performing the ban</param> public GameEvent Ban(String banReason, EFClient sender, bool isEvade) { var e = new GameEvent() { Type = GameEvent.EventType.Ban, Message = banReason, Data = banReason, Origin = sender, Target = this, Owner = sender.CurrentServer, Extra = isEvade }; // enforce level restrictions if (sender.Level <= this.Level) { e.FailReason = GameEvent.EventFailReason.Permission; } sender.CurrentServer.Manager.GetEventHandler().AddEvent(e); return(e); }
/// <summary> /// temporarily ban a client for the given time span /// </summary> /// <param name="tempbanReason">reason for the temp ban</param> /// <param name="banLength">how long the temp ban lasts</param> /// <param name="sender">client performing the tempban</param> public GameEvent TempBan(String tempbanReason, TimeSpan banLength, EFClient sender) { var e = new GameEvent() { Type = GameEvent.EventType.TempBan, Message = tempbanReason, Data = tempbanReason, Origin = sender, Target = this, Extra = banLength, Owner = sender.CurrentServer }; // enforce level restrictions if (sender.Level <= this.Level) { e.FailReason = GameEvent.EventFailReason.Permission; } sender.CurrentServer.Manager.GetEventHandler().AddEvent(e); return(e); }
/// <summary> /// kick a client for the given reason /// </summary> /// <param name="kickReason">reason to kick for</param> /// <param name="sender">client performing the kick</param> public GameEvent Kick(string kickReason, EFClient sender) { var e = new GameEvent() { Type = GameEvent.EventType.Kick, Message = kickReason, Target = this, Origin = sender, Data = kickReason, Owner = sender.CurrentServer }; // enforce level restrictions if (sender.Level <= Level) { e.FailReason = GameEvent.EventFailReason.Permission; } State = ClientState.Disconnecting; sender.CurrentServer.Manager.AddEvent(e); return(e); }
public static Player AsPlayer(this Database.Models.EFClient client) { return(client == null ? null : new Player() { Active = client.Active, AliasLink = client.AliasLink, AliasLinkId = client.AliasLinkId, ClientId = client.ClientId, ClientNumber = -1, FirstConnection = client.FirstConnection, Connections = client.Connections, NetworkId = client.NetworkId, TotalConnectionTime = client.TotalConnectionTime, Masked = client.Masked, Name = client.CurrentAlias.Name, IPAddress = client.CurrentAlias.IPAddress, Level = client.Level, LastConnection = client.LastConnection == DateTime.MinValue ? DateTime.UtcNow : client.LastConnection, CurrentAlias = client.CurrentAlias, CurrentAliasId = client.CurrentAlias.AliasId, IsBot = client.NetworkId == -1 }); }
/// <summary> /// kick a client for the given reason /// </summary> /// <param name="kickReason">reason to kick for</param> /// <param name="sender">client performing the kick</param> public GameEvent Kick(string kickReason, EFClient sender) => Kick(kickReason, sender, null);