public async void OnVerified(VerifiedEventArgs ev) { if (Instance.Config.ShouldSyncRoles) { SyncedUser syncedUser = Instance.SyncedUsersCache.FirstOrDefault(tempSyncedUser => tempSyncedUser?.Id == ev.Player.UserId); if (syncedUser == null) { await Network.SendAsync(new RemoteCommand("getGroupFromId", ev.Player.UserId)).ConfigureAwait(false); } else { syncedUser?.SetGroup(); } } if (Instance.Config.EventsToLog.PlayerJoined && (!ev.Player.DoNotTrack || !Instance.Config.ShouldRespectDoNotTrack)) { await Network.SendAsync(new RemoteCommand("log", "gameEvents", string.Format(Language.HasJoinedTheGame, ev.Player.Nickname, Instance.Config.ShouldLogUserIds ? ev.Player.UserId : Language.Redacted, Instance.Config.ShouldLogIPAddresses ? ev.Player.IPAddress : Language.Redacted))).ConfigureAwait(false); } if (Instance.Config.StaffOnlyEventsToLog.PlayerJoined) { await Network.SendAsync(new RemoteCommand("log", "staffCopy", string.Format(Language.HasJoinedTheGame, ev.Player.Nickname, ev.Player.UserId, ev.Player.IPAddress))).ConfigureAwait(false); } }
/// <inheritdoc cref="API.Network.OnReceivedFull(object, ReceivedFullEventArgs)"/> public void OnReceivedFull(object _, ReceivedFullEventArgs ev) { try { Log.Debug($"[NET] {string.Format(Language.ReceivedData, ev.Data, ev.Length)}", Instance.Config.IsDebugEnabled); RemoteCommand remoteCommand = JsonConvert.DeserializeObject <RemoteCommand>(ev.Data, Network.JsonSerializerSettings); Log.Debug($"[NET] {string.Format(Language.HandlingRemoteCommand, remoteCommand.Action, remoteCommand.Parameters[0], Network.TcpClient?.Client?.RemoteEndPoint)}", Instance.Config.IsDebugEnabled); switch (remoteCommand.Action) { case "executeCommand": JsonConvert.DeserializeObject <GameCommand>(remoteCommand.Parameters[0].ToString())?.Execute(); break; case "setGroupFromId": SyncedUser syncedUser = JsonConvert.DeserializeObject <SyncedUser>(remoteCommand.Parameters[0].ToString(), Network.JsonSerializerSettings); if (syncedUser == null) { break; } if (!Instance.SyncedUsersCache.Contains(syncedUser)) { Instance.SyncedUsersCache.Add(syncedUser); } syncedUser?.SetGroup(); break; case "commandReply": JsonConvert.DeserializeObject <CommandReply>(remoteCommand.Parameters[0].ToString(), Network.JsonSerializerSettings)?.Answer(); break; } } catch (Exception exception) { Log.Error($"[NET] {string.Format(Language.HandlingRemoteCommandError, Instance.Config.IsDebugEnabled ? exception.ToString() : exception.Message)}"); } }
/// <inheritdoc cref="API.Network.OnReceivedFull(object, ReceivedFullEventArgs)"/> public void OnReceivedFull(object _, ReceivedFullEventArgs ev) { try { Log.Debug($"[NET] {string.Format(Language.ReceivedData, ev.Data, ev.Length)}", Instance.Config.IsDebugEnabled); RemoteCommand remoteCommand = JsonConvert.DeserializeObject <RemoteCommand>(ev.Data, Network.JsonSerializerSettings); Log.Debug($"[NET] {string.Format(Language.HandlingRemoteCommand, remoteCommand.Action, remoteCommand.Parameters[0], Network.TcpClient?.Client?.RemoteEndPoint)}", Instance.Config.IsDebugEnabled); switch (remoteCommand.Action) { case "executeCommand": JsonConvert.DeserializeObject <GameCommand>(remoteCommand.Parameters[0].ToString())?.Execute(); break; case "playerList": string description = string.Empty; IList <Field> fields = new List <Field>(); TimeSpan duration = Round.ElapsedTime; string seconds = duration.Seconds < 10 ? $"0{duration.Seconds}" : duration.Seconds.ToString(); string minutes = duration.Minutes < 10 ? $"0{duration.Minutes}" : duration.Minutes.ToString(); IEnumerable <Player> list = Player.List.OrderBy(pl => pl.Id); description += "```diff\n"; foreach (Player ply in list) { if (ply.RemoteAdminAccess) { description += $"- | {ply.Id} | {ply.Nickname} | {ply.Role.Translate()} | Staff |\n"; } else if (ply.CheckPermission("cerberus.viplist")) { description += $"+ | {ply.Id} | {ply.Nickname} | {ply.Role.Translate()} | VIP |\n"; } else if (ply.CheckPermission("cerberus.donadorlist")) { description += $"+ | {ply.Id} | {ply.Nickname} | {ply.Role.Translate()} | Donador |\n"; } else { description += $"+ | {ply.Id} | {ply.Nickname} | {ply.Role.Translate()} |\n"; } } description += "\n```"; if (Player.List.Count() < 1) { description = "```diff\n- No hay jugadores conectados - \n```"; } Network.SendAsync(new RemoteCommand( "sendEmbed", JsonConvert.DeserializeObject <GameCommand>(remoteCommand.Parameters[0].ToString())?.ChannelId, $"| Jugadores {Player.Dictionary.Count}/{Instance.Slots} | Tiempo de la ronda {minutes}:{seconds} |\n | ID | Nombre | Clase | Rol en el servidor |", description)); break; case "setGroupFromId": SyncedUser syncedUser = JsonConvert.DeserializeObject <SyncedUser>(remoteCommand.Parameters[0].ToString(), Network.JsonSerializerSettings); if (syncedUser == null) { break; } if (!Instance.SyncedUsersCache.Contains(syncedUser)) { Instance.SyncedUsersCache.Add(syncedUser); } syncedUser?.SetGroup(); break; case "commandReply": JsonConvert.DeserializeObject <CommandReply>(remoteCommand.Parameters[0].ToString(), Network.JsonSerializerSettings)?.Answer(); break; } } catch (Exception exception) { Log.Error($"[NET] {string.Format(Language.HandlingRemoteCommandError, Instance.Config.IsDebugEnabled ? exception.ToString() : exception.Message)}"); } }