Skip to content

Commit

Permalink
Replaces TryGetUserRole calls with IsAtLeast calls. (RE-SS3D#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan089 authored and TaylorNAlbarnaz committed Feb 15, 2023
1 parent 659b6b4 commit c182b5e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions Assets/Scripts/SS3D/Systems/Permissions/DisableIfNotAdmin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ private void DisableObjects()
return;
}

permissionSystem.TryGetUserRole(_ckey, out ServerRoleTypes role);

if (role == ServerRoleTypes.Administrator)
if (permissionSystem.IsAtLeast(_ckey, ServerRoleTypes.Administrator))
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private void SyncHandleUserPermissionsChanged(SyncDictionaryOperation op, string
SyncUserPermissions();
}

public bool isAtLeast(string ckey, ServerRoleTypes permissionLevelCheck)
public bool IsAtLeast(string ckey, ServerRoleTypes permissionLevelCheck)
{
TryGetUserRole(ckey, out ServerRoleTypes userPermission);

Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/SS3D/Systems/Rounds/RoundSystemBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private void AuthorizeChangeRoundState(NetworkConnection conn, ChangeRoundStateM
string userCkey = playerControlSystem.GetCkey(conn);

// Checks if player can call a round start
if (permissionSystem.TryGetUserRole(userCkey, out ServerRoleTypes role) && role != requiredRole)
if (!permissionSystem.IsAtLeast(userCkey, requiredRole))
{
string message = $"User {userCkey} doesn't have {requiredRole} permission";
Punpun.Say(this, message, Logs.ServerOnly);
Expand Down

0 comments on commit c182b5e

Please sign in to comment.