private void CommonProcess(ulong steamId, SyncVoxelChangeType syncType, long entityId, string searchEntity, bool planet)
        {
            List <IMyVoxelBase> selectedVoxels = new List <IMyVoxelBase>();

            if (entityId != 0)
            {
                MyVoxelBase selectedVoxel;
                if (planet)
                {
                    selectedVoxel = MyAPIGateway.Entities.GetEntityById(entityId) as MyPlanet;
                }
                else
                {
                    selectedVoxel = MyAPIGateway.Entities.GetEntityById(entityId) as MyVoxelMap;
                }

                if (selectedVoxel != null)
                {
                    selectedVoxels.Add(selectedVoxel);
                }
            }
            else if (!string.IsNullOrEmpty(searchEntity))
            {
                var currentPlanetList = new List <IMyVoxelBase>();
                MyAPIGateway.Session.VoxelMaps.GetInstances(currentPlanetList, v => v is Sandbox.Game.Entities.MyPlanet && v.StorageName.IndexOf(searchEntity, StringComparison.InvariantCultureIgnoreCase) >= 0);

                if (currentPlanetList.Count == 1)
                {
                    selectedVoxels.Add(currentPlanetList.First());
                }
                else if (currentPlanetList.Count == 0)
                {
                    List <IMyVoxelBase> planetCache = CommandPlanetsList.GetPlanetCache(steamId);
                    int index;
                    if (searchEntity.Substring(0, 1) == "#" && int.TryParse(searchEntity.Substring(1), out index) && index > 0 && index <= planetCache.Count && planetCache[index - 1] != null)
                    {
                        selectedVoxels.Add(planetCache[index - 1]);
                    }
                }
            }

            if (selectedVoxels.Count == 0)
            {
                MyAPIGateway.Utilities.SendMessage(steamId, "Server", "No planet found.");
                return;
            }

            switch (syncType)
            {
            case SyncVoxelChangeType.DeletePlanet:
            {
                if (selectedVoxels.Count == 1)
                {
                    DeletePlanet(steamId, selectedVoxels.First());
                }
                else if (selectedVoxels.Count > 1)
                {
                    MyAPIGateway.Utilities.SendMessage(steamId, "deleteplanet", "{0} Planets match that name.", selectedVoxels.Count);
                }
            }
            break;
            }
        }
 public static void SendMessage(SyncVoxelChangeType syncType, long entityId, string searchEntity, bool planet)
 {
     Process(new MessageSyncVoxelChange {
         SyncType = syncType, EntityId = entityId, SearchEntity = searchEntity, Planet = planet
     });
 }