mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2024-11-21 21:58:21 -05:00
feat(server): attempt to op the realm owner on join
This commit is contained in:
parent
50042e96ad
commit
28e678bce9
@ -907,9 +907,13 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
|||||||
{
|
{
|
||||||
var connection = _context.Connections.Include(c => c.World).FirstOrDefault(x => x.World.Id == wId);
|
var connection = _context.Connections.Include(c => c.World).FirstOrDefault(x => x.World.Id == wId);
|
||||||
|
|
||||||
|
var isRunning = new DockerHelper(connection.World).IsRunning();
|
||||||
var query = new MinecraftServerQuery().Query(connection.Address);
|
var query = new MinecraftServerQuery().Query(connection.Address);
|
||||||
|
|
||||||
if (query == null) new DockerHelper(connection.World).StartServer();
|
if (!isRunning)
|
||||||
|
{
|
||||||
|
new DockerHelper(connection.World).StartServer();
|
||||||
|
}
|
||||||
|
|
||||||
while (query == null)
|
while (query == null)
|
||||||
{
|
{
|
||||||
@ -917,6 +921,14 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
|||||||
query = new MinecraftServerQuery().Query(connection.Address);
|
query = new MinecraftServerQuery().Query(connection.Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string cookie = Request.Headers.Cookie;
|
||||||
|
string playerUUID = cookie.Split(";")[0].Split(":")[2];
|
||||||
|
|
||||||
|
if (connection.World.OwnerUUID == playerUUID)
|
||||||
|
{
|
||||||
|
new DockerHelper(connection.World).ExecuteCommand($"op {connection.World.Owner}");
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(connection);
|
return Ok(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,23 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
|
|||||||
serverProcess.Start();
|
serverProcess.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsRunning()
|
||||||
|
{
|
||||||
|
ProcessStartInfo containerStateProcessInfo = new();
|
||||||
|
|
||||||
|
containerStateProcessInfo.FileName = "docker";
|
||||||
|
containerStateProcessInfo.Arguments = $"inspect realm-server-{world.Id} -f {{{{.State.Running}}}}";
|
||||||
|
|
||||||
|
containerStateProcessInfo.RedirectStandardOutput = true;
|
||||||
|
|
||||||
|
Process containerStateProcess = new();
|
||||||
|
containerStateProcess.StartInfo = containerStateProcessInfo;
|
||||||
|
containerStateProcess.Start();
|
||||||
|
|
||||||
|
containerStateProcess.WaitForExit();
|
||||||
|
return bool.Parse(containerStateProcess.StandardOutput.ReadToEnd());
|
||||||
|
}
|
||||||
|
|
||||||
public void StartServer()
|
public void StartServer()
|
||||||
{
|
{
|
||||||
ProcessStartInfo serverProcessInfo = new();
|
ProcessStartInfo serverProcessInfo = new();
|
||||||
|
Loading…
Reference in New Issue
Block a user