Skip to content

Commit

Permalink
Updated helper commands handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Pogromca-SCP committed Apr 11, 2024
1 parent c6fab79 commit 8ee8bc2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ This plugin was created using [official Northwood Plugin API](https://github.com
| script_executions_limit | int | 10 | Defines a maximum amount of concurrent executions a single script can have, use it to set max recursion depth. |

## Commands
Commands from this plugin can be accessed from any console if `enable_helper_commands` config property is set to `true`.
Commands from this plugin can be accessed from any console inluded in `allowed_script_command_types` if `enable_helper_commands` config property is set to `true`.
| Command | Usage | Aliases | Description |
| ------------------------------------ | ---------------------------- | ------- | -------------------------------------------------------------------------------------------------------------- |
| slcshelper <a name="slcshelper"></a> | [iterables/syntax] [Args...] | | Provides helper subcommands for SLCommandScript. Displays environment info if no valid subcommand is selected. |
Expand Down
16 changes: 8 additions & 8 deletions SLCommandScript/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class Plugin
/// <summary>
/// Contains current plugin version.
/// </summary>
public const string PluginVersion = "0.6.0";
public const string PluginVersion = "0.7.0";

/// <summary>
/// Contains plugin description.
Expand Down Expand Up @@ -163,17 +163,17 @@ private IScriptsLoader LoadScriptsLoader()
/// </summary>
private void RegisterHelperCommands()
{
if (!PluginConfig.EnableHelperCommands)
if (!PluginConfig.EnableHelperCommands || ScriptsLoaderConfig.AllowedScriptCommandTypes == 0)
{
return;
}

_helperCommands = new(_scriptsLoader);
var registered = CommandsUtils.RegisterCommand(CommandsUtils.AllScopes, _helperCommands);
var registered = CommandsUtils.RegisterCommand(ScriptsLoaderConfig.AllowedScriptCommandTypes, _helperCommands);

if (registered != CommandsUtils.AllScopes)
if (registered != ScriptsLoaderConfig.AllowedScriptCommandTypes)
{
PrintError($"Could not register helper commands for {CommandsUtils.AllScopes ^ (registered ?? 0)}");
PrintError($"Could not register helper commands for {ScriptsLoaderConfig.AllowedScriptCommandTypes ^ (registered ?? 0)}");
}
}

Expand All @@ -187,11 +187,11 @@ private void UnregisterHelperCommands()
return;
}

var unregistered = CommandsUtils.UnregisterCommand(CommandsUtils.AllScopes, _helperCommands);
var unregistered = CommandsUtils.UnregisterCommand(ScriptsLoaderConfig.AllowedScriptCommandTypes, _helperCommands);

if (unregistered != CommandsUtils.AllScopes)
if (unregistered != ScriptsLoaderConfig.AllowedScriptCommandTypes)
{
PrintError($"Could not unregister helper commands from {CommandsUtils.AllScopes ^ (unregistered ?? 0)}");
PrintError($"Could not unregister helper commands from {ScriptsLoaderConfig.AllowedScriptCommandTypes ^ (unregistered ?? 0)}");
}
}
}

0 comments on commit 8ee8bc2

Please sign in to comment.