mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2024-11-21 13:48:21 -05:00
feat: make reset world work
This commit is contained in:
parent
28e678bce9
commit
1a3804e865
@ -657,6 +657,13 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
|||||||
public ActionResult<bool> Reset(int wId)
|
public ActionResult<bool> Reset(int wId)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Resetting world {wId}");
|
Console.WriteLine($"Resetting world {wId}");
|
||||||
|
|
||||||
|
var world = _context.Worlds.Find(wId);
|
||||||
|
var server = new DockerHelper(world);
|
||||||
|
|
||||||
|
server.RunCommand("rm -rf world");
|
||||||
|
server.RebootServer();
|
||||||
|
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,18 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
|
|||||||
serverProcess.Start();
|
serverProcess.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RebootServer()
|
||||||
|
{
|
||||||
|
ProcessStartInfo serverProcessInfo = new();
|
||||||
|
|
||||||
|
serverProcessInfo.FileName = "docker";
|
||||||
|
serverProcessInfo.Arguments = $"container restart realm-server-{world.Id}";
|
||||||
|
|
||||||
|
Process serverProcess = new();
|
||||||
|
serverProcess.StartInfo = serverProcessInfo;
|
||||||
|
serverProcess.Start();
|
||||||
|
}
|
||||||
|
|
||||||
public void DeleteServer()
|
public void DeleteServer()
|
||||||
{
|
{
|
||||||
ProcessStartInfo serverProcessInfo = new();
|
ProcessStartInfo serverProcessInfo = new();
|
||||||
@ -110,5 +122,18 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
|
|||||||
|
|
||||||
commandProcess.Start();
|
commandProcess.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RunCommand(string command)
|
||||||
|
{
|
||||||
|
ProcessStartInfo commandProcessInfo = new();
|
||||||
|
|
||||||
|
commandProcessInfo.FileName = "docker";
|
||||||
|
commandProcessInfo.Arguments = $"exec realm-server-{world.Id} {command}";
|
||||||
|
|
||||||
|
Process commandProcess = new();
|
||||||
|
commandProcess.StartInfo = commandProcessInfo;
|
||||||
|
|
||||||
|
commandProcess.Start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +1,9 @@
|
|||||||
FROM eclipse-temurin:21-jre-alpine
|
FROM eclipse-temurin:21-jre-alpine
|
||||||
|
|
||||||
WORKDIR /server
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN mkdir mc
|
|
||||||
WORKDIR mc
|
|
||||||
|
|
||||||
RUN apk upgrade
|
RUN apk upgrade
|
||||||
RUN apk add openssl
|
RUN apk add openssl at
|
||||||
|
|
||||||
RUN wget -O rcon-cli.tar.gz https://github.com/itzg/rcon-cli/releases/download/1.6.7/rcon-cli_1.6.7_linux_amd64.tar.gz
|
RUN wget -O rcon-cli.tar.gz https://github.com/itzg/rcon-cli/releases/download/1.6.7/rcon-cli_1.6.7_linux_amd64.tar.gz
|
||||||
RUN tar xzf rcon-cli.tar.gz
|
RUN tar xzf rcon-cli.tar.gz
|
||||||
@ -15,6 +11,7 @@ RUN tar xzf rcon-cli.tar.gz
|
|||||||
RUN rm rcon-cli.tar.gz
|
RUN rm rcon-cli.tar.gz
|
||||||
RUN mv rcon-cli /bin/rcon-cli
|
RUN mv rcon-cli /bin/rcon-cli
|
||||||
|
|
||||||
|
WORKDIR mc
|
||||||
RUN wget -O server.jar https://piston-data.mojang.com/v1/objects/450698d1863ab5180c25d7c804ef0fe6369dd1ba/server.jar
|
RUN wget -O server.jar https://piston-data.mojang.com/v1/objects/450698d1863ab5180c25d7c804ef0fe6369dd1ba/server.jar
|
||||||
|
|
||||||
EXPOSE 25565
|
EXPOSE 25565
|
||||||
|
Loading…
Reference in New Issue
Block a user