public async void Recover() { IMyPlayer player = Context.Player; if (player == null) { Context.Respond("Command cannot be ran from console"); return; } string externalIP = utils.CreateExternalIP(Plugin.Config); string currentIp = externalIP + ":" + MySandboxGame.ConfigDedicated.ServerPort; VoidManager voidManager = new VoidManager(Plugin); Tuple<string, string, Vector3D> data = await voidManager.DownloadGridAsync(currentIp, Context.Player.SteamUserId, Context.Player.GetPosition().ToString()); if (data == null) { return; } string targetFile = data.Item1; string filename = data.Item2; Vector3D newPos = data.Item3; MyAPIGateway.Utilities.InvokeOnGameThread(() => { GridImporter gridManager = new GridImporter(Plugin, Context); if (gridManager.DeserializeGridFromPath(targetFile, Context.Player.DisplayName, newPos)) { File.Delete(targetFile); Plugin.DeleteFromWeb(Context.Player.SteamUserId); } }); await RemoveConnection(Context.Player.SteamUserId); var playerEndpoint = new Endpoint(Context.Player.SteamUserId, 0); var replicationServer = (MyReplicationServer)MyMultiplayer.ReplicationLayer; var clientDataDict = _clientStates.Invoke(replicationServer); object clientData; try { clientData = clientDataDict[playerEndpoint]; } catch { return; } var clientReplicables = _replicables.Invoke(clientData); var replicableList = new List<IMyReplicable>(clientReplicables.Count); foreach (var pair in clientReplicables) replicableList.Add(pair.Key); foreach (var replicable in replicableList) { _removeForClient.Invoke(replicationServer, replicable, clientData, true); _forceReplicable.Invoke(replicationServer, replicable, playerEndpoint); } }
public async Task SwitchLocalAsync() { IMyPlayer player = Context.Player; if (player == null) { Context.Respond("Command cannot be ran from console"); return; } if (!Plugin.Config.Enabled) { Context.Respond("Switching is not enabled!"); return; } VoidManager voidManager = new VoidManager(Plugin); await voidManager.PlayerTransfer("single", Sandbox.Game.Multiplayer.Sync.MyId); }
public async Task SwitchAllAsync() { ulong steamid = Sandbox.Game.Multiplayer.Sync.MyId; VoidManager voidManager = new VoidManager(Plugin); await voidManager.PlayerTransfer("all", steamid); }