endstone::CommandSenderWrapper
Represents a wrapper that forwards commands to the wrapped CommandSender and captures its output.
Bases: endstone::CommandSender
Types:
Name | Description |
---|---|
Callback |
Functions:
Name | Description |
---|---|
CommandSenderWrapper | |
addAttachment | Adds a new PermissionAttachment with a single permission by name and value. |
addAttachment | Adds a new empty PermissionAttachment to this object. |
asActor | Gets a CommandSender as Actor . |
asConsole | Gets a CommandSender as ConsoleCommandSender . |
asPlayer | Gets a CommandSender as Player . |
getEffectivePermissions | Gets a set containing all the permissions currently in effect by this object. |
getName | Gets the name of this command sender. |
getPermissionLevel | Gets the permission level of this object. |
getServer | Returns the server instance that this command is running on. |
hasPermission | 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. |
hasPermission | 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. |
isPermissionSet | Checks if this object contains an override for the specified permission, by fully qualified name. |
isPermissionSet | Checks if this object contains an override for the specified Permission . |
recalculatePermissions | Recalculates the permissions for this object, if the attachments have changed values. This should very rarely need to be called from a plugin. |
removeAttachment | Removes the given PermissionAttachment from this object. |
sendErrorMessage | Sends this sender a error message. |
sendMessage | Sends this sender a message. |
Callback
using endstone::CommandSenderWrapper::Callback =
std::function<void(const Message &)>;
CommandSenderWrapper
CommandSenderWrapper(CommandSender &sender, Callback on_message = {},
Callback on_error = {})
addAttachment
PermissionAttachment *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 disabledname
Name of the permission to attachvalue
Value of the permission
Returns:
The PermissionAttachment that was just created
PermissionAttachment *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
asActor
Actor *asActor() override const
Gets a CommandSender as Actor .
Returns:
Actor, nullptr if not an Actor
asConsole
ConsoleCommandSender *asConsole() override const
Gets a CommandSender as ConsoleCommandSender .
Returns:
CommandSender, nullptr if not a ConsoleCommandSender
asPlayer
Player *asPlayer() override const
Gets a CommandSender as Player .
Returns:
Player, nullptr if not a Player
getEffectivePermissions
std::unordered_set<PermissionAttachmentInfo *>
getEffectivePermissions() override const
Gets a set containing all the permissions currently in effect by this object.
Returns:
Set of currently effective permissions
getName
std::string getName() override const
Gets the name of this command sender.
Returns:
Name of the sender
getPermissionLevel
PermissionLevel getPermissionLevel() override const
Gets the permission level of this object.
Returns:
The permission level
getServer
Server &getServer() override const
Returns the server instance that this command is running on.
Returns:
Server instance
hasPermission
bool 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
bool 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:
perm
Permission to get
Returns:
Value of the permission
isPermissionSet
bool 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
bool isPermissionSet(const Permission &perm) override const
Checks if this object contains an override for the specified Permission .
Parameters:
perm
Permission to check
Returns:
true if the permission is set, otherwise false
recalculatePermissions
void 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.
removeAttachment
Result<void> 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
sendErrorMessage
void sendErrorMessage(const Message &message) override const
Sends this sender a error message.
Parameters:
message
Error message to be displayed
sendMessage
void sendMessage(const Message &message) override const
Sends this sender a message.
Parameters:
message
Message to be displayed