mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-31 09:18:38 +00:00
parent
b31522733c
commit
79df7eb02c
5 changed files with 94 additions and 0 deletions
1
.idea/.idea.ProjectLighthouse/.idea/vcs.xml
generated
1
.idea/.idea.ProjectLighthouse/.idea/vcs.xml
generated
|
@ -2,5 +2,6 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/ProjectLighthouse/Fomantic" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -11,6 +11,7 @@ using LBPUnion.ProjectLighthouse.Helpers.Extensions;
|
||||||
using LBPUnion.ProjectLighthouse.Logging;
|
using LBPUnion.ProjectLighthouse.Logging;
|
||||||
using LBPUnion.ProjectLighthouse.Types;
|
using LBPUnion.ProjectLighthouse.Types;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Match;
|
using LBPUnion.ProjectLighthouse.Types.Match;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
@ -86,6 +87,8 @@ public class MatchController : ControllerBase
|
||||||
if (playerData.RoomState != null)
|
if (playerData.RoomState != null)
|
||||||
if (room != null && Equals(room.Host, user))
|
if (room != null && Equals(room.Host, user))
|
||||||
room.State = (RoomState)playerData.RoomState;
|
room.State = (RoomState)playerData.RoomState;
|
||||||
|
|
||||||
|
if (ServerSettings.StartupConfigCheck && !ServerSettings.ConfigCheck()) Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchData is FindBestRoom && MatchHelper.UserLocations.Count > 1)
|
if (matchData is FindBestRoom && MatchHelper.UserLocations.Count > 1)
|
||||||
|
|
40
ProjectLighthouse/Maintenance/Commands/RenameUserCommand.cs
Normal file
40
ProjectLighthouse/Maintenance/Commands/RenameUserCommand.cs
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#nullable enable
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Maintenance.Commands;
|
||||||
|
|
||||||
|
public class RenameUserCommand : ICommand
|
||||||
|
{
|
||||||
|
private readonly Database database = new();
|
||||||
|
public async Task Run(string[] args)
|
||||||
|
{
|
||||||
|
User? user = await this.database.Users.FirstOrDefaultAsync(u => u.Username == args[0]);
|
||||||
|
if (user == null)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
user = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == Convert.ToInt32(args[0]));
|
||||||
|
if (user == null) throw new Exception();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Could not find user by parameter '{args[0]}'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
user.Username = args[1];
|
||||||
|
await this.database.SaveChangesAsync();
|
||||||
|
|
||||||
|
Console.WriteLine($"The username for user {user.Username} (id: {user.UserId}) has been changed.");
|
||||||
|
}
|
||||||
|
public string Name() => "Rename User";
|
||||||
|
public string[] Aliases()
|
||||||
|
=> new[]
|
||||||
|
{
|
||||||
|
"renameUser",
|
||||||
|
};
|
||||||
|
public string Arguments() => "<username/userId> <newUsername>";
|
||||||
|
public int RequiredArgs() => 2;
|
||||||
|
}
|
|
@ -48,6 +48,25 @@
|
||||||
<EmbeddedResource Include="gitUnpushed.txt">
|
<EmbeddedResource Include="gitUnpushed.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<None Remove="StaticFiles\css\themes\default\assets\fonts\outline-icons.woff2"/>
|
||||||
|
<None Remove="StaticFiles\css\themes\default\assets\fonts\outline-icons.woff"/>
|
||||||
|
<None Remove="StaticFiles\css\themes\default\assets\fonts\outline-icons.ttf"/>
|
||||||
|
<None Remove="StaticFiles\css\themes\default\assets\fonts\outline-icons.svg"/>
|
||||||
|
<None Remove="StaticFiles\css\themes\default\assets\fonts\outline-icons.eot"/>
|
||||||
|
<None Remove="StaticFiles\css\themes\default\assets\fonts\icons.woff2"/>
|
||||||
|
<None Remove="StaticFiles\css\themes\default\assets\fonts\icons.woff"/>
|
||||||
|
<None Remove="StaticFiles\css\themes\default\assets\fonts\icons.ttf"/>
|
||||||
|
<None Remove="StaticFiles\css\themes\default\assets\fonts\icons.svg"/>
|
||||||
|
<None Remove="StaticFiles\css\themes\default\assets\fonts\icons.eot"/>
|
||||||
|
<None Remove="StaticFiles\css\themes\default\assets\fonts\brand-icons.woff2"/>
|
||||||
|
<None Remove="StaticFiles\css\themes\default\assets\fonts\brand-icons.woff"/>
|
||||||
|
<None Remove="StaticFiles\css\themes\default\assets\fonts\brand-icons.ttf"/>
|
||||||
|
<None Remove="StaticFiles\css\themes\default\assets\fonts\brand-icons.svg"/>
|
||||||
|
<None Remove="StaticFiles\css\semantic.min.css"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="StaticFiles\css\themes\default\assets\fonts"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
||||||
|
|
|
@ -5,6 +5,7 @@ using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Kettu;
|
using Kettu;
|
||||||
|
using LBPUnion.ProjectLighthouse.Helpers;
|
||||||
using LBPUnion.ProjectLighthouse.Logging;
|
using LBPUnion.ProjectLighthouse.Logging;
|
||||||
|
|
||||||
namespace LBPUnion.ProjectLighthouse.Types.Settings;
|
namespace LBPUnion.ProjectLighthouse.Types.Settings;
|
||||||
|
@ -22,6 +23,8 @@ public class ServerSettings
|
||||||
|
|
||||||
if (File.Exists(ConfigFileName))
|
if (File.Exists(ConfigFileName))
|
||||||
{
|
{
|
||||||
|
if (!(StartupConfigCheck = ConfigCheck())) return;
|
||||||
|
|
||||||
string configFile = File.ReadAllText(ConfigFileName);
|
string configFile = File.ReadAllText(ConfigFileName);
|
||||||
|
|
||||||
Instance = JsonSerializer.Deserialize<ServerSettings>(configFile) ?? throw new ArgumentNullException(nameof(ConfigFileName));
|
Instance = JsonSerializer.Deserialize<ServerSettings>(configFile) ?? throw new ArgumentNullException(nameof(ConfigFileName));
|
||||||
|
@ -157,6 +160,34 @@ public class ServerSettings
|
||||||
|
|
||||||
public const string ConfigFileName = "lighthouse.config.json";
|
public const string ConfigFileName = "lighthouse.config.json";
|
||||||
|
|
||||||
|
public static bool StartupConfigCheck;
|
||||||
|
public static bool ConfigCheck()
|
||||||
|
{
|
||||||
|
#if !DEBUG
|
||||||
|
if (VersionHelper.IsDirty)
|
||||||
|
{
|
||||||
|
string dirtyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".lighthouse");
|
||||||
|
string dirtyFile = Path.Combine(dirtyPath, ".dirty-date");
|
||||||
|
if (File.Exists(dirtyFile))
|
||||||
|
{
|
||||||
|
long timestamp = long.Parse(File.ReadAllText(dirtyFile));
|
||||||
|
if (timestamp + 604800 < TimestampHelper.Timestamp)
|
||||||
|
{
|
||||||
|
Instance = new ServerSettings();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(dirtyPath);
|
||||||
|
File.WriteAllText(dirtyFile, TimestampHelper.Timestamp.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Meta
|
#endregion Meta
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue