Skip to content

Class endstone::CommandSenderWrapper

ClassList > endstone > CommandSenderWrapper

Represents a wrapper that forwards commands to the wrapped CommandSender and captures its output.

  • #include <endstone/command/command_sender_wrapper.h>

Inherits the following classes: endstone::CommandSender

Public Types

Type Name
typedef std::function< void(const Message &)> Callback

Public Functions

Type Name
CommandSenderWrapper (CommandSender & sender, Callback on_message={}, Callback on_error={})
virtual Result< PermissionAttachment * > addAttachment (Plugin & plugin, const std::string & name, bool value) override
virtual Result< PermissionAttachment * > addAttachment (Plugin & plugin) override
virtual Actor * asActor () override const
Gets a CommandSender asActor .
virtual CommandSender * asCommandSender () override const
Casts a Permissible asCommandSender .
virtual ConsoleCommandSender * asConsole () override const
Gets a CommandSender as Console.
virtual Player * asPlayer () override const
Gets a CommandSender asPlayer .
virtual std::unordered_set< PermissionAttachmentInfo * > getEffectivePermissions () override const
virtual std::string getName () override const
Gets the name of this command sender.
virtual Server & getServer () override const
Returns the server instance that this command is running on.
virtual bool hasPermission (std::string name) override const
virtual bool hasPermission (const Permission & perm) override const
virtual bool isOp () override const
Checks if this object is a server operator.
virtual bool isPermissionSet (std::string name) override const
virtual bool isPermissionSet (const Permission & perm) override const
virtual void recalculatePermissions () override
virtual Result< void > removeAttachment (PermissionAttachment & attachment) override
virtual void sendErrorMessage (const Message & message) override const
Sends this sender a error message.
virtual void sendMessage (const Message & message) override const
Sends this sender a message.
virtual void setOp (bool value) override
Sets the operator status of this object.

Public Functions inherited from endstone::CommandSender

See endstone::CommandSender

Type Name
virtual Actor * asActor () const
Gets a CommandSender asActor .
virtual CommandSender * asCommandSender () override const
Casts a Permissible asCommandSender .
virtual ConsoleCommandSender * asConsole () const
Gets a CommandSender as Console.
virtual Player * asPlayer () const
Gets a CommandSender asPlayer .
virtual std::string getName () const = 0
Gets the name of this command sender.
virtual Server & getServer () const = 0
Returns the server instance that this command is running on.
virtual void sendErrorMessage (const Message & message) const = 0
Sends this sender a error message.
void sendErrorMessage (const fmt::format_string< Args... > format, Args &&... args) const
virtual void sendMessage (const Message & message) const = 0
Sends this sender a message.
void sendMessage (const fmt::format_string< Args... > format, Args &&... args) const

Public Functions inherited from endstone::Permissible

See endstone::Permissible

Type Name
virtual Result< PermissionAttachment * > addAttachment (Plugin & plugin, const std::string & name, bool value) = 0
virtual Result< PermissionAttachment * > addAttachment (Plugin & plugin) = 0
virtual CommandSender * asCommandSender () const = 0
Casts a Permissible asCommandSender .
virtual std::unordered_set< PermissionAttachmentInfo * > getEffectivePermissions () const = 0
virtual bool hasPermission (std::string name) const = 0
virtual bool hasPermission (const Permission & perm) const = 0
virtual bool isOp () const = 0
Checks if this object is a server operator.
virtual bool isPermissionSet (std::string name) const = 0
virtual bool isPermissionSet (const Permission & perm) const = 0
virtual void recalculatePermissions () = 0
virtual Result< void > removeAttachment (PermissionAttachment & attachment) = 0
virtual void setOp (bool value) = 0
Sets the operator status of this object.
virtual ~Permissible () = default

Public Types Documentation

typedef Callback

using endstone::CommandSenderWrapper::Callback =  std::function<void(const Message &)>;

Public Functions Documentation

function CommandSenderWrapper

inline explicit endstone::CommandSenderWrapper::CommandSenderWrapper (
    CommandSender & sender,
    Callback on_message={},
    Callback on_error={}
) 

function addAttachment [½]

inline virtual Result< PermissionAttachment * > endstone::CommandSenderWrapper::addAttachment (
    Plugin & plugin,
    const std::string & name,
    bool value
) override

Adds a new PermissionAttachment with a single permission by name and value

Parameters:

  • plugin Plugin responsible for this attachment, may not be null or disabled
  • name Name of the permission to attach
  • value Value of the permission

Returns:

The PermissionAttachment that was just created

Implements endstone::Permissible::addAttachment


function addAttachment [2/2]

inline virtual Result< PermissionAttachment * > endstone::CommandSenderWrapper::addAttachment (
    Plugin & plugin
) override

Adds a new empty PermissionAttachment to this object

Parameters:

  • plugin Plugin responsible for this attachment, may not be null or disabled

Returns:

The PermissionAttachment that was just created

Implements endstone::Permissible::addAttachment


function asActor

Gets a CommandSender asActor .

inline virtual Actor * endstone::CommandSenderWrapper::asActor () override const

Returns:

Player, nullptr if not an Actor

Implements endstone::CommandSender::asActor


function asCommandSender

Casts a Permissible asCommandSender .

inline virtual CommandSender * endstone::CommandSenderWrapper::asCommandSender () override const

Returns:

CommandSender, nullptr if not a CommandSender

Implements endstone::CommandSender::asCommandSender


function asConsole

Gets a CommandSender as Console.

inline virtual ConsoleCommandSender * endstone::CommandSenderWrapper::asConsole () override const

Returns:

CommandSender, nullptr if not a Console

Implements endstone::CommandSender::asConsole


function asPlayer

Gets a CommandSender asPlayer .

inline virtual Player * endstone::CommandSenderWrapper::asPlayer () override const

Returns:

Player, nullptr if not a Player

Implements endstone::CommandSender::asPlayer


function getEffectivePermissions

inline virtual std::unordered_set< PermissionAttachmentInfo * > endstone::CommandSenderWrapper::getEffectivePermissions () override const

Gets a set containing all the permissions currently in effect by this object

Returns:

Set of currently effective permissions

Implements endstone::Permissible::getEffectivePermissions


function getName

Gets the name of this command sender.

inline virtual std::string endstone::CommandSenderWrapper::getName () override const

Returns:

Name of the sender

Implements endstone::CommandSender::getName


function getServer

Returns the server instance that this command is running on.

inline virtual Server & endstone::CommandSenderWrapper::getServer () override const

Returns:

Server instance

Implements endstone::CommandSender::getServer


function hasPermission [½]

inline virtual bool endstone::CommandSenderWrapper::hasPermission (
    std::string name
) override const

Gets the value of the specified permission, if set. If a permission override is not set on this object, the default value of the permission will be returned.

Parameters:

  • name Name of the permission

Returns:

Value of the permission

Implements endstone::Permissible::hasPermission


function hasPermission [2/2]

inline virtual bool endstone::CommandSenderWrapper::hasPermission (
    const Permission & perm
) override const

Gets the value of the specified permission, if set. If a permission override is not set on this object, the default value of the permission will be returned.

Parameters:

Returns:

Value of the permission

Implements endstone::Permissible::hasPermission


function isOp

Checks if this object is a server operator.

inline virtual bool endstone::CommandSenderWrapper::isOp () override const

Returns:

true if this is an operator, otherwise false

Implements endstone::Permissible::isOp


function isPermissionSet [½]

inline virtual bool endstone::CommandSenderWrapper::isPermissionSet (
    std::string name
) override const

Checks if this object contains an override for the specified permission, by fully qualified name

Parameters:

  • name Name of the permission

Returns:

true if the permission is set, otherwise false

Implements endstone::Permissible::isPermissionSet


function isPermissionSet [2/2]

inline virtual bool endstone::CommandSenderWrapper::isPermissionSet (
    const Permission & perm
) override const

Checks if this object contains an override for the specified Permission

Parameters:

Returns:

true if the permission is set, otherwise false

Implements endstone::Permissible::isPermissionSet


function recalculatePermissions

inline virtual void endstone::CommandSenderWrapper::recalculatePermissions () override

Recalculates the permissions for this object, if the attachments have changed values. This should very rarely need to be called from a plugin.

Implements endstone::Permissible::recalculatePermissions


function removeAttachment

inline virtual Result< void > endstone::CommandSenderWrapper::removeAttachment (
    PermissionAttachment & attachment
) override

Removes the given PermissionAttachment from this object

Parameters:

  • attachment Attachment to remove

Returns:

true if the specified attachment was removed successfully, false when it isn't part of this object

Implements endstone::Permissible::removeAttachment


function sendErrorMessage

Sends this sender a error message.

inline virtual void endstone::CommandSenderWrapper::sendErrorMessage (
    const Message & message
) override const

Parameters:

  • message Error message to be displayed

Implements endstone::CommandSender::sendErrorMessage


function sendMessage

Sends this sender a message.

inline virtual void endstone::CommandSenderWrapper::sendMessage (
    const Message & message
) override const

Parameters:

  • message Message to be displayed

Implements endstone::CommandSender::sendMessage


function setOp

Sets the operator status of this object.

inline virtual void endstone::CommandSenderWrapper::setOp (
    bool value
) override

Parameters:

  • value New operator value

Implements endstone::Permissible::setOp



The documentation for this class was generated from the following file include/endstone/command/command_sender_wrapper.h