diff --git a/Assets/Scripts/SS3D/Systems/Permissions.meta b/Assets/Scripts/SS3D/Permissions.meta
similarity index 100%
rename from Assets/Scripts/SS3D/Systems/Permissions.meta
rename to Assets/Scripts/SS3D/Permissions.meta
diff --git a/Assets/Scripts/SS3D/Systems/Permissions/DisableIfNotAdmin.cs b/Assets/Scripts/SS3D/Permissions/DisableIfNotAdmin.cs
similarity index 91%
rename from Assets/Scripts/SS3D/Systems/Permissions/DisableIfNotAdmin.cs
rename to Assets/Scripts/SS3D/Permissions/DisableIfNotAdmin.cs
index 6cece140e4..4466d0785d 100644
--- a/Assets/Scripts/SS3D/Systems/Permissions/DisableIfNotAdmin.cs
+++ b/Assets/Scripts/SS3D/Permissions/DisableIfNotAdmin.cs
@@ -1,16 +1,14 @@
-using System.Collections.Generic;
-using System.Linq;
using Coimbra;
using Coimbra.Services.Events;
-using Cysharp.Threading.Tasks;
using SS3D.Core;
using SS3D.Core.Behaviours;
using SS3D.Core.Settings;
-using SS3D.Core.Utils;
-using SS3D.Systems.Permissions.Events;
+using System.Collections.Generic;
+using System.Linq;
using UnityEngine;
+using UserPermissionsChangedEvent = SS3D.Permissions.Events.UserPermissionsChangedEvent;
-namespace SS3D.Systems.Permissions
+namespace SS3D.Permissions
{
public class DisableIfNotAdmin : NetworkActor
{
diff --git a/Assets/Scripts/SS3D/Systems/Permissions/DisableIfNotAdmin.cs.meta b/Assets/Scripts/SS3D/Permissions/DisableIfNotAdmin.cs.meta
similarity index 100%
rename from Assets/Scripts/SS3D/Systems/Permissions/DisableIfNotAdmin.cs.meta
rename to Assets/Scripts/SS3D/Permissions/DisableIfNotAdmin.cs.meta
diff --git a/Assets/Scripts/SS3D/Systems/Permissions/Events.meta b/Assets/Scripts/SS3D/Permissions/Events.meta
similarity index 100%
rename from Assets/Scripts/SS3D/Systems/Permissions/Events.meta
rename to Assets/Scripts/SS3D/Permissions/Events.meta
diff --git a/Assets/Scripts/SS3D/Systems/Permissions/Events/UserPermissionsChangedEvent.cs b/Assets/Scripts/SS3D/Permissions/Events/UserPermissionsChangedEvent.cs
similarity index 73%
rename from Assets/Scripts/SS3D/Systems/Permissions/Events/UserPermissionsChangedEvent.cs
rename to Assets/Scripts/SS3D/Permissions/Events/UserPermissionsChangedEvent.cs
index 833ef7da2c..8ee1f008fd 100644
--- a/Assets/Scripts/SS3D/Systems/Permissions/Events/UserPermissionsChangedEvent.cs
+++ b/Assets/Scripts/SS3D/Permissions/Events/UserPermissionsChangedEvent.cs
@@ -1,7 +1,7 @@
-using System.Collections.Generic;
-using Coimbra.Services.Events;
+using Coimbra.Services.Events;
+using System.Collections.Generic;
-namespace SS3D.Systems.Permissions.Events
+namespace SS3D.Permissions.Events
{
public partial struct UserPermissionsChangedEvent : IEvent
{
diff --git a/Assets/Scripts/SS3D/Systems/Permissions/Events/UserPermissionsChangedEvent.cs.meta b/Assets/Scripts/SS3D/Permissions/Events/UserPermissionsChangedEvent.cs.meta
similarity index 100%
rename from Assets/Scripts/SS3D/Systems/Permissions/Events/UserPermissionsChangedEvent.cs.meta
rename to Assets/Scripts/SS3D/Permissions/Events/UserPermissionsChangedEvent.cs.meta
diff --git a/Assets/Scripts/SS3D/Permissions/PermissionSettings.cs b/Assets/Scripts/SS3D/Permissions/PermissionSettings.cs
new file mode 100644
index 0000000000..cb1ea3536b
--- /dev/null
+++ b/Assets/Scripts/SS3D/Permissions/PermissionSettings.cs
@@ -0,0 +1,20 @@
+using Coimbra;
+using UnityEngine;
+
+namespace SS3D.Permissions
+{
+ ///
+ /// This settings has general options for the permission system, so if we add a database/SQL/API support we can set stuff here.
+ ///
+ [ProjectSettings("SS3D/Server")]
+ public class PermissionSettings : ScriptableSettings
+ {
+ [SerializeField]
+ private bool _addServerOwnerPermissionToServerHost;
+
+ ///
+ /// We can define if the host will get the owner permission when he joins the game.
+ ///
+ public static bool AddServerOwnerPermissionToServerHost => GetOrFind()._addServerOwnerPermissionToServerHost;
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/SS3D/Permissions/PermissionSettings.cs.meta b/Assets/Scripts/SS3D/Permissions/PermissionSettings.cs.meta
new file mode 100644
index 0000000000..359cd9d0ae
--- /dev/null
+++ b/Assets/Scripts/SS3D/Permissions/PermissionSettings.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: f321f4b30171436abd45f5ecf17afa03
+timeCreated: 1695750532
\ No newline at end of file
diff --git a/Assets/Scripts/SS3D/Systems/Permissions/PermissionSystem.cs b/Assets/Scripts/SS3D/Permissions/PermissionSystem.cs
similarity index 78%
rename from Assets/Scripts/SS3D/Systems/Permissions/PermissionSystem.cs
rename to Assets/Scripts/SS3D/Permissions/PermissionSystem.cs
index df869ed3ff..7e45296949 100644
--- a/Assets/Scripts/SS3D/Systems/Permissions/PermissionSystem.cs
+++ b/Assets/Scripts/SS3D/Permissions/PermissionSystem.cs
@@ -1,15 +1,16 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using FishNet.Object;
+using FishNet.Object;
using FishNet.Object.Synchronizing;
using SS3D.Core.Behaviours;
using SS3D.Data;
using SS3D.Logging;
-using SS3D.Systems.Permissions.Events;
+using SS3D.Permissions.Events;
+using System;
+using System.Collections.Generic;
+using System.Linq;
using File = System.IO.File;
+using UserPermissionsChangedEvent = SS3D.Permissions.Events.UserPermissionsChangedEvent;
-namespace SS3D.Systems.Permissions
+namespace SS3D.Permissions
{
///
/// Handles user permission on what he can do and can't.
@@ -87,15 +88,33 @@ public bool TryGetUserRole(string ckey, out ServerRoleTypes userPermission)
///
/// Updates a user permission.
///
- /// The desired user to update the permission.
+ /// The desired user to update the permission.|
/// The new user role.
[Server]
public void ChangeUserPermission(string ckey, ServerRoleTypes role)
{
- throw new NotImplementedException();
- // TODO: This
- // Add new user permission to list
- // Add new user permission to text file
+ ServerRoleTypes previousRole = _userPermissions.TryGetValue(ckey, out ServerRoleTypes permission) ? permission : ServerRoleTypes.None;
+
+ Log.Information(this, $"Updating user {ckey} role from {previousRole} to {role}");
+
+ _userPermissions[ckey] = role;
+
+ SaveUserPermissions();
+ }
+
+ ///
+ /// Saves the permissions text file with the updated permissions list.
+ ///
+ public void SaveUserPermissions()
+ {
+ string fileContent = string.Empty;
+
+ foreach (KeyValuePair userPermission in _userPermissions)
+ {
+ fileContent += $"{userPermission.Key} {userPermission.Value.ToString()}\n";
+ }
+
+ File.WriteAllText(PermissionsPath, fileContent);
}
///
@@ -164,6 +183,12 @@ private void SyncHandleUserPermissionsChanged(SyncDictionaryOperation op, string
SyncUserPermissions();
}
+ ///
+ /// Returns if the user is at least at a level of access.
+ ///
+ /// The user to check permission for
+ /// The lowest required permission to perform the action.
+ ///
public bool IsAtLeast(string ckey, ServerRoleTypes permissionLevelCheck)
{
TryGetUserRole(ckey, out ServerRoleTypes userPermission);
diff --git a/Assets/Scripts/SS3D/Systems/Permissions/PermissionSystem.cs.meta b/Assets/Scripts/SS3D/Permissions/PermissionSystem.cs.meta
similarity index 100%
rename from Assets/Scripts/SS3D/Systems/Permissions/PermissionSystem.cs.meta
rename to Assets/Scripts/SS3D/Permissions/PermissionSystem.cs.meta
diff --git a/Assets/Scripts/SS3D/Permissions/SS3D.Permissions.asmdef b/Assets/Scripts/SS3D/Permissions/SS3D.Permissions.asmdef
new file mode 100644
index 0000000000..582dfb60dd
--- /dev/null
+++ b/Assets/Scripts/SS3D/Permissions/SS3D.Permissions.asmdef
@@ -0,0 +1,22 @@
+{
+ "name": "SS3D.Permissions",
+ "rootNamespace": "",
+ "references": [
+ "GUID:7c88a4a7926ee5145ad2dfa06f454c67",
+ "GUID:eb124556ba20d60469be9771eb1f0360",
+ "GUID:eb242eaf9f292954eb8c6fbd63c46deb",
+ "GUID:6e00473804df0f0468c07310fbce5737",
+ "GUID:6aabbee860c32c64d9bbd52d0704ed2c",
+ "GUID:d2bbca7254de5e746857b04cfb560876",
+ "GUID:b763ff73a93a62c4ea128e32ed2cd0d6"
+ ],
+ "includePlatforms": [],
+ "excludePlatforms": [],
+ "allowUnsafeCode": false,
+ "overrideReferences": false,
+ "precompiledReferences": [],
+ "autoReferenced": true,
+ "defineConstraints": [],
+ "versionDefines": [],
+ "noEngineReferences": false
+}
\ No newline at end of file
diff --git a/Assets/Scripts/SS3D/Permissions/SS3D.Permissions.asmdef.meta b/Assets/Scripts/SS3D/Permissions/SS3D.Permissions.asmdef.meta
new file mode 100644
index 0000000000..3e37e90e44
--- /dev/null
+++ b/Assets/Scripts/SS3D/Permissions/SS3D.Permissions.asmdef.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 8979f103c1228714eb0115e440b2b33a
+AssemblyDefinitionImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/SS3D/Systems/Permissions/ServerRoleTypes.cs b/Assets/Scripts/SS3D/Permissions/ServerRoleTypes.cs
similarity index 80%
rename from Assets/Scripts/SS3D/Systems/Permissions/ServerRoleTypes.cs
rename to Assets/Scripts/SS3D/Permissions/ServerRoleTypes.cs
index d068fd0863..c97bbaf524 100644
--- a/Assets/Scripts/SS3D/Systems/Permissions/ServerRoleTypes.cs
+++ b/Assets/Scripts/SS3D/Permissions/ServerRoleTypes.cs
@@ -1,4 +1,4 @@
-namespace SS3D.Systems.Permissions
+namespace SS3D.Permissions
{
public enum ServerRoleTypes
{
diff --git a/Assets/Scripts/SS3D/Systems/Permissions/ServerRoleTypes.cs.meta b/Assets/Scripts/SS3D/Permissions/ServerRoleTypes.cs.meta
similarity index 100%
rename from Assets/Scripts/SS3D/Systems/Permissions/ServerRoleTypes.cs.meta
rename to Assets/Scripts/SS3D/Permissions/ServerRoleTypes.cs.meta
diff --git a/Assets/Scripts/SS3D/Systems/Health/BodyParts/Bodypart.cs b/Assets/Scripts/SS3D/Systems/Health/BodyParts/Bodypart.cs
index d90fec2d55..0b8f2e74f3 100644
--- a/Assets/Scripts/SS3D/Systems/Health/BodyParts/Bodypart.cs
+++ b/Assets/Scripts/SS3D/Systems/Health/BodyParts/Bodypart.cs
@@ -1,4 +1,5 @@
-using FishNet.Object;
+using Coimbra;
+using FishNet.Object;
using FishNet.Object.Synchronizing;
using System.Collections.Generic;
using UnityEngine;
@@ -9,7 +10,6 @@
using System.Linq;
using System.Collections.ObjectModel;
using FishNet;
-using Coimbra;
using SS3D.Systems.Inventory.Containers;
using SS3D.Systems.Inventory.Items;
using System;
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/AddHandCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/AddHandCommand.cs
index 95f6f9c888..32bc1cc8b4 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/AddHandCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/AddHandCommand.cs
@@ -1,14 +1,13 @@
using SS3D.Core;
using SS3D.Systems.Entities;
-using SS3D.Systems.Permissions;
using SS3D.Systems.PlayerControl;
using UnityEngine;
using FishNet;
using SS3D.Data;
using SS3D.Data.Enums;
-using FishNet.Object;
using SS3D.Systems.Inventory.Containers;
using FishNet.Connection;
+using SS3D.Permissions;
namespace SS3D.Systems.IngameConsoleSystem.Commands
{
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ChangePermsCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ChangePermsCommand.cs
index 73821eb31e..27c937c92b 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ChangePermsCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ChangePermsCommand.cs
@@ -2,7 +2,7 @@
using System.Linq;
using FishNet.Connection;
using SS3D.Core;
-using SS3D.Systems.Permissions;
+using SS3D.Permissions;
namespace SS3D.Systems.IngameConsoleSystem.Commands
{
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/Command.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/Command.cs
index b2b72090d2..7efc5f86fb 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/Command.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/Command.cs
@@ -1,5 +1,5 @@
using FishNet.Connection;
-using SS3D.Systems.Permissions;
+using SS3D.Permissions;
namespace SS3D.Systems.IngameConsoleSystem.Commands
{
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/DestroyBodyPartCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/DestroyBodyPartCommand.cs
index c765cfc63f..bfa042a54b 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/DestroyBodyPartCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/DestroyBodyPartCommand.cs
@@ -1,16 +1,9 @@
using FishNet.Connection;
using FishNet.Object;
-using SS3D.Core;
-using SS3D.Systems.Entities;
-using SS3D.Systems.Permissions;
-using SS3D.Systems.PlayerControl;
-using System;
-using System.Collections;
+using SS3D.Permissions;
using System.Collections.Generic;
using System.Linq;
-using UnityEditor;
using UnityEngine;
-using static UnityEngine.EventSystems.EventTrigger;
namespace SS3D.Systems.IngameConsoleSystem.Commands
{
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/DumpContainerCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/DumpContainerCommand.cs
index bc7e696a5e..1b4bfa8bd4 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/DumpContainerCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/DumpContainerCommand.cs
@@ -1,14 +1,6 @@
using FishNet.Connection;
-using FishNet;
-using SS3D.Core;
-using SS3D.Data.Enums;
-using SS3D.Data;
-using SS3D.Systems.Entities;
+using SS3D.Permissions;
using SS3D.Systems.Inventory.Containers;
-using SS3D.Systems.Permissions;
-using SS3D.Systems.PlayerControl;
-using System.Collections;
-using System.Collections.Generic;
using UnityEngine;
namespace SS3D.Systems.IngameConsoleSystem.Commands
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/EchoCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/EchoCommand.cs
index aeb4db72c2..b408bb2716 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/EchoCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/EchoCommand.cs
@@ -1,7 +1,7 @@
using System;
using System.Linq;
using FishNet.Connection;
-using SS3D.Systems.Permissions;
+using SS3D.Permissions;
namespace SS3D.Systems.IngameConsoleSystem.Commands
{
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ExamineBodyPartCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ExamineBodyPartCommand.cs
index 932c85a3de..542ebde4d1 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ExamineBodyPartCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ExamineBodyPartCommand.cs
@@ -1,7 +1,6 @@
using FishNet.Connection;
using FishNet.Object;
-using SS3D.Systems.Permissions;
-using System.Collections;
+using SS3D.Permissions;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/HitBodyPartCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/HitBodyPartCommand.cs
index 52eabf5ad7..7079435730 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/HitBodyPartCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/HitBodyPartCommand.cs
@@ -1,7 +1,7 @@
using FishNet.Connection;
using FishNet.Object;
+using SS3D.Permissions;
using SS3D.Systems.Health;
-using SS3D.Systems.Permissions;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/HurtCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/HurtCommand.cs
index 1c17d320fa..90cfc4afed 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/HurtCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/HurtCommand.cs
@@ -1,8 +1,8 @@
using FishNet.Connection;
using FishNet.Object;
using SS3D.Core;
+using SS3D.Permissions;
using SS3D.Systems.Entities;
-using SS3D.Systems.Permissions;
using SS3D.Systems.PlayerControl;
using System;
using System.Collections.Generic;
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/AddTraitCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/AddTraitCommand.cs
index 565e727bc7..a29c1c8182 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/AddTraitCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/AddTraitCommand.cs
@@ -1,8 +1,8 @@
using SS3D.Systems.Inventory.Items;
using UnityEngine;
-using SS3D.Systems.Permissions;
using FishNet.Object;
using FishNet.Connection;
+using SS3D.Permissions;
namespace SS3D.Systems.IngameConsoleSystem.Commands
{
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/DescribeItemCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/DescribeItemCommand.cs
index 893bb3aa89..c03092c97a 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/DescribeItemCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/DescribeItemCommand.cs
@@ -1,8 +1,8 @@
using FishNet.Connection;
+using SS3D.Permissions;
using SS3D.Systems.Inventory.Items;
-using SS3D.Systems.Permissions;
-namespace SS3D.Systems.IngameConsoleSystem.Commands
+namespace SS3D.Systems.IngameConsoleSystem.Commands.ItemCommands
{
///
/// Command to describe an item held in the active hand of the player calling the command.
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/GetTraitsCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/GetTraitsCommand.cs
index f9d373e1ef..0fe9f39806 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/GetTraitsCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/GetTraitsCommand.cs
@@ -1,6 +1,6 @@
using FishNet.Connection;
+using SS3D.Permissions;
using SS3D.Systems.Inventory.Items;
-using SS3D.Systems.Permissions;
namespace SS3D.Systems.IngameConsoleSystem.Commands
{
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/SpawnItemCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/SpawnItemCommand.cs
index 46f9428dea..19f814e279 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/SpawnItemCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/SpawnItemCommand.cs
@@ -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
{
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/KillCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/KillCommand.cs
index 9cbf99f66a..4b2505a3c2 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/KillCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/KillCommand.cs
@@ -1,8 +1,8 @@
using FishNet.Connection;
using FishNet.Object;
using SS3D.Core;
+using SS3D.Permissions;
using SS3D.Systems.Entities;
-using SS3D.Systems.Permissions;
using SS3D.Systems.PlayerControl;
using SS3D.Systems.Health;
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/PlayerListCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/PlayerListCommand.cs
index 0aa92ba0d6..63ee1cd1b7 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/PlayerListCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/PlayerListCommand.cs
@@ -2,8 +2,8 @@
using System.Linq;
using FishNet.Connection;
using SS3D.Core;
+using SS3D.Permissions;
using SS3D.Systems.Entities;
-using SS3D.Systems.Permissions;
using SS3D.Systems.PlayerControl;
namespace SS3D.Systems.IngameConsoleSystem.Commands
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/QuitCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/QuitCommand.cs
index 9909a27989..95893730a4 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/QuitCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/QuitCommand.cs
@@ -1,5 +1,5 @@
using FishNet.Connection;
-using SS3D.Systems.Permissions;
+using SS3D.Permissions;
using UnityEngine;
namespace SS3D.Systems.IngameConsoleSystem.Commands
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/RagdollCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/RagdollCommand.cs
index bb06b1b964..ad7d73c8b9 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/RagdollCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/RagdollCommand.cs
@@ -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
{
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ReconnectCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ReconnectCommand.cs
index d8bc535278..1f6e94b5de 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ReconnectCommand.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ReconnectCommand.cs
@@ -1,6 +1,6 @@
using System.Diagnostics;
using FishNet.Connection;
-using SS3D.Systems.Permissions;
+using SS3D.Permissions;
using UnityEngine.Device;
namespace SS3D.Systems.IngameConsoleSystem.Commands
diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/CommandsController.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/CommandsController.cs
index 4f2be32419..6f40e37eba 100644
--- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/CommandsController.cs
+++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/CommandsController.cs
@@ -6,8 +6,8 @@
using FishNet.Object;
using SS3D.Core;
using SS3D.Core.Behaviours;
+using SS3D.Permissions;
using SS3D.Systems.IngameConsoleSystem.Commands;
-using SS3D.Systems.Permissions;
using SS3D.Systems.PlayerControl;
using UnityEngine;
diff --git a/Assets/Scripts/SS3D/Systems/PlayerControl/PlayerSystem.cs b/Assets/Scripts/SS3D/Systems/PlayerControl/PlayerSystem.cs
index c5d00da8ec..dc3262a2cc 100644
--- a/Assets/Scripts/SS3D/Systems/PlayerControl/PlayerSystem.cs
+++ b/Assets/Scripts/SS3D/Systems/PlayerControl/PlayerSystem.cs
@@ -1,11 +1,14 @@
+using Coimbra;
using System.Collections.Generic;
using System.Linq;
using FishNet.Connection;
using FishNet.Object;
using FishNet.Object.Synchronizing;
using FishNet.Transporting;
+using SS3D.Core;
using SS3D.Core.Behaviours;
using SS3D.Logging;
+using SS3D.Permissions;
using SS3D.Systems.Entities;
using SS3D.Systems.PlayerControl.Events;
using SS3D.Systems.PlayerControl.Messages;
@@ -143,8 +146,7 @@ private void LateSyncServerPlayers()
private void ProcessPlayerJoin(NetworkConnection conn)
{
string message = $"Player joined the server - {conn.ClientId} {conn.GetAddress()}";
- Log.Information(this, "Player joined the server - {clientId} {connectionAddress}",
- Logs.ServerOnly, conn.ClientId, conn.GetAddress());
+ Log.Information(this, "Player joined the server - {clientId} {connectionAddress}", Logs.ServerOnly, conn.ClientId, conn.GetAddress());
NetworkObject unauthorizedUser = Instantiate(_unauthorizedUserPrefab, Vector3.zero, Quaternion.identity);
ServerManager.Spawn(unauthorizedUser, conn);
@@ -160,9 +162,13 @@ private void ProcessPlayerJoin(NetworkConnection conn)
private void ProcessAuthorizePlayer(NetworkConnection conn, UserAuthorizationMessage userAuthorizationMessage)
{
string ckey = userAuthorizationMessage.Ckey;
- bool hasPlayer = _serverPlayers.TryGetValue(ckey, out Player player);
+ bool playedHasConnectedAlready = _serverPlayers.TryGetValue(ckey, out Player player);
- if (!hasPlayer)
+ if (playedHasConnectedAlready)
+ {
+ Log.Information(this, "Player match for {ckey} found, reassigning to client", Logs.ServerOnly, ckey);
+ }
+ else
{
Log.Information(this, "No Player match for {ckey} found, creating a new one", Logs.ServerOnly, ckey);
@@ -171,12 +177,15 @@ private void ProcessAuthorizePlayer(NetworkConnection conn, UserAuthorizationMes
player.SetCkey(ckey);
+ if (conn.IsHost && PermissionSettings.AddServerOwnerPermissionToServerHost)
+ {
+ Log.Information(this, $"Adding ServerOwner permission to server owner: {ckey}", Logs.ServerOnly, ckey);
+
+ Subsystems.Get().ChangeUserPermission(ckey, ServerRoleTypes.ServerOwner);
+ }
+
_serverPlayers.Add(ckey, player);
}
- else
- {
- Log.Information(this, "Player match for {ckey} found, reassigning to client", Logs.ServerOnly, ckey);
- }
player.GiveOwnership(conn);
diff --git a/Assets/Scripts/SS3D/Systems/Rounds/RoundSystemBase.cs b/Assets/Scripts/SS3D/Systems/Rounds/RoundSystemBase.cs
index 3c475ce576..2f851c10f6 100644
--- a/Assets/Scripts/SS3D/Systems/Rounds/RoundSystemBase.cs
+++ b/Assets/Scripts/SS3D/Systems/Rounds/RoundSystemBase.cs
@@ -7,7 +7,7 @@
using SS3D.Core;
using SS3D.Core.Behaviours;
using SS3D.Logging;
-using SS3D.Systems.Permissions;
+using SS3D.Permissions;
using SS3D.Systems.PlayerControl;
using SS3D.Systems.Rounds.Events;
using SS3D.Systems.Rounds.Messages;
diff --git a/Assets/Scripts/SS3D/Systems/SS3D.Systems.asmdef b/Assets/Scripts/SS3D/Systems/SS3D.Systems.asmdef
index 101c952a22..9e8b847383 100644
--- a/Assets/Scripts/SS3D/Systems/SS3D.Systems.asmdef
+++ b/Assets/Scripts/SS3D/Systems/SS3D.Systems.asmdef
@@ -19,7 +19,8 @@
"GUID:9e24947de15b9834991c9d8411ea37cf",
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:eb124556ba20d60469be9771eb1f0360",
- "GUID:46e20dca70571ce4e817a6b5874168a0"
+ "GUID:46e20dca70571ce4e817a6b5874168a0",
+ "GUID:8979f103c1228714eb0115e440b2b33a"
],
"includePlatforms": [],
"excludePlatforms": [],
diff --git a/Assets/Settings/ServerRoleSettings.asset b/Assets/Settings/ServerRoleSettings.asset
new file mode 100644
index 0000000000..49bfedf22e
--- /dev/null
+++ b/Assets/Settings/ServerRoleSettings.asset
@@ -0,0 +1,17 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: f321f4b30171436abd45f5ecf17afa03, type: 3}
+ m_Name: ServerRoleSettings
+ m_EditorClassIdentifier:
+ _preload: 1
+ _type: 2
+ _addServerOwnerPermissionToServerHost: 1
diff --git a/Assets/Settings/ServerRoleSettings.asset.meta b/Assets/Settings/ServerRoleSettings.asset.meta
new file mode 100644
index 0000000000..9c7c2b0e95
--- /dev/null
+++ b/Assets/Settings/ServerRoleSettings.asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: c15209f668bbfab479eb5184981c2bf7
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 11400000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset
index bae922e776..cc31bdf4ab 100644
--- a/ProjectSettings/ProjectSettings.asset
+++ b/ProjectSettings/ProjectSettings.asset
@@ -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