diff --git a/Minecraft-Realms-Emulator/Controllers/TrialController.cs b/Minecraft-Realms-Emulator/Controllers/TrialController.cs
index 314a9a2..fdca4a2 100644
--- a/Minecraft-Realms-Emulator/Controllers/TrialController.cs
+++ b/Minecraft-Realms-Emulator/Controllers/TrialController.cs
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
+using Minecraft_Realms_Emulator.Data;
namespace Minecraft_Realms_Emulator.Controllers
{
@@ -6,9 +7,16 @@ namespace Minecraft_Realms_Emulator.Controllers
[ApiController]
public class TrialController : ControllerBase
{
+ private readonly DataContext _context;
+
+ public TrialController(DataContext context)
+ {
+ _context = context;
+ }
+
[HttpGet(Name = "GetTrial")]
- public bool Get() {
- return true;
+ public bool Get() {
+ return bool.Parse(_context.Configuration.FirstOrDefault(x => x.Key == "trialMode").Value);
}
}
}
diff --git a/Minecraft-Realms-Emulator/Controllers/WorldsController.cs b/Minecraft-Realms-Emulator/Controllers/WorldsController.cs
index f1cbe94..2754678 100644
--- a/Minecraft-Realms-Emulator/Controllers/WorldsController.cs
+++ b/Minecraft-Realms-Emulator/Controllers/WorldsController.cs
@@ -2,8 +2,6 @@
using Microsoft.EntityFrameworkCore;
using Minecraft_Realms_Emulator.Data;
using Minecraft_Realms_Emulator.Entities;
-using System.Collections.Generic;
-using System.Diagnostics.Eventing.Reader;
namespace Minecraft_Realms_Emulator.Controllers
{
diff --git a/Minecraft-Realms-Emulator/Entities/Configuration.cs b/Minecraft-Realms-Emulator/Entities/Configuration.cs
index 514f586..54c3aae 100644
--- a/Minecraft-Realms-Emulator/Entities/Configuration.cs
+++ b/Minecraft-Realms-Emulator/Entities/Configuration.cs
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
+using System.ComponentModel.DataAnnotations.Schema;
namespace Minecraft_Realms_Emulator.Entities
{
@@ -6,6 +7,7 @@ namespace Minecraft_Realms_Emulator.Entities
public class Configuration
{
public string Key { get; set; } = string.Empty;
- public string Value { get; set; } = string.Empty;
+ [Column(TypeName = "jsonb")]
+ public dynamic Value { get; set; } = string.Empty;
}
}
diff --git a/Minecraft-Realms-Emulator/Helpers/Database.cs b/Minecraft-Realms-Emulator/Helpers/Database.cs
index 2461401..c59f9ba 100644
--- a/Minecraft-Realms-Emulator/Helpers/Database.cs
+++ b/Minecraft-Realms-Emulator/Helpers/Database.cs
@@ -18,7 +18,7 @@ namespace Minecraft_Realms_Emulator.Helpers
var newsLink = new Configuration
{
Key = "newsLink",
- Value = "https://github.com/CyberL1/Minecraft-Realms-Emulator"
+ Value = "\"https://github.com/CyberL1/Minecraft-Realms-Emulator\""
};
db.Configuration.Add(newsLink);
@@ -29,12 +29,23 @@ namespace Minecraft_Realms_Emulator.Helpers
var defaultServerAddress = new Configuration
{
Key = "defaultServerAddress",
- Value = "127.0.0.1"
+ Value = "\"127.0.0.1\""
};
db.Configuration.Add(defaultServerAddress);
}
+ if (db.Configuration.FirstOrDefault(x => x.Key == "trialMode") == null)
+ {
+ var trialMode = new Configuration
+ {
+ Key = "trialMode",
+ Value = true
+ };
+
+ db.Configuration.Add(trialMode);
+ }
+
db.SaveChanges();
}
}
diff --git a/Minecraft-Realms-Emulator/Migrations/20240414062222_Configuration_Json.Designer.cs b/Minecraft-Realms-Emulator/Migrations/20240414062222_Configuration_Json.Designer.cs
new file mode 100644
index 0000000..55479b4
--- /dev/null
+++ b/Minecraft-Realms-Emulator/Migrations/20240414062222_Configuration_Json.Designer.cs
@@ -0,0 +1,313 @@
+//
+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("20240414062222_Configuration_Json")]
+ partial class Configuration_Json
+ {
+ ///
+ 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("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("BackupId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("LastModifiedDate")
+ .HasColumnType("bigint");
+
+ b.Property("Metadata")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property("Size")
+ .HasColumnType("integer");
+
+ b.Property("WorldId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("WorldId");
+
+ b.ToTable("Backups");
+ });
+
+ modelBuilder.Entity("Minecraft_Realms_Emulator.Entities.Configuration", b =>
+ {
+ b.Property("Key")
+ .HasColumnType("text");
+
+ b.Property