void DestroyHandler(object target, MyDamageInformation damage) { if (damage.Type == MyDamageType.Grind) { MyDefinitionId blockId = new MyDefinitionId(); MyRelationsBetweenPlayerAndBlock relation = new MyRelationsBetweenPlayerAndBlock(); string faction = "none"; IMyFaction plFaction; List <long> owners = new List <long>(); long ownerID = -1; IMyEntity ent; MyAPIGateway.Entities.TryGetEntityById(damage.AttackerId, out ent); var hand = ent as IMyHandheldGunObject <MyToolBase>; IMyPlayer pl; if (hand != null && hand.DefinitionId.TypeId == typeof(MyObjectBuilder_AngleGrinder)) { var players = new List <IMyPlayer>(); MyAPIGateway.Players.GetPlayers(players); pl = players.FirstOrDefault(p => p.IdentityId.Equals(hand.OwnerIdentityId)); plFaction = MyAPIGateway.Session.Factions.TryGetPlayerFaction(pl.IdentityId); } else { //If nothing was returned from Entity return; } if (target is IMySlimBlock) { IMySlimBlock slim = target as IMySlimBlock; blockId = slim.BlockDefinition.Id; relation = slim.FatBlock.GetUserRelationToOwner(pl.IdentityId); faction = slim.FatBlock.GetOwnerFactionTag(); owners = slim.CubeGrid.SmallOwners; ownerID = slim.OwnerId; } else if (target is IMyCubeBlock) //just in cause { var fat = target as IMyCubeBlock; blockId = fat.BlockDefinition; relation = fat.GetUserRelationToOwner(pl.IdentityId); faction = fat.GetOwnerFactionTag(); owners = fat.CubeGrid.SmallOwners; ownerID = fat.OwnerId;//fat.OwnerBlock.BuiltBy; } MyLog.Default.WriteLine($"OwnerID {ownerID} Owner {relation.ToString()} - Player {pl.IdentityId} Faction {faction} - Player Faction {plFaction.Tag} Built By {owners.Count}"); if (owners.Count > 0 && faction != plFaction.Tag && !owners.Contains(pl.IdentityId)) { CalculatePlayers(blockId, ent, pl); } } }