-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Better Configuration (#437)
Showing
29 changed files
with
775 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,279 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"title": "IServerConfiguration", | ||
"type": "object", | ||
"x-abstract": true, | ||
"additionalProperties": false, | ||
"properties": { | ||
"Logging": { | ||
"$ref": "#/definitions/logging" | ||
}, | ||
"baah": { | ||
"type": [ | ||
"boolean", | ||
"null" | ||
] | ||
}, | ||
"allowLan": { | ||
"type": "boolean" | ||
}, | ||
"motd": { | ||
"type": "string" | ||
}, | ||
"port": { | ||
"type": "integer", | ||
"format": "int32" | ||
}, | ||
"address": { | ||
"type": [ | ||
"null", | ||
"string" | ||
] | ||
}, | ||
"onlineMode": { | ||
"type": "boolean" | ||
}, | ||
"maxPlayers": { | ||
"type": "integer", | ||
"format": "int32" | ||
}, | ||
"pregenerateChunkRange": { | ||
"type": "integer", | ||
"format": "int32" | ||
}, | ||
"serverListQuery": { | ||
"$ref": "#/definitions/ServerListQuery" | ||
}, | ||
"timeTickSpeedMultiplier": { | ||
"type": "integer", | ||
"format": "int32" | ||
}, | ||
"allowOperatorRequests": { | ||
"type": "boolean" | ||
}, | ||
"enableRcon": { | ||
"type": "boolean" | ||
}, | ||
"whitelist": { | ||
"type": "boolean" | ||
}, | ||
"network": { | ||
"$ref": "#/definitions/NetworkConfiguration" | ||
}, | ||
"messages": { | ||
"$ref": "#/definitions/MessagesConfiguration" | ||
}, | ||
"rcon": { | ||
"oneOf": [ | ||
{ | ||
"type": "null" | ||
}, | ||
{ | ||
"$ref": "#/definitions/RconConfiguration" | ||
} | ||
] | ||
}, | ||
"viewDistance": { | ||
"type": "integer", | ||
"format": "byte" | ||
} | ||
}, | ||
"definitions": { | ||
"logLevelThreshold": { | ||
"description": "Log level threshold.", | ||
"type": "string", | ||
"enum": [ | ||
"Trace", | ||
"Debug", | ||
"Information", | ||
"Warning", | ||
"Error", | ||
"Critical", | ||
"None" | ||
] | ||
}, | ||
"logLevel": { | ||
"title": "logging level options", | ||
"description": "Log level configurations used when creating logs. Only logs that exceeds its matching log level will be enabled. Each log level configuration has a category specified by its JSON property name. For more information about configuring log levels, see https://docs.microsoft.com/aspnet/core/fundamentals/logging/#configure-logging.", | ||
"type": "object", | ||
"additionalProperties": { | ||
"$ref": "#/definitions/logLevelThreshold" | ||
} | ||
}, | ||
"logging": { | ||
"title": "logging options", | ||
"type": "object", | ||
"description": "Configuration for Microsoft.Extensions.Logging.", | ||
"properties": { | ||
"LogLevel": { | ||
"$ref": "#/definitions/logLevel" | ||
}, | ||
"Console": { | ||
"properties": { | ||
"LogLevel": { | ||
"$ref": "#/definitions/logLevel" | ||
}, | ||
"FormatterName": { | ||
"description": "Name of the log message formatter to use. Defaults to 'simple'.", | ||
"type": "string", | ||
"default": "simple" | ||
}, | ||
"FormatterOptions": { | ||
"title": "formatter options", | ||
"description": "Log message formatter options. Additional properties are available on the options depending on the configured formatter. The formatter is specified by FormatterName.", | ||
"type": "object", | ||
"properties": { | ||
"IncludeScopes": { | ||
"description": "Include scopes when true. Defaults to false.", | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"TimestampFormat": { | ||
"description": "Format string used to format timestamp in logging messages. Defaults to null.", | ||
"type": "string" | ||
}, | ||
"UseUtcTimestamp": { | ||
"description": "Indication whether or not UTC timezone should be used to for timestamps in logging messages. Defaults to false.", | ||
"type": "boolean", | ||
"default": false | ||
} | ||
} | ||
}, | ||
"LogToStandardErrorThreshold": { | ||
"$ref": "#/definitions/logLevelThreshold", | ||
"description": "The minimum level of messages are written to Console.Error." | ||
} | ||
} | ||
}, | ||
"EventSource": { | ||
"properties": { | ||
"LogLevel": { | ||
"$ref": "#/definitions/logLevel" | ||
} | ||
} | ||
}, | ||
"Debug": { | ||
"properties": { | ||
"LogLevel": { | ||
"$ref": "#/definitions/logLevel" | ||
} | ||
} | ||
}, | ||
"EventLog": { | ||
"properties": { | ||
"LogLevel": { | ||
"$ref": "#/definitions/logLevel" | ||
} | ||
} | ||
}, | ||
"ElmahIo": { | ||
"properties": { | ||
"LogLevel": { | ||
"$ref": "#/definitions/logLevel" | ||
} | ||
} | ||
}, | ||
"ElmahIoBreadcrumbs": { | ||
"properties": { | ||
"LogLevel": { | ||
"$ref": "#/definitions/logLevel" | ||
} | ||
} | ||
} | ||
}, | ||
"additionalProperties": { | ||
"title": "provider logging settings", | ||
"type": "object", | ||
"description": "Logging configuration for a provider. The provider name must match the configuration's JSON property property name.", | ||
"properties": { | ||
"LogLevel": { | ||
"$ref": "#/definitions/logLevel" | ||
} | ||
} | ||
} | ||
}, | ||
"ServerListQuery": { | ||
"type": "string", | ||
"description": "", | ||
"x-enumNames": [ | ||
"Full", | ||
"Anonymized", | ||
"Disabled" | ||
], | ||
"enum": [ | ||
"Full", | ||
"Anonymized", | ||
"Disabled" | ||
] | ||
}, | ||
"NetworkConfiguration": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"shouldThrottle": { | ||
"type": "boolean" | ||
}, | ||
"keepAliveInterval": { | ||
"type": "integer", | ||
"format": "int64" | ||
}, | ||
"keepAliveTimeoutInterval": { | ||
"type": "integer", | ||
"format": "int64" | ||
}, | ||
"connectionThrottle": { | ||
"type": "integer", | ||
"format": "int64" | ||
}, | ||
"mulitplayerDebugMode": { | ||
"type": "boolean" | ||
} | ||
} | ||
}, | ||
"MessagesConfiguration": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"join": { | ||
"type": "string" | ||
}, | ||
"leave": { | ||
"type": "string" | ||
}, | ||
"notWhitelisted": { | ||
"type": "string" | ||
}, | ||
"serverFull": { | ||
"type": "string" | ||
}, | ||
"outdatedClient": { | ||
"type": "string" | ||
}, | ||
"outdatedServer": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"RconConfiguration": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"password": { | ||
"type": [ | ||
"null", | ||
"string" | ||
] | ||
}, | ||
"port": { | ||
"type": "integer" | ||
}, | ||
"broadcastToOps": { | ||
"type": "boolean" | ||
}, | ||
"requireEncryption": { | ||
"type": "boolean" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"title": "WhitelistConfiguration", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"whitelistedPlayers": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/WhitelistedPlayer" | ||
} | ||
}, | ||
"whitelistedIps": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"WhitelistedPlayer": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"id": { | ||
"type": "string", | ||
"format": "guid" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Obsidian.API.Configuration; | ||
public sealed record class MessagesConfiguration | ||
{ | ||
public string Join { get; set; } = "&e{0} joined the game"; | ||
|
||
public string Leave { get; set; } = "&e{0} left the game"; | ||
|
||
public string NotWhitelisted { get; set; } = "You are not whitelisted on this server!"; | ||
|
||
public string ServerFull { get; set; } = "The server is full!"; | ||
|
||
public string OutdatedClient { get; set; } = "Outdated client! Please use {0}"; | ||
public string OutdatedServer { get; set; } = "Outdated server! I'm still on {0}"; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Obsidian.API.Configuration; | ||
public sealed record class NetworkConfiguration | ||
{ | ||
/// <summary> | ||
/// Returns true if <see cref="ConnectionThrottle"/> has a value greater than 0. | ||
/// </summary> | ||
public bool ShouldThrottle => this.ConnectionThrottle > 0; | ||
|
||
public long KeepAliveInterval { get; set; } = 10_000; | ||
|
||
public long KeepAliveTimeoutInterval { get; set; } = 30_000; | ||
|
||
/// <summary> | ||
/// The time in milliseconds to wait before an ip is allowed to try and connect again. | ||
/// </summary> | ||
public long ConnectionThrottle { get; set; } = 15_000; | ||
|
||
/// <summary> | ||
/// If true, each login/client gets a random username where multiple connections from the same host will be allowed. | ||
/// </summary> | ||
public bool MulitplayerDebugMode { get; set; } = false; | ||
} |
6 changes: 3 additions & 3 deletions
6
Obsidian.API/_Types/Config/RconConfig.cs → ...an.API/Configuration/RconConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
using Obsidian.API.Configuration; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Obsidian.API.Configuration; | ||
|
||
public sealed class ServerConfiguration | ||
{ | ||
private byte viewDistance = 10; | ||
|
||
// Anything lower than 3 will cause weird artifacts on the client. | ||
private const byte MinimumViewDistance = 3; | ||
|
||
/// <summary> | ||
/// Enabled Remote Console operation. | ||
/// </summary> | ||
/// <remarks>See more at https://wiki.vg/RCON</remarks> | ||
public bool EnableRcon => Rcon is not null; | ||
|
||
/// <summary> | ||
/// Server description. | ||
/// </summary> | ||
public string Motd { get; set; } = $"§k||||§r §5Obsidian §cPre§r-§cRelease §r§k||||§r \n§r§lRunning on .NET §l§c{Environment.Version} §r§l<3"; | ||
|
||
/// <summary> | ||
/// The port on which to listen for incoming connection attempts. | ||
/// </summary> | ||
public int Port { get; set; } = 25565; | ||
|
||
/// <summary> | ||
/// Whether the server uses MojangAPI for loading skins etc. | ||
/// </summary> | ||
public bool OnlineMode { get; set; } = true; | ||
|
||
/// <summary> | ||
/// Maximum amount of players that is allowed to be connected at the same time. | ||
/// </summary> | ||
public int MaxPlayers { get; set; } = 25; | ||
|
||
/// <summary> | ||
/// Allow people to requests to become an operator. | ||
/// </summary> | ||
public bool AllowOperatorRequests { get; set; } = true; | ||
|
||
public bool ServerShutdownStopsProgram { get; set; } = true; | ||
|
||
/// <summary> | ||
/// Whether to allow the server to load untrusted(unsigned) plugins | ||
/// </summary> | ||
public bool AllowUntrustedPlugins { get; set; } = true; | ||
|
||
public bool? Baah { get; set; } | ||
|
||
public bool Whitelist { get; set; } | ||
|
||
/// <summary> | ||
/// Network Configuration | ||
/// </summary> | ||
public NetworkConfiguration Network { get; set; } = new(); | ||
|
||
/// <summary> | ||
/// Remote Console configuration | ||
/// </summary> | ||
public RconConfiguration? Rcon { get; set; } | ||
|
||
/// <summary> | ||
/// Messages that the server will use by default for various actions. | ||
/// </summary> | ||
public MessagesConfiguration Messages { get; set; } = new(); | ||
|
||
/// <summary> | ||
/// Allows the server to advertise itself as a LAN server to devices on your network. | ||
/// </summary> | ||
public bool AllowLan { get; set; } = true; // Enabled because it's super useful for debugging tbh | ||
|
||
/// <summary> | ||
/// The view distance of the server. | ||
/// </summary> | ||
/// <remarks> | ||
/// Players with higher view distance will use the server's view distance. | ||
/// </remarks> | ||
public byte ViewDistance | ||
{ | ||
get => viewDistance; | ||
set => viewDistance = value >= MinimumViewDistance ? value : MinimumViewDistance; | ||
} | ||
|
||
public int PregenerateChunkRange { get; set; } = 15; // by default, pregenerate range from -15 to 15; | ||
|
||
public ServerListQuery ServerListQuery { get; set; } = ServerListQuery.Full; | ||
|
||
/// <summary> | ||
/// The speed at which world time & rain time go by. | ||
/// </summary> | ||
public int TimeTickSpeedMultiplier { get; set; } = 1; | ||
} | ||
|
||
public sealed class ServerWorld | ||
{ | ||
public string Name { get; set; } = "overworld"; | ||
public string Generator { get; set; } = "overworld"; | ||
|
||
public string Seed { get; set; } = default!; | ||
|
||
public bool Default { get; set; } | ||
|
||
public string DefaultDimension { get; set; } = "minecraft:overworld"; | ||
|
||
public List<string> ChildDimensions { get; set; } = new(); | ||
} | ||
|
||
[JsonConverter(typeof(JsonStringEnumConverter))] | ||
public enum ServerListQuery | ||
{ | ||
Full, | ||
Anonymized, | ||
Disabled | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Obsidian.API.Configuration; | ||
public sealed class WhitelistConfiguration | ||
{ | ||
public List<WhitelistedPlayer> WhitelistedPlayers { get; set; } = []; | ||
|
||
public List<string> WhitelistedIps { get; set; } = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>disable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<EnablePreviewFeatures>true</EnablePreviewFeatures> | ||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>disable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<EnablePreviewFeatures>true</EnablePreviewFeatures> | ||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Remove="Logging\**" /> | ||
<EmbeddedResource Remove="Logging\**" /> | ||
<None Remove="Logging\**" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="config\**\*.*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Obsidian\Obsidian.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="accepted_keys\obsidian.pub.xml"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Obsidian\Obsidian.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="accepted_keys\obsidian.pub.xml"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Reflection; | ||
|
||
public partial class Program | ||
{ | ||
private static async ValueTask GenerateConfigFiles() | ||
{ | ||
const string path = "config"; | ||
|
||
Directory.CreateDirectory(path); | ||
|
||
var serverJsonFile = Path.Combine(path, "server.json"); | ||
var whitelistJsonFile = Path.Combine(path, "whitelist.json"); | ||
|
||
if (!File.Exists(serverJsonFile)) | ||
{ | ||
await using var file = File.Create(serverJsonFile); | ||
|
||
await using var embeddedFile = Assembly.GetExecutingAssembly().GetManifestResourceStream("Obsidian.ConsoleApp.config.server.json"); | ||
|
||
await embeddedFile!.CopyToAsync(file); | ||
} | ||
|
||
if (!File.Exists(whitelistJsonFile)) | ||
{ | ||
await using var file = File.Create(whitelistJsonFile); | ||
|
||
await using var embeddedFile = Assembly.GetExecutingAssembly().GetManifestResourceStream("Obsidian.ConsoleApp.config.whitelist.json"); | ||
|
||
await embeddedFile!.CopyToAsync(file); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/ObsidianMC/Obsidian/master/.schema/server.json", | ||
|
||
"allowLan": true, | ||
"allowOperatorRequests": true, | ||
|
||
"maxPlayers": 25, | ||
"motd": "�k||||�r �5Obsidian �cPre�r-�cRelease �r�k||||�r \n�r�lRunning on .NET �l�c8 �r�l<3", | ||
|
||
"onlineMode": true, | ||
"port": 25565, | ||
"pregenerateChunkRange": 15, | ||
"serverListQuery": "Full", | ||
"timeTickSpeedMultiplier": 1, | ||
"whitelist": false, | ||
|
||
"network": { | ||
"connectionThrottle": 15000, | ||
"keepAliveInterval": 10000, | ||
"keepAliveTimeoutInterval": 30000, | ||
"mulitplayerDebugMode": false | ||
}, | ||
|
||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Warning" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/ObsidianMC/Obsidian/master/.schema/whitelist.json", | ||
"whitelistedPlayers": [], | ||
"whitelistedIps": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,49 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Obsidian.API.Configuration; | ||
using Obsidian.Commands.Framework; | ||
using Obsidian.Net.Rcon; | ||
using Obsidian.Services; | ||
using Obsidian.WorldData; | ||
using System.IO; | ||
|
||
namespace Obsidian.Hosting; | ||
public static class DependencyInjection | ||
{ | ||
public static IServiceCollection AddObsidian(this IServiceCollection services, IServerEnvironment env) | ||
public static IHostApplicationBuilder ConfigureObsidian(this IHostApplicationBuilder builder) | ||
{ | ||
services.AddSingleton(env); | ||
services.AddSingleton(env.Configuration); | ||
services.AddSingleton<IServerConfiguration>(f => f.GetRequiredService<ServerConfiguration>()); | ||
|
||
services.AddSingleton<CommandHandler>(); | ||
services.AddSingleton<RconServer>(); | ||
services.AddSingleton<WorldManager>(); | ||
services.AddSingleton<PacketBroadcaster>(); | ||
services.AddSingleton<IServer, Server>(); | ||
services.AddSingleton<IUserCache, UserCache>(); | ||
services.AddSingleton<EventDispatcher>(); | ||
|
||
services.AddHttpClient(); | ||
|
||
services.AddHostedService(sp => sp.GetRequiredService<PacketBroadcaster>()); | ||
services.AddHostedService<ObsidianHostingService>(); | ||
services.AddHostedService(sp => sp.GetRequiredService<WorldManager>()); | ||
|
||
services.AddSingleton<IWorldManager>(sp => sp.GetRequiredService<WorldManager>()); | ||
services.AddSingleton<IPacketBroadcaster>(sp => sp.GetRequiredService<PacketBroadcaster>()); | ||
builder.Configuration.AddJsonFile(Path.Combine("config", "server.json"), optional: false, reloadOnChange: true); | ||
builder.Configuration.AddJsonFile(Path.Combine("config", "whitelist.json"), optional: false, reloadOnChange: true); | ||
builder.Configuration.AddEnvironmentVariables(); | ||
|
||
return builder; | ||
} | ||
|
||
public static IHostApplicationBuilder AddObsidian(this IHostApplicationBuilder builder) | ||
{ | ||
builder.Services.Configure<ServerConfiguration>(builder.Configuration); | ||
builder.Services.Configure<WhitelistConfiguration>(builder.Configuration); | ||
|
||
builder.Services.AddSingleton<IServerEnvironment, DefaultServerEnvironment>(); | ||
builder.Services.AddSingleton<CommandHandler>(); | ||
builder.Services.AddSingleton<RconServer>(); | ||
builder.Services.AddSingleton<WorldManager>(); | ||
builder.Services.AddSingleton<PacketBroadcaster>(); | ||
builder.Services.AddSingleton<IServer, Server>(); | ||
builder.Services.AddSingleton<IUserCache, UserCache>(); | ||
builder.Services.AddSingleton<EventDispatcher>(); | ||
|
||
builder.Services.AddHttpClient(); | ||
|
||
builder.Services.AddHostedService(sp => sp.GetRequiredService<PacketBroadcaster>()); | ||
builder.Services.AddHostedService<ObsidianHostingService>(); | ||
builder.Services.AddHostedService(sp => sp.GetRequiredService<WorldManager>()); | ||
|
||
builder.Services.AddSingleton<IWorldManager>(sp => sp.GetRequiredService<WorldManager>()); | ||
builder.Services.AddSingleton<IPacketBroadcaster>(sp => sp.GetRequiredService<PacketBroadcaster>()); | ||
|
||
return services; | ||
return builder; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters