public void OnEntityCreating(int handle) { if (players == null) { return; } int sender_id = API.NetworkGetEntityOwner(handle); GeminisPlayer sender = players.GetPlayerFromId(sender_id.ToString()); if (sender != null) { Entity entity = Entity.FromHandle(handle); int entity_type = entity.Type; string entity_type_str = this.TypeToName(entity_type); if (entity_type_str != null) { if (config.entities_ratelimit.TryGetValue(entity_type_str, out _)) { Dictionary <string, EntityRatelimit> playerRatelimit = sender.GetData("entities_ratelimit"); EntityRatelimit entityRatelimit = playerRatelimit[entity_type_str]; if (entityRatelimit.AddAndCheck()) { sender.Ban(utils.Format(locale.entity_ratelimit, entityRatelimit.GetCount().ToString(), entity_type_str, entityRatelimit.time.ToString())); } } } } }
public void OnPlayerConnecting(GeminisPlayer geminisPlayer) { geminisPlayer.SetData("entities_ratelimit", new Dictionary <string, EntityRatelimit> { }); Dictionary <string, EntityRatelimit> playerRatelimit = geminisPlayer.GetData("entities_ratelimit"); foreach (KeyValuePair <string, List <int> > pair in config.entities_ratelimit) { if (this.NameToType(pair.Key) != -1 && pair.Value.Count == 2) { playerRatelimit.Add(pair.Key, new EntityRatelimit(pair.Value[0], pair.Value[1])); } } }
public async void OnClientHeartbeat([FromSource] Player source, string identifier) { GeminisPlayer geminisPlayer = players.GetPlayerFromSource(source); if (geminisPlayer == null) { return; } if (geminisPlayer.GetData("heartbeat_identifier") != identifier) { geminisPlayer.Drop(locale.wrong_heartbeat); return; } geminisPlayer.SetData("heartbeat", utils.GetTimestamp()); }