Skip to content

Commit

Permalink
Fixed merge issues and added documentation to permission system
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoburatto committed Oct 17, 2023
1 parent d8b4f5e commit 613eede
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
6 changes: 6 additions & 0 deletions Assets/Scripts/SS3D/Permissions/PermissionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@

namespace SS3D.Permissions
{
/// <summary>
/// This settings has general options for the permission system, so if we add a database/SQL/API support we can set stuff here.
/// </summary>
[ProjectSettings("SS3D/Server")]
public class PermissionSettings : ScriptableSettings
{
[SerializeField]
private bool _addServerOwnerPermissionToServerHost;

/// <summary>
/// We can define if the host will get the owner permission when he joins the game.
/// </summary>
public static bool AddServerOwnerPermissionToServerHost => GetOrFind<PermissionSettings>()._addServerOwnerPermissionToServerHost;
}
}
9 changes: 9 additions & 0 deletions Assets/Scripts/SS3D/Permissions/PermissionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public void ChangeUserPermission(string ckey, ServerRoleTypes role)
SaveUserPermissions();
}

/// <summary>
/// Saves the permissions text file with the updated permissions list.
/// </summary>
public void SaveUserPermissions()
{
string fileContent = string.Empty;
Expand Down Expand Up @@ -180,6 +183,12 @@ private void SyncHandleUserPermissionsChanged(SyncDictionaryOperation op, string
SyncUserPermissions();
}

/// <summary>
/// Returns if the user is at least at a level of access.
/// </summary>
/// <param name="ckey">The user to check permission for</param>
/// <param name="permissionLevelCheck">The lowest required permission to perform the action.</param>
/// <returns></returns>
public bool IsAtLeast(string ckey, ServerRoleTypes permissionLevelCheck)
{
TryGetUserRole(ckey, out ServerRoleTypes userPermission);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
using SS3D.Core;
using SS3D.Systems.Entities;
using SS3D.Systems.Permissions;
using SS3D.Systems.PlayerControl;
using SS3D.Systems;
using FishNet.Connection;
using SS3D.Core;
using SS3D.Data;
using SS3D.Data.AssetDatabases;
using SS3D.Data.Enums;
using SS3D.Permissions;
using SS3D.Systems.Entities;
using SS3D.Systems.Inventory.Items;
using SS3D.Utils;
using SS3D.Core.Settings;
using UnityEngine;
using UnityEngine.UIElements;
using FishNet.Managing.Server;
using FishNet;
using FishNet.Connection;
using UnityEngine.InputSystem;

namespace SS3D.Systems.IngameConsoleSystem.Commands
namespace SS3D.Systems.IngameConsoleSystem.Commands.ItemCommands
{
public class SpawnItemCommand : Command
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using FishNet.Connection;
using FishNet.Object;
using SS3D.Core;
using SS3D.Permissions;
using SS3D.Systems.Entities;
using SS3D.Systems.Entities.Humanoid;
using SS3D.Systems.Permissions;
using SS3D.Systems.PlayerControl;
using System.Globalization;
using UnityEngine;

namespace SS3D.Systems.IngameConsoleSystem.Commands
{
Expand Down
1 change: 1 addition & 0 deletions ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ PlayerSettings:
- {fileID: 11400000, guid: 3c59f55e6898e694083e7a1ede49fe18, type: 2}
- {fileID: 11400000, guid: 2024dd0c65f45424f98ac0c8a6979181, type: 2}
- {fileID: 11400000, guid: 97967903e9bd51b499aaa39639cc9bb2, type: 2}
- {fileID: 11400000, guid: c15209f668bbfab479eb5184981c2bf7, type: 2}
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1
Expand Down

0 comments on commit 613eede

Please sign in to comment.