mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2024-12-22 04:18:21 -05:00
feat: invites
This commit is contained in:
parent
ca57e03ee3
commit
eeb0ddf64f
150
Minecraft-Realms-Emulator/Controllers/InvitesController.cs
Normal file
150
Minecraft-Realms-Emulator/Controllers/InvitesController.cs
Normal file
@ -0,0 +1,150 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Minecraft_Realms_Emulator.Data;
|
||||
using Minecraft_Realms_Emulator.Entities;
|
||||
using Minecraft_Realms_Emulator.Responses;
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Minecraft_Realms_Emulator.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class InvitesController : ControllerBase
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public InvitesController(DataContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[HttpGet("pending")]
|
||||
public async Task<ActionResult<InviteList>> GetInvites()
|
||||
{
|
||||
string cookie = Request.Headers.Cookie;
|
||||
string playerUUID = cookie.Split(";")[0].Split(":")[2];
|
||||
|
||||
var invites = await _context.Invites.Where(i => i.RecipeintUUID == playerUUID).Include(i => i.World).ToListAsync();
|
||||
|
||||
List<InviteResponse> invitesList = [];
|
||||
|
||||
foreach (var invite in invites)
|
||||
{
|
||||
InviteResponse inv = new()
|
||||
{
|
||||
InvitationId = invite.InvitationId,
|
||||
WorldName = invite.World.Name,
|
||||
WorldOwnerName = invite.World.Owner,
|
||||
WorldOwnerUuid = invite.World.OwnerUUID,
|
||||
Date = ((DateTimeOffset) invite.Date).ToUnixTimeMilliseconds(),
|
||||
};
|
||||
|
||||
invitesList.Add(inv);
|
||||
}
|
||||
|
||||
InviteList inviteListRespone = new()
|
||||
{
|
||||
Invites = invitesList
|
||||
};
|
||||
|
||||
return Ok(inviteListRespone);
|
||||
}
|
||||
[HttpPut("accept/{id}")]
|
||||
public ActionResult<bool> AcceptInvite(string id)
|
||||
{
|
||||
var invite = _context.Invites.FirstOrDefault(i => i.InvitationId == id);
|
||||
|
||||
if (invite == null) return NotFound("Invite not found");
|
||||
_context.Invites.Remove(invite);
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
[HttpPut("reject/{id}")]
|
||||
public async Task<ActionResult<bool>> RejectInvite(string id)
|
||||
{
|
||||
var invite = _context.Invites.Include(i => i.World).FirstOrDefault(i => i.InvitationId == id);
|
||||
|
||||
if (invite == null) return NotFound("Invite not found");
|
||||
|
||||
_context.Invites.Remove(invite);
|
||||
|
||||
string cookie = Request.Headers.Cookie;
|
||||
string playerUUID = cookie.Split(";")[0].Split(":")[2];
|
||||
|
||||
World world = await _context.Worlds.FindAsync(invite.World.Id);
|
||||
var playerIndex = world.Players.FindIndex(p => p.RootElement.GetProperty("uuid").ToString() == playerUUID);
|
||||
|
||||
world.Players.RemoveAt(playerIndex);
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
[HttpPost("{wId}")]
|
||||
public async Task<ActionResult<World>> InvitePlayer(int wId, Player body)
|
||||
{
|
||||
string cookie = Request.Headers.Cookie;
|
||||
string playerName = cookie.Split(";")[1].Split("=")[1];
|
||||
|
||||
if (body.Name == playerName) return Forbid("You cannot invite yourself");
|
||||
|
||||
var world = await _context.Worlds.FirstOrDefaultAsync(w => w.Id == wId);
|
||||
|
||||
if (world == null) return NotFound("World not found");
|
||||
|
||||
if (world.Players.Exists(p => p.RootElement.GetProperty("name").ToString() == body.Name)) return NotFound("Player already invited");
|
||||
|
||||
// Get player UUID
|
||||
var playerInfo = await new HttpClient().GetFromJsonAsync<MinecraftPlayerInfo>($"https://api.mojang.com/users/profiles/minecraft/{body.Name}");
|
||||
body.Uuid = playerInfo.Id;
|
||||
|
||||
JsonDocument player = JsonDocument.Parse(JsonSerializer.Serialize(body));
|
||||
world.Players.Add(player);
|
||||
|
||||
_context.Worlds.Update(world);
|
||||
|
||||
Invite invite = new()
|
||||
{
|
||||
InvitationId = Guid.NewGuid().ToString(),
|
||||
World = world,
|
||||
RecipeintUUID = body.Uuid,
|
||||
Date = DateTime.UtcNow,
|
||||
};
|
||||
|
||||
_context.Invites.Add(invite);
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
return Ok(world);
|
||||
}
|
||||
|
||||
[HttpDelete("{wId}/invite/{uuid}")]
|
||||
public async Task<ActionResult<bool>> DeleteInvite(int wId, string uuid)
|
||||
{
|
||||
Console.WriteLine($"{wId} - {uuid}");
|
||||
|
||||
var world = await _context.Worlds.FirstOrDefaultAsync(w => w.Id == wId);
|
||||
|
||||
if (world == null) return NotFound("World not found");
|
||||
|
||||
var players = world.Players.ToList();
|
||||
|
||||
var playerIndex = world.Players.FindIndex(p => p.RootElement.GetProperty("uuid").ToString() == uuid);
|
||||
|
||||
world.Players.RemoveAt(playerIndex);
|
||||
|
||||
var invite = await _context.Invites.FirstOrDefaultAsync(i => i.RecipeintUUID == uuid);
|
||||
|
||||
if (invite != null) _context.Invites.Remove(invite);
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -9,5 +9,6 @@ namespace Minecraft_Realms_Emulator.Data
|
||||
public DbSet<Subscription> Subscriptions { get; set; }
|
||||
public DbSet<Connection> Connections { get; set; }
|
||||
public DbSet<Backup> Backups { get; set; }
|
||||
public DbSet<Invite> Invites { get; set; }
|
||||
}
|
||||
}
|
||||
|
11
Minecraft-Realms-Emulator/Entities/Invite.cs
Normal file
11
Minecraft-Realms-Emulator/Entities/Invite.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace Minecraft_Realms_Emulator.Entities
|
||||
{
|
||||
public class Invite
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string InvitationId { get; set; }= string.Empty;
|
||||
public string RecipeintUUID { get; set; } = string.Empty;
|
||||
public World World { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
}
|
||||
}
|
20
Minecraft-Realms-Emulator/Entities/Player.cs
Normal file
20
Minecraft-Realms-Emulator/Entities/Player.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Minecraft_Realms_Emulator.Entities
|
||||
{
|
||||
public class Player
|
||||
{
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[JsonPropertyName("uuid")]
|
||||
public string Uuid { get; set; } = string.Empty;
|
||||
[JsonPropertyName("operator")]
|
||||
public bool Operator { get; set; }
|
||||
[JsonPropertyName("accepted")]
|
||||
public bool Accepted { get; set; }
|
||||
[JsonPropertyName("online")]
|
||||
public bool Online { get; set; }
|
||||
[JsonPropertyName("permission")]
|
||||
public string Permission { get; set; } = "MEMBER";
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ namespace Minecraft_Realms_Emulator.Entities
|
||||
public bool Expired { get; set; } = false;
|
||||
public bool ExpiredTrial { get; set; } = false;
|
||||
public string WorldType { get; set; } = "NORMAL";
|
||||
public string[] Players { get; set; } = [];
|
||||
public List<JsonDocument> Players { get; set; } = [];
|
||||
public int MaxPlayers { get; set; } = 10;
|
||||
public string? MinigameName { get; set; }
|
||||
public int? MinigameId { get; set; }
|
||||
|
259
Minecraft-Realms-Emulator/Migrations/20240220092334_Invites.Designer.cs
generated
Normal file
259
Minecraft-Realms-Emulator/Migrations/20240220092334_Invites.Designer.cs
generated
Normal file
@ -0,0 +1,259 @@
|
||||
// <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("20240220092334_Invites")]
|
||||
partial class Invites
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.1")
|
||||
.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.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.Subscription", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("StartDate")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("SubscriptionType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("WorldId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WorldId");
|
||||
|
||||
b.ToTable("Subscriptions");
|
||||
});
|
||||
|
||||
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>("DaysLeft")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("Expired")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("ExpiredTrial")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("MaxPlayers")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("Member")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int?>("MinigameId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("MinigameImage")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("MinigameName")
|
||||
.HasColumnType("text");
|
||||
|
||||
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<string[]>("Players")
|
||||
.IsRequired()
|
||||
.HasColumnType("text[]");
|
||||
|
||||
b.Property<string>("RemoteSubscriptionId")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<JsonDocument[]>("Slots")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb[]");
|
||||
|
||||
b.Property<string>("State")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("WorldType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
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.Subscription", b =>
|
||||
{
|
||||
b.HasOne("Minecraft_Realms_Emulator.Entities.World", "World")
|
||||
.WithMany()
|
||||
.HasForeignKey("WorldId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("World");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Minecraft_Realms_Emulator.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Invites : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Invites",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
InvitationId = table.Column<string>(type: "text", nullable: false),
|
||||
RecipeintUUID = table.Column<string>(type: "text", nullable: false),
|
||||
WorldId = table.Column<int>(type: "integer", nullable: false),
|
||||
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Invites", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Invites_Worlds_WorldId",
|
||||
column: x => x.WorldId,
|
||||
principalTable: "Worlds",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Invites_WorldId",
|
||||
table: "Invites",
|
||||
column: "WorldId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Invites");
|
||||
}
|
||||
}
|
||||
}
|
259
Minecraft-Realms-Emulator/Migrations/20240220110531_Worlds_Players.Designer.cs
generated
Normal file
259
Minecraft-Realms-Emulator/Migrations/20240220110531_Worlds_Players.Designer.cs
generated
Normal file
@ -0,0 +1,259 @@
|
||||
// <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("20240220110531_Worlds_Players")]
|
||||
partial class Worlds_Players
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.1")
|
||||
.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.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.Subscription", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("StartDate")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("SubscriptionType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("WorldId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WorldId");
|
||||
|
||||
b.ToTable("Subscriptions");
|
||||
});
|
||||
|
||||
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>("DaysLeft")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("Expired")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("ExpiredTrial")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("MaxPlayers")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("Member")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int?>("MinigameId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("MinigameImage")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("MinigameName")
|
||||
.HasColumnType("text");
|
||||
|
||||
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<JsonDocument[]>("Players")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb[]");
|
||||
|
||||
b.Property<string>("RemoteSubscriptionId")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<JsonDocument[]>("Slots")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb[]");
|
||||
|
||||
b.Property<string>("State")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("WorldType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
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.Subscription", b =>
|
||||
{
|
||||
b.HasOne("Minecraft_Realms_Emulator.Entities.World", "World")
|
||||
.WithMany()
|
||||
.HasForeignKey("WorldId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("World");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using System.Text.Json;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Minecraft_Realms_Emulator.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Worlds_Players : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql("ALTER TABLE \"Worlds\" ALTER COLUMN \"Players\" TYPE jsonb[] USING \"Players\"::jsonb[]");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql("ALTER TABLE \"Worlds\" ALTER COLUMN \"Players\" TYPE text[] USING \"Players\"::text[]");
|
||||
}
|
||||
}
|
||||
}
|
@ -80,6 +80,35 @@ namespace Minecraft_Realms_Emulator.Migrations
|
||||
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.Subscription", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -153,9 +182,9 @@ namespace Minecraft_Realms_Emulator.Migrations
|
||||
b.Property<string>("OwnerUUID")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string[]>("Players")
|
||||
b.Property<JsonDocument[]>("Players")
|
||||
.IsRequired()
|
||||
.HasColumnType("text[]");
|
||||
.HasColumnType("jsonb[]");
|
||||
|
||||
b.Property<string>("RemoteSubscriptionId")
|
||||
.IsRequired()
|
||||
@ -200,6 +229,17 @@ namespace Minecraft_Realms_Emulator.Migrations
|
||||
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.Subscription", b =>
|
||||
{
|
||||
b.HasOne("Minecraft_Realms_Emulator.Entities.World", "World")
|
||||
|
16
Minecraft-Realms-Emulator/Responses/InviteList.cs
Normal file
16
Minecraft-Realms-Emulator/Responses/InviteList.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace Minecraft_Realms_Emulator.Responses
|
||||
{
|
||||
public class InviteList
|
||||
{
|
||||
public List<InviteResponse> Invites { get; set; }
|
||||
}
|
||||
|
||||
public class InviteResponse
|
||||
{
|
||||
public string InvitationId { get; set; } = string.Empty;
|
||||
public string WorldName { get; set; } = string.Empty;
|
||||
public string WorldOwnerName { get; set; } = string.Empty;
|
||||
public string WorldOwnerUuid { get; set; } = string.Empty;
|
||||
public long Date { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace Minecraft_Realms_Emulator.Responses
|
||||
{
|
||||
public class MinecraftPlayerInfo
|
||||
{
|
||||
public string Id { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public object Result { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user