Changeset 487 for TFP-WebServer/WebServer/src/WebAPI/APIs
- Timestamp:
- Jun 17, 2024, 5:25:43 PM (5 months ago)
- Location:
- TFP-WebServer/WebServer/src/WebAPI/APIs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TFP-WebServer/WebServer/src/WebAPI/APIs/Permissions/CommandPermissions.cs
r486 r487 10 10 private const string propertyCommand = "command"; 11 11 private const string propertyPermissionLevel = "permissionLevel"; 12 private const string propertyIsDefault = "default"; 12 13 13 14 private static readonly byte[] jsonKeyCommand = JsonWriter.GetEncodedPropertyNameWithBeginObject (propertyCommand); 14 15 private static readonly byte[] jsonKeyPermissionLevel = JsonWriter.GetEncodedPropertyNameWithPrefixValueSeparator (propertyPermissionLevel); 16 private static readonly byte[] jsonKeyIsDefault = JsonWriter.GetEncodedPropertyNameWithPrefixValueSeparator (propertyIsDefault); 15 17 16 18 private static AdminCommands CommandsInstance => GameManager.Instance.adminTools.Commands; … … 26 28 27 29 bool first = true; 28 foreach ((_, AdminCommands.CommandPermission commandPermission) in CommandsInstance.GetCommands ()) { 30 31 foreach (IConsoleCommand command in SdtdConsole.Instance.GetCommands ()) { 29 32 if (!first) { 30 33 writer.WriteValueSeparator (); … … 33 36 first = false; 34 37 35 writeCommandJson (ref writer, commandPermission); 38 AdminCommands.CommandPermission commandPermission = CommandsInstance.GetAdminToolsCommandPermission (command.GetCommands()); 39 bool isDefault = commandPermission.PermissionLevel == command.DefaultPermissionLevel; 40 if (commandPermission.Command == "") { 41 commandPermission = 42 new AdminCommands.CommandPermission (command.GetCommands ()[0], commandPermission.PermissionLevel); 43 } 44 45 writeCommandJson (ref writer, commandPermission, isDefault); 36 46 } 37 47 38 48 writer.WriteEndArray (); 39 49 … … 46 56 } 47 57 48 private void writeCommandJson (ref JsonWriter _writer, AdminCommands.CommandPermission _commandPermission) {58 private void writeCommandJson(ref JsonWriter _writer, AdminCommands.CommandPermission _commandPermission, bool _isDefault) { 49 59 _writer.WriteRaw (jsonKeyCommand); 50 60 _writer.WriteString (_commandPermission.Command); 51 61 _writer.WriteRaw (jsonKeyPermissionLevel); 52 62 _writer.WriteInt32 (_commandPermission.PermissionLevel); 63 _writer.WriteRaw (jsonKeyIsDefault); 64 _writer.WriteBoolean (_isDefault); 53 65 _writer.WriteEndObject (); 54 66 } -
TFP-WebServer/WebServer/src/WebAPI/APIs/Permissions/CommandPermissions.openapi.yaml
r486 r487 21 21 type: integer 22 22 description: Permission level of the command 23 default: 24 type: boolean 25 description: Whether the permission level is the default value for the command 23 26 required: 24 27 - command 25 28 - permissionLevel 29 - default 26 30 27 31 CommandPermissionList: -
TFP-WebServer/WebServer/src/WebAPI/APIs/Permissions/WebModules.cs
r486 r487 124 124 } 125 125 126 module .LevelGlobal = permissionLevelGlobal;126 module = module.SetLevelGlobal (permissionLevelGlobal); 127 127 } 128 128 … … 165 165 } 166 166 167 module .LevelPerMethod [(int)method] = permissionLevel;167 module = module.SetLevelForMethod (method, permissionLevel); 168 168 } 169 169 } 170 170 171 module.IsDefault = false;172 171 ModulesInstance.AddModule (module); 173 172 -
TFP-WebServer/WebServer/src/WebAPI/APIs/WorldState/Player.cs
r463 r487 92 92 ClientInfo ci = ConnectionManager.Instance.Clients.ForUserId (_nativeUserId); 93 93 if (ci == null) { 94 Log.Warning ( $"[Web] Player.GET: ClientInfo null");94 Log.Warning ("[Web] Player.GET: ClientInfo null"); 95 95 return; 96 96 } … … 100 100 101 101 if (entity == null) { 102 Log.Warning ( $"[Web] Player.GET: EntityPlayer null");102 Log.Warning ("[Web] Player.GET: EntityPlayer null"); 103 103 return; 104 104 }
Note:
See TracChangeset
for help on using the changeset viewer.