Skip to content

Commit

Permalink
Add the ability to disable matchmaking in configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
sudokoko committed Mar 17, 2024
1 parent b4d67d4 commit 5035dbb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#nullable enable
using System.Text.Json;
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
Expand Down Expand Up @@ -42,6 +43,9 @@ public async Task<IActionResult> Match()
UserEntity? user = await this.database.UserFromGameToken(token);
if (user == null) return this.Forbid();

// Do not allow matchmaking if it has been disabled
if (!ServerConfiguration.Instance.Matchmaking.MatchmakingEnabled) return this.Forbid();

#region Parse match data

// Example POST /match: [UpdateMyPlayerData,["Player":"FireGamer9872"]]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;

public class MatchmakingConfiguration
{
public bool MatchmakingEnabled { get; set; } = true;
}
3 changes: 2 additions & 1 deletion ProjectLighthouse/Configuration/ServerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ServerConfiguration : ConfigurationBase<ServerConfiguration>
// This is so Lighthouse can properly identify outdated configurations and update them with newer settings accordingly.
// If you are modifying anything here, this value MUST be incremented.
// Thanks for listening~
public override int ConfigVersion { get; set; } = 24;
public override int ConfigVersion { get; set; } = 25;

public override string ConfigName { get; set; } = "lighthouse.yml";
public string WebsiteListenUrl { get; set; } = "http://localhost:10060";
Expand All @@ -35,6 +35,7 @@ public class ServerConfiguration : ConfigurationBase<ServerConfiguration>
public AuthenticationConfiguration Authentication { get; set; } = new();
public CaptchaConfiguration Captcha { get; set; } = new();
public DigestKeyConfiguration DigestKey { get; set; } = new();
public MatchmakingConfiguration Matchmaking { get; set; } = new();
public GoogleAnalyticsConfiguration GoogleAnalytics { get; set; } = new();
public MailConfiguration Mail { get; set; } = new();
public UserGeneratedContentLimitConfiguration UserGeneratedContentLimits { get; set; } = new();
Expand Down

0 comments on commit 5035dbb

Please sign in to comment.