mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2025-07-05 19:39:42 -04:00
Compare commits
3 Commits
967518dc71
...
master
Author | SHA1 | Date | |
---|---|---|---|
ff325cf5f6 | |||
484d12463a | |||
0a89b6ade1 |
@ -902,7 +902,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
[HttpGet("v1/{wId}/join/pc")]
|
||||
public async Task<ActionResult<Connection>> Join(int wId)
|
||||
{
|
||||
var connection = _context.Connections.Include(c => c.World).FirstOrDefault(x => x.World.Id == wId);
|
||||
var connection = _context.Connections.Include(c => c.World).Include(c => c.World.Slots).FirstOrDefault(x => x.World.Id == wId);
|
||||
|
||||
var isRunning = new DockerHelper(connection.World).IsRunning();
|
||||
var query = new MinecraftServerQuery().Query(connection.Address);
|
||||
@ -918,7 +918,17 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
query = new MinecraftServerQuery().Query(connection.Address);
|
||||
}
|
||||
|
||||
Slot activeSlot = connection.World.Slots.Find(s => s.SlotId == connection.World.ActiveSlot);
|
||||
|
||||
string cookie = Request.Headers.Cookie;
|
||||
string gameVersion = cookie.Split(";")[2].Split("=")[1];
|
||||
|
||||
if (new MinecraftVersionParser.MinecraftVersion(activeSlot.Version).CompareTo(new MinecraftVersionParser.MinecraftVersion(gameVersion)) < 0 && new DockerHelper(connection.World).RunCommand("! test -f .no-update") == 0)
|
||||
{
|
||||
activeSlot.Version = gameVersion;
|
||||
_context.SaveChanges();
|
||||
}
|
||||
|
||||
string playerUUID = cookie.Split(";")[0].Split(":")[2];
|
||||
|
||||
if (connection.World.OwnerUUID == playerUUID)
|
||||
|
@ -116,7 +116,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
|
||||
commandProcess.Start();
|
||||
}
|
||||
|
||||
public void RunCommand(string command)
|
||||
public int RunCommand(string command)
|
||||
{
|
||||
ProcessStartInfo commandProcessInfo = new();
|
||||
|
||||
@ -127,6 +127,9 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
|
||||
commandProcess.StartInfo = commandProcessInfo;
|
||||
|
||||
commandProcess.Start();
|
||||
commandProcess.WaitForExit();
|
||||
|
||||
return commandProcess.ExitCode;
|
||||
}
|
||||
}
|
||||
}
|
@ -33,6 +33,14 @@ builder.Services.AddDbContext<DataContext>(options =>
|
||||
options.UseNpgsql(dataSource);
|
||||
});
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddDefaultPolicy(policy =>
|
||||
{
|
||||
policy.WithOrigins("http://localhost:5192");
|
||||
});
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Initialize database
|
||||
@ -48,6 +56,7 @@ if (app.Environment.IsDevelopment())
|
||||
var scope = app.Services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<DataContext>();
|
||||
|
||||
app.UseCors();
|
||||
app.MapControllers();
|
||||
|
||||
var mode = Environment.GetEnvironmentVariable("WORKMODE");
|
||||
|
@ -3,7 +3,7 @@ FROM eclipse-temurin:21-jre-alpine
|
||||
COPY . .
|
||||
|
||||
RUN apk upgrade
|
||||
RUN apk add openssl
|
||||
RUN apk add openssl curl jq
|
||||
|
||||
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
|
||||
@ -12,7 +12,6 @@ RUN rm rcon-cli.tar.gz
|
||||
RUN mv rcon-cli /bin/rcon-cli
|
||||
|
||||
WORKDIR mc
|
||||
RUN wget -O server.jar https://piston-data.mojang.com/v1/objects/450698d1863ab5180c25d7c804ef0fe6369dd1ba/server.jar
|
||||
|
||||
EXPOSE 25565
|
||||
|
||||
ENTRYPOINT ["/entrypoint"]
|
@ -11,4 +11,12 @@ if [ ! -f server.properties ]; then
|
||||
echo "level-name=slot-1" >> server.properties
|
||||
fi
|
||||
|
||||
# Download latest server.jar
|
||||
if [ ! -f .no-update ]; then
|
||||
VERSION_URL=$(curl https://piston-meta.mojang.com/mc/game/version_manifest_v2.json | jq -r '.latest.release as $latest | .versions | to_entries[] | select(.value.id == $latest) | .value.url')
|
||||
SERVER_URL=$(curl $VERSION_URL | jq -r .downloads.server.url)
|
||||
|
||||
wget -O server.jar $SERVER_URL
|
||||
fi
|
||||
|
||||
java -jar server.jar
|
@ -2,7 +2,7 @@
|
||||
logs: "x",
|
||||
|
||||
start: (dotNetObject, serverId) => {
|
||||
logs = new EventSource(`http://localhost:8080/api/admin/servers/${serverId}/logs`, { withCredentials: true });
|
||||
logs = new EventSource(`http://localhost:8080/api/admin/servers/${serverId}/logs`);
|
||||
|
||||
logs.onmessage = event => {
|
||||
dotNetObject.invokeMethodAsync("ReceiveLog", event.data);
|
||||
|
Reference in New Issue
Block a user