public void Update(IEnumerable <PunishSource> sources) { var pinnedSources = sources.Where(s => s.IsPinned).ToArray(); foreach (var src in pinnedSources) { if (_pinnedPlayerIds.Contains(src.PlayerId)) { continue; } var message = _config .PunishReportChatFormat .Replace("{player}", src.PlayerName) .Replace("{faction}", src.FactionTag) .Replace("{grid}", src.GridName) .Replace("{level}", $"{src.LagNormal * 100:0}%"); _chatManager.SendMessage(_config.PunishReportChatName, 0, message); Log.Debug($"punishment chat sent: {src}"); } _pinnedPlayerIds.Clear(); _pinnedPlayerIds.UnionWith(pinnedSources.Select(s => s.PlayerId)); }
bool MySafeZoneComponentPatch.IPlugin.PermitsPlayerSafeZone(IMyEntity entity, bool turnOnSafeZone) { Log.Info($"{nameof(TieredWorldConfig)}.{nameof(MySafeZoneComponentPatch.IPlugin.PermitsPlayerSafeZone)}()"); if (!turnOnSafeZone) { return(true); // disabling safezone is permitted anywhere } var entityPosition = entity.PositionComp.GetPosition(); var distance = entityPosition.Length(); var permitted = distance < Config.SafeWorldRadius; Log.Info($"Player SafeZone: {entityPosition}, {distance}"); if (permitted) { return(true); } Log.Info("Player SafeZone denied"); // send a chat message to whoever affected (as to why their safe zone isn't activated) var grid = entity.GetParentEntityOfType <MyCubeGrid>(); var ownerIds = grid.BigOwners.Concat(grid.SmallOwners).ToSet(); foreach (var ownerId in ownerIds) { var steamId = MySession.Static.Players.TryGetSteamId(ownerId); if (steamId == 0) { continue; } _chatManager.SendMessage("Server", steamId, $"Can't activate safe zone here: {distance:0}m away from the world center"); } return(false); }
async Task AnnounceDeletedGrids(CancellationToken canceller) { // stop tracking deleted grids & report cheating // we're doing this right here to get the max chance of grabbing the owner name var lostGrids = new List <TrackedEntity>(); await VRageUtils.MoveToGameLoop(canceller); foreach (var(_, trackedGrid) in _grids.Entities) { if (!MyEntities.TryGetEntityById(trackedGrid.Id, out _)) { lostGrids.Add(trackedGrid); } } await TaskUtils.MoveToThreadPool(canceller); foreach (var lostGrid in lostGrids) { _grids.StopTracking(lostGrid.Id); // high-profile grid deleted if (lostGrid.LagNormal >= _config.QuestLagNormal) { var gridName = lostGrid.Name; var ownerName = lostGrid.OwnerName; Log.Warn($"Laggy grid deleted by player: {gridName}: {ownerName}"); if (_config.EnablePunishChatFeed) { _chatManager.SendMessage(_config.PunishReportChatName, 0, $"Laggy grid deleted by player: {gridName}: {ownerName}"); } } } Log.Trace("announcing deleted entities done"); }
async Task OnMessageReceivedAsync(ISocketMessageChannel channel, SocketUser user, string content) { Log.Info($"input: \"{content}\" by user: {user.Username} in channel: {channel.Name}"); var receivedMessage = content.ToLower(); if (receivedMessage.Contains("check")) { if (_identityLinker.TryGetSteamId(user.Id, out var linkedSteamId)) { var linkedPlayerName = MySession.Static.Players.TryGetIdentityNameFromSteamId(linkedSteamId); await channel.MentionAsync(user.Id, $"Your Discord user is linked to \"{linkedPlayerName}\"."); _chatManager.SendMessage("Alert", linkedSteamId, $"You're linked to \"{user.Username}\"."); } else { await channel.MentionAsync(user.Id, "Your Discord user is not linked to any in-game players. Try `!alert link` in game."); } return; } if (int.TryParse(receivedMessage, out var linkId)) { Log.Info($"link id: {linkId}"); if (_identityLinker.TryMakeLink(linkId, user.Id, out var linkedSteamId)) { Log.Info($"linked steam ID: {linkedSteamId}"); var linkedPlayerName = MySession.Static.Players.TryGetIdentityNameFromSteamId(linkedSteamId); await channel.MentionAsync(user.Id, $"Alert linked to \"{linkedPlayerName}\"."); _chatManager.SendMessage("Alert", linkedSteamId, $"Alert linked to \"{user.Username}\"."); return; } await channel.MentionAsync(user.Id, $"Invalid input; not mapped: {linkId}"); return; } // no linked steam id found if (!_identityLinker.TryGetSteamId(user.Id, out var steamId)) { await channel.MentionAsync(user.Id, "Steam ID not linked"); return; } // delegate to listeners foreach (var messageListener in _messageListeners) { if (messageListener.TryRespond(steamId, receivedMessage, out var response)) { await channel.MentionAsync(user.Id, response); return; } } await channel.MentionAsync(user.Id, $"Unknown message: \"{receivedMessage}\""); }