mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2024-12-21 20:08:21 -05:00
feat: minigames
This commit is contained in:
parent
c40e29b971
commit
83f4a59707
@ -12,9 +12,7 @@
|
||||
public string WorldType { get; set; } = "NORMAL";
|
||||
public List<Player> Players { get; set; } = [];
|
||||
public int MaxPlayers { get; set; } = 10;
|
||||
public string? MinigameName { get; set; }
|
||||
public int? MinigameId { get; set; }
|
||||
public string? MinigameImage { get; set; }
|
||||
public Template? Minigame { get; set; }
|
||||
public int ActiveSlot { get; set; } = 1;
|
||||
public List<Slot> Slots { get; set; } = [];
|
||||
public bool Member { get; set; } = false;
|
||||
|
502
Minecraft-Realms-Emulator/Migrations/20240630120218_Minigames.Designer.cs
generated
Normal file
502
Minecraft-Realms-Emulator/Migrations/20240630120218_Minigames.Designer.cs
generated
Normal file
@ -0,0 +1,502 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Minecraft_Realms_Emulator.Data;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Minecraft_Realms_Emulator.Migrations
|
||||
{
|
||||
[DbContext(typeof(DataContext))]
|
||||
[Migration("20240630120218_Minigames")]
|
||||
partial class Minigames
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Backup", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("BackupId")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("LastModifiedDate")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<JsonDocument>("Metadata")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<int>("Size")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("WorldId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WorldId");
|
||||
|
||||
b.ToTable("Backups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Configuration", b =>
|
||||
{
|
||||
b.Property<string>("Key")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<object>("Value")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.HasKey("Key");
|
||||
|
||||
b.ToTable("Configuration");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Connection", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("PendingUpdate")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("WorldId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WorldId");
|
||||
|
||||
b.ToTable("Connections");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Invite", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("InvitationId")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("RecipeintUUID")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("WorldId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WorldId");
|
||||
|
||||
b.ToTable("Invites");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Notification", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<JsonDocument>("ButtonText")
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<bool>("Dismissable")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Image")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<JsonDocument>("Message")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<string>("NotificationUuid")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<JsonDocument>("Title")
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<JsonDocument>("UrlButton")
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Notifications");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Player", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<bool>("Accepted")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("Online")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("Operator")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Permission")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Uuid")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("WorldId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WorldId");
|
||||
|
||||
b.ToTable("Players");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.SeenNotification", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("NotificationUUID")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PlayerUUID")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SeenNotifications");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Slot", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<bool>("CommandBlocks")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("Difficulty")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("ForceGameMode")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("GameMode")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("Pvp")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("SlotId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("SlotName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("SpawnAnimals")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("SpawnMonsters")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("SpawnNPCs")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("SpawnProtection")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Version")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("WorldId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WorldId");
|
||||
|
||||
b.ToTable("Slots");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Subscription", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("StartDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("SubscriptionType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("WorldId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WorldId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Subscriptions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Template", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Author")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Image")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Link")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("RecommendedPlayers")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Trailer")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Version")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Templates");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.World", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ActiveSlot")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MaxPlayers")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("Member")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int?>("MinigameId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Motd")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Owner")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("OwnerUUID")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int?>("ParentWorldId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("State")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("WorldType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MinigameId");
|
||||
|
||||
b.HasIndex("ParentWorldId");
|
||||
|
||||
b.ToTable("Worlds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Backup", b =>
|
||||
{
|
||||
b.HasOne("Minecraft_Realms_Emulator.Entities.World", "World")
|
||||
.WithMany()
|
||||
.HasForeignKey("WorldId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("World");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Connection", b =>
|
||||
{
|
||||
b.HasOne("Minecraft_Realms_Emulator.Entities.World", "World")
|
||||
.WithMany()
|
||||
.HasForeignKey("WorldId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("World");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Invite", b =>
|
||||
{
|
||||
b.HasOne("Minecraft_Realms_Emulator.Entities.World", "World")
|
||||
.WithMany()
|
||||
.HasForeignKey("WorldId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("World");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Player", b =>
|
||||
{
|
||||
b.HasOne("Minecraft_Realms_Emulator.Entities.World", "World")
|
||||
.WithMany("Players")
|
||||
.HasForeignKey("WorldId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("World");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Slot", b =>
|
||||
{
|
||||
b.HasOne("Minecraft_Realms_Emulator.Entities.World", "World")
|
||||
.WithMany("Slots")
|
||||
.HasForeignKey("WorldId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("World");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Subscription", b =>
|
||||
{
|
||||
b.HasOne("Minecraft_Realms_Emulator.Entities.World", "World")
|
||||
.WithOne("Subscription")
|
||||
.HasForeignKey("Minecraft_Realms_Emulator.Entities.Subscription", "WorldId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("World");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.World", b =>
|
||||
{
|
||||
b.HasOne("Minecraft_Realms_Emulator.Entities.Template", "Minigame")
|
||||
.WithMany()
|
||||
.HasForeignKey("MinigameId");
|
||||
|
||||
b.HasOne("Minecraft_Realms_Emulator.Entities.World", "ParentWorld")
|
||||
.WithMany()
|
||||
.HasForeignKey("ParentWorldId");
|
||||
|
||||
b.Navigation("Minigame");
|
||||
|
||||
b.Navigation("ParentWorld");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.World", b =>
|
||||
{
|
||||
b.Navigation("Players");
|
||||
|
||||
b.Navigation("Slots");
|
||||
|
||||
b.Navigation("Subscription");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Minecraft_Realms_Emulator.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Minigames : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "MinigameImage",
|
||||
table: "Worlds");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "MinigameName",
|
||||
table: "Worlds");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Worlds_MinigameId",
|
||||
table: "Worlds",
|
||||
column: "MinigameId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Worlds_Templates_MinigameId",
|
||||
table: "Worlds",
|
||||
column: "MinigameId",
|
||||
principalTable: "Templates",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Worlds_Templates_MinigameId",
|
||||
table: "Worlds");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Worlds_MinigameId",
|
||||
table: "Worlds");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "MinigameImage",
|
||||
table: "Worlds",
|
||||
type: "text",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "MinigameName",
|
||||
table: "Worlds",
|
||||
type: "text",
|
||||
nullable: true);
|
||||
}
|
||||
}
|
||||
}
|
@ -372,12 +372,6 @@ namespace Minecraft_Realms_Emulator.Migrations
|
||||
b.Property<int?>("MinigameId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("MinigameImage")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("MinigameName")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Motd")
|
||||
.HasColumnType("text");
|
||||
|
||||
@ -403,6 +397,8 @@ namespace Minecraft_Realms_Emulator.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MinigameId");
|
||||
|
||||
b.HasIndex("ParentWorldId");
|
||||
|
||||
b.ToTable("Worlds");
|
||||
@ -476,10 +472,16 @@ namespace Minecraft_Realms_Emulator.Migrations
|
||||
|
||||
modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.World", b =>
|
||||
{
|
||||
b.HasOne("Minecraft_Realms_Emulator.Entities.Template", "Minigame")
|
||||
.WithMany()
|
||||
.HasForeignKey("MinigameId");
|
||||
|
||||
b.HasOne("Minecraft_Realms_Emulator.Entities.World", "ParentWorld")
|
||||
.WithMany()
|
||||
.HasForeignKey("ParentWorldId");
|
||||
|
||||
b.Navigation("Minigame");
|
||||
|
||||
b.Navigation("ParentWorld");
|
||||
});
|
||||
|
||||
|
@ -32,8 +32,8 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
string playerName = cookie.Split(";")[1].Split("=")[1];
|
||||
string gameVersion = cookie.Split(";")[2].Split("=")[1];
|
||||
|
||||
var ownedWorlds = await _context.Worlds.Where(w => w.OwnerUUID == playerUUID).Include(w => w.Subscription).Include(w => w.Slots).ToListAsync();
|
||||
var memberWorlds = await _context.Players.Where(p => p.Uuid == playerUUID && p.Accepted).Include(p => p.World.Subscription).Include(p => p.World.Slots).Select(p => p.World).ToListAsync();
|
||||
var ownedWorlds = await _context.Worlds.Where(w => w.OwnerUUID == playerUUID).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.Minigame).ToListAsync();
|
||||
var memberWorlds = await _context.Players.Where(p => p.Uuid == playerUUID && p.Accepted).Include(p => p.World.Subscription).Include(p => p.World.Slots).Include(p => p.World.Minigame).Select(p => p.World).ToListAsync();
|
||||
|
||||
List<WorldResponse> allWorlds = [];
|
||||
|
||||
@ -48,9 +48,7 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
State = nameof(StateEnum.UNINITIALIZED),
|
||||
WorldType = nameof(WorldTypeEnum.NORMAL),
|
||||
MaxPlayers = 10,
|
||||
MinigameId = null,
|
||||
MinigameName = null,
|
||||
MinigameImage = null,
|
||||
Minigame = null,
|
||||
ActiveSlot = 1,
|
||||
Member = false
|
||||
};
|
||||
@ -78,9 +76,6 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
State = world.State,
|
||||
WorldType = world.WorldType,
|
||||
MaxPlayers = world.MaxPlayers,
|
||||
MinigameId = world.MinigameId,
|
||||
MinigameName = world.MinigameName,
|
||||
MinigameImage = world.MinigameImage,
|
||||
ActiveSlot = world.ActiveSlot,
|
||||
Member = world.Member,
|
||||
Players = world.Players,
|
||||
@ -88,6 +83,13 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
Compatibility = isCompatible
|
||||
};
|
||||
|
||||
if (world.Minigame != null)
|
||||
{
|
||||
response.MinigameId = world.Minigame.Id;
|
||||
response.MinigameName = world.Minigame.Name;
|
||||
response.MinigameImage = world.Minigame.Image;
|
||||
}
|
||||
|
||||
if (world.Subscription != null)
|
||||
{
|
||||
response.DaysLeft = ((DateTimeOffset)world.Subscription.StartDate.AddDays(30) - DateTime.Today).Days;
|
||||
@ -115,9 +117,6 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
State = world.State,
|
||||
WorldType = world.WorldType,
|
||||
MaxPlayers = world.MaxPlayers,
|
||||
MinigameId = world.MinigameId,
|
||||
MinigameName = world.MinigameName,
|
||||
MinigameImage = world.MinigameImage,
|
||||
ActiveSlot = world.ActiveSlot,
|
||||
Member = world.Member,
|
||||
Players = world.Players,
|
||||
@ -128,6 +127,13 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
Compatibility = isCompatible
|
||||
};
|
||||
|
||||
if (world.Minigame != null)
|
||||
{
|
||||
response.MinigameId = world.Minigame.Id;
|
||||
response.MinigameName = world.Minigame.Name;
|
||||
response.MinigameImage = world.Minigame.Image;
|
||||
}
|
||||
|
||||
allWorlds.Add(response);
|
||||
}
|
||||
|
||||
@ -170,9 +176,6 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
State = world.State,
|
||||
WorldType = world.WorldType,
|
||||
MaxPlayers = world.MaxPlayers,
|
||||
MinigameId = world.MinigameId,
|
||||
MinigameName = world.MinigameName,
|
||||
MinigameImage = world.MinigameImage,
|
||||
ActiveSlot = world.ActiveSlot,
|
||||
Member = world.Member,
|
||||
Players = world.Players,
|
||||
@ -180,6 +183,13 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
Compatibility = isCompatible
|
||||
};
|
||||
|
||||
if (world.Minigame != null)
|
||||
{
|
||||
response.MinigameId = world.Minigame.Id;
|
||||
response.MinigameName = world.Minigame.Name;
|
||||
response.MinigameImage = world.Minigame.Image;
|
||||
}
|
||||
|
||||
if (world.Subscription != null)
|
||||
{
|
||||
response.DaysLeft = ((DateTimeOffset)world.Subscription.StartDate.AddDays(30) - DateTime.Today).Days;
|
||||
@ -220,9 +230,6 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
State = world.State,
|
||||
WorldType = world.WorldType,
|
||||
MaxPlayers = world.MaxPlayers,
|
||||
MinigameId = world.MinigameId,
|
||||
MinigameName = world.MinigameName,
|
||||
MinigameImage = world.MinigameImage,
|
||||
ActiveSlot = world.ActiveSlot,
|
||||
Member = world.Member,
|
||||
Players = world.Players,
|
||||
@ -233,6 +240,13 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
Compatibility = isCompatible
|
||||
};
|
||||
|
||||
if (world.Minigame != null)
|
||||
{
|
||||
response.MinigameId = world.Minigame.Id;
|
||||
response.MinigameName = world.Minigame.Name;
|
||||
response.MinigameImage = world.Minigame.Image;
|
||||
}
|
||||
|
||||
if (world.ParentWorld == null)
|
||||
{
|
||||
response.ParentWorldId = -1;
|
||||
@ -284,9 +298,7 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
State = nameof(StateEnum.UNINITIALIZED),
|
||||
WorldType = nameof(WorldTypeEnum.NORMAL),
|
||||
MaxPlayers = 10,
|
||||
MinigameId = null,
|
||||
MinigameName = null,
|
||||
MinigameImage = null,
|
||||
Minigame = null,
|
||||
ActiveSlot = 1,
|
||||
Member = false,
|
||||
ParentWorld = parentWorld,
|
||||
@ -316,9 +328,6 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
State = world.State,
|
||||
WorldType = world.WorldType,
|
||||
MaxPlayers = world.MaxPlayers,
|
||||
MinigameId = world.MinigameId,
|
||||
MinigameName = world.MinigameName,
|
||||
MinigameImage = world.MinigameImage,
|
||||
ActiveSlot = world.ActiveSlot,
|
||||
Member = world.Member,
|
||||
Players = world.Players,
|
||||
@ -328,6 +337,13 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
ParentWorldName = world.ParentWorld.Name,
|
||||
};
|
||||
|
||||
if (world.Minigame != null)
|
||||
{
|
||||
response.MinigameId = world.Minigame.Id;
|
||||
response.MinigameName = world.Minigame.Name;
|
||||
response.MinigameImage = world.Minigame.Image;
|
||||
}
|
||||
|
||||
if (world.Subscription != null)
|
||||
{
|
||||
response.DaysLeft = ((DateTimeOffset)world.Subscription.StartDate.AddDays(30) - DateTime.Today).Days;
|
||||
@ -355,9 +371,6 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
State = world.State,
|
||||
WorldType = world.WorldType,
|
||||
MaxPlayers = world.MaxPlayers,
|
||||
MinigameId = world.MinigameId,
|
||||
MinigameName = world.MinigameName,
|
||||
MinigameImage = world.MinigameImage,
|
||||
ActiveSlot = world.ActiveSlot,
|
||||
Member = world.Member,
|
||||
Players = world.Players,
|
||||
@ -368,6 +381,13 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
Compatibility = isCompatible
|
||||
};
|
||||
|
||||
if (world.Minigame != null)
|
||||
{
|
||||
response.MinigameId = world.Minigame.Id;
|
||||
response.MinigameName = world.Minigame.Name;
|
||||
response.MinigameImage = world.Minigame.Image;
|
||||
}
|
||||
|
||||
allWorlds.Add(response);
|
||||
}
|
||||
|
||||
@ -436,9 +456,6 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
State = world.State,
|
||||
WorldType = world.WorldType,
|
||||
MaxPlayers = world.MaxPlayers,
|
||||
MinigameId = world.MinigameId,
|
||||
MinigameName = world.MinigameName,
|
||||
MinigameImage = world.MinigameImage,
|
||||
ActiveSlot = world.ActiveSlot,
|
||||
Slots = slots,
|
||||
Member = world.Member,
|
||||
@ -450,6 +467,13 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
Compatibility = activeSlotOptions.Compatibility
|
||||
};
|
||||
|
||||
if (world.Minigame != null)
|
||||
{
|
||||
response.MinigameId = world.Minigame.Id;
|
||||
response.MinigameName = world.Minigame.Name;
|
||||
response.MinigameImage = world.Minigame.Image;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -718,8 +742,7 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
[CheckRealmOwner]
|
||||
public ActionResult<bool> SwitchSlot(int wId, int sId)
|
||||
{
|
||||
var world = _context.Worlds.Find(wId);
|
||||
|
||||
var world = _context.Worlds.Include(w => w.Minigame).FirstOrDefault(w => w.Id == wId);
|
||||
var slot = _context.Slots.Where(s => s.World.Id == wId).Where(s => s.SlotId == sId).Any();
|
||||
|
||||
if (!slot)
|
||||
@ -748,6 +771,9 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
}
|
||||
|
||||
world.ActiveSlot = sId;
|
||||
world.Minigame = null;
|
||||
world.WorldType = nameof(WorldTypeEnum.NORMAL);
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
return Ok(true);
|
||||
@ -819,5 +845,21 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
||||
|
||||
return Ok(templatesResponse);
|
||||
}
|
||||
|
||||
[HttpPut("minigames/{mId}/{wId}")]
|
||||
[CheckForWorld]
|
||||
[CheckRealmOwner]
|
||||
public ActionResult<bool> SwitchToMinigame(int mId, int wId)
|
||||
{
|
||||
var world = _context.Worlds.Find(wId);
|
||||
var minigame = _context.Templates.FirstOrDefault(t => t.Type == nameof(WorldTemplateTypeEnum.MINIGAME) && t.Id == mId);
|
||||
|
||||
world.Minigame = minigame;
|
||||
world.WorldType = nameof(WorldTypeEnum.MINIGAME);
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
string playerName = cookie.Split(";")[1].Split("=")[1];
|
||||
string gameVersion = cookie.Split(";")[2].Split("=")[1];
|
||||
|
||||
var ownedWorlds = await _context.Worlds.Where(w => w.OwnerUUID == playerUUID).Include(w => w.Subscription).Include(w => w.Slots).ToListAsync();
|
||||
var memberWorlds = await _context.Players.Where(p => p.Uuid == playerUUID && p.Accepted).Include(p => p.World.Subscription).Include(p => p.World.Slots).Select(p => p.World).ToListAsync();
|
||||
var ownedWorlds = await _context.Worlds.Where(w => w.OwnerUUID == playerUUID).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.Minigame).ToListAsync();
|
||||
var memberWorlds = await _context.Players.Where(p => p.Uuid == playerUUID && p.Accepted).Include(p => p.World.Subscription).Include(p => p.World.Slots).Include(p => p.World.Minigame).Select(p => p.World).ToListAsync();
|
||||
|
||||
List<WorldResponse> allWorlds = [];
|
||||
|
||||
@ -51,9 +51,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
State = nameof(StateEnum.UNINITIALIZED),
|
||||
WorldType = nameof(WorldTypeEnum.NORMAL),
|
||||
MaxPlayers = 10,
|
||||
MinigameId = null,
|
||||
MinigameName = null,
|
||||
MinigameImage = null,
|
||||
Minigame = null,
|
||||
ActiveSlot = 1,
|
||||
Member = false
|
||||
};
|
||||
@ -81,9 +79,6 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
State = world.State,
|
||||
WorldType = world.WorldType,
|
||||
MaxPlayers = world.MaxPlayers,
|
||||
MinigameId = world.MinigameId,
|
||||
MinigameName = world.MinigameName,
|
||||
MinigameImage = world.MinigameImage,
|
||||
ActiveSlot = world.ActiveSlot,
|
||||
Member = world.Member,
|
||||
Players = world.Players,
|
||||
@ -91,6 +86,13 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
Compatibility = isCompatible
|
||||
};
|
||||
|
||||
if (world.Minigame != null)
|
||||
{
|
||||
response.MinigameId = world.Minigame.Id;
|
||||
response.MinigameName = world.Minigame.Name;
|
||||
response.MinigameImage = world.Minigame.Image;
|
||||
}
|
||||
|
||||
if (world.Subscription != null)
|
||||
{
|
||||
response.DaysLeft = ((DateTimeOffset)world.Subscription.StartDate.AddDays(30) - DateTime.Today).Days;
|
||||
@ -118,9 +120,6 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
State = world.State,
|
||||
WorldType = world.WorldType,
|
||||
MaxPlayers = world.MaxPlayers,
|
||||
MinigameId = world.MinigameId,
|
||||
MinigameName = world.MinigameName,
|
||||
MinigameImage = world.MinigameImage,
|
||||
ActiveSlot = world.ActiveSlot,
|
||||
Member = world.Member,
|
||||
Players = world.Players,
|
||||
@ -131,6 +130,13 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
Compatibility = isCompatible
|
||||
};
|
||||
|
||||
if (world.Minigame != null)
|
||||
{
|
||||
response.MinigameId = world.Minigame.Id;
|
||||
response.MinigameName = world.Minigame.Name;
|
||||
response.MinigameImage = world.Minigame.Image;
|
||||
}
|
||||
|
||||
allWorlds.Add(response);
|
||||
}
|
||||
|
||||
@ -173,9 +179,6 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
State = world.State,
|
||||
WorldType = world.WorldType,
|
||||
MaxPlayers = world.MaxPlayers,
|
||||
MinigameId = world.MinigameId,
|
||||
MinigameName = world.MinigameName,
|
||||
MinigameImage = world.MinigameImage,
|
||||
ActiveSlot = world.ActiveSlot,
|
||||
Member = world.Member,
|
||||
Players = world.Players,
|
||||
@ -183,6 +186,13 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
Compatibility = isCompatible
|
||||
};
|
||||
|
||||
if (world.Minigame != null)
|
||||
{
|
||||
response.MinigameId = world.Minigame.Id;
|
||||
response.MinigameName = world.Minigame.Name;
|
||||
response.MinigameImage = world.Minigame.Image;
|
||||
}
|
||||
|
||||
if (world.Subscription != null)
|
||||
{
|
||||
response.DaysLeft = ((DateTimeOffset)world.Subscription.StartDate.AddDays(30) - DateTime.Today).Days;
|
||||
@ -223,9 +233,6 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
State = world.State,
|
||||
WorldType = world.WorldType,
|
||||
MaxPlayers = world.MaxPlayers,
|
||||
MinigameId = world.MinigameId,
|
||||
MinigameName = world.MinigameName,
|
||||
MinigameImage = world.MinigameImage,
|
||||
ActiveSlot = world.ActiveSlot,
|
||||
Member = world.Member,
|
||||
Players = world.Players,
|
||||
@ -236,6 +243,13 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
Compatibility = isCompatible
|
||||
};
|
||||
|
||||
if (world.Minigame != null)
|
||||
{
|
||||
response.MinigameId = world.Minigame.Id;
|
||||
response.MinigameName = world.Minigame.Name;
|
||||
response.MinigameImage = world.Minigame.Image;
|
||||
}
|
||||
|
||||
if (world.ParentWorld == null)
|
||||
{
|
||||
response.ParentWorldId = -1;
|
||||
@ -287,9 +301,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
State = nameof(StateEnum.UNINITIALIZED),
|
||||
WorldType = nameof(WorldTypeEnum.NORMAL),
|
||||
MaxPlayers = 10,
|
||||
MinigameId = null,
|
||||
MinigameName = null,
|
||||
MinigameImage = null,
|
||||
Minigame = null,
|
||||
ActiveSlot = 1,
|
||||
Member = false,
|
||||
ParentWorld = parentWorld,
|
||||
@ -319,9 +331,6 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
State = world.State,
|
||||
WorldType = world.WorldType,
|
||||
MaxPlayers = world.MaxPlayers,
|
||||
MinigameId = world.MinigameId,
|
||||
MinigameName = world.MinigameName,
|
||||
MinigameImage = world.MinigameImage,
|
||||
ActiveSlot = world.ActiveSlot,
|
||||
Member = world.Member,
|
||||
Players = world.Players,
|
||||
@ -331,6 +340,13 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
ParentWorldName = world.ParentWorld.Name,
|
||||
};
|
||||
|
||||
if (world.Minigame != null)
|
||||
{
|
||||
response.MinigameId = world.Minigame.Id;
|
||||
response.MinigameName = world.Minigame.Name;
|
||||
response.MinigameImage = world.Minigame.Image;
|
||||
}
|
||||
|
||||
if (world.Subscription != null)
|
||||
{
|
||||
response.DaysLeft = ((DateTimeOffset)world.Subscription.StartDate.AddDays(30) - DateTime.Today).Days;
|
||||
@ -358,9 +374,6 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
State = world.State,
|
||||
WorldType = world.WorldType,
|
||||
MaxPlayers = world.MaxPlayers,
|
||||
MinigameId = world.MinigameId,
|
||||
MinigameName = world.MinigameName,
|
||||
MinigameImage = world.MinigameImage,
|
||||
ActiveSlot = world.ActiveSlot,
|
||||
Member = world.Member,
|
||||
Players = world.Players,
|
||||
@ -371,6 +384,13 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
Compatibility = isCompatible
|
||||
};
|
||||
|
||||
if (world.Minigame != null)
|
||||
{
|
||||
response.MinigameId = world.Minigame.Id;
|
||||
response.MinigameName = world.Minigame.Name;
|
||||
response.MinigameImage = world.Minigame.Image;
|
||||
}
|
||||
|
||||
allWorlds.Add(response);
|
||||
}
|
||||
|
||||
@ -439,9 +459,6 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
State = world.State,
|
||||
WorldType = world.WorldType,
|
||||
MaxPlayers = world.MaxPlayers,
|
||||
MinigameId = world.MinigameId,
|
||||
MinigameName = world.MinigameName,
|
||||
MinigameImage = world.MinigameImage,
|
||||
ActiveSlot = world.ActiveSlot,
|
||||
Slots = slots,
|
||||
Member = world.Member,
|
||||
@ -453,6 +470,13 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
Compatibility = activeSlotOptions.Compatibility
|
||||
};
|
||||
|
||||
if (world.Minigame != null)
|
||||
{
|
||||
response.MinigameId = world.Minigame.Id;
|
||||
response.MinigameName = world.Minigame.Name;
|
||||
response.MinigameImage = world.Minigame.Image;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -789,8 +813,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
[CheckActiveSubscription]
|
||||
public ActionResult<bool> SwitchSlot(int wId, int sId)
|
||||
{
|
||||
var world = _context.Worlds.Find(wId);
|
||||
|
||||
var world = _context.Worlds.Include(w => w.Minigame).FirstOrDefault(w => w.Id == wId);
|
||||
var slot = _context.Slots.Where(s => s.World.Id == wId).Where(s => s.SlotId == sId).Any();
|
||||
|
||||
if (!slot)
|
||||
@ -819,6 +842,9 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
}
|
||||
|
||||
world.ActiveSlot = sId;
|
||||
world.Minigame = null;
|
||||
world.WorldType = nameof(WorldTypeEnum.NORMAL);
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
return Ok(true);
|
||||
@ -894,5 +920,21 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
|
||||
return Ok(templatesResponse);
|
||||
}
|
||||
|
||||
[HttpPut("minigames/{mId}/{wId}")]
|
||||
[CheckForWorld]
|
||||
[CheckRealmOwner]
|
||||
public ActionResult<bool> SwitchToMinigame(int mId, int wId)
|
||||
{
|
||||
var world = _context.Worlds.Find(wId);
|
||||
var minigame = _context.Templates.FirstOrDefault(t => t.Type == nameof(WorldTemplateTypeEnum.MINIGAME) && t.Id == mId);
|
||||
|
||||
world.Minigame = minigame;
|
||||
world.WorldType = nameof(WorldTypeEnum.MINIGAME);
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,5 +13,8 @@ namespace Minecraft_Realms_Emulator.Entities
|
||||
public string ActiveVersion { get; set; } = null!;
|
||||
public int? ParentWorldId { get; set; }
|
||||
public string? ParentWorldName { get; set; }
|
||||
public int? MinigameId { get; set; }
|
||||
public string? MinigameName { get; set; }
|
||||
public string? MinigameImage { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user