Console Delegate

Console Delegate is the only way to prompt a player and execute the finalized command as the console.

We can think of this feature as a new way to invoke the core part of CommandPrompter, the prompting feature. Instead of intercepting a command executed by a player, we can simply call the Console Delegate command, provide a target player, and the command you want that target player to fulfill.

Motivation

Due to how CommandPrompter works, we can't simply allow completed commands to be executed beyond the permission of the player who's calling that command. This is because CommandPrompter listens to player commands and if they have a PromptQueue argument that augments the whole PromptQueue to be dispatched as console, it leads to a very exploitable vulnerability. This essentially boils down to the fact that we cannot control what the player inputs as a command.

However, with the new console delegate command, we can instead delegate the prompting to a target player . Once the command is completed, it's then sent back to the console to be executed as the console, not the player.

The Console Delegate Command

As I've mentioned before, this command can only be called from the console. However, there's still a permission (commandprompter.consoledelegate) associated with this command to make sure that it does not appear in the player's tab complete without that permission.

Players with OP will be able to see the /consoledelegate command on their tab complete. However, CommandPrompter will not process the console delegate command if the sender instance is not ConsoleSender.

Usage

The console delegate command has the following format:

consoledelegate <target_player> <command...>

The last part of this argument is a greedy argument. Therefore, everything past the first argument which is the target player will be combined into one string and be considered as a command. This command will then be parsed and featuresdelegated to the target player to be completed.

You can also use the placeholder %target_player% somewhere in your command to replace it with your actual target player.

Example

consoledelegate CyR1en gamemode <what gamemode> %target_player%

Here, we are using the default gamemode command and we're delegating the prompt to the player CyR1en. Let's say the player inputted creative, the completed command that will be executed by the console is:

gamemode creative CyR1en

Example with PostCommand

We can also take advantage of CommandPrompter's feature like PostCommand.

consoledelegate CyR1en gamemode <what gamemode> %target_player% <-exa broadcast Gamemode changed to p:0 for %target_player%>

The command above will be executed like the first example. However, we have a post command that executes the following command:

broadcast Gamemode changed to creative for CyR1en

Post Command for Console Delegate will also be executed as the console

Video Example

Last updated