Skip to content

Commit

Permalink
Merge pull request #826 from openmod/Change_perms_priority
Browse files Browse the repository at this point in the history
Change Permssion from lowest to normal
  • Loading branch information
Trojaner authored May 26, 2024
2 parents 47aa569 + efd25fa commit 2d72650
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace OpenMod.Core.Permissions
{
[Priority(Priority = Priority.Lowest)]
[Priority(Priority = Priority.Normal)]
public class DefaultPermissionCheckProvider : IPermissionCheckProvider
{
private readonly IPermissionChecker m_PermissionChecker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace OpenMod.Core.Permissions
{
[OpenModInternal]
[UsedImplicitly]
[ServiceImplementation(Priority = Priority.Lowest, Lifetime = ServiceLifetime.Singleton)]
[ServiceImplementation(Priority = Priority.Normal, Lifetime = ServiceLifetime.Singleton)]
public class DefaultPermissionRoleStore : IPermissionRoleStore
{
private readonly IPermissionRolesDataStore m_PermissionRolesDataStore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace OpenMod.Core.Permissions
{
[Priority(Priority = Priority.Lowest)]
[Priority(Priority = Priority.Normal)]
public class DefaultPermissionStore : IPermissionStore
{
private readonly IUserDataStore m_UserDataStore;
Expand Down
18 changes: 18 additions & 0 deletions unturned/OpenMod.Unturned/ServiceConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using JetBrainsAnnotations::JetBrains.Annotations;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using OpenMod.API;
Expand Down Expand Up @@ -99,6 +100,23 @@ public void ConfigureServices(IOpenModServiceConfigurationContext openModStartup
options.AddPermissionCheckProvider<RocketCooldownPermissionCheckProvider>();
});


for (int i = 0; i < serviceCollection.Count; i++)
{
var serviceDescriptor = serviceCollection[i];
if (serviceDescriptor.ServiceType != typeof(IPermissionRoleStore))
{
continue;
}

if (serviceDescriptor.ImplementationType != typeof(DefaultPermissionRoleStore))
{
continue;
}

serviceCollection.RemoveAt(i);
}

serviceCollection.AddTransient<IPermissionRoleStore, RocketPermissionRoleStore>();
}
else
Expand Down

0 comments on commit 2d72650

Please sign in to comment.