Skip to content

Options

Axwabo edited this page Apr 19, 2025 · 3 revisions

Remote Admin Options

Inspired by CedMod

Example

Remote Admin Options allow developers to add custom functionality to the 4 Request Data buttons by selecting a fake player:

  • Request Data
  • Request IP
  • Request Auth
  • External Lookup

Some options may act as a method to select players. See: Stack

Important

The External Lookup button is disabled unless you have specified the lookup mode the remote admin config (config_remoteadmin.txt). Add the following to enable it:

external_player_lookup_mode: urlonly
external_player_lookup_url: ''

Commands

The remoteAdminOption (raOption or raOpt) command allows you to customize which options are visible to you.

Command Description
show <id> Makes the given option visible
hide <id> Hides the given option
list Shows all available options

Built-in Options

The plugin includes two RA options by default:

Developer Mode

All buttons include a clickable copy icon.

  • Request Data outputs the last command that was executed by the user
  • Reqest IP outputs the last exception thrown by a command executed by the user with IL offsets removed
  • Reqest Auth outputs the last exception thrown by a command executed by the user with IL offsets included

Stack

This option doesn't add button functionality. Selecting it and running a command from the RA GUI will select the topmost list from the player selection stack

Creating an Option

Inherit the Axwabo.CommandSystem.RemoteAdminExtensions.RemoteAdminOptionBase class and override the string HandleButtonClick(RequestDataButton, PlayerCommandSender) method

The option's ID must be specified by an attribute, resolver or by overriding the property InitOnlyOptionId

  • Axwabo.CommandSystem.Attributes.RaExt.AutoGenerateIdAttribute
  • Axwabo.CommandSystem.Attributes.RaExt.RemoteAdminOptionIdentifierAttribute
  • Axwabo.CommandSystem.Attributes.RaExt.RemoteAdminOptionPropertiesAttribute

The ID must contain at least one non-numeric character and may not contain any of the following characters: $@()".<>

Example:

using Axwabo.CommandSystem.Attributes.RaExt;
using Axwabo.CommandSystem.RemoteAdminExtensions;
using RemoteAdmin;

[RemoteAdminOptionProperties("pong", "Pong")]
// or:
[RemoteAdminOptionIdentifier("pong")]
[StaticOptionText("Pong")]
public sealed class PongOption : RemoteAdminOptionBase
{

    protected override string HandleButtonClick(RequestDataButton button, PlayerCommandSender sender)
    {
        return $"You pressed {button}";
    }

}

Override the string GenerateDisplayText(CommandSender) method to create dynamic text.

Important

Options are hidden by default to prevent cluttering the RA GUI. Add the Axwabo.CommandSystem.Attributes.RaExt.VisibleByDefaultAttribute to the option class to make it visible.

ID Assignment

The option ID is assigned in the constructor.

If the ID is auto-generated, it will have a negative numeric ID.

Otherwise, the user-specified ID will be prefixed as follows:

  • The ID is prepended with @ if the option can be used as a standalone selector, specified in one of the following ways:
    • Add the Axwabo.CommandSystem.Attributes.RaExt.StandaloneSelectorAttribute
    • Add the Axwabo.CommandSystem.Attributes.RaExt.RemoteAdminOptionPropertiesAttribute and set property CanBeUsedAsStandaloneSelector to true
    • Implement the interface Axwabo.CommandSystem.RemoteAdminExtensions.Interfaces.IStandaloneSelectorOption and set property CanBeUsedAsStandaloneSelector to true
  • Otherwise, the ID will start with $

Permissions

Adding permission attributes to the class or overriding the Permissions property allows control over who can access the RA option.

An option itself may implement the IPermissionChecker interface to override checking behavior. When this interface is implemented, attribute-based permission checkers are not resolved.

See the permissions article for details.

Visibility

Implement the Axwabo.CommandSystem.RemoteAdminExtensions.Interfaces.IOptionVisibilityController to specify who can see the option.

This may be used to hide the option for a specific user when interaction is not possible at the moment.

Implement the method bool IsVisibleTo(CommandSender)

The AllowInteractionsWhenHidden property specifies whether button clicks can be handled while the option is hidden but accessible

ButtonBasedRemoteAdminOption

This class introduces a handler method for each option. Permissions may be specified by adding a permission attribute to the handler method.

Example:

using Axwabo.CommandSystem.Attributes.RaExt;
using Axwabo.CommandSystem.Permissions;
using Axwabo.CommandSystem.RemoteAdminExtensions;
using RemoteAdmin;

[AutoGenerateId]
[StaticOptionText("Button")]
[OptionIcon("B", ContentColor = "yellow", ShouldBlink = false, SurroundWithBrackets = true)]
public sealed class ButtonOption : ButtonBasedRemoteAdminOption
{

    protected override string OnBasicInfoClicked(PlayerCommandSender sender)
        => "Basic Info";

    [VanillaPermissions(PlayerPermissions.PlayerSensitiveDataAccess)]
    protected override string OnRequestIPClicked(PlayerCommandSender sender) 
        => "IP";

    [StringPermissions("button.secret")]
    protected override string OnRequestAuthClicked(PlayerCommandSender sender)
        => "Super Secret Information";

}

Icons

Icons (if specified) are shown before the generated text.

Specify one by setting the Icon property, using a resolver or attribute:

  • Axwabo.CommandSystem.Attributes.RaExt.OptionIconAttribute
  • Axwabo.CommandSystem.Attributes.RaExt.RemoteAdminOptionPropertiesAttribute (extends OptionIconAttribute)

If the ShouldBlink property is true, the icon will only be visible every other second.

If the SurroundWithBrackets property is true, the Content will look like this: [Content]

Setting TrailingSpace to true will add a space after the end bracket or content to add some room between the icon and generated text.

OverallColor sets the color of the icon and brackets.

Clone this wiki locally