private void OnConnect(int ply, HandledEventArgs handler) { var player = new TSPlayer(ply); if (Config.EnableDNSHostResolution) { player.Group = Users.GetGroupForIPExpensive(player.IP); } else { player.Group = Users.GetGroupForIP(player.IP); } if (TShock.Utils.ActivePlayers() + 1 > Config.MaxSlots + 20) { TShock.Utils.ForceKick(player, Config.ServerFullNoReservedReason); handler.Handled = true; return; } var ipban = Bans.GetBanByIp(player.IP); Ban ban = null; if (ipban != null && Config.EnableIPBans) { ban = ipban; } if (ban != null) { TShock.Utils.ForceKick(player, string.Format("You are banned: {0}", ban.Reason)); handler.Handled = true; return; } if (!FileTools.OnWhitelist(player.IP)) { TShock.Utils.ForceKick(player, "Not on whitelist."); handler.Handled = true; return; } if (TShock.Geo != null) { var code = TShock.Geo.TryGetCountryCode(IPAddress.Parse(player.IP)); player.Country = code == null ? "N/A" : MaxMind.GeoIPCountry.GetCountryNameByCode(code); if (code == "A1") { if (TShock.Config.KickProxyUsers) { TShock.Utils.ForceKick(player, "Proxies are not allowed"); handler.Handled = true; return; } } } Players[ply] = player; }
private void OnJoin(int ply, HandledEventArgs handler) { var player = new TSPlayer(ply); if (Config.EnableDNSHostResolution) { player.Group = Users.GetGroupForIPExpensive(player.IP); } else { player.Group = Users.GetGroupForIP(player.IP); } if (TShock.Utils.ActivePlayers() + 1 > Config.MaxSlots && !player.Group.HasPermission(Permissions.reservedslot)) { TShock.Utils.ForceKick(player, Config.ServerFullReason); handler.Handled = true; return; } var ipban = Bans.GetBanByIp(player.IP); var nameban = Bans.GetBanByName(player.Name); Ban ban = null; if (ipban != null && Config.EnableIPBans) { ban = ipban; } else if (nameban != null && Config.EnableIPBans) { ban = nameban; } if (ban != null) { TShock.Utils.ForceKick(player, string.Format("You are banned: {0}", ban.Reason)); handler.Handled = true; return; } if (!FileTools.OnWhitelist(player.IP)) { TShock.Utils.ForceKick(player, "Not on whitelist."); handler.Handled = true; return; } Players[ply] = player; }