internal bool InvokeNetNameCollision(int who, string name) { NameCollisionEventArgs args = new NameCollisionEventArgs { Who = who, Name = name }; this.NetNameCollision.Invoke(args); return(args.Handled); }
internal bool InvokeNetNameCollision(int who, string name) { NameCollisionEventArgs args = new NameCollisionEventArgs { Who = who, Name = name }; this.NetNameCollision.Invoke(args); return args.Handled; }
/// <summary>NetHooks_NameCollision - Internal hook fired when a name collision happens.</summary> /// <param name="args">args - The NameCollisionEventArgs object.</param> private void NetHooks_NameCollision(NameCollisionEventArgs args) { string ip = Utils.GetRealIP(Netplay.Clients[args.Who].Socket.GetRemoteAddress().ToString()); var player = Players.First(p => p != null && p.Name == args.Name && p.Index != args.Who); if (player != null) { if (player.IP == ip) { Netplay.Clients[player.Index].PendingTermination = true; args.Handled = true; return; } if (player.IsLoggedIn) { var ips = JsonConvert.DeserializeObject<List<string>>(player.User.KnownIps); if (ips.Contains(ip)) { Netplay.Clients[player.Index].PendingTermination = true; args.Handled = true; } } } }
private void NetHooks_NameCollision(NameCollisionEventArgs args) { string ip = TShock.Utils.GetRealIP(Netplay.serverSock[args.Who].tcpClient.Client.RemoteEndPoint.ToString()); var player = TShock.Players.First(p => p != null && p.Name == args.Name && p.Index != args.Who); if (player != null) { if (player.IP == ip) { Netplay.serverSock[player.Index].kill = true; args.Handled = true; return; } else if (player.IsLoggedIn) { User user = TShock.Users.GetUserByName(player.UserAccountName); var ips = JsonConvert.DeserializeObject<List<string>>(user.KnownIps); if (ips.Contains(ip)) { Netplay.serverSock[player.Index].kill = true; args.Handled = true; return; } } } }
private void NetHooks_NameCollision(NameCollisionEventArgs args) { string ip = TShock.Utils.GetRealIP(Netplay.serverSock[args.Who].tcpClient.Client.RemoteEndPoint.ToString()); foreach (TSPlayer ply in TShock.Players) { if (ply == null) { continue; } if (ply.Name == args.Name && ply.Index != args.Who) { if (ply.IP == ip) { if (ply.State < 2) { Utils.ForceKick(ply, "Name collision and this client has no world data.", true, false); args.Handled = true; return; } else { args.Handled = false; return; } } } } args.Handled = false; return; }
/// <summary> /// NetNameCollision callback. /// </summary> /// <param name="args"></param> private void OnNetNameCollision(NameCollisionEventArgs args) { lock (this.m_AddonsLock) { this.m_Addons.ForEach(a => { var ret = a.Value.InvokeEvent("NetNameCollision", args); if (ret != null && ret.Length >= 1) { bool result; if (bool.TryParse(ret[0].ToString(), out result) && result) args.Handled = true; } }); } }